Utilizzando approccio Duck-Typing [1]: for item in Lista: ... try: ... print len(item) ... except TypeError: ... len(str(item))
Ciao [1]: http://en.wikipedia.org/wiki/Duck_typing Il 18 febbraio 2011 13:01, Enrico Franchi <enrico.fran...@gmail.com> ha scritto: > Riccardo Lemmi wrote: >> >> A parte che il codice non รจ molto pythonico, non tutti gli oggetti hanno >> 'len'. > > Io come da convenzioni Python userei il classico EAFP. > Chiami len; se piange, catturi l'eccezione. :) > > > -- > . > ..: -enrico- > > _______________________________________________ > Python mailing list > Python@lists.python.it > http://lists.python.it/mailman/listinfo/python > -- -Gianluca http://proudlygeek.appspot.com _______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python