Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44263
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!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.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:Python': 0.06; 'attribute': 0.07; 'compiler': 0.07; 'nested': 0.07; 'wednesday,': 0.07; 'output,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.11; '24,': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'print': 0.22; 'header:User- Agent:1': 0.23; 'developers': 0.25; 'pass': 0.26; 'defined': 0.27; 'skip:_ 20': 0.27; 'header:X-Complaints-To:1': 0.27; 'class': 0.32; 'skip:_ 10': 0.34; 'subject:the': 0.34; 'agree': 0.35; 'definition': 0.35; 'subject:?': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'enough': 0.39; 'received:org': 0.40; 'expectations': 0.74; "'foo'": 0.84; '2013': 0.98 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: What is the reason for defining classes within classes in Python? |
| Date | Wed, 24 Apr 2013 14:00:55 +0200 |
| Organization | None |
| References | <4e46cc04-248e-4594-a24a-b272648a5e66@googlegroups.com> <mailman.1001.1366755826.3114.python-list@python.org> <ebf43a37-c441-4a8a-9941-995377ae45e5@googlegroups.com> <2cec7512-997e-4f1f-9580-592495d449df@ys5g2000pbc.googlegroups.com> <7143de25-61a1-4eaf-abd1-2eab03c913f8@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p5084bfc0.dip0.t-ipconnect.de |
| User-Agent | KNode/4.7.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| 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.1019.1366804839.3114.python-list@python.org> (permalink) |
| Lines | 48 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1366804839 news.xs4all.nl 16002 [2001:888:2000:d::a6]:52415 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:44263 |
Show key headers only | View raw
vasudevram wrote:
> On Wednesday, April 24, 2013 6:20:36 AM UTC+5:30, alex23 wrote:
>>
>> A nested class definition will be defined as an attribute of the class
>>
>> its defined within:
>>
>>
>>
>> >>> class Outer(object):
>>
>> ... foo = 'FOO'
>>
>> ... class Inner(object):
>>
>> ... bar = 'BAR'
>>
>> ...
>>
>> >>> Outer.Inner
> Just one other doubt:
>
>> >>> Outer.Inner
>>
>> <class '__main__.Inner'>
>>
>
> In the above output, I would have thought Python would print
> __main__.Outer.Inner or Outer.Inner instead of __main__.Inner, since Inner
> is an attribute of Outer?
The Python developers seem to agree with you and have made the compiler
smart enough to accomodate your expectations in Python 3.3:
$ cat tmp.py
class Outer:
class Inner:
pass
print(Outer.Inner)
$ python3.2 tmp.py
<class '__main__.Inner'>
$ python3.3 tmp.py
<class '__main__.Outer.Inner'>
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What is the reason for defining classes within classes in Python? vasudevram <vasudevram@gmail.com> - 2013-04-23 14:50 -0700
Re: What is the reason for defining classes within classes in Python? Ian Kelly <ian.g.kelly@gmail.com> - 2013-04-23 16:22 -0600
Re: What is the reason for defining classes within classes in Python? vasudevram <vasudevram@gmail.com> - 2013-04-23 16:13 -0700
Re: What is the reason for defining classes within classes in Python? alex23 <wuwei23@gmail.com> - 2013-04-23 17:50 -0700
Re: What is the reason for defining classes within classes in Python? vasudevram <vasudevram@gmail.com> - 2013-04-24 04:01 -0700
Re: What is the reason for defining classes within classes in Python? Peter Otten <__peter__@web.de> - 2013-04-24 14:00 +0200
Re: What is the reason for defining classes within classes in Python? vasudevram <vasudevram@gmail.com> - 2013-04-24 06:29 -0700
csiph-web