Re: Why do this?
Fredrik Lundh wrote:
[...]
I especially liked the #end if comments after the single guarded lines.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
Fredrik Lundh wrote:
Lawrence D'Oliveiro wrote:
>
>
>
>
now that's some remarkably ugly Python code. it's well-known that people can
write Fortran in all languages, but writing Visual Basic in Python? (shudder)
>
>
>>Secondly, it's less convenient for cases where a dynamic query is being
>>built. I previously gave the SQLStringList example. If that's not enough,
>>here's another (simple) one:
>>
>>Conditions = []
>>if Name != None :
> Conditions.appe nd("name = %s" % SQLString(Name) )
>>#end if
>>if Address != None :
> Conditions.appe nd("address = %s" % SQLString(Addre ss))
>>#end if
>>if PhoneNr != None :
> Conditions.appe nd("phone_nr = %s" % SQLString(Phone Nr))
>>#end if
>>Query = "select * from table"
>>if len(Conditions) != 0 :
> Query += " where " + " and ".join(Conditio ns)
>>#end if
>>built. I previously gave the SQLStringList example. If that's not enough,
>>here's another (simple) one:
>>
>>Conditions = []
>>if Name != None :
> Conditions.appe nd("name = %s" % SQLString(Name) )
>>#end if
>>if Address != None :
> Conditions.appe nd("address = %s" % SQLString(Addre ss))
>>#end if
>>if PhoneNr != None :
> Conditions.appe nd("phone_nr = %s" % SQLString(Phone Nr))
>>#end if
>>Query = "select * from table"
>>if len(Conditions) != 0 :
> Query += " where " + " and ".join(Conditio ns)
>>#end if
>
now that's some remarkably ugly Python code. it's well-known that people can
write Fortran in all languages, but writing Visual Basic in Python? (shudder)
this is Python, after all, and as we all know, "the joy of coding Python should be
in seeing short, concise, readable classes that express a lot of action in a small
amount of clear code - not in reams of trivial code that bores the reader to death".
>
in seeing short, concise, readable classes that express a lot of action in a small
amount of clear code - not in reams of trivial code that bores the reader to death".
>
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
Comment