| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Comments:
<0> for x in enumerate(list) <--- is this a single interation over a list? <1> Yorick: uh, they're implemented to behave exactly like lists. <0> or an enumeration... then an iteration? <1> Yorick: 'array' is an outmoded broken concept from the days when you had to malloc() and free() <2> jerub, can file do that? <1> triplah: it's a single iteration <1> dave___: do what? <1> dave___: you just said "file stream", and I have no idea what you meant. <2> jerub, i'm trying to read in from a file and apply a regexp.. but the file is 2GB, so i don't want it in memory <3> Yorick: but u can just append stuff to a list, cant u ... while when u r dealing with arrays in some other languages u would have to check array length etc <1> dave___: oh, yeah. <1> dave___: just <1> for line in file('myfile'): ... will do it. <2> the regexp is for multiple lines <1> is it binary data? if it is, it might be a long way between newlines, and iterating like that will go a line at a time. <3> in that way they are more like java vectors, u just append without thinking about length etc :)
<2> jerub, it has to read in an arbitrary number of lines before the regexp will match, but after that, i want it to free up the now unused memory for what it read in so far <1> milosn: that is because a vector is very much like a 'list'. <1> dave___: yeah, so you do: <1> mydata = ''; for line in file('myfile'): mydata += line; dostuff, if match: mydata = '' <3> whatever it is ... <2> jerub, good idea, i can use a StringIO object for that to make it fast, too. <3> ill go and do something usefull <1> dave___: no you can't. <1> dave___: the regexp engine works on python str's, it can't work on a StringIO object. <1> so if you want to match in 'mydata' not in 'line', you need it as a str regardless. <2> yeah, but it's easy to just cstr.read() <1> yes, but less efficient. <4> re <2> less efficient than creating 900,000 string objects? <1> hence me saying, "no its not" <1> dave___: .read() will create exactly the same number <1> it will just add StringIO objects too <4> hi guys - http://nopaste.php-q.net/194848 <1> two strings -> one string <= two strings -> stringio object + 1 string <4> could you take a look at it? <1> yuck. <4> Jerub, don't worry - it'll just blow your monitor <4> and probably your mind because of the ignorance with which the code was written <4> info is as you can see the made out of some parts - it could be getTitle() for example <2> jerub, ok i see. thanks <1> FILE has no attribute info <5> Is there a more elegant way to do dict([(k,v) for k,v in oldDict.iteritems() if v>0])? <1> Wu: don't use an /away script <4> when i call tag.info it should use what stands inside of info (in the example getTitle()) <4> but it doesn't <4> how can i make it do that? <6> sorry about that, crappy irc client <1> luh: you mean to use +info+ not +FILE.info+ <6> i have it enabled by default and i forgot (i do not usually use /away) <1> Wu: thankyou for your attention. we appreciate your help in this matter. :) <7> luh: they are about to tell you that it is evil...soon you will believe it is evil... but you can use exec(info) and if info is 'getTitle()' and you have a getTitle() function it will call it <8> how do i launch something in a separate process instead of a thread? <4> cb921, you mean +FILE.exec(info)+ ? <4> Jerub, using only info doesn't work <9> w1ldch1ld: os.popen is one option <2> w1ldch1ld: fork <4> cb921, it might be really evil what i do atm - but i'm beginner - and atm i can't see a better solution - when i get better i'll probably fix these youth-sins <4> or you show me how to do it better <8> dave___: thanks. shall look it up. <7> luh line 27 needs only 'info' not FILE.info <4> but it doesn't know on which object info is called or? <7> Then use getTitle(FILE) and change the getTitle function to be def getTitle(FILE): <4> hmm - it stopped writing completely <4> (with the changing from File.info to info) <10> has anyone ever used win32com.client.Dispatch to get COM access to firefox? can it be done, i have been having trouble finding any docs about it. <7> luh - is this where you want to RUN the function stored in info? <11> donkeyboy: well I do use this for other things....whats the prob? good docs are the win32 for python programmers (oreilly) and ActiveState python 2.4 docs <4> yeah - because that should return a string <4> and that's the one i want to write in there <10> m0no: i have no problems using it for IE and other windows apps, but i am not able to find any docs with refrence to firefox, like its application name and wat functions it makes callable from the COM interface <12> hm I need to create a function object that accepts a few parameters but has a few set by the creator of the object, can I use a lambda to create this? <4> cb921, info is a member function of a tag object - which returns me a string with some informationabout the tag <11> donkeyboy: did you see this? http://developer.mozilla.org/en/docs/PyXPCOM <4> okay - i'm trying to get the information out first - save the information in a string and write that string
<4> so i'm trying : <4> savedInfo = exec info <4> but that won't work either <10> m0no: taking a look at it now, thanks. <10> wats up with IBM? the last couple days every article or doc i have tried to look at has either been not found or i get an sorry note <11> is it better to go from blah import * or import blah <9> m0no: as with Java, importing every name is considered not ideal style "polluting namespace" - but it saves typing the module prefix <13> mono: if you must, it's best if you "from blah import bar, baz, badtz, blergh" <14> mcmillen: not even 'foo' ? <14> this code sure ain't gonna work. <15> %sorted <15> where are sorted() complete docs? <15> and how can I use pyn to find it out? <16> hey, how can i parse back a email.MIMEMultipart.MIMEMultipart instance from a string (that is a flattened version of an original email.MIMEMultipart.MIMEMultipart instance) <16> ? <17> I need to a website, which needs cookie support, is that possible with urlgrabber, or do I need pycURL ? <18> milosn: No. <17> +connect ^^ <19> Wondering if could ask what might be causing supybot tonot connect to chat.freenode.net? ;) <20> hi <20> how can i check that two lists intersecting? <21> convert them to sets <18> set(a) ^ set(b) <20> thanks <22> http://www.google.com/search?q=python+two+lists+intersect <21> The ^ is the difference rather than intersection <18> no, - is difference. <18> ah sorry, I meant & <21> >>> set([1,2,3]) ^ set([2,3,4]), set([1,2,3]) & set([2,3,4]) <21> (set([1, 4]), set([2, 3])) <21> Symmetrical difference then <18> Right, symmetric. <23> Hi all <23> Ciao a tutti, c' qualche Italiano? <9> un bottiglia di vino bianco, per favore <15> sorted(...) <15> sorted(iterable, cmp=None, key=None, reverse=False) <15> what is cmp and key? <23> we pythonologist :) <21> see the list.sort docs, yango <21> they are here -- http://docs.python.org/lib/typesseq-mutable.html <23> pythonologist, ci sei? <21> cmp is mostly obsolete, when sorting through any other order than the default or reverse, you should use e.g. key = lambda x: get sort key for item x <15> how do I do it if I want to sort an object list by some of its attributes? <15> the equivalent of this pseudocode: sorted(object_list,key=object.attribute) <15> lambda x: x.attr <15> :) <24> Yango: there's actually a key= argument in list.sort... though I'm unsure if it'll work on attributes, it might just work on array-like objects. you could write your own cmp function and p*** it to the sort function though <5> Yango and Crast, key is a function argument. lambda p: p.foobar <24> AKX: aha <25> Yango operator.attrgetter('name')? <21> Just don't use cmp functions anymore. <25> Yango, or operator.itemgetter(1) if you want the 2nd item from a sequence of sequences <15> robrien, lambda and key work fine <15> hmmm, is there a way to mimic sql's sort behavior with sorted? <15> select * from table order by column_A, column_B <26> Yango: Which SQL behaviour? <15> order by <15> sorted(sorted(list)) <26> yango: sorted(key=lambda o: (o.col_a, o_col_b)) <26> Yango: tuple just happen to have the right sort order for your sorting requirements ;) <27> i say u use def <27> its simpler <28> sort has several optional keyword options, depending on what you want it may be possible. <28> wow, I'am lagged. <26> sysfault: yes you are ;) <28> --- Ping reply from yacc : 0.83 second(s) <16> if i have a Message part that was parsed in from a mime email is there anyway to say give me the "text" payload (decoded from base64 if it was encoded that way) ? <21> yacc: What gets more tricky is mimicing ORDER BY cola ASC, colb DESC, colc ASC :) <15> yacc, but that won't let me do order by col_a ASC, col_b DESC <15> will it? <21> rockyburt: you have to use .walk() to walk over the messages, find the text/plain type and call get_payload(decode=True) <26> Erwin: Yes it's more tricky. <21> rockyburt: OR if there is no text/plain payload, ***ume the body is the message
Return to
#python or Go to some related
logs:
#perl #mysql Segmentation Fault in , waiting for debugger modernbill
linux nzb grabber #gentoo ddd crti.s #web #debian yassine satori #linux
|
|