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

<kbrooks> one thread you can use a var for a flag
<Yhg1s> there is no stop method, and no way to stop a thread other than to ask it nicely to stop.
<sanmarcos> kbrooks: no I dont use multiple thread, just one thread I like to start and stop
<Yhg1s> sanmarcos: that would be a second thread, then. The first thread is the one you have even without threading ;)
<sanmarcos> Yhg1s: ah yes
<jsm> i'm trying to right a regexp that matches the following : NY 39348 or NY 23432-3243.. what I have here isn't working... (r'[A-Z][A-Z]\s\s(\d{5}-\d{4})|(\d{5})')
<sanmarcos> hmm is there a way I could use threading module's Timer to create a loop every X seconds that doesnt block my main thread?
<Yhg1s> jsm: that regexp should work. Are you using 'match' instead of 'search'?
<Nurbs> not (\d{5}-\d{4\|\d{5}) ?
<Nurbs> +}
<Nurbs> :o)
<Yhg1s> that works, too, but the extra parentheses don't hurt.
<Yhg1s> oh, and you shouldn't escape the |
<Yhg1s> or it will lose its meaning.
<Yhg1s> jsm: note that the regexp is fairly picky, requiring exactly two spaces (or other whitespace characters) and such.
<Nurbs> I didn't escape it, uh. the \ was meant to be a }
<Nurbs> what I meant is: doesn't [A-Z][A-Z]\s\s(\d{5}-\d{4})|(\d{5}) match "NY 23432-3243" or "39348" (no "NY ")?
<cout> is it possible to get a callback when a def is evaluated?
<sanmarcos> kbrooks: yeah, I have a "code-block" The thing I am trying to do is, I have a loop in a function loopdo() that time.sleeps(seconds) and does something, forever. I want to have a loop that is startable/stopable and it doesnt block my main thread
<pixelfairy> whats a good easy free text editor for windows for python?
<sanmarcos> pixelfairy: vim?
<ribrdb> is there a way to do parallel list comprehensions? ie [ [ i.a for i in stuff], [ i.b for i in stuff], [ i.c for i in stuff ] ]
<pixelfairy> easy
<cout> pixelfairy: vim and emacs both run on windows.
<pixelfairy> this is for people who have never programmed
<sanmarcos> pixelfairy: vim has some really nice python scripts
<pixelfairy> i do like vim myself though
<cout> vim has an "easy mode"
<sanmarcos> pixelfairy: then use the Pyhton IDE that comes with the win32 python extension
<sanmarcos> yeah, gvim for windows has an easy mode shortcut on the desktop
<sanmarcos> no modal editing
<pixelfairy> does gvim have this?
<Yhg1s> Nurbs: no, the | is bounded by the ()'s around the two number-alternatives.
<Yhg1s> cout: what kind of 'callback' would you want?
<pixelfairy> sanmarcos: win32 python extention? is that at python.org?
<cout> yhg1s: dunno, depends on what python is capable of
<Yhg1s> cout: it can do anything. the question is what you want to achieve.
<sanmarcos> pixelfairy: no somewhere else
<Yhg1s> cout: if you want a callback right before the def is evaluated, use 'callback(); def ...'. If you want it right after, use 'def ...: ...; callback()'
<exonic> cout, vim has an "easy mode" care to tell me how to enter it? (I want my employees to use vim)
<Yhg1s> ribrdb: what do you want the result to be? A flat list? Three sublists? The three parts intermeshed?
<cout> exonic: if you install vim on win32, you get a "vim easy" icon on your desktop
<pixelfairy> oh, so its a windows thing
<pixelfairy> the easy mode
<sanmarcos> no, you can use Cream for linux
<ribrdb> Yhg1s: I want three sublists, but I don't want to loop through "stuff" three times
<sanmarcos> see #vim anyways pixelfairy
<cout> exonic: if I do :help easy in vim, it tells me to start vim with -y
<exonic> cout, I was just looking that up :), didn't know if it was actually called "easy mode"
<cout> yhg1s: you're implying calling the callback explicitly? I was hoping there was something implicit.
<pixelfairy> ill try that when i get to a windows box
<pixelfairy> thanks
<Nurbs> Yhg1s: I see. I have to admit that I don't know python regexps, but that's not the case with extended regexps on the shell, mhm
<Yhg1s> cout: explicit is better than implicit. But perhaps what you want to *do* is more easily achieved another way.
<cout> yhg1s: what I'm trying to do is learn python better. I don't have a particular goal in mind.
<Yhg1s> ribrdb: L = zip(*[ (i.a, i.b, i.c) for i in stuff ])
<Yhg1s> cout: ok, well, in that case, nope, 'def' creates a function and that's it.
<Blue89> I have a stupid question: why does every program I run (including simplebot.py I got off the net) tell me "bad magic number in pyc file"?
<cout> yhg1s: are you familiar with the python source code?
<adoniz> I want to browse the web with graphical browser from my WindowsXP pc to my fedora2 dedicated server that I dont have physical access
<Yhg1s> Blue89: it sounds like you're trying to run a .pyc file, rather than a .py file, with a Python version different than the one that compiled it.
<Yhg1s> cout: yes.
<cout> yhg1s: where do I find the source code for 'def'?
<Blue89> ah, I thought py == pyc, I saved with the wrong name *smacks own forehead*
<Yhg1s> cout: well, you'd start by finding what bytecodes it compiles into, which will be (among other things) MAKE_FUNCTION. Then you'll look in Python/ceval.c, which is the main bytecode evaluator loop, and you'll see it calls PyFunction_New()
<cout> yhg1s: ah, I was in the right place, just looking for the wrong thing
<Yhg1s> cout: that's just the building of the function object, though, not the compilation phase of the code that is part of the function. That part happens far sooner.
<cout> yhg1s: right
<cjfs> Blue89: heh
<Yhg1s> adoniz: I suggest VNC, then. Nothing related to Python.
<s0undt3ch> hello ppl
<cout> yhg1s: so the parser knows whether it's looking at a function or a closure?
<s0undt3ch> What's the python equivalent to sed?
<Yhg1s> cout: there is no difference.
<cout> yhg1s: then why MAKE_FUNCTION vs MAKE_CLOSURE?
<Yhg1s> s0undt3ch: there is no direct equivalent, because sed does a lot of things. String methods and the 're' module can do most things sed does.
<s0undt3ch> i need someting to be replaced
<Yhg1s> cout: 'def' compiles into one of those two (or MAKE_GENERATOR, IIRC) depending on the code in the function
<pixelfairy> maybe adoniz wants webmin...
<Yhg1s> cout: a closure is a function with references to variables defined in an outer scope.
<exonic> s0undt3ch, "whatever".replace("what", "who")
<cout> yhg1s: ok
<Yhg1s> the parser doesn't care, though ;)
<cout> yhg1s: when does def compile into MAKE_GENERATOR?
<Blue89> that makes much more sense now :) but on my pocket pc device, it won't let me edit or delete .py files. wierd
<Blue89> I thought maybe py is what you call it when it's finished so nobody messes it up
<cout> yhg1s: the parser just creates an AST?
<s0undt3ch> Yhg1s and exonic: I've tried -> http://python.pastebin.com/549008 but it gives me 'error: Bad file descriptor'
<pixelfairy> Yhg1s: so a closure in c would just be a function with a static variable?
<cout> pixelfairy: there are no closures in (standard) c
<pixelfairy> it looks like the functional equivalent from the wikipida articles first paragraph
<pixelfairy> <-- confused
<Yhg1s> pixelfairy: no, I think you're thinking of argument defaults. they act like 'static' in C (somewhat)
<pixelfairy> static variables are maintained between calls to that function
<Yhg1s> s0undt3ch: you can't open a file for both reading and writing.
<pixelfairy> so you can like count how many times that functions been called or something
<Yhg1s> s0undt3ch: 'rw' actually opens it for reading, so the writing fails.
<Yhg1s> s0undt3ch: read in the file, close it, open it for writing, write out.
<s0undt3ch> k, thanks
<Yhg1s> pixelfairy: closures are nested functions that refer to variables in the function that creates them. C doesn't have nested functions, nor run-time function creation, so closures don't really make sense there.
<Yhg1s> cout: the parser in 2.4 and earlier creates a syntax tree that isn't abstract enough to call it an AST ;) 2.5 has an actual AST.
<Yhg1s> well, will have.
<Yhg1s> cout: and def compiles into MAKE_GENERATOR when 'yield' is used in the function.
<cout> yhg1s: what if it uses yield and refers to variables in the outer scope?
<Yhg1s> then it's a generator which also has cells.
<cout> cells?
<Yhg1s> the mechanism behind closures.
<exonic> Yhg1s, is there a document I can read about this ?
<Yhg1s> all three MAKE_* calls actually create normal-looking functions, just some of the internals differ.
<Yhg1s> exonic: not really. some bits of it are documented. The source is pretty darned readable though.
<exonic> Yhg1s, great
<jtrask> quick question, when extending, how does one construct a python bool? its not listed in the docs
<ShortWave> Hey all
<ShortWave> Quick question
<ShortWave> does python support re-entrant functions?
<Yhg1s> ShortWave: yes.
<ShortWave> Spiffy
<ShortWave> so I can recurse into a function if I have to then.
<Yhg1s> jtrask: one uses Py_True and Py_False
<Yhg1s> ShortWave: yes. and it's often done.
<ShortWave> Spiffy
<ShortWave> I like it.
<Yhg1s> jtrask: one has to INCREF and DECREF them as usual, though.
<ShortWave> Now to write an event queue for a GUI cl*** ;)
<ShortWave> thanks
<Yhg1s> jtrask: http://docs.python.org/api/boolObjects.html is where it's documented, btw.
<jtrask> Yhg1s: Py_INCREF(Py_True); return Py_True; ?
<cout> pixelfairy: if you want to see real closures in C, look at the ffcall library
<Yhg1s> yes.
<jtrask> ah thanks, i was looking in the 2.4.2 extending/embedding docs
<Yhg1s> the API is described in the api docs ;)
<Yhg1s> the extending/embedding docs are more of a tutorial.
<Yhg1s> and it unfortunately doesn't cover everything.
<garou> This function normally gets p***ed two args; I have to set the second to None, which seems to trigger said type arrow; Do you know why or how I could fix that?
<garou> def attach(*args): return _ode.dJoint_attach(*args)
<Yhg1s> garou: I must have missed a previous discussion. What 'type arrow' is triggered?
<Yhg1s> and that functoin is just a thin (very thin) wrapper around _ode.dJoint_attach(). It doesn't say anything about howmany arguments of what type it expects.
<adoniz> IS THIS CHANNEL FOR SNAKES???????????????????
<tic> adoniz, see topic.
<cout> I like seeing comments like /* What does this do? */ in the python source code
<jtrask> cout: makes you feel good about your language? ;)
<Yhg1s> oh, hmm. I guess I could fix that comment.
<Yhg1s> I think I remember what that does.
<cout> lol
<Yhg1s> it clears the stack to the right level after leaving a function.
<jtrask> wtf
<jtrask> Yhg1s: who are you?
<jtrask> Yhg1s: and why do you know everything?


Name:

Comments:

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






Return to #python
or
Go to some related logs:

#mysql
24online quakenet
#python
setting permissions for /dev/nvram
cciss genkernel
shrink ibdata
mysql tutorials Functions dev
#perl
cxipod
adaptec 1200a fedora



Home  |  disclaimer  |  contact  |  submit quotes