What is the meaning of the astarisk in Python
Michael Peuser
mpeuser at web.de
Sun Sep 21 03:29:00 EDT 2003
"John Dean" <john at rygannon.com> schrieb im Newsbeitrag
news:3f6ce54f$0$10962$fa0fcedb at 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
More information about the Python-list
mailing list