Skip to main content

All Questions

24 votes
8 answers
7k views

Is using lambdas to express intent not pythonic?

PEP 8 states the following about using anonymous functions (lambdas) Always use a def statement instead of an assignment statement that binds a lambda expression directly to an identifier: # Correct: ...
N3buchadnezzar's user avatar
3 votes
2 answers
1k views

Python import order, mixing from ... import ... and import ... (and import ... as ...)

This is the mess of imports currently at the top of my file: import argparse from copy import deepcopy from functools import cmp_to_key, partial from itertools import chain import math from ...
user avatar
2 votes
1 answer
154 views

Is it considered bad form to call `next` on the input sequence of a list comprehension?

I want to extract lines from a stream that are preceded by the character L. The list comprehension below does the job, but calls next on the stream inside the comprehension in a way I've never seen ...
Elliot Gorokhovsky's user avatar
174 votes
23 answers
26k views

Programming cleanly when writing scientific code

I don't really write large projects. I'm not maintaining a huge database or dealing with millions of lines of code. My code is primarily "scripting" type stuff - things to test mathematical ...
auden's user avatar
  • 1,657
15 votes
5 answers
19k views

Is using nested function calls a bad thing?

In a recent homework assignment I ended up calling my functions in an ugly way uglyReceipt(cashParser(cashInput())) the program itself worked perfectly but I still felt like I was doing something ...
Carl Groth's user avatar