#python - Sun 4 Mar 2007 between 02:05 and 07:49

NY Lost Funds



kapacehow can i reset readlines?
polpakdefine 'reset'
kapaceinstead of closing and opening the file
polpakf.seek(0)
kapacek..
thxs
ironfroggydepending on the size of the file, you might want to just cache the lines instead.
kapaceits a small file, but thanks anyways..
ironfroggywell thats the case where you'd want to cache it then. larger files would be too expensive to cache.
kapaceo, so how would i cache it? just file = f.read()?
pmcnabbif I have two lists of strings, how can I get a list of all the combinations? (i.e. ['a','b'] and ['c','d','e'] produces ['ac','ad','ae','bc','bd','be'] )
ironfroggykapace: lines = list(f)
kapacefor combinations in ['a','b']+['c','d','e']:
kk
ironfroggypmcnabb: are the strings of different sizes?
pmcnabbyes
ironfroggybut only two lists?
pmcnabbno, usually more
sorry, important detail
ironfroggythats moderately more complicated than when you know how many lists you'll have
pmcnabbi could do a len() to get how many... i didn't know if there was a combination function somewhere..
kapace, that didn't seem to work
kapaceno it was psuedo
ironfroggy: how can i seek to second line?
polpakkapace: well if you have them in a list it'd just be lines[1]
kapaceah
ironfroggykapace: you cant know where lines are without reading them
kapaceok
pmcnabbI found a combination function here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502199
mgorbach228Whats the best way to get two (possibly python) process communicating if they are on a single system?
ironfroggythat may depend on what they are communicating about
mgorbach228I'm think a python bittorrent backend communicating with a (python or cocoa) front end
sending updates on torrent status, peers, etc
Yhg1srefactor into functions so you can return, use the 'else' clause of for/while loops cleverly, or use exceptions.
twbHmph.
Does python have named returns, like Common Lisp?
Kserowhat do named returns do?
twbJust a moment, I'll find an example
http://twb.ath.cx/tmp/tmp.txt
I suppose you'd do that with exceptions in Python.

Page: 2 9 16 23 30 37 44 51 58 65 72 79 

IrcArchive

NY Lost Funds