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


Groups > comp.lang.python > #85421

Weird behavior on __dict__ attr

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <i@introo.me>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.025
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'say,': 0.05; 'context': 0.07; 'python': 0.11; 'stored': 0.12; "'n'": 0.16; 'attr': 0.16; 'binding.': 0.16; 'c++.': 0.16; 'received:143': 0.16; 'written': 0.21; 'import': 0.22; 'header:User-Agent:1': 0.23; 'file.': 0.24; 'node': 0.31; 'seemingly': 0.31; 'class': 0.32; 'received:209.85': 0.35; 'tool': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'received:209': 0.37; 'to:addr:python-list': 0.38; 'little': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'content-disposition:inline': 0.62; 'skip:n 10': 0.64; 'url:me': 0.69; 'simulation': 0.91
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=9arUGbxMVsO0ohZiz1QO1HOgswRJc7TnB6+SrCbl+Pg=; b=H/fMNDfozjPQpJ4G7iDwW6jpOv3o6ECDEzw47WQMJCNFkPgazi9rd1YXPaaKL1aOt0 AV9/PONgcKVvHKFz869SfPy+RyfCf/IxcW9EnEM1PLtwyJN6bvTrIxO1pGEFJvp67Fbr c2qNwjf6x3BiXs1YsvG88KyeP9/ETnKH1AEcOTkvUgOdCqs3Fk/W50DhBU1xQzg3zlAT GJdrBS7nJJZCMl4pb37+C/vM4hulRRIglLpsDAJMW2rwI4hdn/C67+UuZDXSfmpo7Sk5 PuZlJ+P3gKf41pk3/+LzMFTAMg8bDwRXQQ4DjUdoeROY9S4Eov+xUBwu7SwN8JJlUshe qLLQ==
X-Gm-Message-State ALoCoQlQeEVAEVQ6jQEJXFC5JO9w7gDvWFKzmD+IbIfeRpIyc6E/z20iOf8aToYltBD0ZaMlWNRH
X-Received by 10.68.192.101 with SMTP id hf5mr33578518pbc.117.1423536767496; Mon, 09 Feb 2015 18:52:47 -0800 (PST)
Date Tue, 10 Feb 2015 10:52:43 +0800
From Shiyao Ma <i@introo.me>
To python-list@python.org
Subject Weird behavior on __dict__ attr
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Disposition inline
User-Agent All mail clients suck. This one just sucks way more.
X-Info Find me @introom on Freenode. Have beers! :)
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.18589.1423536776.18130.python-list@python.org> (permalink)
Lines 39
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1423536776 news.xs4all.nl 2858 [2001:888:2000:d::a6]:50930
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:85421

Show key headers only | View raw


Hi.

My context is a little hard to reproduce.

NS3 is a network simulation tool written in C++. I am using its Python binding.

So the class I am dealing with is from a .so file.

Say, I do the following:

%

import ns.network.Node as Node

# Node is a class
# it has a __dict__ attr

# Now I instantiate an instance of Node
n = Node()

# I checked, there is no __dict__ on 'n'
# but the following succeeds.

n.foobar = 3



My understanding is the foobar is stored in n.__dict__, but seemingly n has no __dict__.

So where does the foobar go?


TIA.



-- 
Shiyao Ma
http://introo.me

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


Thread

Weird behavior on __dict__ attr Shiyao Ma <i@introo.me> - 2015-02-10 10:52 +0800
  Re: Weird behavior on __dict__ attr Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-02-10 19:00 +1100

csiph-web