Re: [Tutor] aBSOLUTE BEGINNER

2007-10-19 Thread jon vspython
You can find Dive into Python online here: http://diveintopython.org/toc/index.html ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] accessing data in a usable format

2007-10-18 Thread jon vspython
What about this? dic = {} for line in file("findvalue.dat"): a,b,c,d = line.split() dic [a] = (float(b), float(c), float(d)) ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] newbie question

2007-10-18 Thread jon vspython
>From http://diveintopython.org/getting_to_know_python/index.html, we can get this solution which works no matter the size of the dictionaries: print ' '.join(["%s" % (v,) for k,v in menu_specials.items()]) It generates a formatted string for value in the dictionary and then joins them using whit

Re: [Tutor] Regex parsing and writing to file

2007-10-18 Thread jon vspython
Thanks Kent. I didn't see it. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Regex parsing and writing to file

2007-10-18 Thread jon vspython
Cool! It works :-) But I don't get it. Where is the redirection? Thanks Ken. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Regex parsing and writing to file

2007-10-18 Thread jon vspython
I was not trying to get any output. I was trying to modify a source file in place, I just want to replace file content text automatically. So I tried first from python shell in linux. This is what I did: [EMAIL PROTECTED] aut]$ python Python 2.4.3 (#1, Oct 23 2006, 14:19:47) [GCC 4.1.1 20060525 (R

Re: [Tutor] Regex parsing and writing to file

2007-10-18 Thread jon vspython
Sorry, I think I should have explained what I was expecting to get. I wanted plain text back in my file. Real line feed and carrier returns instead of \r and \n, and so on. Thanks again, Jon. ___ Tutor maillist - Tutor@python.org http://mail.python.org/

Re: [Tutor] Regex parsing and writing to file

2007-10-18 Thread jon vspython
Hi, I tried this on a file: for line in fileinput.input("myfile",inplace=1): re.sub(r'LOOP',r'PRUEBALOOP',line) and for lines like this: PT_WT_INIT: LOOP I got this: 'PT_WT_INIT: PRUEBALOOP\r\n' I also tried without raw strings: re.sub('LOOP','PRUEBALO

Re: [Tutor] aBSOLUTE BEGINNER

2007-10-17 Thread jon vspython
> > This is my favourite all time beginner book > http://ibiblio.org/obp/thinkCS/python/english2e/html/index.html. IT is > in html, I don't know if you can get it in pdf. > You can find an revised PDF version here: http://www.greenteapress.com/thinkpython/ It should be more up to date. _

Re: [Tutor] newbie question

2007-10-15 Thread jon vspython
There's also a specially tailored solution for dictionaries: print "%(breakfast)s %(lunch)s %(dinner)s" % menu_specials ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor