Re: socket question

2006-09-13 Thread Jean-Paul Calderone
onnection has been lost If you expect a particular number of bytes, you need to call recv() multiple times and collect the returned strings until you have as many bytes as you wanted. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Unit balancing

2006-09-13 Thread Jean-Paul Calderone
point out his >error. > >Does Python (or SciPy or ..) offer this feature? > >Thanks for your help. > > > Abraham > You might be interested in Unum. http://home.tiscali.be/be052320/Unum.html Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: [Twisted-Python] twisted.web2 and blank values in POST

2006-09-13 Thread Jean-Paul Calderone
py line 91. Hi. You might want to post this to the twisted-web mailing list, instead. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: [Twisted-Python] twisted.web2 and blank values in POST

2006-09-13 Thread Jean-Paul Calderone
Ugg, wrong list obviously. Please disregard. Sorry. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why not event-driven packages in other than the main thread?

2006-09-14 Thread Jean-Paul Calderone
thread. Several projects make use of this feature extensively, so while I wouldn't recommend it, it should certainly work. Perhaps you did something wrong in setting it up, or perhaps you have found a bug. Can you post a minimal example to reproduce this to Twisted's bug tracker? Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: UDP packets to PC behind NAT

2006-09-15 Thread Jean-Paul Calderone
#x27;t work on any widespread configuration I am aware of. In general, most individual solutions are only effective on a portion of existing configurations. A robust solution must employ multiple techniques. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Priority based concurrent execution

2006-09-21 Thread Jean-Paul Calderone
ed as an application API to an implementation of something like what the poster is requesting, inasmuch as many people find them to be a useful way to split a task up into small pieces. However, aside from syntactic convenience, they don't really bring anything fundamentally different to the table. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: How to return an "not string' error in function?

2006-09-21 Thread Jean-Paul Calderone
ce(u"hello", types.UnicodeType) >True > >...or, if you don't want to qualify them with "types." each time, >you can use > > >>> from types import StringType, UnicodeType > >to bring them into the local namespace. >>> str is types.StringType True >>> unicode is types.UnicodeType True Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: threading, subprocesses and wait

2006-09-26 Thread Jean-Paul Calderone
nd, it performs no error handling at all, so if the SIGCHLD for thread 1's process is delivered to thread 2, it may cause the wait call to fail with an EINTR OSError. Whether this is actually possible or not depends on what signal handlers, if any, have been installed, as well as the unde

Re: preserving color ouput of a shell command via os.popen()

2006-09-26 Thread Jean-Paul Calderone
r it is likely that the output is being viewed by a human or a program. Since you are running ls with popen, ls decides it is a program, and elides the colors. Try os.popen("ls --color=yes"). Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Improving telnetlib

2006-10-04 Thread Jean-Paul Calderone
simple terminal emulator (to help you keep track of what vi has done to your virtual terminal). API docs for insults: http://twistedmatrix.com/documents/current/api/twisted.conch.insults.html And for the telnet implementation: http://twistedmatrix.com/documents/current/api/twisted.conch.telnet

Re: A Universe Set

2006-10-04 Thread Jean-Paul Calderone
2147483647 >>> c.next() -2147483648 >>> Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Inotify on netfilter socket

2006-11-17 Thread Jean-Paul Calderone
e iptables/netfilter >mailing lists? Why do you want to use inotify? Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: I/O Multiplexing and non blocking socket

2006-12-01 Thread Jean-Paul Calderone
On 1 Dec 2006 06:07:28 -0800, Salvatore Di Fazio <[EMAIL PROTECTED]> wrote: >Hi guys, >I'm looking for a tutorial to make a client with a i/o multiplexing and >non blocking socket. > >Anybody knows where is a tutorial? http://twistedmatrix.com/projects/core/documentatio

Re: client/server design and advice

