Re: [Tutor] xml question

2010-07-27 Thread Mac Ryan
On Mon, 2010-07-26 at 12:09 -0700, Albert-Jan Roskam wrote: > I am making a data processing program that will use a configuration > file. The file should contain information about: (1) source files > used, (2) (intermediate) output files, (3) used parameters/estimation > methods (4) manual data edi

Re: [Tutor] django help....

2010-07-27 Thread Mac Ryan
On Mon, 2010-07-26 at 14:03 +0100, Dipo Elegbede wrote: > what ook would you recommend for a beginner? I am a django beginner myself. I did the tutorial first (http://docs.djangoproject.com/en/dev/intro/tutorial01/) and now I am very happy with "Practical Django Projects": http://www.amazon.com/Pr

Re: [Tutor] xml question

2010-07-27 Thread Andreas Röhler
Am 27.07.2010 02:29, schrieb Steven D'Aprano: On Tue, 27 Jul 2010 05:09:09 am Albert-Jan Roskam wrote: Hi, I am making a data processing program that will use a configuration file. The file should contain information about: (1) source files used, (2) (intermediate) output files, (3) used pa

[Tutor] nested list help

2010-07-27 Thread Vikram K
Suppose i have this nested list: >>> x [['NM100', 3, 4, 5, 6, 7], ['NM100', 10, 11, 12, 13], ['NM200', 15, 16, 17]] >>> for i in x: ... print i ... ['NM100', 3, 4, 5, 6, 7] ['NM100', 10, 11, 12, 13] ['NM200', 15, 16, 17] >>> how do i obtain from the above the following nested list: >>> z [['NM

Re: [Tutor] nested list help

2010-07-27 Thread Evert Rol
> Suppose i have this nested list: > > >>> x > [['NM100', 3, 4, 5, 6, 7], ['NM100', 10, 11, 12, 13], ['NM200', 15, 16, 17]] > >>> for i in x: > ... print i > ... > ['NM100', 3, 4, 5, 6, 7] > ['NM100', 10, 11, 12, 13] > ['NM200', 15, 16, 17] > >>> > > how do i obtain from the above the followi

[Tutor] need help with msvcrt.getch()

2010-07-27 Thread Richard D. Moores
Python 3.1 on Vista. Please see . I'm trying to recall what I used to know, thus this simple script. But 'y' or 'q' do nothing. What's wrong? Thanks, Dick Moores ___ Tutor maillist - Tutor@python.org To unsubsc

Re: [Tutor] need help with msvcrt.getch()

2010-07-27 Thread Tim Golden
On 27/07/2010 15:22, Richard D. Moores wrote: Python 3.1 on Vista. Please see. I'm trying to recall what I used to know, thus this simple script. But 'y' or 'q' do nothing. What's wrong? msvcrt.getch returns bytes on Python 3.1; you're comparing against

Re: [Tutor] nested list help

2010-07-27 Thread Nick Raptis
On 07/27/2010 04:48 PM, Evert Rol wrote: On the other hand, if you want to combine lists based on their first element, consider using dictionaries and extend lists which have the same key. Depending on how you create the lists (eg, when reading columns from a file), you can actually do this d

Re: [Tutor] need help with msvcrt.getch()

2010-07-27 Thread Nick Raptis
On 07/27/2010 05:22 PM, Richard D. Moores wrote: Python 3.1 on Vista. Please see . I'm trying to recall what I used to know, thus this simple script. But 'y' or 'q' do nothing. What's wrong? Thanks, Dick Moores Hi Dick! I'm not on Windows here so

Re: [Tutor] need help with msvcrt.getch()

2010-07-27 Thread Richard D. Moores
On Tue, Jul 27, 2010 at 07:36, Tim Golden wrote: > On 27/07/2010 15:22, Richard D. Moores wrote: > >> Python 3.1 on Vista. >> >> Please see. >> >> I'm trying to recall what I used to know, thus this simple script. But 'y' >> or 'q' do nothing. What's wrong?

Re: [Tutor] need help with msvcrt.getch()

2010-07-27 Thread Richard D. Moores
On Tue, Jul 27, 2010 at 07:51, Nick Raptis wrote: > On 07/27/2010 05:22 PM, Richard D. Moores wrote: > >> Python 3.1 on Vista. >> >> Please see . >> >> I'm trying to recall what I used to know, thus this simple script. But 'y' >> or 'q' do nothing. What's wr

[Tutor] append in new file??

2010-07-27 Thread Ahmed AL-Masri
hello; I need help in append a data in new file. the problem is the new data are generated in every run. so at the end I should get all the changes in one file (means for all running) if I run 2 times so should get couple of data set. note all outputs in txt file. ex: this is the first run data

Re: [Tutor] need help with msvcrt.getch()

2010-07-27 Thread Alan Gauld
"Richard D. Moores" wrote Please see . I'm trying to recall what I used to know, thus this simple script. But 'y' or 'q' do nothing. What's wrong? I don't think you need kbhit() or the sleep(.1) The if kbhit test will only pass if the key is actually

[Tutor] lambda vs list comp

2010-07-27 Thread Jon Crump
Just as a matter of curiosity piqued by having to understand someone else's code. Is the difference here just a matter of style, or is one better somehow than the other? >>> l [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >>> ','.join([str(x) for x in l]) '0,1,2,3,4,5,6,7,8,9,10' >>> ','.join(map(lambda x:

Re: [Tutor] append in new file??

2010-07-27 Thread Joel Goldstick
2010/7/27 Ahmed AL-Masri > hello; > > I need help in append a data in new file. the problem is the new data are > generated in every run. > so at the end I should get all the changes in one file (means for all > running) if I run 2 times so should get couple of data set. > note all outputs in tx

Re: [Tutor] lambda vs list comp

2010-07-27 Thread Mac Ryan
On Tue, 2010-07-27 at 09:44 -0700, Jon Crump wrote: > Just as a matter of curiosity piqued by having to understand someone > else's code. Is the difference here just a matter of style, or is one > better somehow than the other? > > >>> l > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] > > >>> ','.join([str(

Re: [Tutor] lambda vs list comp

2010-07-27 Thread Rich Lovely
On 27 July 2010 17:53, Mac Ryan wrote: > On Tue, 2010-07-27 at 09:44 -0700, Jon Crump wrote: >> Just as a matter of curiosity piqued by having to understand someone >> else's code. Is the difference here just a matter of style, or is one >> better somehow than the other? >> >> >>> l >> [0, 1, 2, 3

Re: [Tutor] need help with msvcrt.getch()

2010-07-27 Thread Richard D. Moores
On Tue, Jul 27, 2010 at 09:09, Alan Gauld wrote: > > "Richard D. Moores" wrote > > > Please see . >> >> I'm trying to recall what I used to know, thus this simple script. But 'y' >> or 'q' do nothing. What's wrong? >> > > I don't think you need kbhit() I

Re: [Tutor] xml question

2010-07-27 Thread Albert-Jan Roskam
Thank you all for your replies; they were most useful! I've never made a connection between xml and mass-suicide  ---interesting. ;-) Yaml seems a good choice (I didn't llook at config parser yet). In my office, we use Python and R (among other tools) and therfore it seems best not to use some p

Re: [Tutor] nested list help

2010-07-27 Thread Gerard Flanagan
Vikram K wrote: Suppose i have this nested list: >>> x [['NM100', 3, 4, 5, 6, 7], ['NM100', 10, 11, 12, 13], ['NM200', 15, 16, 17]] >>> for i in x: ... print i ... ['NM100', 3, 4, 5, 6, 7] ['NM100', 10, 11, 12, 13] ['NM200', 15, 16, 17] >>> how do i obtain from the above the following nest

Re: [Tutor] need help with msvcrt.getch()

2010-07-27 Thread Richard D. Moores
On Tue, Jul 27, 2010 at 07:51, Nick Raptis wrote: > On 07/27/2010 05:22 PM, Richard D. Moores wrote: > >> Python 3.1 on Vista. >> >> Please see . >> >> I'm trying to recall what I used to know, thus this simple script. But 'y' >> or 'q' do nothing. What's wr

[Tutor] Running .py files in shell

2010-07-27 Thread Kevin Rapley
Hello all, I am new to programming and have opted to learn Python as I hear it is a good first language. I am currently going through the exercises in 'How to Think Like a Computer Scientist: Learning with Python 2nd Edition'. I am running Mac OSX v10.6.4 Snow Leopard I am running Python 2.6.

[Tutor] Decorator listing

2010-07-27 Thread Mary Morris
I'm writing a program with python that compiles a list of decorators from my company's source code. I'm new to python and need help with the following: I'm trying to make the program find ".com" in any lines and not include them in the list of decorators that gets returned. THis is because I had

Re: [Tutor] lambda vs list comp

2010-07-27 Thread Steven D'Aprano
On Wed, 28 Jul 2010 02:44:02 am Jon Crump wrote: > Just as a matter of curiosity piqued by having to understand someone > else's code. Is the difference here just a matter of style, or is one > better somehow than the other? Remember that list comprehensions didn't exist until a few years ago, so

Re: [Tutor] Decorator listing

2010-07-27 Thread Emile van Sebille
On 7/27/2010 1:11 PM Mary Morris said... I'm writing a program with python that compiles a list of decorators from my company's source code. I'm new to python and need help with the following: I'm trying to make the program find ".com" in any lines and not include them in the list of decorators

[Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-27 Thread ZUXOXUS
Hi all pythoners I've got a probably easy to answer question. Say I've got a collections of strings, e.g.: 'man', 'bat', 'super', 'ultra'. They are in a list, or in a sequence or whatever, say a bag of words And now I want to know how many couples I can do with them, and I want the program to s

Re: [Tutor] Decorator listing

2010-07-27 Thread Steven D'Aprano
Hello Mary, On Wed, 28 Jul 2010 06:11:18 am Mary Morris wrote: > I'm writing a program with python that compiles a list of decorators > from my company's source code. I'm new to python and need help with > the following: I'm trying to make the program find ".com" in any > lines and not include t

Re: [Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-27 Thread Nick Raptis
On 07/28/2010 01:20 AM, ZUXOXUS wrote: Hi all pythoners I've got a probably easy to answer question. Say I've got a collections of strings, e.g.: 'man', 'bat', 'super', 'ultra'. They are in a list, or in a sequence or whatever, say a bag of words And now I want to know how many couples I ca

Re: [Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-27 Thread Mark Lawrence
On 27/07/2010 23:20, ZUXOXUS wrote: Hi all pythoners I've got a probably easy to answer question. Say I've got a collections of strings, e.g.: 'man', 'bat', 'super', 'ultra'. They are in a list, or in a sequence or whatever, say a bag of words And now I want to know how many couples I can do

Re: [Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-27 Thread Mac Ryan
On Tue, 2010-07-27 at 23:31 +0100, Mark Lawrence wrote: > On 27/07/2010 23:20, ZUXOXUS wrote: > > Hi all pythoners > > > > I've got a probably easy to answer question. > > > > Say I've got a collections of strings, e.g.: 'man', 'bat', 'super', 'ultra'. > > > > They are in a list, or in a sequence o

Re: [Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-27 Thread ZUXOXUS
Sharp thanks, but: I try to reproduce the example from the table, but: >>> import itertools >>> combinations('ABC', 2) Traceback (most recent call last): File "", line 1, in combinations('ABC', 2) NameError: name 'combinations' is not defined >>> If im not mistaken, it should return AB, A

Re: [Tutor] Running .py files in shell

2010-07-27 Thread Alan Gauld
"Kevin Rapley" wrote I am running Mac OSX v10.6.4 Snow Leopard I am running Python 2.6.1 In general get the MacPython distributions of Python etc, they usually install easier (ie from the GUI) than the "Unix" based versions. 1. How do I execute .py files in the command line shell? I have my

Re: [Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-27 Thread ZUXOXUS
Mac, this is what I get: >>> for prod in itertools.product('ABC', 2): print(prod) Traceback (most recent call last): File "", line 1, in for prod in itertools.product('ABC', 2): TypeError: 'int' object is not iterable hmm, what might be that 'int' object? 2? 2010/7/28 ZUXOXUS > Shar

Re: [Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-27 Thread ZUXOXUS
Oh, I think i got it: >>> for prod in itertools.product('ABC', 'ABC'): print(prod) ('A', 'A') ('A', 'B') ('A', 'C') ('B', 'A') ('B', 'B') ('B', 'C') ('C', 'A') ('C', 'B') ('C', 'C') Thank you very much!! 2010/7/28 ZUXOXUS > Mac, > > this is what I get: > > >>> for prod in itertools.product('A

Re: [Tutor] Calculating and returning possible combinations of elements from a given set

2010-07-27 Thread Dave Angel
ZUXOXUS wrote: Oh, I think i got it: for prod in itertools.product('ABC', 'ABC'): print(prod) ('A', 'A') ('A', 'B') ('A', 'C') ('B', 'A') ('B', 'B') ('B', 'C') ('C', 'A') ('C', 'B') ('C', 'C') Thank you very much!! 2010/7/28 ZUXOXUS You're top-posting, which loses all the

[Tutor] subprocess output

2010-07-27 Thread ashley
I'm using Python 2.6.5 and I've got a challenge with the subprocess module. I'd like the output to be stored in a variable, and not sent to the stdout. The relevant lines as they are now: #!/usr/bin/env python import subprocess import sys dom = sys.argv[1] switch = sys.argv [2] answer = subproces