Re: [Tutor] dictionaries help

2009-07-24 Thread davidwilson
Hello Original Message From: Kent Johnson Apparently from: kent3...@gmail.com To: davidwil...@safe-mail.net Cc: tutor@python.org Subject: Re: [Tutor] dictionaries help Date: Thu, 23 Jul 2009 21:44:33 -0400 > On Thu, Jul 23, 2009 at 7:09 PM, wrote: > > Hello again, > > Here is

Re: [Tutor] how to get blank value

2009-07-24 Thread Alan Gauld
wrote 48 ALA H = 8.33 N = 120.77 CA = 55.18 HA = 4.12 C = 181.50 104 ALA H = 7.70 N = CA = HA = 4.21 C = Now i want to make two another file in which i want to put those lines for which C is missing and another one for which N,CA and C all are missing, I tried in this way: import re expr

Re: [Tutor] how to get blank value

2009-07-24 Thread ALAN GAULD
Please use Reply All to send it to the list as well. > I am trying it in this way also:--- > > import re > expr = re.compile("C") This will find all lines with the letter C in them. Which from your data is all of them. Look at the regex documentation to see how to represent the end of a lin

Re: [Tutor] how to get blank value

2009-07-24 Thread amrita
> What is the python command for searching blank value of a parameter? > Please use Reply All to send it to the list as well. > > >> I am trying it in this way also:--- >> >> import re >> expr = re.compile("C") > > This will find all lines with the letter C in them. > Which from your data is all

Re: [Tutor] how to get blank value

2009-07-24 Thread Luke Paireepinart
You will probably continue to get unsatisfactory responses if you continue to ask unsatisfactory questions.Python won't automatically parse this document in exactly the way you want it to. You're on the right track but you need to do as Alan said and actually read the regex articles to understand

Re: [Tutor] how to get blank value