2006-12-01 Thread Jean-Paul Calderone
ions are more lower level, this is >simply the first client/server application ive created and am doing so >in a language ive never used before ;) http://dsd.lbl.gov/gtg/projects/pyGridWare/ might be of some use. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: twisted problem with reactor.stop()

2006-12-03 Thread Jean-Paul Calderone
tion with twisted? >thanks in advance >Maxime Don't do this. You don't need separate threads for client and server code. There is only one reactor, and you can only run it in one thread. Use it for both your client and your server. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Why not just show the out-of-range index?

2006-12-03 Thread Jean-Paul Calderone
eter, then send a patch to the >maintainers (and hope they notice it in their inboxes), while the >maintainers themselves could probably "fix" the problem in two minutes >flat. No thanks! And I have some laundry that I would like you to do for me. Let me know when a convenien

Re: Monitoring number of smtp bytes sent through python e-mail socket

2006-12-04 Thread Jean-Paul Calderone
mation. You can find a simple example of using Twisted's SMTP client here: http://twistedmatrix.com/trac/browser/trunk/doc/mail/examples/smtpclient_tls.py Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Am I stupid or is 'assert' broken in Python 2.5??

2006-12-06 Thread Jean-Paul Calderone
On 6 Dec 2006 06:34:49 -0800, antred <[EMAIL PROTECTED]> wrote: >I've noticed something odd in Python 2.5, namely that the 2 argument >version of 'assert' is broken. Or at least it seems that way to me. > >Run the following code in your Python interpreter: > >myString = None > >assert( myString, 'T

Re: SSH File Transfer Protocol or SFTP

2006-12-11 Thread Jean-Paul Calderone
gt; Twisted Conch includes support for both SFTP servers and clients. http://twistedmatrix.com/trac/wiki/TwistedConch Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: py-ldap question

2006-12-12 Thread jean-marc pouchoulon
and this set option ? ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT,ldap.OPT_X_TLS_NEVER) HTH Laszlo Nagy a écrit : > By the way, I already tried the set_option function, but I still get the > same error. > > > import ldap > import local > > ldap.set_option(ldap.OPT_X_TLS_ALLOW,1) > ldap.set_op

Re: merits of Lisp vs Python

2006-12-17 Thread Jean-Paul Calderone
>> It's not surprising that no one uses this stuff for serious work. > >I have seen enough libraries that use doctest. Zope, Twisted and Paste >are some of the popular Python projects in that use it. Epydoc supports >it as well. Just as a factual correction, Twisted does not u

Re: Shed Skin - Does it break any Python assumptions?

2006-12-18 Thread Jean-Paul Calderone
: error: cannot convert ‘unsigned int ()(unsigned int)’ to ‘void ()(double)’ in assignment make: *** [foo] Error 1 [EMAIL PROTECTED]:~/Scratch/Source/shedskin-0.0.16$ So yes, it seems that what ShedSkin supports is pretty distant from what a seasoned Python developer might expect, aside from syntactic constructs. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Support of IPv6 extension headers

2006-12-20 Thread Jean-Paul Calderone
sendmsg to send the packet with the extension header. >Does python support the extension header processing? Python doesn't expose sendmsg. There are several third-party modules which do, though. Googling for "python sendmsg" turns up some useful links. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Why can't you use varargs and keyword arguments together?

2006-12-21 Thread Jean-Paul Calderone
You just need to turn things around: >>> def foo(a, b, c): ... return a, b, c ... >>> args = range(2) >>> foo(c=2, *args) (0, 1, 2) >>> Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: loose methods : Smalltalk asPython

2006-12-27 Thread Jean-Paul Calderone
has been modified, at least according to your argument. Do you often worry about it, though? And if not, has it ever come back to bite you? If so, perhaps more than just built-in classes should be restricted in this way? If not, why should built-ins have the restriction? Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: how can I modify an imported variable ?

