Skip to content
murmot

Results for “python split example site:mail.python.org”

  • mail.python.org

    [Tutor] Splitting strings and undefined variables - Python

    Feb 10, 2009 · [Tutor] Splitting strings and undefined variables Andreas Kostyrka andreas at kostyrka.org Tue Feb 10 19:45:47 CET 2009 Previous message: [Tutor] Splitting strings and undefined variables Next message: [Tutor] Simple PassGen Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

  • mail.python.org

    [Tutor] Iterating through tokens from a split command - Python

    Hi Vicki, A couple of things here. First you only ever read a single line from the file. You then iterate over the tokens in that line but never stop - hence the index error! You probably want to restructure it soomething like: for line in inputfile.readlines (): #readlines, plural! tokens = line.split ['|'] for token in tokens: # iterates over the tokens if token == '0x11': new = '0x02 ...

  • mail.python.org

    [Tutor] Parsing text file - Python

    For each rule, write a Python function that tries to recognize what the rule describes. To do its job, each function might call other functions that implement other grammar rules and might call a tokenizer function (see below) when it needs another token from the input stream.

  • mail.python.org

    [Tutor] Splitting at a capital letter in a string - Python

    Oct 29, 2004 · This says, match any capital letter that is preceded by any character: >>> import re >>> s='HiImAStringWithCaps' >>> re.sub (r' (?<=.) ( [A-Z])', r' \1', s) 'Hi Im A String With Caps' If you really want to split the string, use re.findall: >>> re.findall (' [A-Z] [^A-Z]*', s) ['Hi', 'Im', 'A', 'String', 'With', 'Caps'] Kent At 08:14 PM 10/29 ...