473,387 Members | 3,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Passing items of a lsit as arguments

Hi!

I want to call a function that was defined with *args in the header, e.g.
the Tkinter.Canvas.create_polygon function. I got the coordinates in a
long list but how can I achieve that every item in this list is passed as
a single parameter?

Example:
bla = [(1,2), (3,4), (5,6), ...]
has to become
create_polygon((1,2), (3,4), (5,6), ..., fill=blue)

Thanks in Advance

Bye
Tobias

--
please send any mail to botedesschattens(at)web(dot)de
Jul 18 '05 #1
2 1366
On 26 Mar 2004, Tobias Pfeiffer <- me@privacy.net wrote:
the Tkinter.Canvas.create_polygon function. I got the coordinates in a
long list but how can I achieve that every item in this list is passed as
a single parameter? Example:
bla = [(1,2), (3,4), (5,6), ...]
has to become
create_polygon((1,2), (3,4), (5,6), ..., fill=blue)


Either:
apply(create_polygon, bla)
or:
create_polygon(* bla)
KP

--
You know you've been sitting in front of your Lisp machine too long
when you go out to the junk food machine and start wondering how to
make it give you the CADR of Item H so you can get that yummie
chocolate cupcake that's stuck behind the disgusting vanilla one.
Jul 18 '05 #2
On Fri, Mar 26, 2004 at 09:31:47PM +0000, Tobias Pfeiffer wrote:
Hi!

I want to call a function that was defined with *args in the header, e.g.
the Tkinter.Canvas.create_polygon function. I got the coordinates in a
long list but how can I achieve that every item in this list is passed as
a single parameter?

Example:
bla = [(1,2), (3,4), (5,6), ...]
has to become
create_polygon((1,2), (3,4), (5,6), ..., fill=blue)


You can call the functions with the arguments you want this way:
create_polygon(*bla + (...,), **{'fill'=blue})

However, Tkinter.Canvas is forgiving in the way it accepts arguments.
For instance, this works just fine:
c.create_polygon([(10, 10), (10, 30), (30, 30), (30, 10)], fill="blue") or even c.create_polygon([40, 40, 60, 40, 60, 60, 40, 60], fill="green")

so just write '...create_polygon(bla, ..., fill=blue)'.

Jeff

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
2
by: Barry Moon | last post by:
Hi Can anyone give me any help with passing an object across processes, via drag and drop? I've written a custom ListView control, which supports dragging and dropping of its items. The...
2
by: pyrexia | last post by:
Greets all. I'm attempting to write an app that will be used as a 'control/launcher' application for other apps. For the sake of argument let's say the app is launched from a command line: ...
2
by: Colmag | last post by:
I'm running a console application (ghostscript) by starting it as a process with arguments. The problem i'm having is that it's falling over when I pass a file containing spaces in the filename...
3
by: Peter | last post by:
I have 20000 Items (LastName, FirstName) I need to display in a DropDown box, but it takes a while to load them after every postback. What would be the best way to allow user to view these 20000...
4
by: 63q2o4i02 | last post by:
Hi, I'm writing a hand-written recursive decent parser for SPICE syntax parsing. In one case I have one function that handles a bunch of similar cases (you pass the name and the number of...
3
by: rob | last post by:
Hello, If I have an array made up of a bunch of key =value pairs, how can I pass the values of each key as an argument to a function, given that the number of items in the array are not static...
8
by: Csanád | last post by:
Hi, Here's my form: http://www.steinrogan.com/SecureSite_v2_beta/addthis.php When I add two or more Dependant Items and remove one that's not the last that I added, I won't be able to remove...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.