python: length of list

2003-01-08 Thread Andre Poenitz
len(foo) doesn't work: (My first shot at python!) def change_preamble(lines): for line in lines: words = string.split(line) if len(words) 2: if [ \\oddsidemargin, \\evensidemargin, \\marginparwidth,

Re: python: length of list

2003-01-08 Thread Dekel Tsur
On Wed, Jan 08, 2003 at 12:34:51PM +0100, Andre Poenitz wrote: len(foo) doesn't work: (My first shot at python!) def change_preamble(lines): for line in lines: words = string.split(line) if len(words) 2: if [ \\oddsidemargin,

Re: python: length of list

2003-01-08 Thread Andre Poenitz
On Wed, Jan 08, 2003 at 01:52:04PM +0200, Dekel Tsur wrote: if [ \\oddsidemargin, \\evensidemargin, \\marginparwidth, \\textwidth, \\topmargin, \\textheight].count(words[0]) != 0: len = words[1] + words[2]

Re: python: length of list

2003-01-08 Thread Andre Poenitz
On Wed, Jan 08, 2003 at 01:52:04PM +0200, Dekel Tsur wrote: However, it is probably better to use searchreplace of regular expressions. def change_preamble(lines): for i in xrange(0, len(lines)): words = string.split(lines[i]) if len(words) 2 and

python: length of list

2003-01-08 Thread Andre Poenitz
len(foo) doesn't work: (My first shot at python!) def change_preamble(lines): for line in lines: words = string.split(line) if len(words) > 2: if [ "\\oddsidemargin", "\\evensidemargin", "\\marginparwidth",

Re: python: length of list

2003-01-08 Thread Dekel Tsur
On Wed, Jan 08, 2003 at 12:34:51PM +0100, Andre Poenitz wrote: > > len(foo) doesn't work: > > (My first shot at python!) > > def change_preamble(lines): > for line in lines: > words = string.split(line) > if len(words) > 2: > if [

Re: python: length of list

2003-01-08 Thread Andre Poenitz
On Wed, Jan 08, 2003 at 01:52:04PM +0200, Dekel Tsur wrote: > > if [ "\\oddsidemargin", "\\evensidemargin", "\\marginparwidth", > > "\\textwidth", "\\topmargin", >"\\textheight"].count(words[0]) != 0: > > len = words[1] +

Re: python: length of list

2003-01-08 Thread Andre Poenitz
On Wed, Jan 08, 2003 at 01:52:04PM +0200, Dekel Tsur wrote: > However, it is probably better to use search of regular expressions. def change_preamble(lines): for i in xrange(0, len(lines)): words = string.split(lines[i]) if len(words) > 2 and words[0] in