Re: Simplify Code

2008-07-29 Thread Victor Subervi
Thanks. That worked. Victor On 7/16/08, Alexandr N Zamaraev <[EMAIL PROTECTED]> wrote: > > header_sizes = (36, 26, 22, 18, 14, 12) > if x not in header_sizes: > raise Exception() > else: > h36, h26, h22, h18, h14, h12 = tuple( >line if x == size else '' for x in header_sizes) > > > > -- > h

Re: Simplify Code

2008-07-15 Thread Alexandr N Zamaraev
header_sizes = (36, 26, 22, 18, 14, 12) if x not in header_sizes: raise Exception() else: h36, h26, h22, h18, h14, h12 = tuple( line if x == size else '' for x in header_sizes) -- http://mail.python.org/mailman/listinfo/python-list

Re: Simplify Code

2008-07-15 Thread Terry Reedy
Victor Subervi wrote: I set the following variables: # Headers are kept in order to determine nesting of chapters # They are labeled according to font size h36 = '' h26 = '' h22 = '' h18 = '' h14 = '' h12 = '' header_sizes = [36, 26, 22, 18, 14, 12] # Size is the font size of the header size =

Re: Simplify Code

2008-07-15 Thread Michiel Overtoom
Victor wrote... ># Headers are kept in order to determine nesting of chapters ># They are labeled according to font size I'm not sure what you're trying to achieve (I can't divine it from your example code), but I suspect that a dictionary of sizes and header texts is somewhat more manegable than

Re: Simplify Code

2008-07-15 Thread Michiel Overtoom
Victor wrote... ># del is used to determine if should reset the lower header values to '' >del = 0 Apart from many other things that spring to mind, I already see an obvious flaw: 'del' is a keyword, or a 'reserved word' in Python. It is used to remove variables from the namespace. Tip: Use some

Simplify Code

2008-07-15 Thread Victor Subervi
Hi; Forgive multiple posts in one day: online very infrequently I set the following variables: # Headers are kept in order to determine nesting of chapters # They are labeled according to font size h36 = '' h26 = '' h22 = '' h18 = '' h14 = '' h12 = '' header_sizes = [36, 26, 22, 18, 14, 12] # Size