Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
reinhardt
on May 19, 2012
|
parent
|
context
|
favorite
| on:
A few things to remember while coding in Python
A better way: varname = (x for x in l if predicate_with_single_truth_value(x)).next()
Estragon
on May 19, 2012
[–]
That avoids the construction of the list, but doesn't check that the sequence only contains one value, which was the point of the example.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: