[Tutor] class problem
steve at pearwood.info
Sat Sep 18 17:54:11 CEST 2010
On Sat, 18 Sep 2010 07:14:03 pm Roelof Wobben wrote:
This line does not do what you think it does. Brackets in Python are
used for two things, grouping and calling functions.
To call a function, or a class, you need to have the brackets *after*
P = Point() # what about arguments to the function?
If you surround it with brackets, as you do above, it does nothing. It's
x = (1+1) # exactly the same as x = 1+1 without brackets
It is a waste of time to initialise variables immediately before
initialising them again.
> print a
> print b
> print P
> But now id is a decimal so I don't can't translate it.
id(x) returns an integer. By default, integers always print in decimal,
if you want to print them in hex you can do this:
More information about the Tutor