![]() |
Two quick questions
Hey everyone,
I'm currently learning Python, and I have two quick questions. The first one is, when defining an object inside of a class why do we use (self)? ie: :
Is it because self will make the object run what is inside of it? (And therefore use the print?) Secondly, would it be wise for a Python newbie to start learning pygame right away? I know my basic loops, if statements, functions, and classes. Thanks! |
The only way you're gonna find out whether it's wise or not is to actually look at some example code and read/do some starters' tutorials. If you've learnt enough to be asking about objects and definition, I don't think you're far from reaching the point where you'll want to/should learn things like PyGame, PyMedia, BeautifulSoup etc.
Get some source code for the simpler games like Tetris from the PyGame website and look at them. That's how I kinda started ;) |
Quote:
In Python, the first argument of a method belonging to a function is a reference to the object the function is contained within. This argument is, by convention, called "self". Thus: :
x = MyClass():
x = MyClass()e.g.: :
class Test::
10 5 |
Thanks guys, I think I understand it now.
|
| All times are GMT -5. The time now is 4:00 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC