Re: ur'foo' syntax under Python 3

Discussion in 'Python' started by Mark Lawrence, Feb 8, 2014.

  1. On 08/02/2014 19:38, Lele Gaifax wrote:
    > Hi all,
    >
    > I'm using Python 3.3, and I was surprised to realize that it does not
    > support the old Python 2 syntax ur"literal-raw-unicode-strings".
    >
    > Is there any trick to write such literals in a Python2+3 compatible
    > source?
    >
    > Is there a rationale behind the invalid syntax or is it just a glitch?
    >
    > thanks in advance,
    > bye, lele.
    >


    From
    http://docs.python.org/3.3/reference/lexical_analysis.html#string-and-bytes-literals

    "Both string and bytes literals may optionally be prefixed with a letter
    'r' or 'R'; such strings are called raw strings and treat backslashes as
    literal characters. As a result, in string literals, '\U' and '\u'
    escapes in raw strings are not treated specially. Given that Python
    2.x’s raw unicode literals behave differently than Python 3.x’s the 'ur'
    syntax is not supported."

    --
    My fellow Pythonistas, ask not what our language can do for you, ask
    what you can do for our language.

    Mark Lawrence

    ---
    This email is free from viruses and malware because avast! Antivirus protection is active.
    http://www.avast.com
     
    Mark Lawrence, Feb 8, 2014
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    404
    John Roth
    Jul 29, 2005
  2. .rhavin grobert

    vector: Foo[5] == ((foo*)Foo) + 5 ?

    .rhavin grobert, Sep 23, 2008, in forum: C++
    Replies:
    4
    Views:
    418
    JaredGrubb
    Sep 24, 2008
  3. Replies:
    4
    Views:
    170
    Thomas 'PointedEars' Lahn
    Dec 23, 2007
  4. Lele Gaifax

    ur'foo' syntax under Python 3

    Lele Gaifax, Feb 8, 2014, in forum: Python
    Replies:
    0
    Views:
    76
    Lele Gaifax
    Feb 8, 2014
  5. Peter Otten

    Re: ur'foo' syntax under Python 3

    Peter Otten, Feb 8, 2014, in forum: Python
    Replies:
    0
    Views:
    61
    Peter Otten
    Feb 8, 2014
Loading...

Share This Page