Però Generator non espone gli stessi metodi di generator. Ad esempio, su 2.7.3:<br>>>> import email.Generator<br>>>> dir(email.Generator)<br>['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattr__', '__getattribute__', '__hash__', '__init__', '__module__', '__name__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__']<br>
<br>>>> from email import generator<br>>>> dir(generator)<br>['DecodedGenerator', 'Generator', 'Header', 'NL', 'StringIO', 'UNDERSCORE', '_FMT', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_fmt', '_is8bitstring', '_make_boundary', '_width', 'fcre', 'random', 're', 'sys', 'time', 'warnings']<br>
<br>In realtà il problema si verifica per tutti i sotto moduli, non solo per generator:<br>>>> import email<br>>>> dir(email.charset)<br>Traceback (most recent call last):<br> File "<stdin>", line 1, in <module><br>
AttributeError: 'module' object has no attribute 'charset'<br><br>mentre continua a funzionare:<br>>>> import email<br>>>> import email.charset<br>>>> dir(email.charset)<br>['ALIASES', 'BASE64', 'CHARSETS', 'CODEC_MAP', 'Charset', 'DEFAULT_CHARSET', 'MISC_LEN', 'QP', 'SHORTEST', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', 'add_alias', 'add_charset', 'add_codec', 'codecs', 'email', 'encode_7or8bit', 'errors']<br>
<br>Forse è un problema del mapping del naming style da email 3 (Generator) a email 4 (generator), dentro __init__,py, nella classe LazyImporter. Bisognerebbe provare se lo stesso problema si verifica anche con i mime types, visto che anche loro sono soggetti allo stesso mapping...<br>
<div class="gmail_extra"><br><br><div class="gmail_quote">2012/11/10 Carlo Miron <span dir="ltr"><<a href="mailto:miron@python.it" target="_blank">miron@python.it</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Sat, Nov 10, 2012 at 10:35 AM, Giovanni Porcari<br>
<<a href="mailto:giovanni.porcari@softwell.it">giovanni.porcari@softwell.it</a>> wrote:<br>
> Stamattina mi sono trovato un errore che non riesco a spiegarmi.<br>
> Python 2.7.2<br>
>>>> import email<br>
><br>
>>>> email.generator<br>
> Traceback (most recent call last):<br>
> File "<stdin>", line 1, in <module><br>
> AttributeError: 'module' object has no attribute 'generator'<br>
<br>
</div>Non so/ricordo come funzionasse prima di 2.7, ma sul mio 2.7.3 ho:<br>
(nota la G maiuscola)<br>
<br>
>>> import email<br>
>>> dir(email.Generator)<br>
['__class__', '__delattr__', '__dict__', '__doc__', '__format__',<br>
'__getattr__', '__getattribute__', '__hash__', '__init__',<br>
'__module__', '__name__', '__new__', '__reduce__', '__reduce_ex__',<br>
'__repr__', '__setattr__', '__sizeof__', '__str__',<br>
'__subclasshook__', '__weakref__']<br>
>>> email.Generator<br>
<email.LazyImporter object at 0x951476c><br>
>>> dir(email.Generator)<br>
<div class="im">['DecodedGenerator', 'Generator', 'Header', 'NL', 'StringIO',<br>
</div>'UNDERSCORE', '_FMT', '__all__', '__builtins__', '__class__',<br>
'__delattr__', '__dict__', '__doc__', '__file__', '__format__',<br>
'__getattr__', '__getattribute__', '__hash__', '__init__',<br>
'__module__', '__name__', '__new__', '__package__', '__reduce__',<br>
'__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__',<br>
'__subclasshook__', '__weakref__', '_fmt', '_is8bitstring',<br>
<div class="im">'_make_boundary', '_width', 'fcre', 'random', 're', 'sys', 'time',<br>
'warnings']<br>
<br>
<br>
>>>> import email.generator as eg<br>
>>>> dir (eg)<br>
> ['DecodedGenerator', 'Generator', 'Header', 'NL', 'StringIO', 'UNDERSCORE', '_FMT', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_fmt', '_is8bitstring', '_make_boundary', '_width', 'fcre', 'random', 're', 'sys', 'time', 'warnings']<br>
>>>><br>
><br>
> Si tratta di un baco (magari noto) o c'è qualcosa che mi sfugge ?<br>
> Grazie<br>
> G<br>
<br>
</div>©<br>
--<br>
R<br>
K-<M>-S<br>
<div class="HOEnZb"><div class="h5"> L<br>
_______________________________________________<br>
Python mailing list<br>
<a href="mailto:Python@lists.python.it">Python@lists.python.it</a><br>
<a href="http://lists.python.it/mailman/listinfo/python" target="_blank">http://lists.python.it/mailman/listinfo/python</a><br>
</div></div></blockquote></div><br></div>