@# 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



Comments:

<0> urllib i tried
<0> i tried with urlopen with the dictionary attrib, "data" but i failed
<0> i will not say urllib failed .. i was wondering is there any easy solution ..
<1> kryptoz: ClientForm.
<0> `anthony, i will try ClientForm :)
<0> yup :)
<0> http://wwwsearch.sourceforge.net/ClientForm/ <- i was scratching on it ;)
<0> let me read that complete .. i was wondering if its possible with urllib2 itself
<1> sure. it's just not as easy.
<0> `anthony, can u help me ?
<1> kryptoz: "will I write your code?" no.
<0> no no
<0> :p
<2> kryptoz: just read the relevant docs.
<1> kryptoz: This is not a complicated problem. Read the docs, and experiment.
<0> okay :)



<0> let me read more then
<1> You will learn far more that way.
<0> yup yup :p
<0> i was looking for a immediate solution ;)
<0> anyway never mind .. my aim is to learn python ..
<3> Is there any bittorrent-module?
<0> guys another doubt .. when i want to open a web page i used to use urllib.urlopen(url).read()
<0> now i some samples i am seeing "request" first then "open" then "read"
<0> whats the difference ?
<4> Hey, I want to use python to generate messages in realtime to be sent via TCP to the "netreceive" object in pd (Pure Data). Is there a good platform-independent way to obtain fairly high-accuracy timing in python?
<5> PWizard: this will sound strange, but look at pygame :)
<6> time.sleep is about as accurate as the platform/OS can make it.
<5> it has timing functionality that maps to high-resolution timers under various platforms
<6> don't forget to adjust your timer every time you set it, though.
<5> (e.g. QueryPerformanceCounter in win32)
<4> psykotic: not too strange -- it's a common requirement of most games. :)
<6> you may want to look at Shtoom as well, it does VoIP in Python, which requires fairly accurate timers.
<6> (it uses the Twitsed framework to do most of the actual work, though.)
<4> I've never fooled around with the twisted framework...
<6> well, it's a good platform-independant way of doing sockets.
<4> psykotic, Yhg1s: time.sleep() might not be optimal because the processing that occurs between sleeps might cause the timer to drift -- is there some way to obtain a time delta, like timeGetTime() in windows, or gettime() in POSIX?
<6> PWizard: hence my comment about adjusting your timer.
<6> PWizard: like time.sleep(), time.time() implemented fairly accurately.
<4> sec
<6> (it returns floats; if those aren't accurate enough, you do need something else.)
<4> if floats aren't accurate enough, I shouldn't be using an interpreted language. :D
<6> but, frankly, there is very little hardware that is more accurate in timing than a float can express.
<4> the python docs guarantee at most 1 second accuracy, but it depends on the platform
<4> since I'm usin just linux and windows, I'm not worried
<6> I believe the comment about Mac times being forced to whole seconds is outdated, anyhow.
<6> I doubt it's true for MacOS X, just for MacOS 9.
<4> Yhg1s: it doesn't really mention Macs specifically, now
<4> at least not the IDLE built-in help
<6> heh, 'the docs' aren't the built-in 'help', they're docs.python.org/lib/module-time.html
<4> :)
<4> wow.. with no real processing, the timer has a drift of about 1 ms, except for the first 10 or so measurements, where it drifts about 10 ms
<4> but it settles down nicely
<7> hello... i have python installed in ubuntu, however i can only access it through my terminal, and through the terminal i cant seem to save/run my apps... can someone please advise me on what to do
<8> PWizard: threading.Timer?
<7> its vers 2.4.2
<9> what do you mean "save" your apps, exactly?
<7> i type out a small 'example' app in python... then i cant run it there... do i use gedit to make the app?
<7> im new to the programming thing
<8> AdventChild: Try "python myapp.py"
<7> i did
<9> i think he's using the interactive interpreter.
<10> I usually make a small batch file to wrap it (on win32) so that I can skip typing the full thing
<9> AdventChild: Use some form of text editor to save it to disk as a .py file.
<7> im using the terminal window in linux
<8> AdventChild: Write your program in a file and save it with a .py extension, then execute the file with Python.
<10> then an .sh file :=
<7> i cant execute the files in python... thats the problem
<8> AdventChild: Yes you can. Type "python myfile.py" at the terminal.
<10> did you put a constructor in your code?
<7> i did lol... it wont work
<8> AdventChild: How didn't it work?
<7> ceran, could not open file **
<7> !ops
<8> AdventChild: uh, did you cd to the directory where your file is?
<7> yes
<11> how can I refer to a string in raw format? like, I have a string foo, which is "blah\blah", but I want to refer to it as if it was r"blah\blah"...



