@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14



Comments:

<0> for i in len(list1):
<0> list1[i], list2[i]
<0> is this what u want?
<1> for a, b in zip(l1, l2): ...
<0> re.match('\w{3}','abcdefg').group(0)
<0> it will match the first 3 characters
<0> what if I wanna match the last 3?
<0> 'efg', rather than 'abc'
<2> hi. I'm reading turbogear's code and trying to use it, but where threading_local() comes from? There isn't such a method in my 2.4 python installation. Or is that identical to threading.local() ?
<2> or is probably tg specific?
<2> ummm now that I mentiond I think I should download it and grep
<0> ?rex
<0> ?list
<3> kw = str(kw.contents[0]).ltrim().rtrim().trim()
<3> why doesn't ltrim work
<4> pally: re.match('\w*(\w{3})', 'abcdefg').groups()



<0> qabex: cool, it's tricky
<4> brian: trim is VB (I think) -- try strip, lstrip, rstrip
<3> oh right
<0> you use a greedy search of words, force \w{3} to match the end part
<5> I officially hate XML
<6> :)
<0> what's the official reason?
<5> I've built a cl*** that uses a DOM to build an XML message out of a dict. The problem is that I can find no easy way (gotta love the documentation) to take that xml document, and stick it in another xml document
<7> now that's the sort of user I could do with more of... finds a cosmetic problem - but a significant one - comes over and reports it, and thanks me when I fix it :-)
<5> nice Leeds, I'd like to have users like that
<5> it seems so simple
<7> babbitt: are you trying to do this with the DOM representation of an XML document, or the textual form?
<5> I don't really care. From reading the W3C specs (which are actaully fairly readable as far as W3C spec docs go) it looks like I need a DocumentFragment.
<5> but if I just do a toxml() and then use string ops to insert it into the other document's string form, I end up with two <?xml version> headers
<7> can't you just append your documentnode - or whatever the top of the tree you want to append is - to a node in the parent document?
<5> that generates an error in DOM
<8> why should that be an error? i do that all the time.
<5> a document can't be appended to another document
<8> cant you grab the document's root node as a Node and not a Document?
<5> If I'm wrong, please please please show me how to do it? I've got to communicate with quickbooks using this godawful XML interface and its driving me nuts
<5> hmm...that's a great idea, thanks ironfroggy...I'll give it a shot
<9> babbitt: DOM has an importNode method
<10> if I am using the interactive interpreter what is the best way to view methods in a cl*** and the params of those methods
<10> say from some arbitrary module i just imported
<5> dir(ModuleName)
<8> help(module)
<10> thank you, help is exactly what i was looking for
<5> thank you teratorn, that's what I needed
<5> I was reading the DOM 1 specs, importNode was in DOM 2
<9> maybe best to read the docs for your actual DOM-implementing software
<9> e.g. minidom
<5> I read minidom, it referred me to the DOM 1 w3c spec
<5> and the pydoc for the xml stuff seems useless
<9> huh well it has API docs...
<5> no descriptions, just prototypes
<9> actually I remember now
<9> minidom's importNode is undocoumented
<9> i found it reading minidom code
<5> lol...its part of DOM level 2, and is obviously in the code
<5> is there a wikified version of the pydocs?
<5> that'd be a good idea
<7> babbitt: I did say to append the documentnode, not the document
<5> leeds: you were right, but I needed to extract it from the other document
<7> using the fiendishly-hidden documentElement property of the document object? :-)
<5> actually I was using childelements[0]
<5> but documentelement is cleaner, I'll change my code
<1> I have several modules using logging module, and a main app using them... is there an easy way to log the module the message is coming from, or do I have to do it explicitly on the string ?
<11> werneck: fooLog = logging.getLogger("foo")
<1> ok...
<12> I would like to record audio using python on my Macintosh. How should I do this?
<13> werneck: you can use the variables listed in http://docs.python.org/lib/node357.html
<14> I'm a python beginner and some python concepts are unclear to me. I read that the arguments that each function takes is actaully a dictionary. But they are not enclosed in [], which means it's implictly a dictionary. Does that mean that every function takes exactly one or zero arguments? The optional argument is the dictionary
<14> btw, I'm using Dive into python to learn python
<9> ram_einstein: nah you're very confused
<8> no, that is incorrect.
<7> heh... I've been using kid for new stuff for a few weeks - just went back to make a small change to something from before, and it's so much harder
<14> teratorn and ironfroggy: Okay
<14> uh... be back in a bit
<14> gotta grab a sandwitch
<15> I was recommended to "http://www.hetland.org/python/instant-hacking.php"; as a tutorial for a *beginner* attempting to work with Python. Could anyone back this recommendation up or refer me to something that would probably help out a beginner even more?
<8> have you already read some of it to rate how you grok it?



