optional argument to a subclass of a class

Chris Rebert clp2 at rebertia.com
Fri May 21 17:28:06 EDT 2010


On Fri, May 21, 2010 at 1:09 PM, Alex Hall <mehgcap at gmail.com> wrote:
> On 5/21/10, Ethan Furman <ethan at stoneleaf.us> wrote:
>> Alex Hall wrote:
>>> On 5/20/10, alex23 <wuwei23 at gmail.com> wrote:
>>> I have since updated each ship's
>>> __init__ to accept all the arguments that Craft accepts so that I can
>>> support all optional arguments,
>>
>> Ick.  Now you'll have to change several things if you make one change to
>> the Craft class.  Better to do it this way:
>>
>> [borrowing Peter's example]
>>
>> class Craft(object):
> Curious: I do not pass Craft this "object" keyword and I have no
> problems. What is it for? Just a convention, something like self being
> called self?

It causes the class to be "new-style". See
http://docs.python.org/reference/datamodel.html#new-style-and-classic-classes

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list