@# 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 15 16 17 18 19



Comments:

<0> mcmillen: ok.
<0> ty
<1> reversed() returns something iterator-like, which may or may not be what you want
<0> mcmillen: doing it in the interpreter .. lol
<0> >>> print reversed('test')
<0> <reversed object at 0x403e628c>
<0> >>>
<2> wow, mochikit looks sweet
<1> for l in reversed('foo'): print l ;)
<2> lol
<0> mcmillen: hmm.. i think 'foo'[::-1] is easier :S :P
<1> rohan: probably ;)
<3> [i for i in reversed('foo')]
<0> that will give a space after each character
<3> reversed is better if youre using generators
<0> ok.



<1> smirnov: actually, "".join([i for i in reversed('foo')])
<3> yeah, I didnt know reversed had spaces :-D
<1> rohan's original way was better ;)
<3> yep
<3> how do I add a \n to a string?
<0> :D
<3> s = s + r'\n' ?
<0> Smirnov: string + '\n' ?
<1> put \n in it ;)
<3> that wouldnt put \\n in it?
<0> yes, r'\n', Smirnov
<1> or do you want the literal characters, a slash followed by an n?
<3> no, the enter
<0> Smirnov: doesnt work.
<0> >>> string += r'\n'
<0> >>> string
<0> 'foo\\n'
<0> :S
<0> remove the r makes it
<0> >>> string += r'\n'
<0> >>> string
<0> 'foo\\n'
<0> err.. sorrt
<0> removing the r makes the string 'foo\n'
<4> rohan: use print string ...
<0> oh, that worked :D
<2> str += chr(13)
<0> this is sounding like perl .. TIMTOWTDI
<3> Does anyone know of a way to estimate square root really quickly?
<5> math.sqrt()?
<6> Smirnov: n**2
<1> smirnov: divide by 100
<6> oh, sorry
<6> Smirnov: n**(.5)
<0> Jerub: n** (1/2)
<5> that probably does the same thing as math.sqrt()
<5> :P
<6> rohan: it would be nice if that worked, but instead of working, you get 1
<5> estimate, you could just int(math.sqrt())
<4> rohan: actually, 1/2 is 0 ... may cause problems :)
<0> oh .. yes :S
<1> koollman: from __future__ import division
<5> n**(1.0/2.0)
<1> (a must in .pystartup if you want to use python as a reasonable calculator)
<5> score!
<5> :P
<1> while result > n*n: result -= 0.01
<0> what is __future__ ?
<6> rohan: a special meta-module
<2> Smirnov newton will converge fairly quickly
<2> for an approximiation
<6> rohan: it is how you invoke magic features that will be in future pythons, but aren't standard in the current python.
<5> is there a way to get the hex byte of a value, similar to the way the md5 and sha modules return?
<0> ok.
<5> in digest() ?
<2> hex(ord('l'))
<2> reikon oh, .hexdigest()
<6> foo.encode('hex')
<0> so, like, stuff in __future__ will be in python 2.4.3 or something ?
<2> Smirnov http://en.wikipedia.org/wiki/Square_root
<6> rohan: no, python2.5 or even further into the future.



<0> ok. python 2.4.x are bugfix releases ?
<6> rohan: for instance, in python2.2, in order to use 'yield' (which was made standard in 2.3) you needed to use 'from __future__ import generators'
<5> well i wanted it escaped as well :P
<6> rohan: yep.
<1> it'll be in python sqrt(6.25)
<5> i guess i could use ord... not much for it though
<0> Jerub: ok. never knew about __future__ :D
<6> rohan: it's like the complete reverse of the deprecation process.
<5> python shall create a paradox with this! we're all going to perish!!
<0> what does the division function do ?
<0> >>> help('division')
<0> no Python documentation found for 'division'
<2> rohan changes int style division to float
<2> 2/3 = 0, after inmport, 2/3 = 0.66666..7
<0> oh, ok.
<5> you could just do 2.0/3.0 :P
<0> wow, thats really useful :D
<1> parks: yes
<6> help('__future__.division')
<0> oh, ok
<2> mcmillen yes what?
<5> parks, i think he meant rohan
<1> Jerub: that just gives me "__future__.division = cl*** instance(object)
<1> | instance(cl***[, dict])
<1> |
<1> | Create an instance without calling its __init__() method.
<1> | The cl*** must be a cl***ic cl***.
<1> | If present, dict must be a dictionary or None."
<0> same here
<1> indeed, i did
<0> maybe a wrong docstring or something ?
<1> too magic for docstrings ;)
<0> :D
<6> uh, that works for me.
<6> c'est la vie
<0> Jerub: which platform ? what version ? python 2.4.2 ?
<6> python2.4.2, after running 'from __future__ import division'
<6> oh hey, but the help is worthless
<6> sorry :)
<2> Jerub can you remove BloodyShades ban
<2> ta
<7> hmm. "return True" fails. that's a new one.
<7> NameError: True
<6> python 2.1 ?
<7> i must be doing something astoundingly stupid.
<7> Jerub: Jython, yes, python 2.1
<6> muhoo: doesn't exist
<7> oh, ok.
<6> True, False = 1==1,1==0
<7> thanks.
<6> muhoo: in python2.2 True and False are added, and the basic type 'bool', which is a subcl*** of int.
<7> good to know, thanks
<8> True==1
<9> I have an interesting question. I am experimenting on something and feel I hit the wall. I have a 'feedback = raw_input('enter db name now')' and I wish to turn the result of the variable feedback into an actual name... e.g. If someone entered 'things', I then wish to create a new dictionary with the name 'things'... Maybe I am being slow but how would one do this?
<9> wow. I bet this is easy once you know it but I am stumped :(
<6> d[name] = 1
<6> oh, sorry, new dictionary named 'thing'
<6> d[name] = {}
<10> is python dying?
<6> vbgunz: dont' define it as a namespace name, just create a dict to put the names in.
<6> bomber098: dying? hell no.
<9> Jerub: sound right, let me trying
<9> sometimes I sound as foreign as they come :)
<9> OMG. Komodo really does **** hard core... I thank god this is a trial...
<6> vbgunz: vim is the only editor I'll use
<6> bomber098: what makes you ask?
<9> Jerub: It's kind of difficult for me to learn an editor like vim while trying to learn a programming language like Python. When things go wrong I might go crazy... I prefer SciTE which is very simple *but* sheesh, it's support for Python I've found to be quite limited...
<11> bomber098 : of course not, this is probably not the appropriate place to ask though unless you are looking for no as an answer
<9> The latest gedit for Dapper (Ubuntu) looks very promising. It has an internal file browser and better Python integration (still does not support raw_input)...
<11> I'm a vi fan myself, but from what I understand emacs is pretty decent for python (if you like emacs)
<10> y hate emacs
<9> At the moment, am only experimenting with Komodo but find it ridiculously unstable on my Ubuntu Breezy 5.10 system. Everything else runs just fine. Komodo... BAD...
<11> personal prefrence, I don't have anything specific against it, just don't like using it


Name:

Comments:

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






Return to #python
or
Go to some related logs:

gnome install mouse cursor
gentoo totem firefox-bin
frostwire troubles connecting ubuntu
Table for maximume tune
gentoo nl_NL.UTF-8
#mysql
emerge nasm + ubuntu
suse atieventsd conf
#bash
#web



Home  |  disclaimer  |  contact  |  submit quotes