why and when we should do it?
Terry Reedy
tjreedy at udel.edu
Tue Mar 29 22:16:15 EST 2005
"Su Wei" <pollux.suwei at gmail.com> wrote in message
news:466e311e05032917387550237e at mail.gmail.com...
>i hvae seen some code like this before:
I really hope not...
>class BusinessBO :
dev __init__(slef):
#write you own code here
dev businessMethod :
#write you own code here
That is 'def', not 'dev'
>pass
This is completely useless at top (unindented) module level
>why and when we should add the keyword "pass" ?
When you need it to avoid a syntax error. That is when you want a
'do-nothing' suite. One example: def f(): pass
>and some time i have seen
>class SomeObject(Object) :
#some code
>why and when we should inherit Object?
That is 'object', not 'Object'. It makes the class new style instead of
old style. Unless you inheret from another new-style class, which does the
same, I would advise always unless you specifically know you want an
old-style class.
Another pass example: class stuff(object): pass. The difference between
o=object() and s=stuff() is that you can add attributes to s but not to o.
Terry J. Reedy
PS: posting plain ascii text, which this is not, makes responding easier
More information about the Python-list
mailing list