2006-12-27 Thread Jean-Paul Calderone
the different functions and methods of your program so that they can inspect and mutate it. If you use globals, you will end with code which is harder to unit test and harder to re-use. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie question: any better way to write this code?

2006-12-27 Thread Jean-Paul Calderone
h more easily: >>> import numarray >>> buf = numarray.array('') >>> buf.tostring() '' >>> (buf ^ 123).tostring() '\x03\x03\x03\x03\x03\x03\x03\x03' >>> In any case, you can at lea

RE: Looking for python SIP/MGCP stacks

2007-01-02 Thread Jean-Paul Calderone
mProject Shtoom is LGPL. Sine borrows some code from it, so it is probably LGPL as well. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: search mail by date with imaplib

2007-01-06 Thread Jean-Paul Calderone
ap4 import Query >>> Query(after='01-Jan-2007') '(AFTER "01-Jan-2007")' >>> Since documentation was brought up, I'll point out Query's docs too, since that might help shed some further light on what's possible. http://twistedmatrix.com/documents/current/api/twisted.mail.imap4.html#twisted.mail.imap4.Query Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Some thougts on cartesian products

2006-01-22 Thread Jean-Paul Calderone
to this implementation: binary = lambda i,c = (lambda i,c: i and (c(i>>1, c) + str(i&1)) or ''): c(i,c) Although I won't claim it is the best solution. Fortunately for you, I guess, it looks like Python 2.5 will have either a bin() builtin or a '%b' format charac

Re: Backreferences in python ?

2006-01-23 Thread Jean-Paul Calderone
strToReplace = "for\(" + pattern + "\1\;" > >fNew.write( l.replace( strToFind, strToReplace) ) > >print l > >fNew.close() > str.replace() does not support regular expressions. Take a look at the re module. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter listener thread?

2006-01-26 Thread Jean-Paul Calderone
#x27;) internet.UDPServer( 12345, TkDisplayProtocol(Tk.Tk())).setServiceParent(application) Save to "udptk.tac" and run using "twistd -noy udotk.tac". Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Starting terminal applications from within python

2006-02-02 Thread Jean-Paul Calderone
r/bin/xterm", "-e", "/opt/itt/ncbr/bin/linux/bar") Each argumnent after the 2nd to spawnlp() is an argument to the program you are running. passing "-e /path" as a single argument is the same as trying to do this on the command line: xterm "-e /path" which I think you will find fails in the same way. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: my openGL API need threads!!! But how to ,ake it work???

2006-02-02 Thread Jean-Paul Calderone
n remotely transparent. Stop chasing a fantasy, or start doing ground-breaking research to advance the state of the art. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: classmethod and instance method

2006-02-02 Thread Jean-Paul Calderone
lassmethod >def meth(cls, self): >#do stuff > >but it didn't work. Any suggestions? Hint: decorators usually return functions. What does your decorator return? Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Another try at Python's selfishness

2006-02-03 Thread Jean-Paul Calderone
erstand what's going on? Python 2.4.2 (#2, Sep 30 2005, 21:19:01) [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def foo(): pas

Re: Another try at Python's selfishness

2006-02-03 Thread Jean-Paul Calderone
On Fri, 3 Feb 2006 15:27:51 -0500, Terry Reedy <[EMAIL PROTECTED]> wrote: > >"Magnus Lycka" <[EMAIL PROTECTED]> wrote in message >news:[EMAIL PROTECTED] >> [EMAIL PROTECTED] wrote: >> Today, Python has a syntactic shortcut. If 'a' is an >> instance of class 'A', a.f(x,y,z) is a shortcut for >> A.f(

Re: Replacing curses (Was: Re: Problem with curses and UTF-8)

2006-02-08 Thread Jean-Paul Calderone
t;- a way to hide and show the cursor >- a way to detect when the terminal is resized >- a way to query the terminal size You might be interested in Twisted Conch's insults package. I haven't followed this thread closely, so I'm not sure if it covers all your requirem

Re: Tracking down memory leaks?

2006-02-12 Thread Jean-Paul Calderone
garbage collection purposes. It's moot, since the garbage collector can collect cycles: Make a cycle: >>> a = [] >>> b = [] >>> a.append(b) >>> b.append(a) Get rid of all references to all objects participating in it: >>> del a, b Explicitly invoke the garbage collector in order to observe the number of objects it cleans up: >>> gc.collect() 2 Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: is socket thread safe?

2006-02-15 Thread Jean-Paul Calderone
gether and not use any polling loops. > >i.e. consumer goes to sleep while data buffer is empty, producer >produces and signals condition object, consumer wakes up and consumes. What makes you think process isn't implemented to notify a condition, and getdata isn't implemented to wait on one? :) Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: any ftpd written in python?

