0

I'm using the pydev plugin for Eclipse and have run across the problem whilst trying to include unicode strings. As far as I can tell this is NOT the common problem of unicode compatibility between pydev and the python on the commandline.

If I use a unicode string such as the following:

INFINITY_STRING = u"\u5555"

pydev flags it with the error:

Multiple markers at this line

- occurrence
- Undefined variable: u
- Encountered "\"\\u5555\"" at line 54, column 13. Was expecting one of:     <NEWLINE>                    ...     "(" ...     "[" ...     ";" ...     "," ...     "." ...     "+" ...     "-" ...       "*" ...     "/" ...     "//" ...    
"<<" ...     ">>" ...     "%" ...     "^" ...     "|" ...     "&" ...     "=" ...     ">" ...     "<" ...     "==" ...     "<=" ...     ">=" ...     "!=" ...     "or" ...     "and" ...     "not" ...     "is" ...     "in" ...     "if" ...     
";" ...     "," ...

The code compiles and runs but this supposed error messes up the autocompletion and refactoring features. Does anyone know how to prevent pydev from throwing an error when presented with unicode strings?

1
  • I can't see any problem with that on a Win7, Eclipse 3.6.1, Python 2.6 and pydev 2.7.1. Maybe it helps, if you specify the coding (e.g. # -*- coding: utf-8)? Commented Aug 20, 2013 at 9:38

1 Answer 1

1

My guess is you have configured pydev to run the code with Python 3 but you use Python 2 on the command line.

Python 3.0 doesn't support the u prefix for strings anymore; all strings in Python 3 are already Unicode.

Note that it has been restored with Python 3.3 (PEP-0414, docs). Kudos to Janne Karila for pointing that out.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, you were completely right, I'd got confused whether you needed the "u" in python 3.3 or not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.