Pb encodage & import

Michel Claveau - abstraction méta-galactique non triviale en fuite perpétuelle. unseulmcmcmcmc at msupprimerlepoint.claveauPOINTcom
Thu Jan 6 22:17:15 CET 2005


Bonsoir !            Hi !

My english is short, therefore, I do short.

Two scripts, "i1.py" and "i2.py" :

i1.py :
    import i2
    print i2.GlobalA

i2.py :
    GlobalA ="azerty"




Like this, it's OK ; but :



i1.py :
    import i2
    print i2.GlobalA

i2.py :
    GlobalA = "azerty"

OK

==============================

i1.py :
    import i2
    print i2.GlobalA

i2.py :
    # -*- coding: cp1252 -*-

    GlobalA = "azerty"

SyntaxError

==============================

i1.py :
    import i2
    print i2.GlobalA

i2.py :
    # -*- coding: utf-8 -*-

    GlobalA = "azerty"

OK

==============================

i1.py :
    # -*- coding: utf-8 -*-

    import i2
    print i2.GlobalA

i2.py :
    # -*- coding: utf-8 -*-

    GlobalA = "azerty"

OK

==============================

i1.py :
    # -*- coding: utf-8 -*-

    import i2
    print i2.GlobalA

i2.py :
    # -*- coding: cp1252 -*-

    GlobalA = "azerty"

SyntaxError

==============================

i1.py :
    # -*- coding: utf-8 -*-

    import i2
    print i2.GlobalA

i2.py :
    GlobalA = u"azérty"  #see unicode & accent

OK

==============================

i1.py :
    # -*- coding: utf-8 -*-

    import i2
    print i2.GlobalA

i2.py :
    # -*- coding: utf-8 -*-

    GlobalA = u"azérty"  #see unicode & accent

UnicodeDecodeError

==============================


All files are recorded in ANSI ; tests with Python 2.4 on Win-XP.



Ideas, ou suggests  ?




@-salutations
-- 
Michel Claveau








More information about the Python-list mailing list