3 ms·
If whoever created this stops by, I got an error message on this snippet: import itertools name_generator = itertools.imap("name-{}".format,itertools.c
by cschmidt 15y ago
If whoever created this stops by, I got an error message on this snippet:
import itertools
name_generator = itertools.imap("name-{}".format,itertools.count())
# to get the next name:
new_name = next(name_generator)
- ronreiter 15y agothanks
- rplnt 15y agohttp://facts.learnpython.org/2003 http://facts.learnpython.org/2003 gives me error as well
- zalew 15y agoI came across another error map(int, "10 20 30".split()) Output:
- AgentConundrum 15y agoWhat's the error you're getting? That code worked fine for me (2.7.2) >>> import itertools >>> name_generator = itertools.imap("name-{}".format,itertools.count()) >>> new_name = next(name_generator) >>> new_name 'name-0' >>> new_name = next(name_generator) >>> new_name 'name-1'
- koenigdavidmj 15y agoIn 2.6 or earlier replace the last line with: new_name = name_generator.next()
- neq 15y agoThe python version available is 2.5.2 yet some of the tips use newer features and syntax. This is definitely a problem.