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


Groups > comp.lang.python > #12551

Re: Constructors...BIIIIG PROBLEM!

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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; 'constructor': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'trailing': 0.09; 'def': 0.15; 'class,': 0.15; 'code?': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:t-dialin.net': 0.16; 'subject:PROBLEM': 0.16; 'things...': 0.16; 'wrote:': 0.16; 'say,': 0.19; 'says': 0.25; 'hey': 0.26; 'problem': 0.28; 'explicitly': 0.29; 'from:addr:web.de': 0.30; 'class': 0.30; 'to:addr:python-list': 0.33; 'which,': 0.34; 'header:X-Complaints- To:1': 0.35; 'supposed': 0.35; 'object': 0.35; 'doing': 0.36; 'something': 0.37; 'two': 0.37; 'could': 0.38; 'think': 0.38; 'received:org': 0.38; 'subject:: ': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'your': 0.61; 'leading': 0.61; 'subject:!': 0.67
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: Constructors...BIIIIG PROBLEM!
Date Thu, 01 Sep 2011 09:56:11 +0200
Organization None
References <CABWGKeW6sw2GJghQRbPcUA7_EO2V7SX5iJH0Pz0u513wX9TPNw@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p5084a90a.dip.t-dialin.net
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.649.1314863755.27778.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1314863755 news.xs4all.nl 2492 [2001:888:2000:d::a6]:46102
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:12551

Show key headers only | View raw


Amogh M S wrote:

> Hey guys...
> I think we have a problem with my _init_ method and the constructor
> When I create a class and its _init_ method and try to create an object of
> it outside the class,
> Say, something like
> 
> class S:
>    def _init_(self, name=None):

Your __init__() method needs two leading and two trailing underscores.

>        self.name = name
> s = S("MyName")
> 
> It says that the constructor takes no arguments!! I have to explicitly
> call the _init_ method which, I think is not the right way of doing
> things... Could you tell me if that is what is supposed to happen or is
> something wrong with my code?

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


Thread

Re: Constructors...BIIIIG PROBLEM! Peter Otten <__peter__@web.de> - 2011-09-01 09:56 +0200

csiph-web