2009-07-24 Thread Albert-Jan Roskam
Mark Summerfield recently wrote a book called Programming in Python 3 (http://www.qtrac.eu/py3book.html) The chapter on regexes happens to be freely downloadable as a sample chapter: http://ptgmedia.pearsoncmg.com/images/9780137129294/samplepages/0137129297_Sample.pdf I found that chapter (in f

[Tutor] traversing page and then following the link

2009-07-24 Thread davidwilson
Hello, I would like to download all the flags from the http://en.wikipedia.org/wiki/Gallery_of_sovereign-state_flags so that I can create a flags sprite from this. The flags seem to follow some order in that all the svg files are in the following pattern: http://en.wikipedia.org/wiki/File:Flag

Re: [Tutor] traversing page and then following the link

2009-07-24 Thread vince spicer
there are many ways to parse html pages and retrieve data, I tend to use lxml and xpath to simplify things and urllib to pull down the data lxml is not a core library but can be installed via easy_install, the main benefit is the xpath support =

[Tutor] Help with multiple substitution

2009-07-24 Thread vankayala sailakshman
Hi All, Help needed to write a python script!!! Iam a python newbie and my problem is doing multiple substitution in a text file using Python regular expressions. Here is my following data, I need to chop of all the extensions that are given in the following list

Re: [Tutor] traversing page and then following the link

2009-07-24 Thread Emile van Sebille
On 7/24/2009 7:48 AM davidwil...@safe-mail.net said... Hello, I would like to download all the flags from the http://en.wikipedia.org/wiki/Gallery_of_sovereign-state_flags so that I can create a flags sprite from this. You did -- most of the time when you look at a page the files were copie

[Tutor] Reading text until a certain point

2009-07-24 Thread Stefan Lesicnik
Hi Guys, It seems like this keeps coming up (for me anyways), and i'm never sure how to do it. I'm very new to programming... I have a file that has text in a certain format. Lets assume ''' name: stefan id: 12345 color: blue name: joe id: 54321 color: red ''' The format is predictable. I unde

Re: [Tutor] Help with multiple substitution

2009-07-24 Thread vince spicer
not perfect or tested but import re chopset.reverse() #: put the longer extensions first exts = "|".join([re.escape(x) fro x in chopset)]) for line in file: print exts.sub("", line) On Fri, Jul 24, 2009 at 9:22 AM, vankayala sailakshman < sailakshm...@hotmail.com> wrote: > > Hi All, > >

Re: [Tutor] Reading text until a certain point

2009-07-24 Thread vince spicer
you can build a dictionary and keep the active key, again this would only work in predictable data users = {} name = None for line in file: key, value = [x.strip() for x in line.split(":")] if key == "name": name = data[1] users[name] = {} else: users[name][d

[Tutor] What kind of number is this

2009-07-24 Thread عماد نوفل
Hi Tutors, I have a bunch of text files that have many occurrences like the following which I believe, given the context, are numbers: ١٨٧٢ ٥٧ ٢٠٠٨ etc. So, can somebody please explain what kind of numbers these are, and how I can get the original numbers back. The files are in Arabic and we

Re: [Tutor] What kind of number is this

2009-07-24 Thread Skipper Seabold
2009/7/24 Emad Nawfal (عماد نوفل) : > Hi Tutors, > I have a bunch of text files that have many occurrences like the following > which I believe, given the context,  are numbers: > > ١٨٧٢ > > ٥٧ > >  ٢٠٠٨ > > etc. > > So, can somebody please explain what kind of numbers these are, and how I > can ge

Re: [Tutor] Reading text until a certain point

2009-07-24 Thread Dave Angel
vince spicer wrote: you can build a dictionary and keep the active key, again this would only work in predictable data users = {} name = None for line in file: key, value = [x.strip() for x in line.split(":")] if key == "name": name = data[1] users[name] = {} else:

Re: [Tutor] Pygame

2009-07-24 Thread bhaaluu
On Thu, Jul 23, 2009 at 11:49 AM, David wrote: > Hi, > > there also is: > "Invent Your Own Computer Games with Python", which apparently does not > use pygame (like Dawson). > http://pythonbook.coffeeghost.net/ > > I can't comment on the quality. > > David > I have looked through almost half of th

Re: [Tutor] dictionaries help

2009-07-24 Thread Kent Johnson
On Fri, Jul 24, 2009 at 3:01 AM, wrote: >> If ws_industry contains 25 items, it will probably be faster to search >> it if it is a set rather than a list. Just use >> ws_industry = set(('it', 'science')) > > ws_industry contains only unique values OK. It will still be faster to check membership i

[Tutor] Syntax Problem

2009-07-24 Thread Jesse Harris
for d in Decks.all(): #loop thru all available decks   self.response.out.write(''+d.name)       self.response.out.write(''+d.description) self.response.out.write('') self.response.out.write('') : invalid syntax (main.py, line 206)   args = ('invalid syntax', (r'C:\Program Files\

Re: [Tutor] Reading text until a certain point

2009-07-24 Thread Alan Gauld
"Stefan Lesicnik" wrote I have a file that has text in a certain format. Lets assume ''' name: stefan id: 12345 color: blue name: joe id: 54321 color: red ''' The format is predictable. I understand for non predictable text, you would have to use pyparser or the like to build a match. T

Re: [Tutor] Syntax Problem

2009-07-24 Thread wesley chun
On Fri, Jul 24, 2009 at 2:34 PM, Jesse Harris wrote: > for d in Decks.all(): #loop thru all available decks >   self.response.out.write(''+d.name) >       self.response.out.write(''+d.description) > self.response.out.write('') > self.response.out.write('') > > : invalid syntax (main.py,

Re: [Tutor] Reading text until a certain point

2009-07-24 Thread Alan Gauld
"Alan Gauld" wrote class Item(object): def __init__(self, aFile): data = aFile.readline().strip().split(:) setattr(self, data[0], data[1]) The last two lines should of course be repeated 3 times... Either in a loop or - for just 3 items - maybe hard coded... items = [] f =

[Tutor] Need to be pointed in the right direction for file organisation.

2009-07-24 Thread Mac Ryan
Hello everybody, I am new to python programming, but - thanks to "dive into python" - I had no difficulties in picking up the basics of the language and experimenting on my own with PyGTK and STORM. While I am working my way up to a more pythonic and cleaner style in the code, one

[Tutor] How to force stop a thread

2009-07-24 Thread Amit Sethi
Hi , I am trying to implement python threads in a gtk based app . Now the thing is that in the application I have to fetch a lot of data from various sources from web. During this time I wish to show a dialog that indicates it to the user . During the same time I want to fetch data as well . Now t

[Tutor] Reading and Manipulating XML Data

2009-07-24 Thread Luis Galvan
Being new to Python and programming, I'm having a very difficult time studying and finding helpful (beginner) documentation on XML. I'm at the point where I have learned the syntax and am just starting to get my feet wet with learning how to utilize it. (and by "utilizing it" I mean making useful

[Tutor] Reading Data From File

2009-07-24 Thread Chris Castillo
Okay I really need help with the program I am writing. I've can't seem to figure out what I need to do and have tried several different methods. I need to read in a text file in python that contains the following: Student Name ( could be unknown amount in file ) Numeric Grade ( could be unknown

Re: [Tutor] Reading Data From File

2009-07-24 Thread wesley chun
On Fri, Jul 24, 2009 at 11:40 PM, Chris Castillo wrote: > Okay I really need help with the program I am writing. I've can't seem to > figure out what I need to do and have tried several different methods. hi chris, and welcome to Python! the tutors here are very helpful to those who are new to pr