optional argument to a subclass of a class
Christian Heimes
lists at cheimes.de
Fri May 21 14:10:34 EDT 2010
Am 21.05.2010 04:56, schrieb Alex Hall:
> Hi all,
> I am now trying to allow my classes, all of which subclass a single
> class (if that is the term), to provide optional arguments. Here is
> some of my code:
>
> class Craft():
> def __init__(self,
> name,
> isAircraft=False,
> id=helpers.id(),
> hits=0,
> weapons=[]):
I hope you are aware that helpers.id() is called just once when the
*class* is defined and that the list weapons is shared across all
instances of the craft class. :)
Have you read about *args and **kwargs in the Python docs? I bet you
find them useful for your problem.
Christian
More information about the Python-list
mailing list