[Tutor] parsing .txt

Kent Johnson kent37 at tds.net
Tue Jun 10 14:19:27 CEST 2008


On Tue, Jun 10, 2008 at 7:45 AM, bob gailer <bgailer at gmail.com> wrote:
> questionary = []
>
> for line in textdata.split('\n'):
>   if line:
>       tag, content = line.split(' ', 1)
         tag = tag[1:] # strip leading %
>       if tag == "question":
>           questionary.append({tag : content})
>       else:
>           questionary[-1].update({tag : content})

or
  questionary[-1][tag] = content

Kent


More information about the Tutor mailing list