Duncan Booth skrev:
I'll guess you mean None rather than Null.
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).
Thanks for your help. The problem now is that I cant enter the Swedish
characters åöä etc without getting the following error -
Enter word> Påe
Traceback (most recent call last):
File "C:\Documents and Settings\workspace\simple\src\main.py", line
25, in <module>
archive.Test()
File "C:\Documents and Settings\workspace\simple\src\verb.py", line
192, in Test
uni=unicode(word,sys.stdin.encoding or sys.getdefaultencoding())
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 1:
ordinal not in range(128)
The call to sys.getdefaultencoding() returns ascii. Since I can enter
the characters åöä on the command line in Pydef/Eclipse doesn't that
mean that the stdin is not ascii? What should I do?
Thanks again,
Aine.