473,378 Members | 1,067 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,378 software developers and data experts.

DeprecationWarning: Non-ASCII character '\xf3'

jau
Hi co-listers!

I have been off Python for 2 years and now, that i'm used to Eclipse and
Java, I decided to start a project with Python to refresh skills this
time using Eclipse and TrueStudio. But now, two things can be occured
since the last time i used it.

the first one, something concerning to the encoding has changed and i
haven't noticed it.

the other one, when using Python from Eclipse i have to add any special
config lines at the begining of my Python files.

if i have this hello world python "program" (i have to call it by
someway, hahaha)

print "hello world"

i get this output

hello world
sys:1: DeprecationWarning: Non-ASCII character '\xf3' in file
C:\Workspace\J&J\src\es\jau\main.py on line 2, but no encoding declared;
see http://www.python.org/peps/pep-0263.html for details

the article mentioned above didn't explain so much for me.

i doesn't look to be an error, but curiosity is bitting me... what's
really happening here? Do I need to do any special thing to avoid this?

Thanks everyone!

Salut i república
Aug 23 '05 #1
2 7639
"jau" <ja************@airtel.net> wrote:
print "hello world"

i get this output

hello world
sys:1: DeprecationWarning: Non-ASCII character '\xf3' in file
C:\Workspace\J&J\src\es\jau\main.py on line 2, but no encoding declared;
see http://www.python.org/peps/pep-0263.html for details

the article mentioned above didn't explain so much for me.


the error message means that Python found an \xF3-character
on the second line in your main program (\xF3 is usually "latin
small letter o with acute", or "ó")

the document you were referred to says

Python will default to ASCII as standard encoding if no other
encoding hints are given.

(in other words, Python wants you to use plain ASCII in your source
code, unless otherwise specified).

and continues

To define a source code encoding, a magic comment must
be placed into the source files either as first or second
line in the file:

#!/usr/bin/python
# -*- coding: <encoding name> -*-

(in other words, if you want to keep using non-ASCII characters, you
need to add a line like

# -*- coding: iso-8859-1 -*-

and make sure it's the first or second line in your script. if you didn't
mean to add it, just get rid of it and try again. if eclipse doesn't
display
the character, check the file using notepad or some other editor)

</F>

Aug 23 '05 #2
jau wrote:
Hi co-listers!

I have been off Python for 2 years and now, that i'm used to Eclipse and
Java, I decided to start a project with Python to refresh skills this
time using Eclipse and TrueStudio. But now, two things can be occured
since the last time i used it.

the first one, something concerning to the encoding has changed and i
haven't noticed it.

the other one, when using Python from Eclipse i have to add any special
config lines at the begining of my Python files.

if i have this hello world python "program" (i have to call it by
someway, hahaha)

print "hello world"

i get this output

hello world
sys:1: DeprecationWarning: Non-ASCII character '\xf3' in file
C:\Workspace\J&J\src\es\jau\main.py on line 2, but no encoding declared;
see http://www.python.org/peps/pep-0263.html for details

the article mentioned above didn't explain so much for me.

i doesn't look to be an error, but curiosity is bitting me... what's
really happening here? Do I need to do any special thing to avoid this?


The single print statement above should not trigger this warning. Are there
any non-ASCII character in the file (perhaps comments?).
If you use non-ASCII characters in python source files, you have to tell the
interpreter which encoding you are using - otherwise funny things will
happen. You have to find out which encoding Eclipse uses to save file
(looks like iso-8859-1) and add the line

# -*- coding: iso-8859-1 -*-

at the top of the file.

Python does not make any assumptions about the encoding beyond US-ASCII
(perhaps it does, but it does not encourage taking advantage of this) - if
you use anything else, then you'll have to declare it.

This will be important, if you use unicode strings:

u"stränge characters"

Python must know the encoding of the file in order to decode the string
literal into an unicode string.

--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
Aug 23 '05 #3

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

Similar topics

6
by: Pierre Rouleau | last post by:
Hi all! I am using Python 2.3.1 on Win32 (NT, 2000). Whenever a file imports the standard tempfile module, Python 2.3.1 issues the following warning: C:\Python23\lib\fcntl.py:7:...
0
by: Ben Finney | last post by:
Howdy all, I'm using a library that uses SmartCookie. In Python 2.3, that gives this warning: /usr/lib/python2.3/Cookie.py:712: DeprecationWarning: Cookie/SmartCookie class is insecure; do...
77
by: Gerrit Holl | last post by:
Hi, the <> inequality test operator has been deprecated for a loooooong time. Is there a reason that it doesn't trigger a DeprecationWarning? $ python2.2 -Wall -c "print 0 <> 0" 0 $...
5
by: klaus triendl | last post by:
hi, recently i discovered a memory leak in our code; after some investigation i could reduce it to the following problem: return objects of functions are handled as temporary objects, hence...
25
by: Yves Glodt | last post by:
Hello, if I do this: for row in sqlsth: ________pkcolumns.append(row.strip()) ________etc without a prior:
32
by: Adrian Herscu | last post by:
Hi all, In which circumstances it is appropriate to declare methods as non-virtual? Thanx, Adrian.
8
by: Bern McCarty | last post by:
Is it at all possible to leverage mixed-mode assemblies from AppDomains other than the default AppDomain? Is there any means at all of doing this? Mixed-mode is incredibly convenient, but if I...
5
by: Dan Jacobson | last post by:
Here's the deal: I have to maintain this long gone guy's programs and lately they've been saying ../north_pass.py:14: DeprecationWarning: integer argument expected, got float...
7
by: John Nagle | last post by:
How do I suppress "DeprecationWarning: Old style callback, use cb_func(ok, store) instead". A library is triggering this message, the library is being fixed, but I need to make the message...
4
by: oliver | last post by:
Hey There, Sorry if I am missing something here, but I get a DeprecationWarning when importing a list which has some unicode characters in it (it's a list of countries -- it's being raised on...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?

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.