What is **kwargs mean in python? When you put double **, does it mean
passing by reference?
For example:
def redirect_to(request, url, **kwargs): 2 8770
johnny a écrit :
What is **kwargs mean in python? When you put double **, does it mean
passing by reference?
Nope.
Python as support for both positional (*args) and named (**kwargs) varargs.
For example:
def redirect_to(request, url, **kwargs):
means that redirect_to expect a positional 'request' arg, a positional
'url' argument, and any other arbitrary named arguments.
You'll find all relevant doc in the FineManual(tm): http://www.python.org/doc/current/tu...00000000000000
HTH
johnny wrote:
What is **kwargs mean in python? When you put double **, does it mean
passing by reference?
here's a little example:
>>def f(a, *args, **kw):
.... print 'a:',a
.... print 'args:',args
.... print 'kw:',kw
....
>>f(1,2,3,x=4)
a: 1
args: (2, 3)
kw: {'x': 4}
>>f(a=1,b=2,c=3)
a: 1
args: ()
kw: {'c': 3, 'b': 2} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Carlo v. Dango |
last post by:
Hello there. I have found a need to runtime generate a method and instert
it into an object instance. The code is a simple forwarding mechanism like
def foo(self, *args, **kwargs):...
|
by: Magnus Lyck? |
last post by:
Something really strange is happening to me (sometimes).
I'm using Python 2.3.2 on NT 4.0 as well as win32all-157,
adodbapi and db_row.
During a recursive call to a method, it seems Python...
|
by: liorm |
last post by:
Hi everyone,
I need to write a web app, that will support millions of user accounts,
template-based user pages and files upload. The client is going to be
written in Flash. I wondered if I coudl...
|
by: n.estner |
last post by:
Having read previous discussions on python-dev I think I'm not the only
Python programmer who doesn't particularly like python's "self"
parameter:
class Foo:
def bar(self, a,b):
return a+b...
|
by: Alex Popescu |
last post by:
Hi all!
I was reading through Python Cookbook the Singleton recipe. At this moment
I am a bit puzzled as the example in the book is not working resulting in:
TypeError:...
|
by: Arnaud Delobelle |
last post by:
Hi fellow python enthusiasts.
Having recently acquired a MacBook Pro (Intel Core 2 Duo) which comes
with python2.5, I have been installing some modules that I need (PIL,
psycopg2, PyXML ...).
...
|
by: Scott SA |
last post by:
On 5/1/08, Brian Vanderburg II (BrianVanderburg2@aim.com) wrote:
Did you review this?
<http://pydispatcher.sourceforge.net/>
from what I understand is originally based upon this:...
|
by: =?UTF-8?B?TmlscyBPbGl2ZXIgS3LDtmdlcg==?= |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I don't think the global interpreter lock is what you need ... read here
for reference:
http://docs.python.org/api/threads.html
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |