|
|
|
|
|
by cbo
5313 days ago
|
|
Not just PEP8-compliant. Some of these are just plain bad. The first one I was greeted with when I opened the site was: > print eval('+'.join(map(str, [1, 1]))) If I ever saw this in production code, I would lose my mind. It's the kind of one-liner I'd expect to find in an obfuscated code competition. It's not intuitively understood, shows a lack of basic Python functionality (the builtin sum() function), and most of all, it's SLOW. As in, 54 times slower than a simple sum -- tested on xrange(1,10) -- on my development Macbook Pro. That said, clicking through some other examples, there are a lot of great Python examples on this site. Just beware of some of them, and always make sure you test new code yourself. |
|