What's with the @ sign

jordan.taylor2 at gmail.com jordan.taylor2 at gmail.com
Tue May 23 13:13:55 EDT 2006


What's with code that has the @ symbol in front of classes or
functions?  This has probably already been asked but I can't find any
info on it.

Here is a slice of code I found that uses this, can someone please
explain what the @'s for??
::

def option_error_decorator(func):
    def wrapper(*a, **k):
        try:
            return func(*a, **k)
        except _socket.error, (errno, info):
            raise SocketOptionError(errno, info)
    return wrapper

def BoolOption(level, option):
    @option_error_decorator
    def getter(self):
        return bool(self._sock.getsockopt(level, option))
    @option_error_decorator
    def setter(self, value):
        return self._sock.setsockopt(level, option, int(value))
    return property(getter, setter)
::

Thanks in advance,
Jordan




More information about the Python-list mailing list