On Dec 30, 2008, at 10:30 PM, James Mills wrote:
On Wed, Dec 31, 2008 at 12:55 PM, Yanom Mobis <yanom@xxxxxxxxxxxxxx> wrote:I was reading some Python code examples, and i found the @ symbol. Whatexactly does this operator do?This syntax was introduced in Python 2.4 ? IIRC They are called "Decorators". That is, function decorators. As Noah has said, you use them to wrap up a function within another function.
They were called function decorators, but now in 2.6 and 3.0 you can use them on classes too (so the syntax is just "decorator"). This allows much simpler implementations of many patterns that used to require using a metaclass.
--Noah