4 ms·
I totally agree with you on indentation. I started with PHP and didn't bother indenting at all for a long time, then when I did it was only a single space. I tr
by Jach 15y ago
I totally agree with you on indentation. I started with PHP and didn't bother indenting at all for a long time, then when I did it was only a single space. I tried three spaces for a while in an AP CS course in high school (I also tried and hated Python for a weekend during that first semester), then toward the end of that year I learned Python more seriously and fell in love. I still only indent two spaces though, my One True Way. =P
I think part of my initial dislike for Python was manually typing nested indentation, even with one space the level for class->def->for->if can get annoying to type. I used to use EditPad Lite that didn't have auto-indent. Everything got better once I learned vim.
Regarding multi-line lambdas in Python, you can do it more or less but like you said it's not clean and can be dangerous.
a = [1]
blah = lambda x: eval(compile('''
print x
a.append(x)
''', '', 'exec'))