[Tutor] Amara pushbind to retrieve data from Xml Doc
Hey I am pretty new to Python ( about a day old ). I am currently writing a small script to just cycle through an XML page and retrieve data if it exists. So for example an extract from the Xml page will have an element tagged entry like so I want this data I can use the following loop to list out all element.name, element.type and element.originalValue like so for subtree in binderytools.pushbind('/screen/panel/list/row/element', source=xmlfile): print subtree.originalValue source=xmlfile is just referencing a variable I have set to point to the actual xml page. How can I change the above loop to cycle through each , check if data exists like above and print this out. Any help would be appreciated. Thanks k -- "Behind every great man, there is a great woman. Behind that woman is Mr.T." ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] New Programmer using Python and ArcGIS
Hi there, I don't have a lot of experience programming and have to be writing Python scripts for ArcGIS 9.X. and would like to know if someone up there is working in this area so that I can be asking for some advises and help. Tkx Mat ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New programmer, need some help getting started on my first project
Kent, Thanks once again."I wonder if maybe you need to write some code? You talk about *reading* but you haven't mentioned *writing*. You can't learn to program without writing programs - that would be like learning to write a foreign language by reading books in the language - it helps but it won't get you there!So if you have just been reading, I suggest you try writing a few small programs as warmups."I think you are right on the money here. I need to write some more simple stuff. I did work through the books but I wrote very little on my own, just sort of followed along and said "Oh that makes sense". So I decided to go through the practice exercises in the book and then post here with any problems. SO here is my first stab and I keep getting a syntax error in my first if statement. The = sign is highlighted and I cant figure out what is wrong. Im almost embarassed to mail this. # A program that simulates flipping a coin 100 times and the reports the number of heads and tails that were flipped#import randomheads = 0tails = 0flips = 0if flips <= 100:coin = random.randrange(2)if coin = 0:heads +=elif coin = 1:tails +=flips +=1print "The coin was flipped 100 times and it was heads" + heads + "times and tails" + tails + "times!"raw_input("\n\nPress the Enter key to exit")THanks, Chris New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New programmer, need some help getting started on my first project
Kent, Thanks once again."I wonder if maybe you need to write some code? You talk about *reading* but you haven't mentioned *writing*. You can't learn to program without writing programs - that would be like learning to write a foreign language by reading books in the language - it helps but it won't get you there!So if you have just been reading, I suggest you try writing a few small programs as warmups."I think you are right on the money here. I need to write some more simple stuff. I did work through the books but I wrote very little on my own, just sort of followed along and said "Oh that makes sense". So I decided to go through the practice exercises in the book and then post here with any problems. SO here is my first stab and I keep getting a syntax error in my first if statement. The = sign is highlighted and I cant figure out what is wrong. Im almost embarassed to mail this. # A program that simulates flipping a coin 100 times and the reports the number of heads and tails that were flipped#import randomheads = 0tails = 0flips = 0if flips <= 100:coin = random.randrange(2)if coin = 0:heads +=elif coin = 1:tails +=flips +=1print "The coin was flipped 100 times and it was heads" + heads + "times and tails" + tails + "times!"raw_input("\n\nPress the Enter key to exit")THanks, Chris Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New programmer, need some help getting started on my first project
On Thursday 18 May 2006 16:19, Chris Delgado wrote: > import random > > heads = 0 > tails = 0 > flips = 0 > > if flips <= 100: > > coin = random.randrange(2) > > if coin = 0: > heads += > elif coin = 1: > tails += > > flips +=1 > > print "The coin was flipped 100 times and it was heads" + heads + "times > and tails" + tails + "times!" > > raw_input("\n\nPress the Enter key to exit") I think you want '==' and not '='. Look up assignment and equal! John ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New programmer, need some help getting started on my first project
johnf, Yup, I actually thought that might be my mistake but I forgot to actually try it. So I did and revised the code (which I'll post below) and now get a syntax error after my heads += line..yikes .# A program that simulates flipping a coin 100 times and the reports the number of heads and tails that were flipped#import randomheads = 0tails = 0flips = 0if flips <= 100: coin = random.randrange(2) if coin == 0: heads += else: tails += flips += 1 print "The coin was flipped 100 times and it was heads" + heads + "times and tails" + tails + "times!"raw_input("\n\nPress the Enter key to exit")johnf <[EMAIL PROTECTED]> wrote: On Thursday 18 May 2006 16:19, Chris Delgado wrote:> import random>> heads = 0> tails = 0> flips = 0>> if flips <= 100:>> coin = random.randrange(2)>> if coin = 0:> heads +=> elif coin = 1:> tails +=>> flips +=1>> print "The coin was flipped 100 times and it was heads" + heads + "times> and tails" + tails + "times!">> raw_input("\n\nPress the Enter key to exit")I think you want '==' and not '='. Look up assignment and equal!John___Tutor maillist - Tutor@python.orghttp://mail.python.org/mailman/listinfo/tutor Be a chatter box. Enjoy free PC-to-PC calls with Yahoo! Messenger with Voice.___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New programmer, need some help getting started on my first project
Chris Delgado wrote: > johnf, > > Yup, I actually thought that might be my mistake but I forgot to > actually try it. So I did and revised the code (which I'll post below) > and now get a syntax error after my heads += line..yikes . > > # A program that simulates flipping a coin 100 times and the reports > the number of heads and tails that were flipped# > > import random > > heads = 0 > tails = 0 > flips = 0 > > if flips <= 100: > > coin = random.randrange(2) > > if coin == 0: > heads += > else: > tails += > > flips += 1 > > print "The coin was flipped 100 times and it was heads" + heads + > "times and tails" + tails + "times!" > > raw_input("\n\nPress the Enter key to exit") Good - you wrote it. Did you run it? Because there are several things that will lead to "compile errors" and "execution errors". I hope you run it and think about the errors, then if stumped ask us. -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New programmer, need some help getting started on my first project
Bob et al, Ok guys, program is all fixed up and runs well. HEre is the final code. Thanks for the help and its on to the next prog. Thanks for the patience and help!Chris# A program that simulates flipping a coin 100 times and the reports the number of heads and tails that were flipped#import randomheads = 0tails = 0flips = 0while flips < 100: coin = random.randrange(2) if coin == 0: heads += 1 else: tails += 1 flips += 1 print "The coin was flipped 100 times and it was heads " +str(heads)+ " times and tails " + str(tails) + " times!"raw_input("\n\nPress the Enter key to exit") Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries for just 2¢/min with Yahoo! Messenger with Voice.___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New programmer, need some help getting started on my first project
Chris Delgado wrote: > Bob et al, > > Ok guys, program is all fixed up and runs well. HEre is the final > code. Thanks for the help and its on to the next prog. Thanks for the > patience and help! > > Chris > > # A program that simulates flipping a coin 100 times and the reports > the number of heads and tails that were flipped# > > import random > > heads = 0 > tails = 0 > flips = 0 > > while flips < 100: > > coin = random.randrange(2) > > if coin == 0: > heads += 1 > else: > tails += 1 > > flips += 1 > > print "The coin was flipped 100 times and it was heads " +str(heads)+ > " times and tails " + str(tails) + " times!" > > raw_input("\n\nPress the Enter key to exit") Congrats! Now consider some "simplifications": import random heads = 0 for flips in range(1,101): heads += random.randrange(2) print "The coin was flipped %s times and it was heads %s times and tails %s times!" % (flips, heads, flips - heads) raw_input("\n\nPress the Enter key to exit") -- Bob Gailer 510-978-4454 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] New programmer, need some help getting started on my first project
Bob, Thanks for the input. I was trying to stick to the lessons in the chapter whose problems I was working on and so I knew using a for loop might be a bit better, I decided to stick with the stuff from the chapter. I do like the way you simplified using the random function, very clever. I need to start thinking like that. Thanks again, I'll have more questions soon I'm sure!ChrisBob Gailer <[EMAIL PROTECTED]> wrote: Chris Delgado wrote:> Bob et al,>> Ok guys, program is all fixed up and runs well. HEre is the final > code. Thanks for the help and its on to the next prog. Thanks for the > patience and help!>> Chris>> # A program that simulates flipping a coin 100 times and the reports > the number of heads and tails that were flipped#>> import random>> heads = 0> tails = 0> flips = 0>> while flips < 100:>> coin = random.randrange(2)>> if coin == 0:> heads += 1> else:> tails += 1>> flips += 1 >> print "The coin was flipped 100 times and it was heads " +str(heads)+ > " times and tails " + str(tails) + " times!">> raw_input("\n\nPress the Enter key to exit")Congrats! Now consider some "simplifications":import randomheads = 0for flips in range(1,101): heads += random.randrange(2)print "The coin was flipped %s times and it was heads %s times and tails %s times!" % (flips, heads, flips - heads)raw_input("\n\nPress the Enter key to exit")-- Bob Gailer510-978-4454 Be a chatter box. Enjoy free PC-to-PC calls with Yahoo! Messenger with Voice.___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor