Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38939
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <bob.brusa@gmail.com> |
| 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; 'syntax': 0.03; 'argument': 0.04; 'initialize': 0.05; 'method.': 0.05; 'class,': 0.07; 'correct.': 0.07; 'executed': 0.07; 'received:192.168.178': 0.07; 'python': 0.09; 'created,': 0.09; 'definition,': 0.09; 'specifying': 0.09; 'worked.': 0.09; 'def': 0.10; '*a,': 0.16; 'notations': 0.16; 'type:': 0.16; 'module': 0.19; 'equivalent': 0.20; 'parameters': 0.20; 'either.': 0.22; 'help.': 0.22; 'statement': 0.23; 'this:': 0.23; 'downloaded': 0.24; 'pass': 0.25; 'tried': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; '(which': 0.26; 'errors.': 0.27; 'executing': 0.27; 'things,': 0.29; 'definition': 0.29; 'skip:_ 10': 0.29; 'class': 0.29; 'error': 0.30; 'code': 0.31; 'to:addr:python-list': 0.33; 'hi,': 0.33; 'received:google.com': 0.34; 'self': 0.34; 'thanks': 0.34; 'expected': 0.35; 'offered': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'message- id:@gmail.com': 0.36; 'method': 0.36; 'execute': 0.37; 'does': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'build': 0.39; 'called': 0.39; 'received:192.168': 0.40; 'think': 0.40; 'bottom': 0.60; 'further': 0.61; "you'll": 0.62; 'thomas': 0.62; 'here': 0.65; 'header:Reply-To:1': 0.68; 'reply-to:no real name:2**0': 0.72; 'reply-to:addr:gmail.com': 0.79; 'absolutely': 0.84; 'here...': 0.84; 'analyses': 0.91; 'bob': 0.91; 'net.': 0.91; 'besides,': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:reply-to:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=HFG5GpTIWU5mU5MAvN4f59ohIxO7Iy0nu4G6cVXW1x4=; b=zp5FR3pjDhllohIq/ffNvtP2UzQJZG8XC/9byT+HlCJCSyjT1F/XcoEPpQ/kDXvc6A C4AZK1HpOWrTy9BHd14xxb9pT/VNJJszSPJg9TXmxlCcfemP7SPzXSXWVO64q2ptExsl lilnsNcVVy9ZS3X5X8g+NYFmqNnoUApkvCgcL8R/xiqFfbB/bwuxSMGUQ4tFvfRtvHhS fVwqz/5mHkj+oA/PfPDH+suDTIyTo7v0PXOhFGXzkREAjQ5xEfwX8FEls4/92yYLg70z 7qNLmkTSh8o5LZcXFK9rUCe8NZlyZq5yeUGcV5Ebg4ANbuk06Y5hn7xk+upYdyMC1Rar lieQ== |
| X-Received | by 10.14.3.70 with SMTP id 46mr10907533eeg.2.1360950601677; Fri, 15 Feb 2013 09:50:01 -0800 (PST) |
| Date | Fri, 15 Feb 2013 18:50:02 +0100 |
| From | Bob Brusa <bob.brusa@gmail.com> |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: inheritance and how to use it |
| References | <mailman.1819.1360947575.2939.python-list@python.org> <kflpto$suo$1@r03.glglgl.gl> |
| In-Reply-To | <kflpto$suo$1@r03.glglgl.gl> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | bob.brusa@gmail.com |
| 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.1826.1360950608.2939.python-list@python.org> (permalink) |
| Lines | 60 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1360950608 news.xs4all.nl 6874 [2001:888:2000:d::a6]:34805 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:38939 |
Show key headers only | View raw
Am 15.02.2013 18:06, schrieb Thomas Rachel:
> Am 15.02.2013 17:59 schrieb Bob Brusa:
>> Hi,
>> I use a module downloaded from the net. Now I want to build my own
>> class, based on the class SerialInstrument offered in this module - and
>> in my class I would like to initialize a few things, using e. g. the
>> method clear() offered by SerialInstrument. Hence I type:
>>
>> class myClass(SerialInstrument)
>> self.clear(self)
>> def f1(self, str1, str2)
>> ...do something etc.
>>
>> I then get the message "self not know" from the statement
>> self.clear(self).
>
> Which is absolutely correct. Besides, I would have expected some syntax
> errors.
>
> You try to execute the clear() method during the definition of the
> class, not during the instantiation.
>
> Instantiation happens in the __init__() method.
>
> You'll have to do it like this:
>
> class myClass(SerialInstrument):
> def __init__(self, *a, **k): # accept all parameters
> super(myClass, self).__init__(*a, **k)
> self.clear() # I don't think that self is to be given twice
> here...
> def f1(self, str1, str2):
> pass
>
> I have tried many other notations - none worked. What
>> works is however the following code - specifying myClass without the
>> self.clear(self) in it:
>>
>> x = myClass("argument")
>> x.clear()
>
> Here the clear() is called on the object which has been created, so
> after calling the __init__() above (which is, roughly, equivalent to
> calling it at the bottom of __init__()).
>
>
> Thomas
Thomas,
This does not work either. The error comes while python analyses the
code - even prior to executing my program.... But what I want to achieve
is that this clear() is executed when the class is instantiated....which
I do with the code
x = myClass("COM7")
Of course, when scanning the class definition, the argument "COM7" is
not yet known.
Thanks for further help. Bob
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
inheritance and how to use it Bob Brusa <bob.brusa@gmail.com> - 2013-02-15 17:59 +0100
Re: inheritance and how to use it Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-02-15 18:06 +0100
Re: inheritance and how to use it Bob Brusa <bob.brusa@gmail.com> - 2013-02-15 18:50 +0100
Re: inheritance and how to use it Dave Angel <davea@davea.name> - 2013-02-15 13:06 -0500
Re: inheritance and how to use it Bob Brusa <bob.brusa@gmail.com> - 2013-02-15 20:40 +0100
Re: inheritance and how to use it Tony the Tiger <tony@tiger.invalid> - 2013-02-19 16:04 -0600
csiph-web