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
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
>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
Thanks Kent. I didn't see it.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
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
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
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/
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
>
> 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.
_
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
10 matches
Mail list logo