r/Python • • Feb 28 '13

What's the one code snippet/python trick/etc did you wish you knew when you learned python?

I think this is cool:

import this

259 Upvotes

307 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Feb 28 '13

[deleted]

7

u/Fayden Feb 28 '13

Lambda syntax is a bit awkward in Python (in opposition of functional languages, where you can usually use partial application). I think it's easier to read generator expressions or list comprehensions in Python.

9

u/yen223 Feb 28 '13

It's not accidental. Guido van Rossum is explicitly trying to avoid functional programming styles in Python.

Informative StackOverflow link: http://stackoverflow.com/questions/1017621/why-isnt-python-very-good-for-functional-programming

9

u/vext01 Feb 28 '13

Yet python's functional programming support is pretty decent.

3

u/selementar Feb 28 '13

a pain when using the debugger, as pdb wants to hit that line for each element

There's a command unt for that (and useful for any loop at all, not just the comprehensions).

3

u/demosthenes02 Feb 28 '13

Use the until command in pdb. Check it out!

2

u/krypton86 Feb 28 '13

Yoink! — the sound of me stealing that