2006-02-16 Thread Jean-Paul Calderone
4096 Feb 16 14:15 c drwxr-xr-x 2 exarkun exarkun 4096 Feb 16 14:15 d 226 Transfer Complete. ftp> quit 221 Goodbye. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Safe Python Execution

2006-02-17 Thread Jean-Paul Calderone
c 'print ' + ''.join(map(chr, [ 95, 95, 98, 117, 105, 108, 116, 105, 110, 115, 95, 95])) """ You can come up with a long list of restrictions to impose, and maybe that will be good enough. But making it /perfect/ is a Herculean task, as is maintaining it as new Python releases are made, and auditing it every time you add a new piece of code to your system. Just keep that in mind if you decide to pursue this. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: question about scope

2006-02-17 Thread Jean-Paul Calderone
print dir # comes from "enclosing scope" - foo's scope Hope this helps, Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: commenting out blocks of code

2006-02-17 Thread Jean-Paul Calderone
On Sat, 18 Feb 2006 12:36:06 +1100, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > [snip] > >Commenting and uncommenting should be two different commands: the whole >point of nested comments is that it allows you to comment a block of text >which may already contain comments. Having one command do bo

Re: Multi-threaded SSL

2006-02-18 Thread Jean-Paul Calderone
dedicated Twisted mailing list you can use as a resource: <http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web>. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiplication optimization

2006-02-18 Thread Jean-Paul Calderone
CONVERT_TO_LONG(w, b); longprod = a * b; doubleprod = (double)a * (double)b; doubled_longprod = (double)longprod; I think the rest of the function is probably irrelevant, as far as your question goes. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

RE: Which is faster? (if not b in m) or (if m.count(b) > 0)

2006-02-19 Thread Jean-Paul Calderone
mething, the timeit module is your friend. Discussions about *why* you >get certain performance results are then useful. But this stuff is all still true :) Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: wanted: ftp server class

2006-03-06 Thread Jean-Paul Calderone
wto/producers.xhtml>). It might be beneficial to direct follow-up questions to the Twisted list (<http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python>), since more people familiar with this will be paying attention there. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Problem listing services with wmi

2005-05-16 Thread Jean-Sébastien Guay
= wmi.WMI () for s in c.Win32_Service (): if s.State == 'Stopped': print s.Caption, s.State gives me the same result as above. Could someone please point me in the right direction to find out what's wrong? Thanks in advance, J-S -- ___

Re: Problem listing services with wmi

2005-05-16 Thread Jean-Sébastien Guay
there any reason why whitespace between the method name and parameter list parentheses isn't good? Because the code I posted before was copy-pasted from Tim Golden's site (http://tgolden.sc.sabren.com/python/wmi.html) and the spaces were there. Thanks, J-S -- __

Re: Problem listing services with wmi

2005-05-17 Thread Jean-Sébastien Guay
very glad to address it. > > Not at all, this is a small project I'm using to try and learn Python... I'm currently on summer break before I start my Masters, so I have the luxury of keeping this on the back burner until I find a fix... Thanks for your help! J-S -- ___ Jean-Sébastien Guay [EMAIL PROTECTED] http://whitestar02.webhop.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem listing services with wmi

2005-05-17 Thread Jean-Sébastien Guay
have no problem with trying out other suggestions. Thanks a lot, just by your small scripts I've already learned a lot more about Python! J-S -- ___ Jean-Sébastien Guay [EMAIL PROTECTED] http://whitestar02.webhop.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem listing services with wmi

2005-05-18 Thread Jean-Sébastien Guay
sterday, with the same results. It would seem (from what I can understand) that c.ExecQuery() just makes a list of proxy objects, and that when you call Count on the set, it has to create them all for real and that's where it fails when reaching the "bad" service. Thanks again, loo

Re: Python on a public library computer

2005-05-18 Thread Jean-Sébastien Guay
exe? (yes, I have seen so-called "locked down" machines with a "program black list" that were that stupid) Worth a try! :-) And then you could rename ssh.exe to explorer.exe, perl.exe to java.exe or something funny like that... J-S -- _

Re: Standalone HTTP parser?

2007-05-31 Thread Jean-Paul Calderone
us I/O >using my own engine (multitask), so I need a HTTP package that won't >insist on doing the I/O for me. > Neither of Twisted's HTTP implementations insist on doing the I/O for you. All protocols in Twisted are independent of their transport. You can feed them data any way

Re: How to use TLS lite

2007-06-08 Thread Jean-Paul Calderone
tion.sendmail("[EMAIL PROTECTED]","[EMAIL PROTECTED]",msg) > File "/usr/lib/python2.5/smtplib.py", line 684, in sendmail >raise SMTPSenderRefused(code, resp, from_addr) >smtplib.SMTPSenderRefused: (530, '5.7.0 Must issue a STARTTLS command first >m75sm2193378wrm', '[EMAIL PROTECTED]') > >Where am I going wrong? > Notice that in response to the STARTTLS you sent, you received this response: 503 5.5.1 EHLO/HELO first m75sm2193378wrm The command was rejected and ignored and TLS was not initiated. You need to send the STARTTLS later. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Could someone show me a sample how to flush the socket sending buffer? Thanks a lot.

2007-06-08 Thread Jean-Paul Calderone
he second line is still >in the sending buffer, and not reach the server side. There is no buffer you can flush. Also, you forgot to check the return value of the send method. It is important. You might want to look at the sendall method. Or you might want to check out Twisted. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

RE: Hooking exceptions outside of call stack

2007-06-09 Thread Jean-Paul Calderone
t;The interactive session is different from running in the IDE (am using >ActiveState's Visual Python) which exits just after the `a[b]=1` without >calling hook. > >Am I missing something? Perhaps this is the wrong approach? I want Python to >check a specific set of locals first, before checking globals. For instance: > Yes. Python doesn't have restartable exceptions. Perhaps you would like to take a look at CL or Smalltalk? Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Threads, signals and sockets (on UNIX)

2007-06-11 Thread Jean-Paul Calderone
ther signals or threads. Interaction between the two is very complicated and, as you've noticed, varies across platforms. Twisted is solving the problem for you here by letting you do I/O without using threads, making signals *almost* simple. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: A gotcha: Python pain point?

2007-06-11 Thread Jean-Paul Calderone
ion into english will somehow help reveal how this behavior is consistent. For what it's worth, I agree that scoping in Python is not ideal and this is a good example of an area where that shortcoming causes surprises. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Embedding unit tests in source files?

2007-06-17 Thread Jean-Paul Calderone
iding. You might be able to find a way to avoid this import behavior if you get a little creative, but I doubt it's worth the effort or the trickery. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Conceptualizing Threading

2007-06-21 Thread Jean-Paul Calderone
ent it. You described how threads introduce a problem in your program -- that of generating a sequence of sequential identifiers -- but you didn't describe the problem that threads are solving in your program. Maybe you don't need them at all? What led you to threading in the first place? Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Conceptualizing Threading

2007-06-21 Thread Jean-Paul Calderone
ving in your program. Maybe you don't >> need them at all? What led you to threading in the first place? >> >> Jean-Paul > >Well, the problem I thought they would solve is ensuring everyone got >a sequential number. But I suppose they wouldn't solve that, since &

Re: Do eval() and exec not accept a function definition? (like 'def foo: pass) ?

2007-06-23 Thread Jean-Paul Calderone
ss) ? > >eval() is a function, and it only evaluates EXPRESSIONS, not code blocks. Actually, that's not exactly true: >>> x = compile('def foo():\n\tprint "hi"\n', '', 'exec') >>> l = {} >>> eval(x, l) >>> l['foo']() hi >>> Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Non-blocking keyboard read

2007-06-26 Thread Jean-Paul Calderone
e never tried >this, but it is my platform independent idea. select won't work on stdin on windows, and it won't work to read anything less than a line on posix either, unless you put the pty into unbuffered mode first (but then it will work). Twisted has a more abstract API for this kind

Re: PyKQueue

2007-06-27 Thread Jean-Paul Calderone
On Tue, 26 Jun 2007 21:48:46 -0700, Adam Atlas <[EMAIL PROTECTED]> wrote: >Does anyone have a copy of PyKQueue 2.0 around? The site it's supposed >to be on (http://python-hpio.net/trac/wiki/PyKQueue) is down. > >-- >http://mail.python.org/mailman/listinfo/python-list > http://twistedmatrix.com/tra

Re: IMAP library

2007-06-28 Thread Jean-Paul Calderone
ttachments and other MIME features, you can use the stdlib email package to parse the message into a structured form and then process it appropriately. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-29 Thread Jean-Paul Calderone
will be used. Such assumptions are called "preconditions", which are >an understood notion in software engineering and by me when I write >software. You realize that Python has exceptions, right? Have you ever encountered a traceback object? Is one of your preconditions that no one

Re: Python compilation ??

2007-07-02 Thread Jean-Paul Calderone
or the one with a #! at the top which gets respected, or the .py file on Windows which is associated with python.exe as its interpreter), but that it doesn't save the results of this compilation to a file to be used next time? Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Python IRC bot using Twisted

2007-07-03 Thread Jean-Paul Calderone
http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IReactorTime.html http://twistedmatrix.com/documents/current/api/twisted.internet.task.LoopingCall.html Hope this helps, Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Debugging "broken pipe" (in telnetlib)

2007-07-03 Thread Jean-Paul Calderone
e closed (for example, sending a message which the remote side decides is invalid and causing it to close the socket explicitly from its end). It's difficult to make any specific suggestions in that area without knowing exactly what your program does. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: what is wrong with that r"\"

2007-07-03 Thread Jean-Paul Calderone
g/ref/strings.html for more information. I wonder if the OP was asking how to spell the one-length string \? In that case, the answer is that it can't be done using raw strings, but "\\" does it. Backslash escapes aren't interpreted in raw strings, but you still can't end a raw string with a backslash. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Python IRC bot using Twisted

2007-07-03 Thread Jean-Paul Calderone
On Tue, 03 Jul 2007 13:44:34 -, ddtm <[EMAIL PROTECTED]> wrote: >On 3, 16:01, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > [snip] > >Thank you very much! It's a very useful information. One more >question: can I cancel the DelayedCall using its ID

Re: python 3.0 or 3000 ....is it worth waiting??? Newbie Question

2007-07-03 Thread Jean-Paul Calderone
9>), you'll be able to convert any code you write for Python 2.x into Python 3.x code easily. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Python IRC bot using Twisted

2007-07-03 Thread Jean-Paul Calderone
On Tue, 03 Jul 2007 15:51:30 -, ddtm <[EMAIL PROTECTED]> wrote: >On 3, 17:55, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: >> On Tue, 03 Jul 2007 13:44:34 -, ddtm <[EMAIL PROTECTED]> wrote: >> >On 3, 16:01, Jean-Paul Calderone <[EMAIL PROT

Re: Debugging "broken pipe" (in telnetlib)

2007-07-03 Thread Jean-Paul Calderone
On Tue, 03 Jul 2007 08:54:25 -0700, Samuel <[EMAIL PROTECTED]> wrote: >On Jul 3, 3:03 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: >> EPIPE results when writing to a socket for which writing has been shutdown. >> This most commonly occurs when the socket has

Re: SMTP server w/o using Twisted framework

2007-07-05 Thread Jean-Paul Calderone
X records are simple and it's not much work to pick the right host once you can do the MX lookups. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Expandable 2D Dictionaries?

2007-07-06 Thread Jean-Paul Calderone
ring), that python will dynamically add that key/value pair? This gets much easier if you change your structure around a bit: d = {} d["cat", "paw"] = "some string" Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: In search of python idiom for accessing arbitrary fields at run time

2007-07-08 Thread Jean-Paul Calderone
On Sun, 08 Jul 2007 18:21:41 -, mshiltonj <[EMAIL PROTECTED]> wrote: >I'm trying to find the preferred python idiom for access arbitrary >fields of objects at run time. > It's not an idiom, it's a built-in function: getattr. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Per thread data

2007-07-09 Thread Jean-Paul Calderone
On Mon, 09 Jul 2007 13:57:02 +0100, Will McGugan <[EMAIL PROTECTED]> wrote: >Hi, > >Is there a canonical way of storing per-thread data in Python? > See threading.local: http://python.org/doc/lib/module-threading.html Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Python IRC bot using Twisted

2007-07-11 Thread Jean-Paul Calderone
> self.msg('www', msg) >This code doesn't work. But if try to send private message back to >user: >if channel == self.nickname: > self.msg(user, msg) >everything works fine. I really don't know what to do. > self.msg('www', msg) will send msg to the

Re: Best architecture for proxy?

2007-07-11 Thread Jean-Paul Calderone
ngle thread. If it is the case, then you might want to keep around a thread pool (or process pool, or cluster) and push the filtering work to it, reserving the IO thread strictly for IO. This is still a win, since you end up with a constant number of processes vying for CPU time (and you can tune this to an ideal value given your available hardware), rather than one per connection. This translates directly into reduced context switch overhead. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: variable naming query

2007-07-12 Thread Jean-Paul Calderone
gt;self._myvariable This is the convention for private attributes. >self.__myvariable This causes the name to be mangled in an inconvenient way by the runtime. You probably /don't/ want to name your variables like this, since the consequence is primarily that the result is harder to use. Jean

Re: Pickled objects over the network

2007-07-18 Thread Jean-Paul Calderone
> File "/usr/lib/python2.5/pickle.py", line 874, in marker >while stack[k] is not mark: k = k-1 >IndexError: list index out of range > >Hopefully I'm doing something obviously wrong, but if anyone can help based >on that description or if you need to see the source, p

Re: How do you debug when a unittest.TestCase fails?

2007-07-18 Thread Jean-Paul Calderone
x27;testIt'); t.run() > >nothing happens. I use `trial -b ', which automatically enables a bunch of nice debugging functionality. ;) However, you can try this, if you're not interested in using a highly featureful test runner: try: unittest.main() except: import pdb pdb.pm() This will "post-mortem" the exception, a commonly useful debugging technique. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: UDP broadcast over a specific interface

2007-07-19 Thread Jean-Paul Calderone
.AF_INET, socket.SOCK_DGRAM) sock.bind((host,0)) sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) You shouldn't need to mess with anything beyond that. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: How do you debug when a unittest.TestCase fails?

2007-07-19 Thread Jean-Paul Calderone
ributed with Twisted: http://twistedmatrix.com/trac/wiki/Downloads I don't use unittest directly very much. I'm only slightly surprised that it is doing something which breaks post-morteming. If you want, you could probably fix it (probably something related to how it handles excep

Re: subprocess (spawned by os.system) inherits open TCP/UDP/IP port

2007-07-20 Thread Jean-Paul Calderone
l.fcntl(s.fileno(), fcntl.F_SETFD, old | fcntl.FD_CLOEXEC) Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Pickled objects over the network

2007-07-20 Thread Jean-Paul Calderone
twork) > >or, better without a new "as" keyword: > >my_received_dict=cpickle.loads(data_from_network,type=dict) > >Is this at all feasible? No. You could write a replacement for pickle, though. Oh, wait... Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess (spawned by os.system) inherits open TCP/UDP/IP port

2007-07-20 Thread Jean-Paul Calderone
On Fri, 20 Jul 2007 08:15:39 -0500, alf <[EMAIL PROTECTED]> wrote: >Jean-Paul Calderone wrote: > >> >> You can avoid this, if you like. Set FD_CLOEXEC on the socket after you >> open it, before you call os.system: >> >> old = fcntl.fcntl(s.fileno(

Re: Pickled objects over the network

2007-07-20 Thread Jean-Paul Calderone
m which uses strings longer than one byte must have a framing protocol to be reliable. So, this isn't really specific to pickle. Basically, all protocols have to address this. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Sorting dict keys

2007-07-20 Thread Jean-Paul Calderone
3]. b.sort() returns None. The sort method of the list type performs an in-place sort and always returns None. With that in mind, the rest of your code snippets might make more sense. I'll leave it to you to figure out how to jam everything into one line (or, more realistically, another

Re: Select weirdness

2007-04-22 Thread Jean-Paul Calderone
nt to use select in the first place). Or avoid the low-level networking entirely and use a high-level HTTP library that takes care of these details for you. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Select weirdness

2007-04-23 Thread Jean-Paul Calderone
o >extract the sandbox name, connect to the appropriate unix server socket, >and then bidirectionally pipe bytes back and forth. But it has to do >this for multiple connections simultaneously, which is why I need select. Twisted does this out of the box, for what it's worth. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: bitwise shift?

2007-04-25 Thread Jean-Paul Calderone
11,12,12,...,25 assuming that 1 << k means "1 shift >left by k" which is the same as multiplying with k. No. http://python.org/doc/ref/shifting.html Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: My python annoyances so far

2007-04-26 Thread Jean-Paul Calderone
outfix closure operator, []: >>> def account(s): ... b = [s] ... def add(a): ... b[0] += a ... def balance(): ... return b[0] ... return add, balance ... >>> add, balance = account(100) >>> add(5) >>> balance() 105 >>> ;) Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: wtf

2007-04-26 Thread Jean-Paul Calderone
lways rounded towards minus infinity: 1/2 is 0, (-1)/2 is -1, 1/(-2) is -1, and (-1)/(-2) is 0. Note that the result is a long integer if either operand is a long integer, regardless of the numeric value. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: ascii to unicode line endings

2007-05-02 Thread Jean-Paul Calderone
>>> f = file('test-newlines-file') >>> f.read() '\xff\xfe\r\x00\n\x00' >>> And how it differs from your example. Are you sure you're examining the resulting output properly? By the way, "\r\0\n\0" isn't a "unicode line ending", it's just the UTF-16 encoding of "\r\n". Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: I wish that [].append(x) returned [x]

2007-05-02 Thread Jean-Paul Calderone
27;%s')" % (name,)) if I enter my name to be "'; DELETE FROM users;", then you are probably going to be slightly unhappy. However, if you insert rows into your database like this: cursor.execute("INSERT INTO users (name) VALUES (%s)", (name,)) then I will simply e

<    4   5   6   7   8   9   10   11   12   13   >