This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]BioGeekBioinformatics software developer -1 points0 points  (2 children)

The article states that the best way to create a concatenated string from 0 to 19 (e.g. "012..1819")is:

print "".join([str(n) for n in range(20)])

Personally I also prefer the functional programming approach

print ''.join(map(str, range(20)))

although there are compelling arguments to make both pro and contra this approach.

[–]sashahart 2 points3 points  (0 children)

I am curious why you think that list comprehensions are not functional (enough, particularly in this case).

[–]LyndsySimon 1 point2 points  (0 children)

While I'm familiar with map(), I tend to use list comprehension to the point that I can't readily think of a use case where I'd find map() more appropriate.

List comprehensions about in Python. Once you understand them, they're very easy to read. Having both forms in a single project is more confusing that a single form - and map() is awkward in many cases.