[Tutor] Generating XML using Python

2011-04-11 Thread tee chwee liong
hi, i'm using python to generate xml with elementtree api. and i'm getting error when opening the output xml. it doesnt give error when running. i also tried to use python to output to a text file and it works without any error. Pls advise me how i can rectify the error when opening the

Re: [Tutor] Generating XML using Python

2011-04-11 Thread Peter Otten
tee chwee liong wrote: i'm using python to generate xml with elementtree api. and i'm getting error when opening the output xml. it doesnt give error when running. i also tried to use python to output to a text file and it works without any error. Pls advise me how i can rectify the error

Re: [Tutor] How to design the structure of multi-steps(and substeps)scripts

2011-04-11 Thread Alan Gauld
leechau char...@sohu.com wrote def step1: local_var1 = ... # some other variable definitions for step1 def substep11: pass # more substeps ... global_var1 = ... # more global var definitions... if step1.return_success: step2 Since this is obviously pseudo code I'll

Re: [Tutor] Python to XML

2011-04-11 Thread Alan Gauld
tee chwee liong tc...@hotmail.com wrote i just started to learn xml using python and i'm getting error when opening the output xml. it doesnt give error when running. Always post full error codes and the asociated source code. For shorty programs like this its more convenient to include the

Re: [Tutor] Generating XML using Python

2011-04-11 Thread tee chwee liong
hi Peter, thanks for your reply. seems that xml doesnt accept a space in between. anyway, the output generated is: - Test - Default_Config Port=8 LINK2/LINK Target_Speed3/Target_Speed /Default_Config /Test it overwrites every time the port number is incremented and only

Re: [Tutor] Invisible Characters in Fortran/Python

2011-04-11 Thread Francesco Loffredo
On 04/10/2011 0.12, Tyler Glembo wrote: Hi All, So I have a ~3000 line fortran code that needs to be updated to run new files by simply updating a few lines in the code (~10 lines). I thought python would be a great way to do so since I know a little python but not fortran. So, my plan was

Re: [Tutor] Generating XML using Python

2011-04-11 Thread Peter Otten
tee chwee liong wrote: thanks for your reply. seems that xml doesnt accept a space in between. anyway, the output generated is: - Test - Default_Config Port=8 LINK2/LINK Target_Speed3/Target_Speed /Default_Config /Test it overwrites every time the port number is

Re: [Tutor] Generating XML using Python

2011-04-11 Thread tee chwee liong
sorry for lack of details. yes i would like to output in 1 xml file. i would like to generate port 1 and its details (link, speed etc) then move to second port, port 2 and generate its details (link, speed etc) tq To: tutor@python.org From: __pete...@web.de Date: Mon, 11 Apr 2011 10:39:48

Re: [Tutor] Generating XML using Python

2011-04-11 Thread tee chwee liong
Do you want them all in one file? Move the code to create the root element and the code to write the file out of the loop. Do you want to write multiple files? Use a different name from every file. yes i would like to generate 1 xml file by incrementing the port number in the range.

Re: [Tutor] Generating XML using Python

2011-04-11 Thread tee chwee liong
hi peter, yes it worked after i moved the root outside the for loop. code: import elementtree.ElementTree as ET lspeed=2 tspeed=3 f=open(out.txt, w) root = ET.Element(Test) for port in range (1,9): print Port %d %port #root = ET.Element(Test) f.write(Port %d\n %port) head1 =

Re: [Tutor] Generating XML using Python

2011-04-11 Thread Peter Otten
tee chwee liong wrote: sorry for lack of details. yes i would like to output in 1 xml file. i would like to generate port 1 and its details (link, speed etc) then move to second port, port 2 and generate its details (link, speed etc) tq As I said, instead of creating a new root on every

[Tutor] A Dictionary question

2011-04-11 Thread Sophie DeNofrio
Hi Everyone,  I am a super beginner and am little muddled right now. So I apologize for the low level question but I am trying to write a function that will return a dictionary of a given list of strings containing two coordinates separated by a space with the first numbers as a key and the

Re: [Tutor] A Dictionary question

