__bases__ misleading error message

Mario Figueiredo marfig at gmail.com
Sat Jan 24 22:14:24 CET 2015


In article <54c39366$0$13006$c3e8da3$5496439d at news.astraweb.com>, 
steve+comp.lang.python at 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 impossible: objects may have no name,
> one name, or many names, and they do not know what names they are bound to.
> So the Sub instance bound to the name 'foo' doesn't know that its name
> is 'foo', so it cannot display it in the error message.

Thanks for the information! :)

But that begs the OT question: How does Python maps names to memory 
addresses in the interpreter?

    "__main__"
    from module import a_name
    y = a_name + 1

How does python interpreter know how to map 'name' to the correct memory 
location, if this __main__ code is only ran after 'module' code?  



More information about the Python-list mailing list