Hi
Below is a line taken from Andy Dustman's MySQLdb module:
def Connect(*args, **kwargs):
I would be grateful if somebody explain the meaning of the astarisks, since
I was under the impression that pointers are not used in Python and the
above look very must like pointers to me
--
Best Regards
John 5 1737
"John Dean" <jo**@rygannon.com> wrote in message
news:3f***********************@lovejoy.zen.co.uk.. . Hi Below is a line taken from Andy Dustman's MySQLdb module: def Connect(*args, **kwargs):
I would be grateful if somebody explain the meaning of the astarisks,
since I was under the impression that pointers are not used in Python and the above look very must like pointers to me
One asterisk creates a list of all positional arguements,
two asterisks creates a dictionary of all keyword arguements.
"All" means "not otherwise represented in the parameter list."
John Roth -- Best Regards John
They're both shortcuts for specifying parameters. args is a tuple of
positional arguments, kwargs is a dictionary of keyword arguments.
Like this: def myfunc(*args):
... print args
...
myfunc(3,4,"c")
(3, 4, 'c')
def myfunc(**kwargs):
... print kwargs
...
myfunc(a=3, b=4)
{'a': 3, 'b': 4}
def myfunc(*args, **kwargs):
... print args, kwargs
...
myfunc(2, 3, c=5, d=6)
(2, 3) {'c': 5, 'd': 6}
myfunc(2, 3)
(2, 3) {}
myfunc(c=5, d=6)
() {'c': 5, 'd': 6}
--
Contact info (decode with rot13): ce******@bcrenznvy.pbz
Fcnzserr! Cyrnfr qb abg hfr va choyvp zrffntrf. V ernq gur yvfg, ab arrq gb PP.
Posted via http://dbforums.com
At 06:13 PM 9/20/2003, John Roth wrote: "John Dean" <jo**@rygannon.com> wrote in message news:3f***********************@lovejoy.zen.co.uk. .. Hi Below is a line taken from Andy Dustman's MySQLdb module: def Connect(*args, **kwargs):
I would be grateful if somebody explain the meaning of the astarisks,since I was under the impression that pointers are not used in Python and the above look very must like pointers to me
One asterisk creates a list of all positional arguements,
Do you mean tuple?
two asterisks creates a dictionary of all keyword arguements. "All" means "not otherwise represented in the parameter list."
Bob Gailer bg*****@alum.rpi.edu
303 442 2625
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.506 / Virus Database: 303 - Release Date: 8/1/2003
"John Dean" <jo**@rygannon.com> schrieb im Newsbeitrag
news:3f***********************@lovejoy.zen.co.uk.. . Hi Below is a line taken from Andy Dustman's MySQLdb module: def Connect(*args, **kwargs):
I would be grateful if somebody explain the meaning of the astarisks,
since I was under the impression that pointers are not used in Python and the above look very must like pointers to me
In addition to the other answers:
It also works the other way: You can use tuples ore dicts for positional or
keyword parameters. This generally comes handy for co-ordinates in graphic
routines.
def p(a,b,c,d, x=None,y=None):
print a,b,c,d,x,y
abcd=(1,2,3,4)
xy={'x':100, 'y':200}
p(*abcd)
p(0,0,0,0,**xy)
Kindly
MichaelP This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: jinal jhaveri |
last post by:
Hi All,
I have one question regarding circular inheritance
I have 3 files
1) A.py , having module A and some other modules
2) B.py having module B and some other modules
3) C.py having...
|
by: Brandon J. Van Every |
last post by:
What's better about Ruby than Python? I'm sure there's something. What is
it?
This is not a troll. I'm language shopping and I want people's answers. I
don't know beans about Ruby or have...
|
by: Boris Boutillier |
last post by:
Hi all,
I've got problems with the Py_TPFLAGS_HEAPTYPE and the new
'hackcheck' in python 2.3.
I'm writing a C-extension module for python 2.3.
I need to declare a new class, MyClass.
For...
|
by: Li Daobing |
last post by:
Hello,
Does anyone know what's the meaning of Dutch in "The Zen of Python"?
Thanks in advance
Li Daobing
The Zen of Python, by Tim Peters
|
by: Xah Lee |
last post by:
What is Expresiveness in a Computer Language
20050207, Xah Lee.
In languages human or computer, there's a notion of expressiveness.
English for example, is very expressive in manifestation,...
| |
by: Xah Lee |
last post by:
The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully
Functional Notations
Xah Lee, 2006-03-15
Let me summarize: The LISP notation, is a functional notation, and is
not a...
|
by: Frederick Gotham |
last post by:
If we look at a programming language such as C++: When an updated Standard
comes out, everyone adopts it and abandons the previous one.
It seems though that things aren't so clear-cut in the C...
|
by: parag_paul |
last post by:
hi All,
I have no idea why I need to learn a new scripting language,
nothing much to the sytnax,
I need to understand what could be the prupose of another scripting
language
Cna you please...
|
by: grbgooglefan |
last post by:
I am creating functions, the return result of which I am using to make
decisions in combined expressions.
In some expressions, I would like to inverse the return result of
function.
E.g....
|
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...
|
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...
| |
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |