473,398 Members | 2,212 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Re: mean of arobase in python

Guilhem Faure wrote:
What means @ in python ?
usually called "at sign" in english.
In this script for exemple (this script return an error in my konsole...)

@f1(arg)
@f2
def func(): pass

I see several script where used this symbol but I can't understand.
in your example, "f1(arg)" and "f2" are decorators. the above is
equivalent to writing

def func():
pass
func = f1(arg)(f2(func))

that is, define a function, and then pass it to the function "f2", and
then to the function that's returned by calling "f1(arg)". the final
value of the "func" variable is whatever the decorators returned.

the decorator functions (f2 and whatever f1(arg) returns) can manipulate
the function being defined, or even replace it with something else.

specification:

http://www.python.org/dev/peps/pep-0318/

some (semi-advanced) articles:

http://www.ibm.com/developerworks/li...l-cpdecor.html
http://www.phyast.pitt.edu/~micheles...mentation.html

</F>

Jul 23 '08 #1
0 891

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ng Pheng Siong | last post by:
Hi, I just noticed that demo/evp_ciph_test.py of my M2Crypto package causes a core dump. It used to not do that. ;-) The core dump happens when the program is exiting; in the output below,...
2
by: mr. ice | last post by:
I am new to python, The following statement is in the beginning of class definition in a python scripts, what does it mean? Help? class %(class_)s_W : public XMsg_W { icemon
37
by: Jon Perez | last post by:
I saw this code snippet: sock.listen(20) for _ in range(20): newsock, client_addr = sock.accept() print "Client connected:", client_addr data = "" why use _ for this example? Is there any...
7
by: Jonathan Fine | last post by:
Giudo has suggested adding optional static typing to Python. (I hope suggested is the correct word.) http://www.artima.com/weblogs/viewpost.jsp?thread=85551 An example of the syntax he proposes...
14
by: John Coleman | last post by:
Greetings, I am currently trying to learn Python through the excellent "Learning Python" book. I wrote my first non-trivial program, which began with several comment lines. One of the comment...
4
by: yaru22 | last post by:
Hi. I just started learning python. In the exercise in my book, it asks me to try print "%u" % (-5) I'm wondering what this %u mean? Thank you. Regards,
8
by: SpreadTooThin | last post by:
import array a = array.array('f', ) print a.mean() print a.std_dev() Is there a way to calculate the mean and standard deviation on array data? Do I need to import it into a Numeric Array...
7
by: p.lavarre | last post by:
Subject: announce: FAQs suggested ... That suggested FAQ is misleadingly incorrect as stated - we need help rewording it. /F correctly commented: "eval" is never a good choice if you cannot...
4
by: zslevi | last post by:
I've been reading the following example, and couldn't figure out, what **kw mean. (It's an empty dictionary, but what's the semantics): def wrap(method): def wrapped(self, *args, **kw): print...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.