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