En Wed, 25 Jul 2007 11:45:00 -0300, Jeff <[EMAIL PROTECTED]> escribió:
> You can create a lexical closure using a Python generator function,
> which allows iteration using a block of code while maintaining
> internal state. A generator is a regular function which uses yield
> (like Ruby) to defin
True, and I should have known better than to not have thoroughly
tested code I post to Usenet :). That being said, it was intended as
a fast example of how a generator operates for someone coming from
Ruby.
--
http://mail.python.org/mailman/listinfo/python-list
On Jul 24, 7:58 am, treble54 <[EMAIL PROTECTED]> wrote:
> Does anyone know a way to use closures or blocks in python like those
> used in Ruby? Particularly those used in the { } braces.
Inner functions allow you to define closures and (named) blocks
anywhere). Anonymous blocks must consist of a
Jeff wrote:
> # Generic counter
> def counter(min=None, max):
> if not min:
> min = 0
> for i in xrange(min, max):
> yield i
> i = i + 1
>
Just for the record:
>>> # Generic counter
... def counter(min=None, max):
... if not min:
... min = 0
... for i in xrange(min, max)
In article <[EMAIL PROTECTED]>,
Jason <[EMAIL PROTECTED]> wrote:
.
[good detail]
.
.
>If you can't find a way of doing what you want with iterators,
>comprehensions, or lambda, consider writing a little functio
You can create a lexical closure using a Python generator function,
which allows iteration using a block of code while maintaining
internal state. A generator is a regular function which uses yield
(like Ruby) to define the point at which the function should return an
expression to the calling cod
treble54 a écrit :
> Does anyone know a way to use closures or blocks in python like those
> used in Ruby? Particularly those used in the { } braces.
>
Instead of looking for what you think is the solution, you'd be better
explaining your concrete problem.
--
http://mail.python.org/mailman/listi
On Jul 24, 8:58 am, treble54 <[EMAIL PROTECTED]> wrote:
> Does anyone know a way to use closures or blocks in python like those
> used in Ruby? Particularly those used in the { } braces.
Python isn't Ruby. Python has a lambda function for creating
anonymous functions, but many of the common use c
On 2007-07-24, treble54 <[EMAIL PROTECTED]> wrote:
> Does anyone know a way to use closures or blocks in python like
> those used in Ruby? Particularly those used in the { } braces.
Python's nameless functions are week. So it supports iterators
and generators using protocols, comprehensions and a
On Tue, 2007-07-24 at 14:58 +, treble54 wrote:
> Does anyone know a way to use closures or blocks in python like those
> used in Ruby? Particularly those used in the { } braces.
Please describe the problem you're trying to solve. Even if Python had a
direct equivalent of "Ruby closures or bloc
Does anyone know a way to use closures or blocks in python like those
used in Ruby? Particularly those used in the { } braces.
--
http://mail.python.org/mailman/listinfo/python-list
11 matches
Mail list logo