Steven D'Aprano ste...@remove.this.cybersource.com.au writes:
According to Wikipedia, functor can be used as a synonym for function
object: ... http://en.wikipedia.org/wiki/Function_object
Hmm, I hadn't seen that usage before. I guess there's no law against
it, but it seems a bit bogus to me.
As near as I can tell, a functor is just an object which is
callable like a function
I believe that's how they're defined in the C++ world, in which, of
course, functions aren't first-class objects...
-
Rami Chowdhury
Never assume malice when stupidity will suffice. -- Hanlon's
Steven D'Aprano ste...@remove.this.cybersource.com.au writes:
As near as I can tell, a functor is just an object which is
callable like a function without actually being implemented as a
function, e.g.:
No it's not anything like that either, at least as I'm used to the
term in programming or
On Thu, 20 Aug 2009 01:36:14 -0700, Paul Rubin wrote:
Steven D'Aprano ste...@remove.this.cybersource.com.au writes:
As near as I can tell, a functor is just an object which is callable
like a function without actually being implemented as a function, e.g.:
No it's not anything like that
On Aug 20, 2009, at 5:25 AM, Steven D'Aprano wrote:
On Thu, 20 Aug 2009 01:36:14 -0700, Paul Rubin wrote:
Steven D'Aprano ste...@remove.this.cybersource.com.au writes:
As near as I can tell, a functor is just an object which is callable
like a function without actually being implemented as
Terry Reedy a écrit :
Robert Dailey wrote:
I'm using Python 2.6. And using the legacy syntax in the lambda does
not work either. I want to avoid using a def if possible. Thanks.
In Python, writing
name = lambda arg: expr
instead of
def name(arg): return expr
is all negative and no
On Wed, 2009-08-19 at 15:56 +0200, Bruno Desthuilliers wrote:
Terry Reedy a écrit :
Robert Dailey wrote:
I'm using Python 2.6. And using the legacy syntax in the lambda does
not work either. I want to avoid using a def if possible. Thanks.
In Python, writing
name = lambda arg:
Robert Dailey rcdai...@gmail.com writes:
I want to simply wrap a function up into an object so it can be called
with no parameters.
Nitpick: what you are asking for is called a closure. Functor means
something completely different. As a few other people have explained,
print in python 2.x is
On Wed, 19 Aug 2009 18:42:32 -0700, Paul Rubin wrote:
Robert Dailey rcdai...@gmail.com writes:
I want to simply wrap a function up into an object so it can be called
with no parameters.
Nitpick: what you are asking for is called a closure. Functor means
something completely different.
Robert Dailey wrote:
I'm using Python 2.6. And using the legacy syntax in the lambda does
not work either. I want to avoid using a def if possible. Thanks.
In Python, writing
name = lambda arg: expr
instead of
def name(arg): return expr
is all negative and no positive and should be
Hello,
I want to simply wrap a function up into an object so it can be called
with no parameters. The parameters that it would otherwise have taken
are already filled in. Like so:
print1 = lambda: print( Foobar )
print1()
However, the above code fails with:
File
Robert Dailey rcdai...@gmail.com wrote:
Hello,
I want to simply wrap a function up into an object so it can be called
with no parameters. The parameters that it would otherwise have taken
are already filled in. Like so:
print1 = lambda: print( Foobar )
print1()
However,
On Aug 18, 3:31 pm, Duncan Booth duncan.bo...@invalid.invalid wrote:
Robert Dailey rcdai...@gmail.com wrote:
Hello,
I want to simply wrap a function up into an object so it can be called
with no parameters. The parameters that it would otherwise have taken
are already filled in. Like so:
On Aug 18, 3:31 pm, Duncan Booth duncan.bo...@invalid.invalid wrote:
Robert Dailey rcdai...@gmail.com wrote:
Hello,
I want to simply wrap a function up into an object so it can be called
with no parameters. The parameters that it would otherwise have taken
are already filled in. Like so:
On Tue, Aug 18, 2009 at 1:32 PM, Robert Daileyrcdai...@gmail.com wrote:
On Aug 18, 3:31 pm, Duncan Booth duncan.bo...@invalid.invalid wrote:
Robert Dailey rcdai...@gmail.com wrote:
Hello,
I want to simply wrap a function up into an object so it can be called
with no parameters. The
On Aug 18, 3:40 pm, Chris Rebert c...@rebertia.com wrote:
On Tue, Aug 18, 2009 at 1:32 PM, Robert Daileyrcdai...@gmail.com wrote:
On Aug 18, 3:31 pm, Duncan Booth duncan.bo...@invalid.invalid wrote:
Robert Dailey rcdai...@gmail.com wrote:
Hello,
I want to simply wrap a function up into
Lambda expressions are, I believe, syntactically limited to a single
expression -- no statements, like 'print' is in Python 2.x.
If you are strongly against just defining a function, you might have to
use a trick to get around it -- this page
In article
c217c4a4-b891-469e-af4f-4e44e2c95...@z24g2000yqb.googlegroups.com,
Robert Dailey rcdai...@gmail.com wrote:
On Aug 18, 3:31 pm, Duncan Booth duncan.bo...@invalid.invalid wrote:
Robert Dailey rcdai...@gmail.com wrote:
Hello,
I want to simply wrap a function up into an object
18-08-2009 o 22:32:55 Robert Dailey rcdai...@gmail.com wrote:
On Aug 18, 3:31 pm, Duncan Booth duncan.bo...@invalid.invalid wrote:
Robert Dailey rcdai...@gmail.com wrote:
Hello,
I want to simply wrap a function up into an object so it can be called
with no parameters. The parameters that
On Aug 18, 3:45 pm, Rami Chowdhury rami.chowdh...@gmail.com wrote:
Lambda expressions are, I believe, syntactically limited to a single
expression -- no statements, like 'print' is in Python 2.x.
If you are strongly against just defining a function, you might have to
use a trick to get
On Aug 18, 3:51 pm, Jan Kaliszewski z...@chopin.edu.pl wrote:
18-08-2009 o 22:32:55 Robert Dailey rcdai...@gmail.com wrote:
On Aug 18, 3:31 pm, Duncan Booth duncan.bo...@invalid.invalid wrote:
Robert Dailey rcdai...@gmail.com wrote:
Hello,
I want to simply wrap a function up into
On Tue, Aug 18, 2009 at 4:27 PM, Robert Daileyrcdai...@gmail.com wrote:
Hello,
I want to simply wrap a function up into an object so it can be called
with no parameters. The parameters that it would otherwise have taken
are already filled in. Like so:
print1 = lambda: print( Foobar )
why am I able to use print as a
function in general-purpose code in my Python 2.6 script
I believe it's because that is parsed as the print statement followed by a
parenthesized expression.
On Tue, 18 Aug 2009 13:42:59 -0700, Robert Dailey rcdai...@gmail.com
wrote:
On Aug 18, 3:40 pm,
On 2009-08-18, Robert Dailey rcdai...@gmail.com wrote:
Hello,
I want to simply wrap a function up into an object so it can be called
with no parameters. The parameters that it would otherwise have taken
are already filled in. Like so:
print1 = lambda: print( Foobar )
print1()
The example I gave earlier is a bit contrived, the real example
fundamentally requires a lambda since I am actually passing in local
variables into the functions the lambda is wrapping. Example:
def MyFunction():
localVariable = 20
CreateTask( lambda: SomeOtherFunction( localVariable ) ) #
The example I gave earlier is a bit contrived, the real example
fundamentally requires a lambda since I am actually passing in local
variables into the functions the lambda is wrapping. Example:
funcs = []
for i in xrange(10):
def f(i=i):
print i
funcs.append(f)
for f in
Dnia 18-08-2009 o 22:51:19 Robert Dailey rcdai...@gmail.com napisał(a):
The example I gave earlier is a bit contrived, the real example
fundamentally requires a lambda since I am actually passing in local
variables into the functions the lambda is wrapping. Example:
def MyFunction():
27 matches
Mail list logo