Però Generator non espone gli stessi metodi di generator. Ad esempio, su 2.7.3: >>> import email.Generator >>> dir(email.Generator) ['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattr__', '__getattribute__', '__hash__', '__init__', '__module__', '__name__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__']
>>> from email import generator >>> dir(generator) ['DecodedGenerator', 'Generator', 'Header', 'NL', 'StringIO', 'UNDERSCORE', '_FMT', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_fmt', '_is8bitstring', '_make_boundary', '_width', 'fcre', 'random', 're', 'sys', 'time', 'warnings'] In realtà il problema si verifica per tutti i sotto moduli, non solo per generator: >>> import email >>> dir(email.charset) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'charset' mentre continua a funzionare: >>> import email >>> import email.charset >>> dir(email.charset) ['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'] 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... 2012/11/10 Carlo Miron <mi...@python.it> > On Sat, Nov 10, 2012 at 10:35 AM, Giovanni Porcari > <giovanni.porc...@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 > _______________________________________________ > Python mailing list > Python@lists.python.it > http://lists.python.it/mailman/listinfo/python >
_______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python