Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.072 X-Spam-Evidence: '*H*': 0.86; '*S*': 0.00; 'attribute': 0.07; 'python': 0.11; "'__doc__',": 0.16; 'attributes.': 0.16; 'class:': 0.16; 'object()': 0.16; 'subject:object': 0.16; 'x()': 0.16; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'pass': 0.26; "skip:' 10": 0.31; '"",': 0.31; 'file': 0.32; 'class': 0.32; '(most': 0.33; 'objects': 0.35; 'there': 0.35; 'shorter': 0.36; 'list': 0.37; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'explain': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'new': 0.61; 'simple': 0.61; 'different': 0.65; 'subjectcharset:iso-8859-1': 0.66; "'foo'": 0.84; "'object'": 0.84 X-PV-Sent: sailor@lists.xtsubasa.org From: Pavel Volkov To: Subject: =?iso-8859-1?Q?object().=5F=5Fdict=5F=5F?= Date: Wed, 23 Apr 2014 09:39:04 +0400 User-Agent: Trojita/0.4.1; Qt/4.8.5; X11; Linux; MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1398231951 news.xs4all.nl 2923 [2001:888:2000:d::a6]:56932 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70528 There are some basics about Python objects I don't understand. Consider this snippet: >>> class X: pass ...=20 >>> x =3D X() >>> dir(x) ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__',=20 '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__',=20 '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__',=20 '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__',=20 '__str__', '__subclasshook__', '__weakref__'] >>> x.foo =3D 11 And now I want to make a simple object in a shorter way, without declaring=20= X class: >>> y =3D object() >>> dir(y) ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__',=20= '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__le__',=20 '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__',=20 '__setattr__', '__sizeof__', '__str__', '__subclasshook__'] >>> y.foo =3D 12 Traceback (most recent call last): File "", line 1, in AttributeError: 'object' object has no attribute 'foo' The attribute list is different now and there's no __dict__ and the object=20= does not accept new attributes. Please explain what's going on.