Re: __bases__ misleading error message

2015-01-26 Thread Marco Buttu
On 24/01/2015 13:43, Steven D'Aprano wrote: Mario Figueiredo wrote: > class Sub: > pass > > foo = Sub() > > Sub.__bases__ > foo.__bases__ > >The last statement originates the following error: > > AttributeError: 'Sub' object has no attribute '

Re: __bases__ misleading error message

2015-01-25 Thread Ian Kelly
On Jan 25, 2015 2:37 PM, "Terry Reedy" wrote: > 2. the second array is a compact array of entries in insertion order, such as > > [hash, ptr to 'x', ptr to 23] > [hash, ptr to 'colour', ptr to 'red'] > [hash, ptr to the string 'y', ptr to the int 42] > > Iteration would use the compact

Re: __bases__ misleading error message

2015-01-25 Thread Terry Reedy
On 1/25/2015 7:00 AM, Steven D'Aprano wrote: What happens inside the dictionary? Dictionaries are "hash tables", so they are basically a big array of cells, and each cell is a pair of pointers, one for the key and one for the value: [dictionary header] [blank] [blank] [ptr t

Re: __bases__ misleading error message

2015-01-25 Thread Marko Rauhamaa
Mario Figueiredo : > Knowing Python internals is something that will end benefiting me in > the long run. There's much to be gained by knowing the inner working > of your programming language... > > Python is missing an under-the-hood book, I suppose. Tracing through > Python source code to learn

Re: __bases__ misleading error message

2015-01-25 Thread Mario Figueiredo
In article <54c4dae1$0$13005$c3e8da3$54964...@news.astraweb.com>, steve+comp.lang.pyt...@pearwood.info says... > [...] Most excellent. Thanks for the hard work, explaining this to me. :) Knowing Python internals is something that will end benefiting me in the long run. There's much to be gained

Re: __bases__ misleading error message

2015-01-25 Thread Steven D'Aprano
Mario Figueiredo wrote: > In article <54c4606a$0$13002$c3e8da3$54964...@news.astraweb.com>, > steve+comp.lang.pyt...@pearwood.info says... >> >> It doesn't. > > Your explanation was great Steven. Thank you. But raises one question... > >> >> Assigning a value to a variable ("m = 42", hex 2A) r

Re: __bases__ misleading error message

2015-01-25 Thread Mario Figueiredo
In article <54c4606a$0$13002$c3e8da3$54964...@news.astraweb.com>, steve+comp.lang.pyt...@pearwood.info says... > > It doesn't. Your explanation was great Steven. Thank you. But raises one question... > > Assigning a value to a variable ("m = 42", hex 2A) results in the compiler > storing that

Re: __bases__ misleading error message

2015-01-25 Thread Marco Buttu
On 25/01/2015 01:55, Terry Reedy wrote: 'This situation' being that Someclass.attro works but Someclass().attro raises... In other words, if 'Someclass.attro' evaluates to an object ... then 'Someclass().attro' *normally* evaluates to the same object I am sorry Terry, but I do not agree, beca

Re: __bases__ misleading error message

2015-01-24 Thread Steven D'Aprano
Mario Figueiredo wrote: > But that begs the OT question: How does Python maps names to memory > addresses in the interpreter? It doesn't. You are thinking of an execution model like C or Pascal, where variables are best thought of as fixed memory addresses. But Python, like many modern languages

Re: __bases__ misleading error message

2015-01-24 Thread Terry Reedy
On 1/24/2015 4:51 PM, Marco Buttu wrote: On 24/01/2015 20:24, Terry Reedy wrote: On 1/24/2015 5:16 AM, Mario Figueiredo wrote: Consider the following code at your REPL of choice class Sub: pass foo = Sub() Sub.__bases__ foo.__bases__ The last

Re: __bases__ misleading error message

2015-01-24 Thread Mario Figueiredo
In article , ros...@gmail.com says... > Awesome! I'm always a bit wary of analogies... sometimes they're > really helpful, other times they're unhelpful and confusing. Yeah. Your's was all it took :) The thing with analogies is to never take them literally. They are analogies, after all. But th

Re: __bases__ misleading error message

2015-01-24 Thread Mario Figueiredo
In article , ian.g.ke...@gmail.com says... > > No, you're being told that the *object* doesn't know the names of the > variables that it's bound to. In the context above, the variable is > right there under that name in the globals dict, as can be seen in the > disassembly: [snipped] Yes. I got

Re: __bases__ misleading error message

2015-01-24 Thread Chris Angelico
On Sun, Jan 25, 2015 at 9:33 AM, Mario Figueiredo wrote: > In article , > ros...@gmail.com says... >> >> Let me explain by way of analogy. > [snipped] > > Gotcha! Thanks for the explanation :) Awesome! I'm always a bit wary of analogies... sometimes they're really helpful, other times they're unh

Re: __bases__ misleading error message

