Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19821 > unrolled thread

Re: multiple constructor __init__

Started byTerry Reedy <tjreedy@udel.edu>
First post2012-02-02 22:43 -0500
Last post2012-02-02 22:43 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: multiple constructor __init__ Terry Reedy <tjreedy@udel.edu> - 2012-02-02 22:43 -0500

#19821 — Re: multiple constructor __init__

FromTerry Reedy <tjreedy@udel.edu>
Date2012-02-02 22:43 -0500
SubjectRe: multiple constructor __init__
Message-ID<mailman.5389.1328240613.27778.python-list@python.org>
On 2/2/2012 8:09 PM, Emmanuel Mayssat wrote:
> Hello all,
>
> I would like to instantiate my class as follow
>
>
> QObject(<param1>, <parent>)
> QObject(<parent>)
>
> an example would be
> http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qmenu.html
>
> How can I do this without have to specify parent=<parent> in the second
> version
> (I always need to supply the parent parameter, but I would like to
> supply it last)

The same way range(stop) versus range(start,stop) works.
But I really recommend against that api.
It makes both doc and code messy.
You need a really good reason to not use the obvious
def __init__(self, parent, param=default):...

-- 
Terry Jan Reedy

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web