| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Comments:
<0> get vim for windows <1> dont have time to fix <0> now <2> yes, gvim for windows <1> ok :) <3> PerceptualChaos, Why not PythonWin or IDLE ? <1> its nice to be able to edit html as well <0> okay, ***uming it behaves the same on Linux as on Windows... the problem is that rfile is *not* a file object which gives EOF... so if you read it, you block <1> like gedit <2> how could I count the number of numbers, in a string like "6 6 23 5 10 61 14 6 5 10 15 9", I dont want len(), just how many numbers are in the string (non-whitespace) <0> sanmarcos: count the whitespace <2> Leeds: can you explain? <2> its midnight <1> Leeds: sounds right <0> if the string is "1 2 5 23" it has 3 spaces and 4 numbers... easier to count 3+1 than 4 <3> what if there is more than one whitespace between some numbers ?
<2> exaclty, or if there is a beginnign whitespace <0> then it's not a string in the form you gave <3> the easiest way: count = len("12 3 4 55 6 ".split()) <1> haha <4> why not split? <4> heh <0> and if there's whitespace at the beginning? <2> right, what if there is whitespace in the beginning? <4> trim? <3> strip() <2> hmm yes <2> oh, strip() does it <4> lol <4> split doesn't even care about whitespace at the beginning <2> strip baby <3> but there's no need to call strip() manual, <2> ahmeni: no? <3> split() calls it <4> In [3]: len(" 2 3 4".split()) <4> Out[3]: 3 <2> len(string.split()) there <2> thanks :) <1> Leeds: I'll try open a file and write it using the same syntax just to test your hypothesis <0> PerceptualChaos: the problem is that it's not a file... it's a file object created from a blocking socket <0> PerceptualChaos: frankly... use GET :-) <1> Leeds: how so? <1> and actually that would be breaking our protocol <0> PerceptualChaos: that way you don't have to parse a neverending file <0> your protocol is broken <1> we need to send messages as an HTTP post <0> then don't use BaseHTTPServer <1> yeah that might be the only option <1> use real CGI scripting <0> so do you or do you have *have* to use BaseHTTPServer? <1> well everyone else has <1> so its possible <1> and he wants us to <1> but I could probably use the python apache server thing <1> (I forget the name) <0> mod_python? nope, don't do that <2> ok, I have something like this msg = "4 5 7 4 7 45 87 12 78 12 78 16 74"; addcipher = "8 4 7 6 8 13". I need the numbers in addchiper (for n in addchiper), to be added to the numbers in the msg string. See addchiper has 6 numbers, so I need those six to be added to the first six in msg, then the second six, and so on. Any ideas? <1> what do you suggest? <4> "Note: the cl*** in this module doesn't implement any HTTP request; see <4> SimpleHTTPServer for simple implementations of GET, HEAD and POST" <1> I don't like giving up on a problem though, especially when I know its possible to solve <4> Would SimpleHTTPServer be a viable solution? <0> SimpleHTTPServer does not implement POST <1> ahmeni: yeah I write the do_POST and do_GET myself <1> thats the whole point <1> you have more control and implement yourself <4> heh, someone needs to fix the basehttp docs then <5> morning #python <1> evening <1> (here) <6> wow.. reading in data takes about 3min, is there a way i can put this data in memory and access it from seperate execution of my code?.. maybe shared memory? <0> mid-afternoon here, and I've got someone ***uming I'm going to be a stripper at a hen party tonight <2> string.split()[:6] maybe <0> PerceptualChaos: do you know select()? <1> no <0> it will let you read from rfile without hanging <1> do you know the syntax or should I look it up?
<0> look it up <2> so any ideas on my question? <0> and for reference... although I should have known... remember that most of the python library is implemented in python... I had a look at how CGIHTTPServer does it <7> eugenekim15: what data are you loading? <8> sanmarcos, writing something right now <2> TFK: heh, thanks; I am pondering this problem too <6> ironfroggy: it's a dictionary, but i'm storing it to my data structure <6> ironfroggy: word dictionary <8> ?itertools <7> eugenekim15: what is your data structure? <6> ironfroggy: the outermost structure is python dict <6> ironfroggy: but the dict has each english letter not the words from the original dict <8> sanmarcos, in your example, is this the correct answer: [12, 9, 14, 10, 15, 58, 95, 16, 85, 18, 86, 29, 82] ? <2> TFK: I havent tried it yet, but just by looking at it it seems right <6> ironfroggy: i tried saving it using pickle, funny it takes longer to load the saved data structure <9> eugenekim15: cpickle will be about a billion times faster <7> yes, use cPickle <6> oooooo <7> if you want to go the pickle route <6> ok ill look into it thanks <7> just change 'import pickle' to 'import cPickle as pickle' and the rest of your code will work without change. <2> TFK: i was thinking of getting the amount of numbers in the msg, and the amount of numbers in the cipher, and doing msgnum / ciphernum, with that split the msg and apply the cipher math.. dont know if I am right <8> sanmarcos, >>> from itertools import cycle, izip; print [i + j for i, j in izip(map(int, msg.split()), cycle(map(int, addcipher.split())))] <8> [12, 9, 14, 10, 15, 58, 95, 16, 85, 18, 86, 29, 82] <6> wow interchangable api nice <8> This could be made more readable when spread out on more lines, of course :-P <2> TFK: wow, never heard of itertools, or cycle <8> ?itertools sanmarcos <2> TFK: i was thinking of doing loops myself <8> Best thing since sliced bread. Honest :-) <2> i guess I have a lot to read <6> wonder if you can open pickled object with cpickle? <0> of course you can <6> cool <8> Not that much, actually. <2> TFK: I will read the manuals and try to understand your code. Thank you so much :) <1> Note that on Windows, it only works for sockets; on other operating systems, it also works for other file types (in particular, on Unix, it works on pipes) <1> :-/ <1> this documentation is rather confusing <1> select( iwtd, owtd, ewtd[, timeout]) <1> so I guess I need to go: from select import select; r=select(rin,[],[],1) <8> sanmarcos, oh, and you can substitute map for imap (from itertools) there :-P <1> then print r or someting <6> duh,, cpickle is still too slow(as a matter of fact, it was little slower than pickle for me).. <6> what are other options? can you use shared memory in python? <1> er, rin should be fp <1> Leeds: r=select(fp,[],[],1) didn't work <2> is there a way to invert a dict? where the values become the keys and viceversa ? <0> PerceptualChaos: get a real computer <7> PerceptualChaos: it takes lists of file objects, not file objects. <1> ha ok I'll try test my luck in Ubuntu <1> ironfroggy: can you give me an example? <6> ironfroggy: might mmap be what i'm looking for? <7> eugenekim15: i dont see why it would be. <7> PerceptualChaos: you dont know what a list is? <1> ironfroggy: I know what a list is, I don't know how I would apply a list to that function in this situation <7> you p*** it.. <1> you mean I should call it as [fp] <7> yes. <8> sanmarcos, on possibility is: revdict = dict((value, key) for key, value in mydict.itervalues()) # however, what happens when the values are unhashable or are not unique? <3> overwrites <1> ironfroggy, Leeds: I get empty lists when I call it like that <8> Yeah, and when they're unhashable, it chokes. <1> r,w,e=select([fp],[],[],1) <3> TFK, that's was quite impressive, with itertools. i wish i've heard about that before <1> then print r gives [] <10> anyone using python and eclipse here? apparently the default path is set to c:\progra~1\eclipse and not my workspace and projectpath <10> I'm looking for a config file, but it isn't in the same path <1> I want to jump off a cliff <1> :-/ <0> PerceptualChaos: don't do that - you'll make a mess <1> oh sorry, wrong window that should have been for the emo room <1> :-P <11> hello, I want to send strings that points to filenames (file = "path/to/file.txt") to a shell application. I'd like to know how I could automaticly replace all special characters to espace them: file = "path/to/some file.txt" <-- here I'd like to escape " ". I can do file.replace(" ", "\ "), but I thought there might be a way replacing all chars at the same time. I thought using the re. module, but I'm not very good at it yet.
Return to
#python or Go to some related
logs:
suse 10 dual monitor pear install HTML_AJAX-alpha grub.conf xp sd0 gentoo tvtime+ubuntu+audigy #math Synaptics deviceOFF called gentoo #perl ubuntu no sensors found #perl #math
|
|