2015-01-24 Thread Mario Figueiredo
In article , ros...@gmail.com says... > > Let me explain by way of analogy. [snipped] Gotcha! Thanks for the explanation :) -- https://mail.python.org/mailman/listinfo/python-list

Re: __bases__ misleading error message

2015-01-24 Thread Chris Angelico
On Sun, Jan 25, 2015 at 9:09 AM, Mario Figueiredo wrote: > Meaning the interpreter knows a variable's name. Which would allow it to > produce an error message such as: > > AttributeError: 'foo' object has no attribute '__bases__' > > For the following code: > > class Sub: > pass >

Re: __bases__ misleading error message

2015-01-24 Thread Ian Kelly
On Sat, Jan 24, 2015 at 3:02 PM, Mario Figueiredo wrote: > In article , > tjre...@udel.edu says... >> >> > "__main__" >> > from module import a_name >> >> A module is a namespace associating names with objects. This statememt >> says to import the a_name to object association from modul

Re: __bases__ misleading error message

2015-01-24 Thread Mario Figueiredo
In article , ian.g.ke...@gmail.com says... > > On Sat, Jan 24, 2015 at 2:14 PM, Mario Figueiredo wrote: > > But that begs the OT question: > > No, it doesnt. http://en.wikipedia.org/wiki/Begging_the_question Cute. > I'm not sure I'm understanding what you're asking, but the import > statement

Re: __bases__ misleading error message

2015-01-24 Thread Marco Buttu
On 24/01/2015 13:43, Steven D'Aprano wrote: Mario Figueiredo wrote: > class Sub: > pass > > foo = Sub() > > Sub.__bases__ > foo.__bases__ > >The last statement originates the following error: > > AttributeError: 'Sub' object has no attribute

Re: __bases__ misleading error message

2015-01-24 Thread Mario Figueiredo
In article , tjre...@udel.edu says... > > > "__main__" > > from module import a_name > > A module is a namespace associating names with objects. This statememt > says to import the a_name to object association from module and add it > to __main__ > > > y = a_name + 1 > > This

Re: __bases__ misleading error message

2015-01-24 Thread Terry Reedy
On 1/24/2015 4:14 PM, Mario Figueiredo wrote: In article <54c39366$0$13006$c3e8da3$54964...@news.astraweb.com>, steve+comp.lang.pyt...@pearwood.info says... AttributeError: 'Sub' instance has no attribute '__bases__', AttributeError: 'foo' object has no attribute '__bases__'

Re: __bases__ misleading error message

2015-01-24 Thread Marco Buttu
On 24/01/2015 20:24, Terry Reedy wrote: On 1/24/2015 5:16 AM, Mario Figueiredo wrote: Consider the following code at your REPL of choice class Sub: pass foo = Sub() Sub.__bases__ foo.__bases__ The last statement originates the following error:

Re: __bases__ misleading error message

2015-01-24 Thread Ian Kelly
On Sat, Jan 24, 2015 at 2:14 PM, Mario Figueiredo wrote: > In article <54c39366$0$13006$c3e8da3$54964...@news.astraweb.com>, > steve+comp.lang.pyt...@pearwood.info says... >> > AttributeError: 'Sub' instance has no attribute '__bases__', >> > AttributeError: 'foo' object has no att

Re: __bases__ misleading error message

2015-01-24 Thread Mario Figueiredo
In article <54c39366$0$13006$c3e8da3$54964...@news.astraweb.com>, steve+comp.lang.pyt...@pearwood.info says... > > AttributeError: 'Sub' instance has no attribute '__bases__', > > AttributeError: 'foo' object has no attribute '__bases__' > > The first would be nice. The second is

Re: __bases__ misleading error message

2015-01-24 Thread Mario Figueiredo
In article , tjre...@udel.edu says... > > AttributeError: 'Sub' object has no attribute '__bases__' > > In this message, 'Sub' is an adjective, modifying 'object, not naming > it. If you attend to the last line of the traceback > My first reaction is to look at 'Sub' as a noun, not an

Re: __bases__ misleading error message

2015-01-24 Thread Terry Reedy
On 1/24/2015 5:16 AM, Mario Figueiredo wrote: Consider the following code at your REPL of choice class Sub: pass foo = Sub() Sub.__bases__ foo.__bases__ The last statement originates the following error: This is an anomalous situation. Normall

Re: __bases__ misleading error message

2015-01-24 Thread Steven D'Aprano
Mario Figueiredo wrote: > > Consider the following code at your REPL of choice > > class Super: > pass Super is irrelevant here, since it isn't used. > class Sub: > pass > > foo = Sub() > > Sub.__bases__ > foo.__bases__ > > The

__bases__ misleading error message

2015-01-24 Thread Mario Figueiredo
Consider the following code at your REPL of choice class Super: pass class Sub: pass foo = Sub() Sub.__bases__ foo.__bases__ The last statement originates the following error: AttributeError: 'Sub' object has no attribute '__ba