Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #18748
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <prvs=3491571d1=jeanmichel@sequans.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python.': 0.04; 'function,': 0.07; 'python': 0.08; '__name__': 0.09; 'callable': 0.09; 'shortcut': 0.09; 'url:peps': 0.09; 'def': 0.13; '"__main__":': 0.16; 'ideas?': 0.16; 'subject:function': 0.16; 'subject:variable': 0.16; 'url:pep-0008': 0.16; 'cc:addr:python- list': 0.16; 'wrote:': 0.18; 'cc:no real name:2**0': 0.20; 'trying': 0.21; 'header:In-Reply-To:1': 0.22; 'url:dev': 0.23; 'cc:2**0': 0.24; 'object,': 0.24; 'classes': 0.26; 'function': 0.27; 'variable': 0.28; 'print': 0.29; 'cc:addr:python.org': 0.29; 'class': 0.29; 'usually': 0.31; 'values': 0.32; 'header:User- Agent:1': 0.33; 'object': 0.33; 'it.': 0.34; 'calling': 0.34; '???': 0.34; 'url:python': 0.36; 'but': 0.37; 'reference': 0.37; 'skip:_ 10': 0.37; 'some': 0.38; 'url:org': 0.39; 'should': 0.39; "couldn't": 0.39; 'data,': 0.39; "it's": 0.40; 'subject:Calling': 0.84 |
| X-IronPort-AV | E=Sophos;i="4.71,486,1320620400"; d="scan'208";a="59848" |
| X-Virus-Scanned | amavisd-new at zimbra.sequans.com |
| Date | Tue, 10 Jan 2012 12:03:12 +0100 |
| From | Jean-Michel Pichavant <jeanmichel@sequans.com> |
| User-Agent | Mozilla-Thunderbird 2.0.0.24 (X11/20100328) |
| MIME-Version | 1.0 |
| To | Yigit Turgut <y.turgut@gmail.com> |
| Subject | Re: Calling a variable inside a function of another class |
| References | <5a91e124-b6e9-4e2f-88d6-50a33eb496db@k29g2000vbl.googlegroups.com> |
| In-Reply-To | <5a91e124-b6e9-4e2f-88d6-50a33eb496db@k29g2000vbl.googlegroups.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Cc | python-list@python.org |
| 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.4587.1326193399.27778.python-list@python.org> (permalink) |
| Lines | 31 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1326193399 news.xs4all.nl 6944 [2001:888:2000:d::a6]:49332 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:18748 |
Show key headers only | View raw
Yigit Turgut wrote: > class test(test1): > > def __init__(self, device): > . > . > . > def _something(self, x=1) > self.dt = data > > > if __name__ == "__main__": > test.something.dt ??? > > I am trying to call a variable located in a function of a class from > main but couldn't succeed.Any ideas? > if __name__ == "__main__": aTest = test(whateverdevice) print aTest.dt Some advices: - a common practice in python is to name classes in CamelCase ( read http://www.python.org/dev/peps/pep-0008/ ) - if dt is a shortcut for data, it's a bad one. - default values are for loosers, they should be used only to keep backward compatibility (personal opinion, a lot of ppl would disagree) - "call" is usually reserved for method and function, or any callable object in python. What you're trying to do is to reference an object, not calling it. JM
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Calling a variable inside a function of another class Yigit Turgut <y.turgut@gmail.com> - 2012-01-07 07:00 -0800
Re: Calling a variable inside a function of another class Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-01-07 16:01 +0000
Re: Calling a variable inside a function of another class Yigit Turgut <y.turgut@gmail.com> - 2012-01-07 08:18 -0800
Re: Calling a variable inside a function of another class Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-01-07 14:03 -0500
Re: Calling a variable inside a function of another class Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-01-10 12:03 +0100
Re: Calling a variable inside a function of another class Terry Reedy <tjreedy@udel.edu> - 2012-01-10 17:41 -0500
csiph-web