[Tutor] How to use Python 2.6 with IDLE?

2009-07-27 Thread Dick Moores
I've taken a long break from Python, and now I want to try scripting with 2.62. I downloaded and installed 2.62, changed Win XP environmental variables to use Python26. Entering python at the command line shows I'm using 2.62: C:\Documents and Settings\Riley>python Python 2.6.2 (r262:71605, Apr 14

Re: [Tutor] simple text replace

2009-07-27 Thread Albert-Jan Roskam
Hi! Did you consider using a regex? import re re.sub("python\s", "snake ", "python is cool, pythonprogramming...") Cheers!! Albert-Jan --- On Mon, 7/27/09, Dave Angel wrote: > From: Dave Angel > Subject: Re: [Tutor] simple text replace > To: "j booth" > Cc: tutor@python.org > Date: Monday

Re: [Tutor] renaming files within a directory

2009-07-27 Thread davidwilson
Here is what I have so far: import os import csv countries = {} reader = csv.reader(open("countries.csv")) for row in reader: code, name = row countries[name] = code files = set([file for file in os.listdir(os.getcwd()) if file.endswith('svg')]) print len(files) for file in files: f

Re: [Tutor] renaming files within a directory

2009-07-27 Thread Christian Witts
davidwil...@safe-mail.net wrote: Here is what I have so far: import os import csv countries = {} reader = csv.reader(open("countries.csv")) for row in reader: code, name = row countries[name] = code files = set([file for file in os.listdir(os.getcwd()) if file.endswith('svg')]) print l

Re: [Tutor] renaming files within a directory

2009-07-27 Thread Christian Witts
davidwil...@safe-mail.net wrote: Here is what I have so far: import os import csv countries = {} reader = csv.reader(open("countries.csv")) for row in reader: code, name = row countries[name] = code files = set([file for file in os.listdir(os.getcwd()) if file.endswith('svg')]) print l

Re: [Tutor] renaming files within a directory

2009-07-27 Thread Tim Golden
davidwil...@safe-mail.net wrote: Here is what I have so far: import os import csv countries = {} reader = csv.reader(open("countries.csv")) for row in reader: code, name = row countries[name] = code files = set([file for file in os.listdir(os.getcwd()) if file.endswith('svg')]) You d

Re: [Tutor] renaming files within a directory

2009-07-27 Thread Alan Gauld
wrote The problem is that for example the file Flag_of_the_United_States.svg when I use the strip('.svg') it is returned as Flag_of_the_United_State Thats because strip removes all of the characters in the given string. You would probably be better removing the extension using the os.path.

Re: [Tutor] simple text replace

2009-07-27 Thread Dave Angel
Albert-Jan Roskam wrote: Hi! Did you consider using a regex? import re re.sub("python\s", "snake ", "python is cool, pythonprogramming...") Cheers!! Albert-Jan --- On Mon, 7/27/09, Dave Angel wrote: From: Dave Angel Subject: Re: [Tutor] simple text replace To: "j booth" Cc: tutor@pyt

Re: [Tutor] First code snipet

2009-07-27 Thread Dave Angel
Darth Kaboda wrote: Good point. It is important to state your goal for the code, preferably in comments in your code, as well as in the message asking us the question. Suggest you include a doc-string for each class and method declaration. But it's important to tell us how you expect to use i

Re: [Tutor] renaming files within a directory

2009-07-27 Thread Kent Johnson
On Mon, Jul 27, 2009 at 5:10 AM, wrote: > files = set([file for file in os.listdir(os.getcwd()) if > file.endswith('svg')]) > print len(files) > > for file in files: >    file = file.strip('.svg') >    print file > #    if countries.has_key(file): > #       print file > > When I run this I get:

Re: [Tutor] How to use Python 2.6 with IDLE?

2009-07-27 Thread Gregor Lingl
Dick Moores schrieb: I've taken a long break from Python, and now I want to try scripting with 2.62. I downloaded and installed 2.62, changed Win XP environmental variables to use Python26. Entering python at the command line shows I'm using 2.62: C:\Documents and Settings\Riley>python Python 2.

Re: [Tutor] renaming files within a directory

2009-07-27 Thread davidwilson
Here is the updated viersion: --- import glob import csv from os import rename countries = {} reader = csv.reader(open("countries.csv")) for row in reader: code, name = row countries[name] = code files = set([file for file in glob.glob('Flag_of_*.svg')]) for file in files: file =

Re: [Tutor] renaming files within a directory

2009-07-27 Thread Christian Witts
davidwil...@safe-mail.net wrote: Here is the updated viersion: --- import glob import csv from os import rename countries = {} reader = csv.reader(open("countries.csv")) for row in reader: code, name = row countries[name] = code files = set([file for file in glob.glob('Flag_of_*.svg'

Re: [Tutor] renaming files within a directory

2009-07-27 Thread Dave Angel
davidwil...@safe-mail.net wrote: Here is the updated viersion: --- import glob import csv from os import rename countries =} reader =sv.reader(open("countries.csv")) for row in reader: code, name =ow countries[name] =ode files =et([file for file in glob.glob('Flag_of_*.svg')]) for f

Re: [Tutor] How to use Python 2.6 with IDLE?

2009-07-27 Thread Dave Angel
Gregor Lingl wrote: Dick Moores schrieb: I've taken a long break from Python, and now I want to try scripting with 2.62. I downloaded and installed 2.62, changed Win XP environmental variables to use Python26. Entering python at the command line shows I'm using 2.62: C:\Documents and Settings\R

Re: [Tutor] How to use Python 2.6 with IDLE?

2009-07-27 Thread Dick Moores
On Mon, Jul 27, 2009 at 04:27, Gregor Lingl wrote: > Dick Moores schrieb: >> >> I've taken a long break from Python, and now I want to try scripting >> with 2.62. I downloaded and installed 2.62, changed Win XP >> environmental variables to use Python26. Entering python at the >> command line shows

Re: [Tutor] renaming files within a directory

2009-07-27 Thread davidwilson
Thank you all for your help. Original Message From: Dave Angel Apparently from: srs0=pajg=du=ieee.org=da...@srs.perfora.net To: davidwil...@safe-mail.net Cc: ken...@tds.net, tutor@python.org Subject: Re: Re: [Tutor] renaming files within a directory Date: Mon, 27 Jul 2009 09:01:

Re: [Tutor] renaming files within a directory

2009-07-27 Thread Alan Gauld
wrote files = set([file for file in glob.glob('Flag_of_*.svg')]) for file in files: file = file[8:-4] Yu probably want to keep the filename unouched and use a variable like country here. if file.startswith('the_'): file = file[4:] if countries.has_key(file): b = 'flag-'+ cou

Re: [Tutor] How to use Python 2.6 with IDLE?

2009-07-27 Thread Alan Gauld
"Dick Moores" wrote I suggest you have to change the association of *.pyw files to the program, which is used to 'open' it. Yes! After I did that, now when I call E:\Python26\Lib\idlelib\idle.pyw the IDLE that opens uses 2.62. But I also want to use Ulipad, actually my main Python editor. W

[Tutor] problem with csv dictreader

2009-07-27 Thread Eduardo Vieira
Hello, I'm enjoying learning python but then I come across some basic things that makes me stumped... I have 2 csv files and I want to see which ones are duplicates based on two criteria email, or telephone. The order of fields in both csv files are different. Here are a sample bogus data: import

[Tutor] subprocess.call

2009-07-27 Thread davidwilson
Hello again, >From my previous post I would now like to transform the SVG images using the >svg2png library, but am having difficulties in making it work. Here is the >code: import glob import csv from os import rename import subprocess countries = {} reader = csv.reader(open("countries.csv"))

[Tutor] Eng to Leet Speek

2009-07-27 Thread Chris Castillo
so I have a string: 1 4|-| 50 |_33+. I love [#ick3n 4nd ch3353. Don't you love +|_|2|\e7 \/\/1+# the |#a|-|i|_7? and I am trying to turn it into english with the following code: fileIn = open("encrypted.txt", "r").read() def eng2leet(astring): astring = astring.replace("4","a") astri

Re: [Tutor] How to use Python 2.6 with IDLE?

2009-07-27 Thread Dave Angel
Dick Moores wrote: On Mon, Jul 27, 2009 at 04:27, Gregor Lingl wrote: Dick Moores schrieb: I've taken a long break from Python, and now I want to try scripting with 2.62. I downloaded and installed 2.62, changed Win XP environmental variables to use Python26. Entering python at the comm

Re: [Tutor] Eng to Leet Speek

2009-07-27 Thread J Sisson
You need a deterministic algorithm for conversion. It's impossible (without analyzing the context of the word) to translate "|_|#" (it's either "lf" or "uh", but which?). On Mon, Jul 27, 2009 at 1:13 PM, Chris Castillo wrote: > so I have a string: > > 1 4|-| 50 |_33+. I love [#ick3n 4nd ch3

[Tutor] subprocess.call

2009-07-27 Thread davidwilson
OK I think I found my error, here is what I did: flags = set([file for file in glob.glob('flag-*.svg')]) def call(cmd): subprocess.call([cmd], shell=True) for flag in flags: name = flag[:-4] out = name+'.png' call('svg2png --width=17 --height=12 %s %s' \ % (flag, o

Re: [Tutor] How to use Python 2.6 with IDLE?

2009-07-27 Thread Dave Angel
Dick Moores wrote: On Mon, Jul 27, 2009 at 04:27, Gregor Lingl wrote: Dick Moores schrieb: I've taken a long break from Python, and now I want to try scripting with 2.62. I downloaded and installed 2.62, changed Win XP environmental variables to use Python26. Entering python at the comm

Re: [Tutor] Eng to Leet Speek

2009-07-27 Thread Chris Castillo
On Mon, Jul 27, 2009 at 1:38 PM, J Sisson wrote: > You need a deterministic algorithm for conversion. It's impossible > (without analyzing the context of the word) to translate "|_|#" (it's either > "lf" or "uh", but which?). > > > > > On Mon, Jul 27, 2009 at 1:13 PM, Chris Castillo wrote: > >>

Re: [Tutor] Eng to Leet Speek

2009-07-27 Thread Dave Angel
Chris Castillo wrote: so I have a string: 1 4|-| 50 |_33+. I love [#ick3n 4nd ch3353. Don't you love +|_|2|\e7 \/\/1+# the |#a|-|i|_7? and I am trying to turn it into english with the following code: fileIn = open("encrypted.txt", "r").read() def eng2leet(astring): astring = astring.re

Re: [Tutor] How to use Python 2.6 with IDLE?

2009-07-27 Thread Dick Moores
On Mon, Jul 27, 2009 at 09:32, Alan Gauld wrote: > > "Dick Moores" wrote > >>> I suggest you have to change the association of *.pyw files to the >>> program, which is used to 'open' it. >>> >> Yes! After I did that, now when I call >> E:\Python26\Lib\idlelib\idle.pyw the IDLE that opens uses 2.62

Re: [Tutor] Eng to Leet Speek

2009-07-27 Thread Chris Castillo
On Mon, Jul 27, 2009 at 2:08 PM, Dave Angel wrote: > Chris Castillo wrote: > >> so I have a string: >> >> 1 4|-| 50 |_33+. I love [#ick3n 4nd ch3353. Don't you love +|_|2|\e7 >> \/\/1+# the |#a|-|i|_7? >> >> >> and I am trying to turn it into english with the following code: >> >> fileIn = open

Re: [Tutor] subprocess.call

2009-07-27 Thread Sander Sweers
On Mon, 2009-07-27 at 14:40 -0400, davidwil...@safe-mail.net wrote: > OK I think I found my error, here is what I did: > > flags = set([file for file in glob.glob('flag-*.svg')]) > > def call(cmd): > subprocess.call([cmd], shell=True) You hardly ever need shell=True. And using [cmd] is close

Re: [Tutor] How to use Python 2.6 with IDLE?

2009-07-27 Thread ALAN GAULD
> > What I do for these things is create a shortcut which specifies the full > > path to the interpreter and to the pyw file. I also set the working foldeer > > to wherever is most appropriate - usually my project folder. That's fairly > > bulletproof in my experience! > > Alan, here's what have

Re: [Tutor] Eng to Leet Speek

2009-07-27 Thread Alan Gauld
"Chris Castillo" wrote and I am trying to turn it into english with the following code: def eng2leet(astring): astring = astring.replace("4","a") astring = astring.replace("8","b") astring = astring.replace("[","c") astring = astring.replace("|)","d") You might want to investig

Re: [Tutor] How to use Python 2.6 with IDLE?

2009-07-27 Thread Dick Moores
On Mon, Jul 27, 2009 at 12:50, ALAN GAULD wrote: > > >> > What I do for these things is create a shortcut which specifies the full >> > path to the interpreter and to the pyw file. I also set the working foldeer >> > to wherever is most appropriate - usually my project folder. That's fairly >> > bu

Re: [Tutor] How to use Python 2.6 with IDLE?

2009-07-27 Thread Alan Gauld
"Dick Moores" wrote So edit the Target field of the shortcut to say: E:\Python26\pythonw.exe E:\Programs\Ulipad37\ulipad.pyw No, I'd already tried that. Doesn't work. Nothing happens. OK, You could try changing pythonw.exe tyo python.exe to bring up a console and watch for errors there...

Re: [Tutor] How to use Python 2.6 with IDLE?

2009-07-27 Thread Dick Moores
On Mon, Jul 27, 2009 at 14:32, Alan Gauld wrote: > > "Dick Moores" wrote > >>> So edit the Target field of the shortcut to say: >>> >>> E:\Python26\pythonw.exe E:\Programs\Ulipad37\ulipad.pyw >> >> No, I'd already tried that. Doesn't work. Nothing happens. > > OK, You could try changing pythonw.ex

Re: [Tutor] Eng to Leet Speek

2009-07-27 Thread Kent Johnson
On Mon, Jul 27, 2009 at 4:02 PM, Alan Gauld wrote: > You might want to investigate the maketrans and translate functions in the > string module. > > The seem to be quite similar in intent to what you are trying to do? No, those will only do 1-for-1 character substitutions. Kent _

[Tutor] Help...

2009-07-27 Thread Ryan V
For this source code, i am getting some errors, and not sure how to fix it, as i am returning all the values. it is telling me that there is no value for the variables i am returning. any help is greatly appreciated! Source #main function def main(): print 'The menu is:' print 'Yum Yum Bur

Re: [Tutor] Eng to Leet Speek

2009-07-27 Thread bob gailer
Kent Johnson wrote: On Mon, Jul 27, 2009 at 4:02 PM, Alan Gauld wrote: You might want to investigate the maketrans and translate functions in the string module. The seem to be quite similar in intent to what you are trying to do? No, those will only do 1-for-1 character substitutions

[Tutor] Getting Data from a Web Page

2009-07-27 Thread Paras K.
First let me say this mailing list is GREAT!!! Has helped me out through many things. I have written some code with Python that currently goes through a directory of all csv files and pulls out the lines that are needed by this program. These csv files have the following information: IP Address,

[Tutor] self.name vs. passing a name

2009-07-27 Thread Che M
This is another very basic structural question, related to one I asked last week, and again is not necessarily germane only to Python. Let's say you have a sequence of two calculations or manipulations you need to do, each one done as a function called by an overall calculate_something() funct

Re: [Tutor] How to use Python 2.6 with IDLE?

2009-07-27 Thread ALAN GAULD
> I get a console for a fraction of a second. Can't read anything it says. > > > Or just try typing the command into a console session till > > you get one that works! > So what happens when you run the same command from a console? That should leave the errors visible. > I'm not sure how to

Re: [Tutor] self.name vs. passing a name

2009-07-27 Thread Kent Johnson
On Mon, Jul 27, 2009 at 7:39 PM, Che M wrote: > 1.Pass the variable to the second function. > > def calculate_something(self): >     answer = self.do_first_calculation()    #1st function returns answer >     self.do_second_calculation(answer)    #2nd is passed answer and uses it. > > 2. Create the

Re: [Tutor] [Baypiggies] Egnyte: hiring

2009-07-27 Thread mobiledreamers
Seems interesting http://fotoroll.com/searchvideo?q=vineet%20jain,%20ceo%20of%20egnyte&id=0&type=video On Mon, Jul 27, 2009 at 7:46 PM, Aahz wrote: > My new company (I just started today) closed a big venture

[Tutor] No Elegant XML Output in ElementTree?

2009-07-27 Thread Luis Galvan
Hi tutors, Okay, so I just started to learn ElementTree (and XML processing in general) and I just can't, for the life of me, find a way to output the XML file in an actual hierarchic presentation. What I mean by this is that it all outputs on a single line. For example, I create an element tree

Re: [Tutor] No Elegant XML Output in ElementTree?

2009-07-27 Thread Marc Tompkins
On Mon, Jul 27, 2009 at 8:32 PM, Luis Galvan wrote: > Hi tutors, > Okay, so I just started to learn ElementTree (and XML processing in > general) and I just can't, for the life of me, find a way to output the XML > file in an actual hierarchic presentation. What you want is generically called "p

Re: [Tutor] Help...

2009-07-27 Thread Christian Witts
Ryan V wrote: For this source code, i am getting some errors, and not sure how to fix it, as i am returning all the values. it is telling me that there is no value for the variables i am returning. any help is greatly appreciated! Source #main function def main(): print 'The menu is:'