Need help understanding some Python code
Posted
by Yarin
on Stack Overflow
See other posts from Stack Overflow
or by Yarin
Published on 2010-06-13T17:15:55Z
Indexed on
2010/06/13
17:22 UTC
Read the original article
Hit count: 221
python
I'm new to Python, and stumped by this piece of code from the Boto project:
class SubdomainCallingFormat(_CallingFormat):
@assert_case_insensitive
def get_bucket_server(self, server, bucket):
return '%s.%s' % (bucket, server)
def assert_case_insensitive(f):
def wrapper(*args, **kwargs):
if len(args) == 3 and not (args[2].islower() or args[2].isalnum()):
raise BotoClientError("Bucket names cannot contain upper-case " \
"characters when using either the sub-domain or virtual " \
"hosting calling format.")
return f(*args, **kwargs)
return wrapper
Trying to understand what's going on here.
- What is the '@' symbol in
@assert_case_sensitive
? - What do the args
*args, **kwargs
mean? - What does '
f
' represent?
Thanks!
© Stack Overflow or respective owner