Hello !
I see these things in many sources, under wxPy:
def __init__(self,p arams,**kw,**ar gs)
What are these parameters, and what's the meaning of the double * ?
Thanx for any info.
--
Best regards,
fowlertrainer mailto:fo****** *****@anonym.hu
PS:
Please send me private message, if possible, because I'm in digest
mode.
Thx 3 2968
In article <ma************ *************** ************@py thon.org>,
<fo***********@ anonym.hu> wrote: I see these things in many sources, under wxPy:
def __init__(self,p arams,**kw,**ar gs)
What are these parameters, and what's the meaning of the double * ?
First of all, when asking questions like this, please make sure to
cut'n'paste the text; I'm certain that isn't the code you were reading.
Second, read the docs. Start with the tutorial section on functions: http://www.python.org/doc/current/tut/node6.html
--
Aahz (aa**@pythoncra ft.com) <*> http://www.pythoncraft.com/
"The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code --
not in reams of trivial code that bores the reader to death." --GvR
On Wed, 04 Feb 2004 10:59:13 +0100, fowlertrainer wrote: I see these things in many sources, under wxPy:
def __init__(self,p arams,**kw,**ar gs)
What are these parameters, and what's the meaning of the double * ?
Python functions can have positional arguments and keyword arguments;
if the *last* argument of a function begins with **, all extra keyword
arguments (i.e. those which do not match any of the parameter names of
the function) are put in a dictionary.
(The single * is used for passing a variable number of arguments.)
You will thus often see function definitions like the following:
def f(x, y, *args, **kw):
# the dictionary is kw
The following example should make this a little bit clearer:
def f(x, y, *args, **kw):
print x, y,
for i in args:
print i,
for k, v in kw.iteritems():
print k, v,
f(1, 2, 3, 4, five=5, six=6)
The output of this example is:
1 2 3 4 six 6 five 5
(Observe that dictionaries are not sorted!)
Remark: in your example, the ** is used two times; that is not
allowed (and does not make sense).
HTH / Nuff
Hello, I see these things in many sources, under wxPy:
def __init__(self,p arams,**kw,**ar gs)
What are these parameters, and what's the meaning of the double * ?
Try the tutorial. (Hint 4.7.2 Keyword Arguments and 4.7.3 Arbitrary Argument Lists).
HTH.
Miki This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Stefan Behnel |
last post by:
Hi!
I'm trying to do this in Py2.4b1:
-------------------------------
import logging
values = {'test':'bla'}
logging.log(logging.FATAL, 'Test is %(test)s', values)
-------------------------------
|
by: Steven Bethard |
last post by:
So, as I understand it, in Python 3000, zip will basically be replaced
with izip, meaning that instead of returning a list, it will return an
iterator. This is great for situations like:
zip(*)
where I want to receive tuples of (item1, item2, item3) from the
iterables. But it doesn't work well for a situation like:
zip(*tuple_iter)
|
by: TheDD |
last post by:
Hello all,
right now, i'm using the following macro to automatically add informations
to exceptions:
#define THROW(Class, args...) throw Class(__FILE__, __LINE__, ## args)
but AFAIK, it's gcc specific. Is there a way to do it in a standard c++ way?
TIA
|
by: Ivar |
last post by:
Hi,
For my supprise I found that functions have 32 parameter limit.
Where to find more info about this limitation or similar limitations ?
I need at least 50, 100 would be ok.
Real life function below:
|
by: ern |
last post by:
I want to pass arguments to the main( ) function of my C program.
Currently, I'm using
main(char * args)
But when I try to print args, I get an unhandled exception error. Is
there a better, safer way to pass args to main (from another
module) ?
| |
by: goodnamesalltaken |
last post by:
Hello fellow python users,
I've been working on a basic implementation of a privilege separated
web server, and I've goto the point of running a basic cgi script.
Basically when the execCGI function in my Unpriv.py program is called a
few things should happen, it should fork (which it does), the stdout of
the child should be redirected to a given pipe (which it does), and the
script should execute using execve(which is has problems...
|
by: xamman |
last post by:
the handler declaration:
CustomValidator1_ServerValidate(ByVal source As System.Object, ByVal
args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles
CustomValidator1.ServerValidate
the question:
if in this sub i am to set args.IsValid to true or false depending on
my custom validator code,
|
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 "begin"
method(self, *args, **kw)
print "end"
return wrapped
|
by: Miki |
last post by:
Hello All,
I'm try to write the C equivalent of:
def kw(*args, **kw):
print "%d args" % len(args),
if "default" in kw:
print "default is %s" % kw
else:
print "no default"
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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 we have to send another system
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |