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


Groups > comp.lang.python > #19821

Re: multiple constructor __init__

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'api.': 0.05; 'received:verizon.net': 0.07; 'terry': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.13; 'instantiate': 0.16; 'parameter,': 0.16; 'reedy': 0.16; 'url:riverbankcomputing': 0.16; 'versus': 0.16; 'wrote:': 0.16; 'jan': 0.19; 'header:In-Reply- To:1': 0.22; 'works.': 0.23; 'specify': 0.24; 'code': 0.25; 'pm,': 0.26; 'all,': 0.27; 'example': 0.28; 'second': 0.29; 'class': 0.29; 'parent': 0.30; 'version': 0.31; 'header:User-Agent:1': 0.33; 'to:addr:python-list': 0.33; 'doc': 0.34; 'header:X -Complaints-To:1': 0.34; 'but': 0.37; 'received:org': 0.37; 'skip:_ 10': 0.37; 'url:docs': 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.40; 'url:uk': 0.40; 'url:co': 0.63; 'supply': 0.68; 'emmanuel': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: multiple constructor __init__
Date Thu, 02 Feb 2012 22:43:16 -0500
References <CACB6ZmB9ofRz+ZAjqbbnwm2GfL9Vwth+jrz2mAQoMBp6-x5o2A@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-74-109-121-73.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0
In-Reply-To <CACB6ZmB9ofRz+ZAjqbbnwm2GfL9Vwth+jrz2mAQoMBp6-x5o2A@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5389.1328240613.27778.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1328240613 news.xs4all.nl 6860 [2001:888:2000:d::a6]:37059
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:19821

Show key headers only | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web