Re: Is this a bug of str.join?

Discussion in 'Python' started by Cameron Simpson, Feb 17, 2011.

  1. On 16Feb2011 12:01, Terry Reedy <> wrote:
    | On 2/16/2011 1:32 AM, fireinice wrote:
    | >I'm sorry, I found it should be the terminal width caused visual
    | >problem, please kindly ignore this post.
    |
    | For future reference, the way to get more info about what is really
    | in a string is to print its repr(), or even its list() version.
    | Len() is also helpful. On Windows, both the Command Prompt window
    | and IDLE refuse to expand tabs, so
    |
    | >>> s='\t'.join(('a','b','c'))
    | >>> str(s)
    | 'a\tb\tc'
    | >>> repr(s)
    | "'a\\tb\\tc'"
    | >>> len(s)
    | 5
    | >>> list(s)
    | ['a', '\t', 'b', '\t', 'c']

    And on UNIX, a common way to inspect program output at the character
    level is like this:

    python my_python-program | od -c

    possibly sent off into a temp file. That will let you see what character
    are actually escaping from the program (versus terry's suggestion, which
    is good for looking at the characters before they escape).

    Cheers,
    --
    Cameron Simpson <> DoD#743
    http://www.cskk.ezoshosting.com/cs/

    I'm not making any of this up you know. - Anna Russell
     
    Cameron Simpson, Feb 17, 2011
    #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. David
    Replies:
    2
    Views:
    502
    Thomas G. Marshall
    Aug 3, 2003
  2. Trevor

    sizeof(str) or sizeof(str) - 1 ?

    Trevor, Apr 3, 2004, in forum: C Programming
    Replies:
    9
    Views:
    660
    CBFalconer
    Apr 10, 2004
  3. Paul Du Bois
    Replies:
    1
    Views:
    334
    Tim Peters
    Apr 11, 2006
  4. fireinice

    Is this a bug of str.join?

    fireinice, Feb 16, 2011, in forum: Python
    Replies:
    4
    Views:
    218
    Terry Reedy
    Feb 16, 2011
  5. Ethan Furman
    Replies:
    4
    Views:
    269
    Roy Smith
    May 27, 2011
Loading...

Share This Page