User Profile

Collapse

Profile Sidebar

Collapse
Slippy27
Slippy27
Last Activity: Aug 12 '08, 03:16 PM
Joined: May 2 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Slippy27
    replied to newbie: how do I test a byte string?
    I guess I get to solve my own thread (thanks again to the Natural Language Toolkit's online tutorial). The function repr() appears to give me what I need:

    [code=Python]
    line = u'\u0144'
    line_utf = line.encode('ut f8')

    print 'line = ', line_utf
    print 'line repr = ', repr(line_utf)
    [/code]

    Output:
    line = Å„
    line repr = '\xc5\x84'

    It's the...
    See more | Go to post

    Leave a comment:


  • If you want to count all members of the list without specifying which one to count, you could use this reasonably standard count method (this is from the Natural Language Toolkit's online Python tutorial: http://nltk.org/doc/en/programming.htm l)

    [code=Python]
    alist = [1,2,3,4,4,4]

    count = {}
    for thing in alist: # iterates though each member of your list
    if thing not in count: # checks...
    See more | Go to post

    Leave a comment:


  • Slippy27
    started a topic newbie: how do I test a byte string?

    newbie: how do I test a byte string?

    How do I test a byte string in Python? I want to manually convert (no libraries or functions) a UTF-8 string into UTF-16.

    My basic solution is to read from the stream some number of UTF-8 bytes, convert them into codepoints, then convert those codepoints into UTF-16 bytes. I want to code this myself, but I don't understand how to test the actual byte sequence.

    Let's say I use the following code to ensure I have a UTF-8...
    See more | Go to post

  • EXCELLENT! This worked perfectly. Thread SOLVED!! Thanks!
    See more | Go to post

    Leave a comment:


  • Slippy27
    started a topic help for newbie -- using find() for exact match

    help for newbie -- using find() for exact match

    I'm trying to modify a find/replace script which iterates through a file A and makes replacements defined in a csv file B. My original goal was to change any line in file A containing a search string (in whole or as a substring) defined in file B. File B contains both the search string and the string it should be changed into.

    Example file A
    whippy
    slippy
    ippy
    slippy
    snoob
    flop
    bloppy...
    See more | Go to post
No activity results to display
Show More
Working...