| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Comments:
<0> >>> biglist.sort(key=lambda s: int(s.split(" ", 1)[0])) <0> >>> print biglist.sort(key=lambda s: int(s.split(" ", 1)[0])) <0> None <0> (sorry for the paste) <1> l.sort() sorts in situ. <0> sorry? <1> sorted(l) returns a new list. l.sort() mutates the current list and returns nothing. <0> ahh <0> so newlist = biglist.sort(........) ? <1> No. l.sort() returns nothing. Never ***ign it to anything. <0> ok after taking your biglist.sort command above how do i print the results? <1> print biglist <0> oh really <0> ok <2> any electric guitar players? <0> oh ok cardinal i get it now
<0> thanks a million - now i gotta go read and figure out what that command actually does :) <1> monkeywk: One makes a copy of the list and sorts the copy. The other changes the list in-place. <1> monkeywk: Are you new to lambda as well? I can rewrite that. <0> Cardinalfang: yes, i actually don't do any coding at all I just got asked to hack this out and fuddling my way through :) <1> def record_comparison(record):\n first, rest = record.split(" ", 1)\n return int(first) <1> biglist.sort(key=record_comparison) <0> brb <3> hey, guys.. I hope this is suitable place to ask some python programming questions :) <4> tuisu: don0t ask to ask, just ask ... you are welcome to ask any question here <5> Yeah, we're not #java or something :) <3> well, I'm trying to build a simple script that fetches some pages from the internet and I want it to keep connection open - keep-alive <3> so I'm using urlgrabber to handle keep-alive for me.. but i would also like to use session - fetch and send cookies <3> I'm using urgrabber.keepalive.HTTPHandler for urllib2 connection so all the keep-alive stuff is handled nicely.. <6> anyone of you ever wrote(or can quickly write) a prime number finding script? <6> if so, mind uploading it on pastebin so I can compare? <3> I read the ClientCookie intro and it seems to handle cookies the same way - by installing a opener - ClientCookie.HTTPCookieProcessor <3> and so I'm in trouble.. I can't install them both, so I can't handle keep-alive and cookies simultaneously <7> anyone good with sqlite? Why am I getting this error? http://rafb.net/paste/results/XQrEZk91.html <8> Yahoo, swig + dll + stuff works <8> Ok now I will stay with python. <8> well this was only something easy yet <3> I tried exctracting cookies manually.... like CookieJar.extract_cookies(response, request) <3> and later on to add those cookies to my request like this CookieJar.add_cookie_header(request) .. and I did check the request headers to see if it did add the cookies - it did, but when fetching data I still get links with session_id (stuff.phph?sess_id=54534).. so there seems to be some kind of problem <9> in a regex, how do you use the thing of (option1|option2) without making a group? <3> so, how would it be possible to use both the urlgrabber keep-alive and ClientCookie cookie-management features.. or should I manually read and set request headers? <10> OrgulloKmoore: (?: ...) <3> and would it work when I did it manually? like.. request.add_header('Cookie', 'cookiedata') <9> tirkal-> that would take it out of the picture completely... <9> I want to be able to rechieve it, but not create a group <11> synic: hmm, is that ipython? any chance at all it's ipython instead of (py)sqlite triggering it? <7> well, it happens in the app too <11> ok, so that's not it then... <7> it causes only about 101 rows to be selected out of about 2000 <10> OrgulloKmoore: "rechieve" it? <11> synic: I ***ume the same query works when you use sqlite directly instead of pysqlite? <7> yes <9> tirkal-> lol, I think I made up a word, did I? <11> synic: any obvious "weird" chars in the rows pysqlite blows up on? <10> OrgulloKmoore: yup <9> grrr <4> tuisu: maybe you could hack into ClientCookie and have it use urlgrabber's connection <7> marienz: dunno, but if there were, how would I get rid of them? <9> haha, that's hillarious <9> School's for fools <11> synic: good question. I'm a bit puzzled as to why pysqlite tries to utf8-decode them without being asked in any obvious way. <9> tirkal-> retrieve.. <4> tuisu: or rather ... why do you need urlgrabber's keepalive, if you have the cookie handler at work <10> OrgulloKmoore: re.findall(r'(?:foo|bar)', 'foo') <10> #=> ['foo'] <9> let's see.. <3> rox: well.. I only use urlgrabber so it would keep connection open.. when I'm using urllib2 p***ing 'Connection: keep-alive' won't work.. and I have about 50 request, so I do want to have keep-alive on <7> tirkal: what does the "r" do ? <12> Is there some way to do cleanup for a extended c module? There's the init<module_name> function, is there something like a cleanup<module_name>? <13> does anyone know how to create a new process, using win32process module, that runs in its own process space....and will keep running even if the calling program completes? <10> synic: it means a raw string format, making \ not escape any char except quotes. <7> cool <9> I don't think it worked... <3> rox: as far as I can tell, the only way to get the keep-alive thing working is with urlgrabber <9> tirkal-> can I put something in the pastebin for you to look at?
<14> i'm trying to do: <4> tuisu: i don't get it .. you are saying that ClientCookie works by having a connection open <14> odbc.windows.connect('text','text','text') <4> tuisu: and yet you are having another opener <14> but i keep getting this error: <4> tuisu: s/having/using/ <7> marienz: how do you utf8-decode any string? <14> data source name not found and no default driver specified <4> tuisu: how about opening the connection through Clientcookie and forgeting about urlgrabber? <14> does anybody know why i can't seem to use this odbc.windows.connect thing <15> hello <15> is there a standard way of dealing with signals and callbacks in python? <15> like libsigc++ for c++ <4> tuisu: if it doesn't work, then you should figure out what closed the connection in ClientCookie and work around it <11> synic: hmm, I just skimmed the sqlite and pysqlite docs a bit, and it looks like pysqlite will try to give you a unicode object if the sqlite type affinity of the column is "text" <10> OrgulloKmoore: you can put it for everyone to look at it :) <10> I'll look too. <11> synic: unfortunately I haven't found a trick to change the column affinity to "blob" so you can get the data out yet <9> tirkal-> oops, I got it <10> great :) <3> rox: yeah, ClientCookie works by opening a connection and managing cookies and everything.. but it doesn't keep the connection open (like if I want to fetch something else, I have to open the connection again - not manually, but still is slows things down) <4> tuisu: meaning that you can't keep the ClientCookie connection alive <3> rox: and it did search around to see if it's somehow my problem.. but I found couple of similar problems and the point was that somehow urllib2 is not able to keep connections open <4> tuisu: if i were you, i would dig into clientcookie and have it's connection handler keep the connection alive, rather then mangle cookies manually <3> rox: ok, I'll try to do that. thanks <3> rox: but actually i'm not sure that it's about ClientCookie.. it's still about urllib2. Because urllib2 can't keep persistent connections and ClientCookie is just on top of that with some cookie management functions <16> err <16> whats wrong with <16> if foo not True: ? <17> try if not foo: <15> hm <15> if foo not True is invalid syntax <15> if not foo is True <15> is valid <16> ah <17> but usually you would never check if something IS True <16> if foo is not True as well <16> stain: no. <17> because there is lots of other things than True that is true <3> rox: this guy seems to have the same problem - http://www.karlnelson.net/weblog/000943.html <15> yeah <4> tuisu: then how about doing it in reverse ... use urlgrabber's connection in clientcookie <17> hds: what I'm saying is that it is usually a bad idea to check identity against True.. <3> rox: yeah. I though about that but I still hoped I was my bad and it was easy to fix. Have to get my hands dirty then :) <13> anyone know how to spawn a new process (seperate from parent proc) using win32process...that isnt orphaned when parent completes? <3> rox: anyway, thanks <11> stain: unless you do something crazy/ugly of course (I've used a True/False/None tristate of sorts once or twice) <17> I think then it would be better to just have some other constant values =) <4> tuisu: i wasn't much help anyway, but you'r welcome <17> ALT1 = object() ALT2 = object() etc. <11> it seemed like a good idea at the time :) <17> marienz: it always does =) <11> (esp. since the boolean interpretation still made some sense too) <16> stain: it's an if-condition without an else to catch a wrong-going of a method. or how would you do that? <17> hds: so why would it be "not True" ? <18> hds use the object itself as the truth test <17> where does True come from? <18> hds "is True" tests if the object is the SAME OBJECT as the "True" object. It almost never is. <16> Zalamander: k <18> hds "if foo" tests if foo is true or false <16> <16> ^ <16> IndentationError: expected an indented block <16> huuuh? <16> how can such a thing happen? <18> hds you can't start with extra whitespace :-) <11> hds: we cannot really tell without a pastebin of the code. <4> tuisu: ok, once again ... ClientCookie closes stuff right after grabing it? <16> Zalamander: ah <16> marienz: i don't even know which line... <16> marienz: it just tells me "last line of the code" never mind where that is <11> hds: interactive python or running some .py file? <16> marienz: aah. all the content after an if was commented out. that was the problem
Return to
#python or Go to some related
logs:
#perl os-interface rlim #gentoo compat-expat #perl +mythweb +client denied debian group www-data laptop external monitor detect ubuntu Fedora for AMD 64 #web
|
|