[Python] problema di import con email generator

Carlo Miron miron a python.it
Sab 10 Nov 2012 11:53:44 CET


On Sat, Nov 10, 2012 at 10:35 AM, Giovanni Porcari
<giovanni.porcari a softwell.it> wrote:
> Stamattina mi sono trovato un errore che non riesco a spiegarmi.
> Python 2.7.2
>>>> import email
>
>>>> email.generator
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> AttributeError: 'module' object has no attribute 'generator'

Non so/ricordo come funzionasse prima di 2.7, ma sul mio 2.7.3 ho:
(nota la G maiuscola)

>>> import email
>>> dir(email.Generator)
['__class__', '__delattr__', '__dict__', '__doc__', '__format__',
'__getattr__', '__getattribute__', '__hash__', '__init__',
'__module__', '__name__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__setattr__', '__sizeof__', '__str__',
'__subclasshook__', '__weakref__']
>>> email.Generator
<email.LazyImporter object at 0x951476c>
>>> dir(email.Generator)
['DecodedGenerator', 'Generator', 'Header', 'NL', 'StringIO',
'UNDERSCORE', '_FMT', '__all__', '__builtins__', '__class__',
'__delattr__', '__dict__', '__doc__', '__file__', '__format__',
'__getattr__', '__getattribute__', '__hash__', '__init__',
'__module__', '__name__', '__new__', '__package__', '__reduce__',
'__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__',
'__subclasshook__', '__weakref__', '_fmt', '_is8bitstring',
'_make_boundary', '_width', 'fcre', 'random', 're', 'sys', 'time',
'warnings']


>>>> import email.generator as eg
>>>> dir (eg)
> ['DecodedGenerator', 'Generator', 'Header', 'NL', 'StringIO', 'UNDERSCORE', '_FMT', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_fmt', '_is8bitstring', '_make_boundary', '_width', 'fcre', 'random', 're', 'sys', 'time', 'warnings']
>>>>
>
> Si tratta di un baco (magari noto) o c'è qualcosa che mi sfugge ?
> Grazie
> G

©
--
  R
K-<M>-S
  L


Maggiori informazioni sulla lista Python