Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #85423 > unrolled thread
| Started by | Dave Angel <davea@davea.name> |
|---|---|
| First post | 2015-02-09 22:12 -0500 |
| Last post | 2015-02-09 22:12 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Weird behavior on __dict__ attr Dave Angel <davea@davea.name> - 2015-02-09 22:12 -0500
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2015-02-09 22:12 -0500 |
| Subject | Re: Weird behavior on __dict__ attr |
| Message-ID | <mailman.18591.1423537938.18130.python-list@python.org> |
On 02/09/2015 09:52 PM, Shiyao Ma wrote: > Hi. > > My context is a little hard to reproduce. WHY don't you try? Telling us about a class without showing how it's defined leaves us all guessing. Start by telling us Python version. And if it's 2.x, tell us whether this class is an old style or new style class. > > 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? > Lots of possibilities. Simplest is slots. if you define __slots__, then there's no dictionary in each instance. https://docs.python.org/3.4/reference/datamodel.html#slots -- DaveA
Back to top | Article view | comp.lang.python
csiph-web