python Programming Glossary: my_function
What does `@` mean in Python? http://stackoverflow.com/questions/1053732/what-does-mean-in-python fashion. So doing something like this @login_required def my_function pass Is just a fancy way of doing this def my_function pass.. def my_function pass Is just a fancy way of doing this def my_function pass my_function login_required my_function For more check out.. Is just a fancy way of doing this def my_function pass my_function login_required my_function For more check out the documentation..
Python normal arguments vs. keyword arguments http://stackoverflow.com/questions/1419046/python-normal-arguments-vs-keyword-arguments and can't be passed positionally. The syntax is def my_function arg1 arg2 kwargs Any keyword arguments you pass into this function.. the keys of this dictionary at run time like this def my_function kwargs print str kwargs my_function a 12 b abc 'a' 12 'b' 'abc'..
Function inside function - every time? http://stackoverflow.com/questions/16031092/function-inside-function-every-time can check the bytecode with the dis module import dis def my_function ... def little_function ... print Hello World ... ... dis.dis.. def little_function ... print Hello World ... ... dis.dis my_function 2 0 LOAD_CONST 1 code object little_function at 0xb74ef9f8 file.. inner function is compiled only once . Every time you call my_function it is loaded and a new function object is created in this sense..
How to get the function name as string in Python? http://stackoverflow.com/questions/251464/how-to-get-the-function-name-as-string-in-python function name as a string without calling the function def my_function pass print get_function_name_as_string my_function # my_function.. def my_function pass print get_function_name_as_string my_function # my_function is not in quotes should output my_function . Is.. pass print get_function_name_as_string my_function # my_function is not in quotes should output my_function . Is this available..
Python - making decorators with optional arguments http://stackoverflow.com/questions/3888158/python-making-decorators-with-optional-arguments wrapper return decorator Example The following decorates my_function with foo_register instead of ever making it to decorator . @foo_register.. instead of ever making it to decorator . @foo_register def my_function print 'hi...' Example The following works as expected. @foo_register.. following works as expected. @foo_register 'say_hi' def my_function print 'hi...' If I want it to work correctly in both applications..
python - why use def main() [duplicate] http://stackoverflow.com/questions/4041238/python-why-use-def-main the top of the file then just write code under it ie def my_function # my code here def my_function_two # my code here # some code.. write code under it ie def my_function # my code here def my_function_two # my code here # some code # call function # print something..
|