All Questions
5 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: ...
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 ...
2
votes
1
answer
155
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 ...
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 ...
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 ...