[Tutor] class problem

Steven D'Aprano steve at pearwood.info
Sat Sep 18 17:54:11 CEST 2010

On Sat, 18 Sep 2010 07:14:03 pm Roelof Wobben wrote:

> P=(Point)

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* 
the function:

P = Point()  # what about arguments to the function?

If you surround it with brackets, as you do above, it does nothing. It's 
like this:

x = (1+1)  # exactly the same as x = 1+1 without brackets

> a=0
> b=0
> a=id(P)

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:


Steven D'Aprano

More information about the Tutor mailing list