very strange syntax errors

H

hg

Hi,

I'v been facing some very strange errors lately:

one example:

def __init__(self):
.....
import my_info
some_text = my_info.T_SOME_TEXT
^ syntax error


I manage to get rid of that one by moving the import on top of my file.

Note: Python 2.4.1 under Windows


Any clue ?

Thanks,

hg
 
H

hg

hg said:
Hi,

I'v been facing some very strange errors lately:

one example:

def __init__(self):
....
import my_info
some_text = my_info.T_SOME_TEXT
^ syntax error


I manage to get rid of that one by moving the import on top of my file.

Note: Python 2.4.1 under Windows


Any clue ?

Thanks,

hg


PS:

and I also get some even weirder studd such as an error on line 374 when I
add a print on line 65

I'm using pydev + pydev ext

hg
 
H

hg

Facundo said:
hg wrote:



You'll need to paste here the exact code and the traceback.

Regards,

--
. Facundo
.
Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/

Hi,

the code is _very_ long and has many dependencies (the longest file has a
few thousand lines (GUI callbacks) ... I know, need to refactor / but my
client is in a hurry right now so that'll wait )

So I'm not sure how I can provide any source that'll help .

I'll try the untab function of pydev on all files and see whether that fixes
the problems

hg
 
T

Terry Reedy

| I'v been facing some very strange errors lately:
| one example:
|
| def __init__(self):
| ....
| import my_info
| some_text = my_info.T_SOME_TEXT
| ^ syntax error
|
| I manage to get rid of that one by moving the import on top of my file.
| Note: Python 2.4.1 under Windows
| Any clue ?

Mixing tabs and spaces and not matching (s and 's are typical causes.
 
P

Peter Otten

hg said:
I'v been facing some very strange errors lately:

one example:

def __init__(self):
....
import my_info
some_text = my_info.T_SOME_TEXT
^ syntax error


I manage to get rid of that one by moving the import on top of my file.

Note: Python 2.4.1 under Windows


Any clue ?

A guess: you may have mixed Unix ("\n") and Windows ("\r\n") newlines. Try
to ensure that every line ends with "\r\n".

Peter
 
D

David Nicolson

This might be stating the obvious, but have you detabbed your text,
if you are using spaces?
 
S

skip

I'v been facing some very strange errors lately: ...
hg> PS:

hg> and I also get some even weirder studd such as an error on line 374
hg> when I add a print on line 65

I think you're going to have to post a bit more of your code and some actual
tracebacks if people are to understand what the problem is. For example, we
can't tell what the relationship is in your code between lines 65 and 374
without actually seeing the code. I could look at those lines in an
arbitrary bit of my own code, but i doubt it would help. Maybe not all of
your code, but a few lines of code around the suspect points.

Skip
 
G

Georg Brandl

Peter said:
A guess: you may have mixed Unix ("\n") and Windows ("\r\n") newlines. Try
to ensure that every line ends with "\r\n".

That shouldn't be a problem since Python reads source files in universal
newline mode.

Georg
 
P

Peter Otten

Georg said:
Peter Otten schrieb:

That shouldn't be a problem since Python reads source files in universal
newline mode.

Oops, I should have guessed /that/.

Peter
 
J

John J. Lee

hg said:
Hi,

I'v been facing some very strange errors lately:

one example:

def __init__(self):
....
import my_info
some_text = my_info.T_SOME_TEXT
^ syntax error


I manage to get rid of that one by moving the import on top of my file.

Note: Python 2.4.1 under Windows


Any clue ?

Do you have an encoding declaration in that file? IIRC 2.4.1 gave
spurious syntax errors in some cases with files having coding
declarations.


John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top