rules of thumb for cross os code
Bruno Desthuilliers
bruno.42.desthuilliers at websiteburo.invalid
Tue Aug 26 04:35:46 EDT 2008
DwBear75 a écrit :
> I am considering using python as a replacement for a lot of bash
> scripting that I have been doing. I would like to be as cross platform
> as possible, writing scripts for both windows and linux. Are there any
> guides are general rules of thumb on
> 1) keeping code os independant
<obvious>
Use os.path, avoid any os-specific module.
</obvious>
> 2) nifty lambda's or other things to create functions fit for the
> environment
You don't need lambdas here.
import random
some_condition = random.choice((True, False))
if some_condition:
def myfunc():
print "myfunc for 'somecondition==True'"
else:
def myfunc():
print "myfunc for 'somecondition==False'"
More information about the Python-list
mailing list