On 10/19/06, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
>
> John Henry wrote:
> > I see lots of this "@expose" thing in the TurboGear tutorial.  Is this
> > a Python 2.4 feature?
>
> It's a decorator. The syntactic sugar for decorators is a Python 2.4
> feature, but decorators by themselves are not.

There is a way to make all of this work with 2.3, and TurboGears has
tried to maintain 2.3 compatibility, so you shouldn't have to update
your Python just to use TurboGears.

As Bruno mentioned:

@expose()
def myFunction():
    return "hi"

Is the equivelent of:

def myFunction():
   return "Hi"
myFunction=expose(myFunction)

That's not really pretty, so TurboGears provides Python 2.3 users with
a trick that allows you to use the following syntax:

[expose()]
def some_method(self, someval):
    return "Hi"

The preceding code works in both Python 2.3 and 2.4, so you can write
code that works on both versions of Python.

--Mark Ramm

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to