Re: [Tutor] Question about formating string with dictionary

2007-04-26 Thread John Fouhy
On 27/04/07, Shuai Jiang (Runiteking1) <[EMAIL PROTECTED]> wrote: > Hello everyone, > > The program that I am working on right now have a template for string > formatting. > My question is that is it possible to use multiple dictionary to format the > string. > > For example > x = {'foo':1234, 'bar

[Tutor] Question about formating string with dictionary

2007-04-26 Thread Shuai Jiang (Runiteking1)
Hello everyone, The program that I am working on right now have a template for string formatting. My question is that is it possible to use multiple dictionary to format the string. For example x = {'foo':1234, 'bar': 5678} y = {'spam':'hello','cheese':'good-bye'} is there any way to use his ps

Re: [Tutor] Feeding a list into a function as arguments

2007-04-26 Thread Kent Johnson
Kent Johnson wrote: > Stevie Broadfoot wrote: >> actually scrap that, it works perfectly :) thank you very much for your >> help. One last question, does this only work on lists? or will tuples >> work too and what else? > > It will work on any sequence including lists and tuples. More precisel

Re: [Tutor] Feeding a list into a function as arguments

2007-04-26 Thread Kent Johnson
Stevie Broadfoot wrote: > actually scrap that, it works perfectly :) thank you very much for your > help. One last question, does this only work on lists? or will tuples > work too and what else? It will work on any sequence including lists and tuples. Kent _

Re: [Tutor] Feeding a list into a function as arguments

2007-04-26 Thread Andreas Kostyrka
It works for me. [EMAIL PROTECTED]:~> python /tmp/q.py hello there [EMAIL PROTECTED]:~> cat /tmp/q.py list = ["hello", "there"] def printout(firstword, secondword): print firstword print secondword printout(*list) What does it do? It passes the arguments from

[Tutor] a way to glob over http?

2007-04-26 Thread John Washakie
Hello all, I'm writing a program which take input about a path. The path may be http or absolute or local. Once I have the path, I want to search the directory for images (type also defined by user), then get a count on the number of images in order to build the rest of my program: searchPath = i

Re: [Tutor] Feeding a list into a function as arguments

2007-04-26 Thread Stevie Broadfoot
actually scrap that, it works perfectly :) thank you very much for your help. One last question, does this only work on lists? or will tuples work too and what else? On 4/27/07, Stevie Broadfoot <[EMAIL PROTECTED]> wrote: This is the best answer i've gotten so far... but its still not working..

Re: [Tutor] Feeding a list into a function as arguments

2007-04-26 Thread Stevie Broadfoot
This is the best answer i've gotten so far... but its still not working... what exactly does the star do? the other solutions people provided do not suit my needs, my printout function was just an example, what i need it for is more complicated. I actually just need to feed the members of the li

Re: [Tutor] sys.path, managing modules and packages

2007-04-26 Thread Kent Johnson
Switanek, Nick wrote: > Can someone help me better understand how I ought to manage the modules > and packages that I download? I often find that I can’t use the code > I’ve just downloaded, despite putting it into Lib/site-packages. site-packages should just contain the module or package itself

Re: [Tutor] Feeding a list into a function as arguments

2007-04-26 Thread Andreas Kostyrka
* Stevie Broadfoot <[EMAIL PROTECTED]> [070426 09:56]: >I have a list... say for example > >list = ["hello", "there"] > >and i have a function > >def printout(firstword, secondword): >print firstword >print secondword > >and i want to call > >the functio

Re: [Tutor] Feeding a list into a function as arguments

2007-04-26 Thread Andre Engels
2007/4/26, Stevie Broadfoot <[EMAIL PROTECTED]>: > I have a list... say for example > > list = ["hello", "there"] > > and i have a function > > def printout(firstword, secondword): > print firstword > print secondword > > and i want to call > > the function like this > > printout(list) > >

Re: [Tutor] Feeding a list into a function as arguments

2007-04-26 Thread Rikard Bosnjakovic
On 4/26/07, Stevie Broadfoot <[EMAIL PROTECTED]> wrote: > How can I get around this problem? def printout(somelist): for x in somelist: print x -- - Rikard - http://bos.hack.org/cv/ ___ Tutor maillist - Tutor@python.org http://mail.python.or

[Tutor] Feeding a list into a function as arguments

2007-04-26 Thread Stevie Broadfoot
I have a list... say for example list = ["hello", "there"] and i have a function def printout(firstword, secondword): print firstword print secondword and i want to call the function like this printout(list) but that doesnt work because it takes the list as an argument. How can I get

Re: [Tutor] Averaging a list of lists with a listcomp?

2007-04-26 Thread Andreas Kostyrka
* Terry Carroll <[EMAIL PROTECTED]> [070426 07:14]: > I have a list (of arbitrary length) of lists, each sublist having a fixed > number N of items, all integers. > > I would like to produce a list of N items, each item of which is an > integer which is the average of the elements in the same pos

Re: [Tutor] Averaging a list of lists with a listcomp?

2007-04-26 Thread Terry Carroll
On Thu, 26 Apr 2007, John Fouhy wrote: > So, here is your one-line solution: > > >>> [sum(x)/len(x) for x in zip(*orig)] > [30, 20, 50] Beautiful. Thanks. I wasn't looking for a one-liner, exactly, but just something that was more straightforward and pythonic than what I was doing. But I fin