<8> AdventChild: Can you see your file if you type "ls"
<12> The new absolute import stuff in Python 2.5: won't this break all my packages? I have files in a package which have a __main__ section, so they can be run alone for testing; if I do that, will all the imports break because they'll be absolute?
<7> ok... its working now... sorry and ty
<7> idk why, but it is
<4> ceran: time.time()
<8> PWizard: that's not a timer. that just returns the system time.
<10> aquarius_work: old news, but usually if you want a module to be runnable as a script you add the __name__ = "__main__" trick to it instead of a __main__ definition
<12> Brandano: sorry, yes, that's what I do do (bad explanation on my part).
<4> ceran: I know. check this out: http://deadbeefbabe.org/paste/174
<4> ceran: the parentheses weirdness is an artifact of me editing in the python shell. :-/
<10> I don't see how that would break your modules. But then again I don't know what this new absolute import stuff is, I have only used PY until 2.4 so far
<4> and the tab weirdness
<8> PWizard: yeah, the indentation's all messed up. Is all that code supposed to be inside ttest()?
<4> yeah
<8> PWizard: edit it idle ;)
<8> *in
<10> or scite
<8> PWizard: um, why do you have a while 1: ?
<10> How can I make a copy of a custom cl*** instance?
<4> ceran: ok, check it now
<6> Brandano: if it's your own cl***, write a method on the cl*** to make a copy.
<4> ceran: because it's an infinite loop. I'm just taking a time delta
<6> aquarius_work: absolute import stuff in 2.5 will not break anything, since it doesn't change anything unless you use the future-import
<10> Yhg1s: that's the first thing I tried. However, it's really slow. I was hoping there was a quicker hardcoded method
<8> PWizard: What is this supposed to show?
<6> aquarius_work: whether Python 2.7 or 3.0 will break anything depends on what you're doing, exactly, but if you routinely run package-submodules as scripts, yes, that will change in 2.7. 'python -m' may be of help to you, though.
<6> Brandano: eh, how fast that is depends on how you write it. I'm not sure what you're looking for. Making copies of arbitrary objects isn't something that is often done in Python.
<4> ceran: er... the current system time and the time since the last sleep() call? It's a timer
<4> see, it's for timing stuff.
<4> gtg now, cl*** is over
<4> thanks for your hints, Yhg1s, etc
<8> PWizard: The td correctly shows up as 0.01 on my system.
<13> hi all
<13> is possible do something as this : ?
<13> a = 1; b = 'print a + 2'; exec(b) ?
<8> J_P: Yes.
<6> J_P: well, it would be easy to try, in the interactive interpreter.
<13> ceran: this above is better method ?
<14> J_P: yes, but it's completely insane and if you have any design that requires that ****, I'd love to know why.
<8> J_P: Although the correct syntax would be "exec b"
<13> Yes, I try taht, I would like if is the best form!
<6> J_P: best form for what?
<13> ceran: exec(b) works too
<13> Yhg1s: for do that
<6> J_P: well, in that particular example, the best solution would be 'a = 1; b= 3'
<6> J_P: no need for exec, or +.
<6> J_P: so perhaps you have other requirements that the code snippet doesn't explain. why do you need (or think you need) exec?
<13> ok
<8> J_P: Are you training for the obfuscated code contest?
<6> you may want "b = vars()['a'] + 2", for instnace. it's certainly better than using exec, if it does what you want. Or you may be happy with stuffing 'a' in a dict, rather than in a variable: 'd = {'a': 1}; d['b'] = d['a'] + 2'
<13> Yhg1s: becouse in my log I like put the mark using "inspect.getlineno(inspect.currentframe())", I have much logs and that sentence to do mark is large. So I thought do logmark = "inspect.getlineno(inspect.currentframe())" and when I will need use mark I only do exec(logmark).
<13> Yhg1s: see ?
<6> J_P: eh, don't do that. Do 'def logmark(): return inspect.getlineno(inspect.currentframe(1))', and use logmark() whenever you need it.
<6> note the argument to currentframe(); in spite of its name, it doesn't return the current frame, it returns the current frame's parent ;)
<13> Yhg1s: ahh ok, thanks! :-)
<13> humm
<8> J_P: writing "inspect.getlineno(inspect.currentframe())" to a file won't allow you to get the currentframe later...
<6> ceran: that's what the 'exec' was for.
<8> Yhg1s: Unless you manage to magically serialize frame objects, that code is only going to return the frame executing that code. not the frame in which that code was logged.
<6> ceran: of course, it will execute at the point of the 'exec'.
<6> not at the point of 'logmark = "..."'
<6> that's the case for either solution (and in fact the only possible way it could work)
<15> for item in os.listdir(dirname):........... how do find if item is a directory ?
<6> vimman: os.path.isdir()
<16> os.path.isdir
<15> thanks Yhg1s sysfault
<6> vimman: you may also be interested in 'os.walk'
<8> Yhg1s: maybe I'm misunderstanding what he's trying to do, but it seems similar to storing "print time.time()" to a file so you can retrieve a past time later on...
<6> ceran: well, that makes no sense to me, so I didn't ***ume that. I figured he just didn't want to sprinkle inspect.getlineno(inspect.currentframe()) all over his code, and preferred a simple functioncall, but didn't know about getting the right frame then.
<6> if what you say is true, it can't be done, anyway ;)
<17> bye
<13> Yhg1s: 'def logmark(): return inspect.getlineno(inspect.currentframe(1))' works fine! Thank you! ;-) That (1) is magic heheeh
<8> Yhg1s: I know, it didn't make sense to me either. But it seemed like a real roundabout why of making a function call.
<18> dict.items() returns the items in abitrary order. i'm reading lines of a file, split them and put the parts in a dict. lateron, i would like to write the dictionary back to a file, but with the same order as i have read them. is there a way to have the items returned in the same order as they were inserted?


Name:

Comments:

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






Return to #python
or
Go to some related logs:

atiold suse
ndiswrapper wpnt511
#perl
xubuntu ma401
#linux
linux2fs
#kde
dapper prism54
#python
casiopiea wifi



Home  |  disclaimer  |  contact  |  submit quotes