On u'Unicode string literals' (Py3)

Discussion in 'Python' started by jmfauth, Feb 29, 2012.

  1. jmfauth

    jmfauth Guest

    For those who do not know:
    The u'' string literal trick has never worked in Python 2.

    >>> sys.version

    '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]'
    >>> print u'Un oeuf à zéro EURO uro'

    Un uf à zéro uro
    >>>


    jmf
    jmfauth, Feb 29, 2012
    #1
    1. Advertising

  2. jmfauth

    Dave Angel Guest

    Just who are you replying to?

    On 02/29/2012 08:45 AM, jmfauth wrote:
    > For those who do not know:
    > The u'' string literal trick has never worked in Python 2.
    >


    No trick there. If you have something explicit to say, then say it.
    >>>> sys.version

    > '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]'


    Why then does the subject line say Py3 ?

    >>>> print u'Un oeuf à zéro EURO uro'


    You're testing three things here, so there's no telling which might be
    wrong. Your source encoding, the implicit str() conversion for unicode,
    and the particular terminal you're printing it on. It'd be amazing if
    all three were right, unless you're on Linux.

    > Un uf à zéro uro
    > jmf



    --

    DaveA
    Dave Angel, Feb 29, 2012
    #2
    1. Advertising

  3. jmfauth

    jmfauth Guest

    Re: On u'Unicode string literals' reintroduction (Py3)

    On 29 fév, 14:45, jmfauth <> wrote:
    > For those who do not know:
    > The u'' string literal trick has never worked in Python 2.
    >
    > >>> sys.version

    >
    > '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]'>>> print u'Un oeuf à zéro EURO uro'
    >
    > Un  uf à zéro  uro
    >
    >
    >
    > jmf



    Sorry, I just wanted to show a small example.
    I semms Google as "changed" again.

    You should read (2nd attempt)
    u'Un œuf à zéro €' with the *correct* typed glyphs 'LATIN SMALL
    LIGATURE OE'
    in œuf and 'EURO SIGN' in '€uro'.

    jmf
    jmfauth, Feb 29, 2012
    #3
    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:
    4
    Views:
    872
    Roedy Green
    Nov 21, 2005
  2. John Goche
    Replies:
    8
    Views:
    16,430
  3. nico
    Replies:
    6
    Views:
    771
  4. Gnarlodious

    Py3: Read file with Unicode characters

    Gnarlodious, Apr 8, 2010, in forum: Python
    Replies:
    4
    Views:
    341
    Gnarlodious
    Apr 8, 2010
  5. jmfauth

    Py3.3 unicode literal and input()

    jmfauth, Jun 18, 2012, in forum: Python
    Replies:
    24
    Views:
    531
    Steven D'Aprano
    Jun 25, 2012
Loading...

Share This Page