#ifdef like question.
holger krekel
pyth at devel.trillke.net
Tue May 14 09:24:57 EDT 2002
Roman Yakovenko wrote:
> Yes it is.
(meaning he wants to have either generators or normal
list-returning functions depending on the python-version)
well, you have two options:
(1) put the different versions in different files
(2) put both versions in one file
Most people will recommend to do it the (1) way.
This means you put your generator functions into e.g.
'funcs_generators.py' and the list-versions into
'funcs_oldway.py'
then:
try:
import funcs_generators as funcs
except:
import funcs_oldway as funcs
for item in funcs.getsome():
print item
where getsome could be a generator or a full-list-constructing
function.
If you want to put both versions into one file
it *is* possible but involves some tricks which
are considered 'bad style'. So i am only going
to show them if you don't want to go with the the other
method :-)
regards,
holger
P.S: i took this posting back to python-list at python.org
as i think you didn't mean to sent private mail.
More information about the Python-list
mailing list