How to create functors?

Robert Dailey rcdailey at
Tue Aug 18 22:27:49 CEST 2009


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" )

However, the above code fails with:

  File "C:\IT\work\distro_test\", line 286
    print1 = lambda: print( "Foobar" )
SyntaxError: invalid syntax

How can I get this working?

More information about the Python-list mailing list