Testing the following code, I've differend return with python 3.1.2 and 3.2.2

-----------------------------------------------------------
# -*- coding: utf-8 -*-

import os
import sys
import platform

print('\nPython version: ', sys.version.split()[0])
print(platform.platform())

paths = ['/home/vincent/image.jpg', '/home/vincent/àéèîö.jpg']

for path in paths:
    print('\nPath: {0}, Type: {1}'.format(path, type(path)))
    if not os.path.exists(path) or not os.path.isfile(path):
        print('File not found: {0}'.format(path))
    else:
        print('File exists')

------------------------------------------------------------------------------

My pc ubuntu:


vincent@tiemoko:~/Python/oqapy/devel$ python3 string_2.py

Python version: 3.1.2
Linux-2.6.32-33-generic-i686-with-Ubuntu-10.04-lucid

Path: /home/vincent/image.jpg, Type: <class 'str'>
File exists

Path: /home/vincent/

àéèîö.jpg, Type: <class 'str'>
File exists
vincent@tiemoko:~/Python/oqapy/devel$
-----------------------------------------------------------------------------

Second pc:


[vincent@myhost ~]$ python string_2.py

Python version:  3.2.2
Linux-3.0-ARCH-x86_64-Pentium-R-_Dual-Core_CPU_T4500_@_2.30GHz-with-glibc2.2.5

Path: /home/vincent/image.jpg, Type: <class 'str'>
File exists
Traceback (most recent call last):
  File "string_2.py", line 13, in <module>
    print('\nPath: {0}, Type: {1}'.format(path, type(path)))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 21-25: ordinal not in range(128)
[vincent@myhost ~]$
----------------------------------------------------------------------------------

I never had problem with unicode and python3.

Thanks for all advices.
--
Vincent V.V.
Oqapy . Qarte+7 . PaQager
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to