<15> I read several paragraphs of the beginning of the tutorial, scanned through the rest to see just how complex it is to me, then came here to know if it really is useful before I spend my time closely examining it to find out it's useless.
<15> And before that, another tutorial brought me to Python in the first place. I have always been told that VB is the best place to start for a Windows user just-starting out with programming.
<15> Until now atleast
<15> The author of the tutorial I read that directed me to Python, stressed the importance of learning Python first so badly that I had to check it out ;)
<16> insanity is contagious
<17> Heretician: that tutorial looks like a decent intro to the very basics of programming. and I'd agree that learning Python is a damn good first language to learn, light-years better than any form of Basic,
<15> "Decent" as in you know of better? :)
<9> Heretician: I really hate completely abstract programming exercises
<8> Heretician: expirience will teach you more than any tutorial, so get through the tut and stop wasting your time.
<9> I mean how the hell are you supposed to "get" OOP by cooking spam in an oven
<8> teratorn: but honestly, what concrete exercises could be given?
<9> ?
<9> anything
<8> if you have to put too much effort into it, then it better be something you'll find interesting.
<16> starting out w/OOP is probably counterproductive. you need some procedural to write methods.
<18> Heretician: I think this is a good intro. http://www.ibiblio.org/obp/thinkCSpy/
<16> Heretician, whats the URL to the tutorial?
<9> ne1uno: eh, i'm not so sure about that
<9> ne1uno: for the longest time I didn't understand why you would bother writing things as objects with methods
<15> http://www.hetland.org/python/instant-hacking.php
<9> ne1uno: because I had a lot of procedural-only experience
<9> ne1uno: It seemed a waste of time to do anything else
<16> there is no way to really know, is there?
<15> If your talking about the one that recommended me to Python, don't recall it, nor is it up ;/
<16> teratorn> hearing abouot OOP for the first time is not exactly the same as knowing it has just recently been invented either.
<9> ne1uno: I don't see your point...
<19> hi all - quick question - is there a function I can use to get and store the hash of a string?? There is a hash built-in function but help(hash) says that it is to hash objects - i was wondering if it is the most effecient way to also hash a string (the hash needs to be stored on a DB)
<20> cain297: a string is an object. so hash(s) is the way to hash it.
<21> G'day all.
<20> hello Tennessee
<19> tirkal: I realise that - :). I just wanted to make sure there is no specialised function for strings specifically
<20> cain297: there actually is, and hash() uses it.
<20> cain297: basically, hashable objects have a special method called __hash__
<20> when you call hash(obj), you basically get back the return value of obj.__hash__
<21> Does anyone know if Google Chat is accessible through their API?
<19> tirkal: aah - gotcha - that makes sense now
<6> Tennessee: uh, google chat is just jabber.
<6> i.e. xmpp
<20> cain297: yes, the magic of protocols: calling the same function on different objects results in different method calls on the object - specific to the object.
<21> Jerub: Well, should be possible then. I just hadn't thought about it very hard, and asked before I googled ... :)
<19> tirkal: yea...
<19> tirkal: so do u know the no. of bits of hash produced by the string hash function
<8> that is implementation defined.
<8> i think.
<22> what's a good trick for multiplying all the elements of a sequence together?
<22> also, Hey guy's how's it goin?
<20> cain297: it returns an integer, with large variation in length.
<6> Nedlinpopo: reduce(operator.mul, mylist)
<22> ah yes, reduce
<22> isnt' that the same as curry in LISP?
<18> currying is something else.
<18> I don't know Lisp, but it might be called "fold"
<20> Nedlinpopo: it's like rfold
<18> there you go. :)
<20> gzl: yup, rfold and lfold :)
<22> right, Fold!
<19> tirkal: that's what I was noticing - i figured since some algorithms produce a set no. of bits, mayabe this hash function did the same too:)
<20> cain297: no, not the Python hash function. notice the difference between hash(1) and hash('s')
<22> operator.mul isn't a valid function refrence
<22> is it hding somewhere else?
<20> Nedlinpopo: import operator
<22> do i really have to?
<20> cain297: there's a practical upper limit, though - the maximum number of bits per your sys.maxint
<20> Nedlinpopo: yes, if you want to use operator attributes.
<22> mkay
<22> are those what the builtins call?
<20> reduce calls operator.mul in Jerub's solution.
<6> in python2.5 there should be a 'product' builtin
<22> right, but i mean does '*' call operator.mul? or is that optimized away in CPython?
<8> operator.mul is just a shortcut to let you call the multiplication operator as a function, without knowing the type. for example, if you knew for a fact they were all int objects, you might do reduce(int.__mul__, mylist) but operator.mul will perform the proper operation for the given object. its just a helper function.
<22> oh that's right, * calls __mul__()
<22> wow, it's been too long.
<6> operator.mul == lambda x,y:x*y
<6> but is faster.


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #python
or
Go to some related logs:

#python
ide=nodma grub
suse kinternet cumulative
Can't locate auto/POSIX
disable read-only freebsd
rapidsvn plink
cups ubuntu brother mfc-420cn
perl date manip is heavy
#web
shorten ubuntu shntool



Home  |  disclaimer  |  contact  |  submit quotes