473,396 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Bug? import cp1252

Hi!

I've a problem with these 2 scripts:
file aaa.py (write in ANSI/cp1252):

# -*- coding: cp1252 -*-

compo={}

compo['pxrtf']= {
'fichier': "pxrtf.py",
'description': "Génération de fichiers RTF"
}

file bbb.py (write in ANSI/cp1252):

# -*- coding: cp1252 -*-

import aaa

With run bbb.py, I see:

Traceback (most recent call last):
File "D:\dev\python\bbb.py", line 3, in <module>
import aaa
File "D:\dev\python\aaa.py", line 3

^
SyntaxError: invalid syntax

(run directly aaa.py give no problem)
(Python 2.5.1 + win_XP-SP2_french)


BUT, if I write the file aaa.py in UTF-8, with 1st line: # -*- coding:
utf-8 -*-
the problem is removed (file bbb.py stay in ANSI/cp1252)

Bug? or am I wrong?

@-salutations

Michel Claveau

May 12 '07 #1
2 3642
On May 13, 3:33 am, "Méta-MCI" <enleverlesX.X...@XmclaveauX.com>
wrote:
Hi!

I've a problem with these 2 scripts:

file aaa.py (write in ANSI/cp1252):
What is "ANSI/cp1252"???
>
# -*- coding: cp1252 -*-

compo={}

compo['pxrtf']= {
'fichier': "pxrtf.py",
'description': "Génération de fichiers RTF"
}

file bbb.py (write in ANSI/cp1252):

# -*- coding: cp1252 -*-

import aaa

With run bbb.py, I see:

Traceback (most recent call last):
File "D:\dev\python\bbb.py", line 3, in <module>
import aaa
File "D:\dev\python\aaa.py", line 3

^
SyntaxError: invalid syntax

(run directly aaa.py give no problem)

(Python 2.5.1 + win_XP-SP2_french)

BUT, if I write the file aaa.py in UTF-8, with 1st line: # -*- coding:
utf-8 -*-
the problem is removed (file bbb.py stay in ANSI/cp1252)

Bug? or am I wrong?

@-salutations
Michel, I can't reproduce this -- Python 2.5.1, Windows XP Pro SP2

Given that the syntax error seems to be pointing to a blank empty
line, I suspect that's there's some invisible character in the file.
This would be likely not to show up when we view your file through a
web browser or news client. I suggest that you show us *exactly* what
you've got:

print open('aaa.py', 'rb').read()

HTH,
John

May 12 '07 #2
Hi!
>>I suspect that's there's some invisible character in the file
No ; because I reproduce the problem, on another CPU, with typing from
scratch.
>>I can't reproduce this -- Python 2.5.1, Windows XP Pro SP2
I'm sorry. Perhaps my "french" windows is a co-factor?
Perhaps my locale has Or my local influence?

I had try on four computer, with the same problem.

Fortunately, write in UTF-8 delete the problem...
--
Michel Claveau
May 14 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Stian Sřiland | last post by:
all examples performed with: Python 2.3+ (#2, Aug 10 2003, 11:09:33) on linux2 (2, 3, 0, 'final', 1) This is a recursive import:
3
by: David Eppstein | last post by:
I'm working on some Python code for reading files in a certain format, and the examples of such files I've found on the internet appear to be in either cp850 or cp1252 encoding (except for one...
0
by: Vio | last post by:
Hi, I've been trying to embed (statically) wxPy alongside an embedded py interpreter on a linux/gtk box. At one point, for some reason misc.o linking reported "multiple definitions of...
1
by: Michel Claveau - abstraction méta-galactique non t | last post by:
Bonsoir ! Hi ! My english is short, therefore, I do short. Two scripts, "i1.py" and "i2.py" : i1.py : import i2 print i2.GlobalA
5
by: Steve Holden | last post by:
This is even stranger: it makes it if I import the module a second time: import dbimp as dbimp import sys if __name__ == "__main__": dbimp.install() #k = sys.modules.keys() #k.sort() #for...
4
by: Olivier Noblanc ATOUSOFT | last post by:
Hello, In the botom of this post you will see my source code. The problem is when i launch main.py that doesn't make anything why ? Thanks olivier noblanc Atousoft...
0
by: Do Re Mi chel La Si Do | last post by:
Hi ! *** for information *** There is a bug in Python 2.4, worsened with the 2.4.1, for scripts, if they are: - large - with larges lines
9
by: Arancaytar | last post by:
I have so far seen two methods for including external resources as CSS stylesheets in a document. The first is this: <link href="/stylesheets/style.css" rel="stylesheet" type="text/css" /> And...
9
by: rsoh.woodhouse | last post by:
Hi, I'm trying to work out some strange (to me) behaviour that I see when running a python script in two different ways (I've inherited some code that needs to be maintained and integrated with...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.