AttributeError of a module instance
Paolino
paolo_veronelli at yahoo.it
Mon Dec 27 05:59:29 EST 2004
Terry Reedy wrote:
>
>> I'd like to catch AttributeError on the module level,so that I can
>> declare default bindings for useds defore definition.How is this to
>> be done?
>
>
> 'defore' is obviously 'before', but what is 'useds'? In and case...
Unresolved bindings,possibly like
>>> _rdf_type
Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: name '_rdf_type' is not defined
> If you are asking for the module equivalent of __getattr__ class
> methods, there is none. Modules are namespaces. They are like dicts
> but minus the dict methods and with .attribute instead of
> ['attribute'] access. This is possible because all 'keys' are names
> (hence 'namespace').
In the previous example I'd like to see an answer like
'<rdf:type>'
even if I never defined it.Is this not possible?I use __getattr__ in
other situations,and it's very useful for proxying procedures,I was
hoping on a real objectivation of a module.
Why the language should not consider a module as a 'normal' instance
with 'normal' attributes?
Sorry for my language skills.Paolino
More information about the Python-list
mailing list