Problem getting a file pathname with tkFileDialog

Sefyroth cdroulers at hotmail.com
Wed Nov 8 22:29:22 EST 2006


Thank you!!! I have had problems with other stuff because of this
(mainly py2exe!)

It did the job! I thank you a lot.

Just wondering though,

D:/Travaux/5ème session/B51 - Dev. de
Systèmes/Workspace/LMAOSoft/Controleur.py
That's my filepath, what is not ASCII in there? è????

Just checked and it's 138 in ascii... Anyway, thanks a lot

Christian


Tim Daneliuk wrote:
> Sefyroth wrote:
> > Thanks,
> >
> > but I get this error when I try this.
> >
> > UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in
> > position 12: ordinal not in range(128)
> >
> >  I had encountered it with the askdirectory method as well. Is there an
> > easy way to bypass this?
> >
> > Thanks again
>
> I believe you are running into a directory or file name that has
> non-ascii characters in it.  Python as shipped is set up to
> deal with ascii as its native encoding format.  You can change
> this by editing the "site.py" file - look in the Lib directory
> in your python installation.  Look for this code:
>
> -------------------------------
> def setencoding():
>      """Set the string encoding used by the Unicode implementation.  The
>      default is 'ascii', but if you're willing to experiment, you can
>      change this."""
>      encoding = "ascii" # Default value set by _PyUnicode_Init()
>      if 0:
>          # Enable to support locale aware default string encodings.
>          import locale
>          loc = locale.getdefaultlocale()
>          if loc[1]:
>              encoding = loc[1]
> -------------------------------
>
>
>
> Change the "if 0:" to "if 1:" and see if that doesn't fix the problem.
>
>
>
> --
> ----------------------------------------------------------------------------
> Tim Daneliuk     tundra at tundraware.com
> PGP Key:         http://www.tundraware.com/PGP/




More information about the Python-list mailing list