sys.stdin.encoding
Duncan Booth
duncan.booth at invalid.invalid
Mon Dec 11 03:44:06 EST 2006
aine_canby at yahoo.com wrote:
> The following line in my code is failing because sys.stdin.encoding is
> Null.
I'll guess you mean None rather than Null.
> This has only started happening since I started working with
> Pydef in Eclipse SDK. Any ideas?
>
> uni=unicode(word,sys.stdin.encoding)
>
You could give it a fallback value:
uni = unicode(word, sys.stdin.encoding or sys.getdefaultencoding())
or even just:
uni = unicode(word, sys.stdin.encoding or 'ascii')
which should be the same in all reasonable universes (although I did get
bitten recently when someone had changed the default encoding in a system).
More information about the Python-list
mailing list