2011-04-11 Thread Andre Engels
On Mon, Apr 11, 2011 at 1:01 PM, Sophie DeNofrio swimbabe...@yahoo.comwrote: Hi Everyone, I am a super beginner and am little muddled right now. So I apologize for the low level question but I am trying to write a function that will return a dictionary of a given list of strings containing

Re: [Tutor] A Dictionary question

2011-04-11 Thread Wayne Werner
On Mon, Apr 11, 2011 at 6:01 AM, Sophie DeNofrio swimbabe...@yahoo.comwrote: Hi Everyone, I am a super beginner and am little muddled right now. So I apologize for the low level question That's what this list is for, so you're asking in the right place! but I am trying to write a

Re: [Tutor] A Dictionary question

2011-04-11 Thread Steven D'Aprano
Hello Sophie, or do you prefer Annie? Sophie DeNofrio wrote: Hi Everyone, I am a super beginner and am little muddled right now. So I apologize for the low level question but I am trying to write a function that will return a dictionary of a given list of strings containing two coordinates

Re: [Tutor] A Dictionary question

2011-04-11 Thread Sophie DeNofrio
Thank you to everyone who helped! Steven D'Aprano I was secretly hoping you'd help. This is a family not personal and 'junk' (this isn't junk obviously. But it falls into that not personal category) account so you are talking to Annie lol. I guess I should have just signed up using my own email

[Tutor] Running python on windows

2011-04-11 Thread Mike Silverson
Hi, I need to know if there is any way to run a python file without Python installed on the target computer. I am trying to send a program to a friend using windows and he does not have python installed, and does not want to take the time to install it. Is there any way to send him the file (or

[Tutor] Converting files

2011-04-11 Thread sunil tech
Hi all... is there any way to convert any file (eg: document files image files) to .pdf? if so, kindly share... thank you in advance. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

Re: [Tutor] Generating XML using Python

2011-04-11 Thread Karim
On 04/11/2011 10:04 AM, tee chwee liong wrote: hi Peter, thanks for your reply. seems that xml doesnt accept a space in between. anyway, the output generated is: *-* file:///C:/Python25/myscript/cmm/port1.xml# Test *-* file:///C:/Python25/myscript/cmm/port1.xml# Default_ConfigPort=*8* **

Re: [Tutor] Running python on windows

2011-04-11 Thread Nicholas Holley
On Mon, 11 Apr 2011 21:01:37 +0800 Mike Silverson msilvers...@gmail.com wrote: Hi, I need to know if there is any way to run a python file without Python installed on the target computer. I am trying to send a program to a friend using windows and he does not have python installed, and does

Re: [Tutor] Converting files

2011-04-11 Thread Emile van Sebille
On 4/11/2011 10:40 AM sunil tech said... Hi all... is there any way to convert any file (eg: document files image files) to .pdf? Look into reportlab. Look at the opensource area: http://www.reportlab.com/software/opensource/ if so, kindly share... thank you in advance.

[Tutor] Python on TV

2011-04-11 Thread Alan Gauld
I've just watched the Channel 5 programme The Gadget Show where the presenters set a new Guinness world record for operating the heaviest machine(*) using mind power. The software behind this feat - was written in Python of course! :-) (*)The machine in question was a 50 ton industrial crane...

Re: [Tutor] Running python on windows

2011-04-11 Thread James Reynolds
I use http://cx-freeze.sourceforge.net/ personally. I found py2exe to be a headache compared to cx. On Mon, Apr 11, 2011 at 9:01 AM, Mike Silverson msilvers...@gmail.comwrote: Hi, I need to know if there is any way to run a python file without Python installed on the target computer. I am

Re: [Tutor] Running python on windows

2011-04-11 Thread Alan Gauld
Mike Silverson msilvers...@gmail.com wrote installed on the target computer. I am trying to send a program to a friend using windows and he does not have python installed, and does not want to take the time to install it. Given how quickly Python installs compared to many other apps I can

[Tutor] ImportError: No module named wdmmgext.load

2011-04-11 Thread Ben Teeuwen
Hi, Thanks Emile van Sebille for answering my last question. I'm now testing my imported data and I get 21 errors (see attached). The majority sounds like: from wdmmgext.load import uganda ImportError: No module named wdmmgext.load I've searched the files that use this module. Attached is

Re: [Tutor] Converting files

2011-04-11 Thread Alan Gauld
sunil tech sunil.tech...@gmail.com wrote is there any way to convert any file (eg: document files image files) to .pdf? if so, kindly share... Install a PDF print driver and then print the file to that printer. Set it to save as a file. Then if its printable you can get it as a PDF.

Re: [Tutor] Running python on windows

2011-04-11 Thread James Reynolds
At least in my case it was about simplicity. If it was a simple matter of using a base python program, that would be one thing, but the last program i distributed here at work used pygtk as it's GUI (which at the time required four different packages, I believe they have consolidated this down to

Re: [Tutor] Python on TV

2011-04-11 Thread bob gailer
On 4/11/2011 4:20 PM, Alan Gauld wrote: I've just watched the Channel 5 programme The Gadget Show where the presenters set a new Guinness world record for operating the heaviest machine(*) using mind power. The software behind this feat - was written in Python of course! :-) (*)The machine in

[Tutor] Import multiple lines of text into a variable

2011-04-11 Thread Sean Carolan
I'm not sure how to do this. I'm reading lines in from a text file. When I reach the string notes:, I want to assign the remainder of the text file to a single variable (line breaks and all): text moretext moretext notes: This is the stuff I want in my variable. And this line should be included

Re: [Tutor] Converting files

2011-04-11 Thread Evans Anyokwu
I use Openoffice and it has an option to export your files to .pdf and lots of other file formats. It's a free download - and has all the usual Office applications... Search for 'OpenOffice' online. On Mon, Apr 11, 2011 at 9:48 PM, Alan Gauld alan.ga...@btinternet.comwrote: sunil tech

Re: [Tutor] Import multiple lines of text into a variable

2011-04-11 Thread Sean Carolan
So right now my code looks something like this: for line in open('myfile','r'):  if line.startswith('notes'):      ## Assign rest of file to variable Is there an easy way to do this?  Or do I need to read the entire file as a string first and carve it up from there instead? I ended up

Re: [Tutor] Import multiple lines of text into a variable

2011-04-11 Thread bob gailer
On 4/11/2011 5:14 PM, Sean Carolan wrote: So right now my code looks something like this: for line in open('myfile','r'): if line.startswith('notes'): ## Assign rest of file to variable Is there an easy way to do this? Or do I need to read the entire file as a string first and carve

Re: [Tutor] Running python on windows

2011-04-11 Thread ALAN GAULD
At least in my case it was about simplicity. If it was a simple matter of using a base python program, that would be one thing, but the last program i distributed here at work used pygtk as it's GUI Valid comment although its not much more work to build a custom installer that

Re: [Tutor] Running python on windows

2011-04-11 Thread Wayne Werner
On Mon, Apr 11, 2011 at 4:24 PM, ALAN GAULD alan.ga...@btinternet.comwrote: It doesn't make sense to say, go here, install this, ok, now drop this in this folder, ok now drop this in that folder, ok now open your command prompt and type this string Agreed, we need to package our apps so

Re: [Tutor] Generating XML using Python

2011-04-11 Thread Karim
On 04/11/2011 07:50 PM, Karim wrote: On 04/11/2011 10:04 AM, tee chwee liong wrote: hi Peter, thanks for your reply. seems that xml doesnt accept a space in between. anyway, the output generated is: *-* file:///C:/Python25/myscript/cmm/port1.xml# Test *-*

Re: [Tutor] Import multiple lines of text into a variable

2011-04-11 Thread Alan Gauld
Sean Carolan scaro...@gmail.com wrote I ended up doing this, but please reply if you have a more elegant solution: if line.startswith('notes'): break notes = open('myfile','r').read().split(notes:\n')[1] The first two lines are redundant you only need the last one. HTH, Alan G.

Re: [Tutor] Import multiple lines of text into a variable

2011-04-11 Thread Sean Carolan
if line.startswith('notes'):   break notes = open('myfile','r').read().split(notes:\n')[1] The first two lines are redundant you only need the last one. I should have clarified, the if line.startswith part was used to break out of the previous for loop, which was used to import the other,