optional argument to a subclass of a class

Alex Hall mehgcap at gmail.com
Fri May 21 00:22:11 EDT 2010


On 5/20/10, alex23 <wuwei23 at gmail.com> wrote:
> Patrick Maupin <pmau... at gmail.com> wrote:
>> One thing you can do is in battleship, you can accept additional
>> keyword arguments:
>>
>>     def __init__(self, name, ..., **kw):
>>
>> Then you could invoke the superclass's init:
>>
>>     Craft.__init__(self, name, **kw)
>
> _All_ of which is covered in the tutorial. At what point do we expect
> people to actually put some effort into learning the language
> themselves? Is this why we're constantly spammed with "write my code
> for me" requests?
I am certainly NOT asking anyone to write my code for me. In fact, I
almost never copy and paste code, since writing it myself helps me to
both remember it and examine it to see what is going on and figure out
why it works. I am basically teaching myself Python; my experience is
in Java (basic), JS (somewhat advanced), and a smattering of other
languages. I have rarely dealt with classes before, and certainly not
sub-classing. I have googled all of this and have read the docs and
tutorials, but nothing made sense enough for me to figure out why I
would be getting my particular error. I have since updated each ship's
__init__ to accept all the arguments that Craft accepts so that I can
support all optional arguments, but I thought subclassing was supposed
to take care of this for me... Suppose not.
>
> If you're asking _basic_ "how do I" questions, and you don't even have
> the common sense to read through the support docs before doing so,
> then you really should be directing questions here:
> http://mail.python.org/mailman/listinfo/tutor
Again, I have read the docs. I often find them quite useful, but there
are times where a new concept, in a relatively new language, just will
not work and a doc is not going to say "at this point in your code,
you should to A instead of B, because..."
> --
> http://mail.python.org/mailman/listinfo/python-list
>


-- 
Have a great day,
Alex (msg sent from GMail website)
mehgcap at gmail.com; http://www.facebook.com/mehgcap



More information about the Python-list mailing list