Ben Finney wrote:
Peter Otten __pete...@web.de writes:
Ben Finney wrote:
Peter Otten __pete...@web.de writes:
That's an unexpected inconsistency between list comprehensions
versus generator expressions, then. Is that documented explicitly in
the Python 2 documentation?
Peter Otten __pete...@web.de writes:
Ben Finney wrote:
Peter Otten __pete...@web.de writes:
That's an unexpected inconsistency between list comprehensions
versus generator expressions, then. Is that documented explicitly in
the Python 2 documentation?
On 2015-08-12 10:01, Ben Finney wrote:
How can I ensure incidental names don't end up in the class definition,
with code that works on both Python 2 and Python 3?
With the following class definition, the incidental names `foo` and
`bar`, only needed for the list comprehension, remain in the
Ben Finney wrote:
How can I ensure incidental names don't end up in the class definition,
with code that works on both Python 2 and Python 3?
With the following class definition, the incidental names `foo` and
`bar`, only needed for the list comprehension, remain in the `Parrot`
MRAB pyt...@mrabarnett.plus.com writes:
Have you thought about catching the NameError?
I had not, but that is obvious now you say it. Thanks.
Where there isn't a more elegant solution, I'll use that. It might not
be elegant, but it's at least clear and expressive of the intent.
Jussi
Peter Otten __pete...@web.de writes:
I would probably use a generator expression. These don't leak names:
That's an unexpected inconsistency between list comprehensions versus
generator expressions, then. Is that documented explicitly in the Python
2 documentation?
Python 2.7.6 (default, Jun
Ben Finney wrote:
Peter Otten __pete...@web.de writes:
I would probably use a generator expression. These don't leak names:
That's an unexpected inconsistency between list comprehensions versus
generator expressions, then. Is that documented explicitly in the Python
2 documentation?
How can I ensure incidental names don't end up in the class definition,
with code that works on both Python 2 and Python 3?
With the following class definition, the incidental names `foo` and
`bar`, only needed for the list comprehension, remain in the `Parrot`
namespace::
__metaclass__ =
On Wed, Aug 12, 2015 at 7:01 PM, Ben Finney ben+pyt...@benfinney.id.au wrote:
class Parrot:
A parrot with beautiful plumage.
plumage = [
(foo, bar) for (foo, bar) in feathers.items()
if bar == beautiful]
del foo, bar # ← FAILS,
On Thu, Aug 13, 2015 at 1:39 AM, Peter Otten __pete...@web.de wrote:
But I would probably use a generator expression. These don't leak names:
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type help, copyright, credits or license for more information.
class Parrot:
...
Ben Finney writes:
How can I ensure incidental names don't end up in the class
definition, with code that works on both Python 2 and Python 3?
With the following class definition, the incidental names `foo` and
`bar`, only needed for the list comprehension, remain in the `Parrot`
11 matches
Mail list logo