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

Re: ascii to unicode line endings

2007-05-03 Thread Jean-Paul Calderone
On 3 May 2007 04:30:37 -0700, [EMAIL PROTECTED] wrote: >On 2 May, 17:29, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: >> On 2 May 2007 09:19:25 -0700, [EMAIL PROTECTED] wrote: >> >> >> >> >The code: >> >> >import codecs >> >>

Re: Microsoft's Dynamic Languages Runtime (DLR)

2007-05-03 Thread Jean-Paul Calderone
far from the truth. > >The claimed figures were 50,000 Pystones for CPython 2.5, and 101,000 for >the latest IronPython. (He didn't mention it, but I believe Psyco will >outdo both of these.) fwiw, my desktop happens to do 50,000 pystones with cpython 2.4 and 294,000 pystones with cpython 2.4 and psyco.full() Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Non blocking sockets with select.poll() ?

2007-05-04 Thread Jean-Paul Calderone
I do a >telnet connection to port 10000. > What were you expecting? Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Non blocking sockets with select.poll() ?

2007-05-04 Thread Jean-Paul Calderone
On Fri, 4 May 2007 15:05:46 +0300, Maxim Veksler <[EMAIL PROTECTED]> wrote: >On 5/4/07, Maxim Veksler <[EMAIL PROTECTED]> wrote: >>On 5/4/07, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: >> > On Fri, 4 May 2007 13:04:41 +0300, Maxim Veksler &l

Re: Non blocking sockets with select.poll() ?

2007-05-05 Thread Jean-Paul Calderone
On Sat, 5 May 2007 15:37:31 +0300, Maxim Veksler <[EMAIL PROTECTED]> wrote: >On 5/4/07, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: >> >""" >> >#!/usr/bin/env python >> >import socket >> >import select >> > >>

Re: Setting up python socket server with non-standard termination string.

2007-05-08 Thread Jean-Paul Calderone
t import reactor from twisted.internet.protocol import ServerFactory from twisted.protocols.basic import LineOnlyReceiver class CellProtocol(LineOnlyReceiver): delimiter = '-ND-' def lineReceived(self, line): print 'got a line' f = ServerFactory(

Re: Thread-safe dictionary

2007-05-10 Thread Jean-Paul Calderone
t be better to use threading.RLock, mutex, ... instead? > The builtin dict type is already thread safe. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Moving class used in pickle

2007-05-15 Thread Jean-Paul Calderone
b.py and import the relevant class(es) from c.py into it - 'from a.c import ClassA'. You could also build a much more complex system in the hopes of being able to do real "schema" upgrades of pickled data, but ultimately this is likely a doomed endeavour (vis <http://divmod.org:81/websvn/wsvn/Quotient/trunk/atop/versioning.py?op=file&rev=0&sc=0>). Hope this helps, Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: NEWBIE: Extending a For Statement.

2007-05-21 Thread Jean-Paul Calderone
in mydict if key in xrange(60, 69) or key == 3] For the statement form of 'for', there is no syntactic way to combine it with 'if' into a single statement. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: howto check does module 'asdf' exist? (is available for import)

2007-05-21 Thread Jean-Paul Calderone
;>> 'Numeric' in modules False >>> getModule('Numeric') PythonModule<'Numeric'> >>> 'Numeric' in modules False >>> Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: split on NO-BREAK SPACE

2007-07-22 Thread Jean-Paul Calderone
27;s only inconsistent if you think it should behave based on the name of a unicode code point. It doesn't use the name, though. It uses the category. NO-BREAK SPACE is in the Zs category (Separator, Space). ZERO WIDTH NO-BREAK SPACE is in the Cf category (Other, Format). Maybe that makes unicode inconsistent (I won't try to argue either way), but it's pretty clear that isspace is being consistent based on the data it has to work with. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Detecting __future__ features

2007-07-30 Thread Jean-Paul Calderone
is >example, and many more. > >Making the switch between different parser-implementations on the fly isn't >technically impossible - but really, really, really complicated. But then, >if it's lameness sucks so much, you might wanna take a stab at it? > I think you misunderstood the behavior which was being called lame. The earlier poster was suggesting that only the first Python code to run any where in a process could perform future imports. This is, of course, not true. It's only restricted to the first Python code to run in a particular file. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: File handle not being released by close

2007-07-30 Thread Jean-Paul Calderone
On Mon, 30 Jul 2007 07:36:00 -0700, [EMAIL PROTECTED] wrote: >Hi, > > [snip] >f=open(fileBeginning+".tmp", 'w') >f.write("Hello") >f.close > You forgot to call close. Try this final line, instead: f.close() Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: interaction of 'with' and 'yield'

2007-07-31 Thread Jean-Paul Calderone
aving to >syntactically enclose the code in the 'with' scope, and I am hoping that >the the yield does not exit the 'with' scope and release the resource. It doesn't. Keep in mind that if the generator isn't resumed or garbage collected, the cleanup with never run, though. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: python 3.0, pywin32 and scipy

2007-08-02 Thread Jean-Paul Calderone
strode along with that? Compared to python, that has been >started in 1991 and now approaches it's third incarnation, I'd say >python has a record of steadiness that surpasses that of MS-based tools >by any means. This is not a valid comparison. In fact, C# 3 is completely

Re: python 3.0, pywin32 and scipy

2007-08-02 Thread Jean-Paul Calderone
On Thu, 02 Aug 2007 23:07:12 +0200, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >Jean-Paul Calderone schrieb: >> On Thu, 02 Aug 2007 21:16:04 +0200, "Diez B. Roggisch" >> <[EMAIL PROTECTED]> wrote: >>> vml schrieb: >>>> Hello,

Re: Importing * From a Package

2007-08-06 Thread Jean-Paul Calderone
fore they can find out what any particular name is bound to, and potentially leading to bugs where names from one package accidentally obscure names from another package. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: udp, datagram sockets

2007-08-06 Thread Jean-Paul Calderone
, causing the server to never see the termination marker. UDP is difficult to use effectively. Fortunately, TCP is suitable for many applications. You should consider using it, instead. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Stackless Integration

2007-08-09 Thread Jean-Paul Calderone
oblems with the current C-extensions? It seems >like if something is fully compatible and better, then it would be >adopted. However, it hasn't been in what appears to be 7 years of >existence, so I assume there's a reason. It's not Pythonic. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Stackless Integration

2007-08-09 Thread Jean-Paul Calderone
On Thu, 9 Aug 2007 05:05:31 -0700, Michael Bentley <[EMAIL PROTECTED]> wrote: > >On Aug 9, 2007, at 4:48 AM, Jean-Paul Calderone wrote: > >> On Thu, 09 Aug 2007 09:00:27 -, "Justin T." >> <[EMAIL PROTECTED]> wrote: >>> Hi, >>> >

Re: The Future of Python Threading

2007-08-10 Thread Jean-Paul Calderone
me point, someone needs to write some code. Stackless is great, but it's not the code that will solve this problem. In the mean time, you might consider some multi-process solutions. There are a number of tools for getting concurrency like that. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: The Future of Python Threading

2007-08-10 Thread Jean-Paul Calderone
On Fri, 10 Aug 2007 16:37:19 -, "Justin T." <[EMAIL PROTECTED]> wrote: >On Aug 10, 3:52 am, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: >> On Fri, 10 Aug 2007 10:01:51 -, "Justin T." <[EMAIL PROTECTED]> wrote: >> >Hello, >>

Re: curses library

2007-08-14 Thread Jean-Paul Calderone
gt; widget. > >Forgot to say, i don't need it to work on windows :) You might be interested in insults: API docs: http://twistedmatrix.com/documents/current/api/twisted.conch.insults.html Examples: http://twistedmatrix.com/projects/conch/documentation/examples/ Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Fast socket write

2007-08-22 Thread Jean-Paul Calderone
in mind, maybe you can try to provide more details about the functionality to narrow the field a bit. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: My 'time' module is broken, unsure of cause

2007-08-23 Thread Jean-Paul Calderone
1, in ? AttributeError: 'module' object has no attribute 'time' >>> print time.__file__ time.py >>> ^D [EMAIL PROTECTED]:~$ rm time.py [EMAIL PROTECTED]:~$ rm time.pyc [EMAIL PROTECTED]:~$ python Python 2.4.3 (#2, Oct 6 2006, 0

Re: Python is overtaking Perl

2007-09-04 Thread Jean-Paul Calderone
On Tue, 04 Sep 2007 00:32:23 -, Ben <[EMAIL PROTECTED]> wrote: >Here are the statistics from Google Trends: > >http://benyang22a.blogspot.com/2007/09/perl-vs-python.html > >From the graph, it seems more accurate to say that Perl is undertaking Python. Jean-Paul -- h

Re: implementing SFTP using Python

2007-03-02 Thread Jean-Paul Calderone
python+sftp+server%22&btnG=Search might be a place to start. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Webserver balance load

2007-03-05 Thread Jean-Paul Calderone
On 5 Mar 2007 11:47:15 -0800, Johny <[EMAIL PROTECTED]> wrote: >Can anyone suggest a way how to balance load on Apache server where I >have Python scripts running? >For example I have 3 webservers( Apache servers) and I would like to >sent user's request to one of the three server depending on a lo

Re: Database module & multithreading

2007-03-10 Thread Jean-Paul Calderone
s is the error I am getting > Do you recognize that this has absolutely nothing to do with threading? If this is the reason you want to switch away from SQLite3, reconsider, because it's just a bug in your application code, and no matter what database or adapter you use, bugs in your application code will prevent your application from working properly. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Still the __new__ hell ...

2007-03-19 Thread Jean-Paul Calderone
On Mon, 19 Mar 2007 13:17:11 +0100, Bruno Desthuilliers > > [snip] > >And what if it's a unicode string ? >The correct idiom here is: > if isinstance(year, basestring): > >> year,month,day=map(int,string.split(year,'-')) > year, month,

Re: Still the __new__ hell ...

2007-03-19 Thread Jean-Paul Calderone
On Mon, 19 Mar 2007 15:39:49 +0100, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: >Jean-Paul Calderone a écrit : >> On Mon, 19 Mar 2007 13:17:11 +0100, Bruno Desthuilliers >>> >>> [snip] >>> >>> And what if it's a unicode string ? >>&

Re: Python object overhead?

2007-03-24 Thread Jean-Paul Calderone
quot;, "n"] > Only one list is created. It is used to define a C array where attributes will be stored. Each instance still has that C array, but it has much less overhead than a Python list or dictionary. Whether this reduction in overhead actually results in a useful or measurable perfor

Re: Python object overhead?

2007-03-24 Thread Jean-Paul Calderone
On 24 Mar 2007 13:52:46 -0700, 7stud <[EMAIL PROTECTED]> wrote: >On Mar 24, 2:19 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: >> Only one list is created. It is used to define a C array where attributes >> will be stored. Each instance still has that C

Re: Strange behavior when printing a returned closure function

2007-03-25 Thread Jean-Paul Calderone
>what ...? They're _not_ the same function object, just like the `is' test told you. They just happen to have been allocated at the same memory address. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Fortran vs Python - Newbie Question

2007-03-26 Thread Jean-Paul Calderone
meric without losing the readability of Python. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Fortran vs Python - Newbie Question

2007-03-26 Thread Jean-Paul Calderone
On 26 Mar 2007 06:47:18 -0700, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >On Mar 26, 2:42 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: >> On 26 Mar 2007 06:20:32 -0700, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >> >> >

Re: Sending ECHO_REQUEST (pinging) with python

2007-03-26 Thread Jean-Paul Calderone
this in >python.. You need a sendmsg wrapper (there are several, none in the stdlib), then you need a privileged process which is willing to give you the privilege. It's pretty inconvenient. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Python object overhead?

2007-03-26 Thread Jean-Paul Calderone
ss is one which has a type of type instead of ClassType. For example: >>> class notnewstyle: ... pass ... >>> type(notnewstyle) >>> class newstyle(object): ... pass ... >>> type(newstyle) >>> class alsonewstyle(list

Re: newbi question on python rpc server, how it works?

2007-03-29 Thread Jean-Paul Calderone
shnakant. Here's an example Twisted-based XML-RPC server: http://twistedmatrix.com/projects/web/documentation/examples/xmlrpc.py When using MySQLdb with Twisted, twisted.enterprise.adbapi is useful. This document explains it and gives some examples of its usage: http://twistedmatrix.co

Re: socket read timeout

2007-03-29 Thread Jean-Paul Calderone
t; So set a long timeout when you want to write and short timeout when you want >> to read. >> > >Are sockets full duplex? Uh, yes. > >I know Ethernet isn't. Not that this is relevant, but unless you're using a hub, ethernet _is_ full duplex. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: with timeout(...):

2007-03-29 Thread Jean-Paul Calderone
that. > >I'm assuming that the timeout function is running in a thread... What does it do when the timeout expires? How does it interrupt recv(2) or write(2) or `for (int i = 0; i < (unsigned)-1; ++i);'? This is what we're talking about, right? Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: socket read timeout

2007-03-30 Thread Jean-Paul Calderone
On Fri, 30 Mar 2007 08:22:18 +0200, Hendrik van Rooyen <[EMAIL PROTECTED]> wrote: >"Jean-Paul Calderone" <[EMAIL PROTECTED]> wrote: > >> On Thu, 29 Mar 2007 07:29:35 +0200, Hendrik van Rooyen ><[EMAIL PROTECTED]> wrote: > >> >Are sockets full

Re: Why is __getslice__ still implemented?

2007-04-10 Thread Jean-Paul Calderone
atibility reasons >(though it is being removed in Python 3000). If you have a specific >suggestion for what doc should be updated and how, that would be >helpful. Please post it to: Why does this mean that the unicode type has to implement __getslice__? Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: installing pyqt4 on ubuntu 6.06

2007-04-10 Thread Jean-Paul Calderone
>from PyQt4 import QtCore, QtGui >ImportError: No module named PyQt4 > > >Any pointers regarding what packages should i install to get the >system into working condition would be very helpful > >Thanks a lot Qt4 Python bindings aren't available in 6.06, afaik. I

Re: Why is __getslice__ still implemented?

2007-04-10 Thread Jean-Paul Calderone
On Tue, 10 Apr 2007 09:51:45 -0600, Steven Bethard <[EMAIL PROTECTED]> wrote: >Jean-Paul Calderone wrote: >> On Tue, 10 Apr 2007 08:35:56 -0600, Steven Bethard >> <[EMAIL PROTECTED]> wrote: >>> Yes, you do still need to implement __getslice__ if you're subc

Re: unittest assertRaises Problem

2007-04-16 Thread Jean-Paul Calderone
a callable. assertRaises will call it (so that it can do exception handling), so you shouldn't: self.assertRaises(ValueError, f.testException) Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Queue enhancement suggestion

2007-04-16 Thread Jean-Paul Calderone
for >each reader. I found my code cluttered with > >for i in xrange(number_of_worker_threads): > q.put(sentinel) > >which certainly seems like a code smell to me. Instead of putting multiple sentinels, just pre-construct the iterator object. work = iter(q.get, sentine

Re: Queue enhancement suggestion

2007-04-17 Thread Jean-Paul Calderone
On 17 Apr 2007 14:32:01 GMT, Antoon Pardon <[EMAIL PROTECTED]> wrote: >On 2007-04-17, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: >> On 17 Apr 2007 13:32:52 GMT, Antoon Pardon <[EMAIL PROTECTED]> wrote: >>>On 2007-04-17, Hendrik van Rooyen <[EMAIL PROTECT

Re: Using X509 (and TLSlite) authentication

2007-04-17 Thread Jean-Paul Calderone
code in Twisted for this. It's based on PyOpenSSL. http://twistedmatrix.com/trac/browser/trunk/twisted/internet/_sslverify.py Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Queue enhancement suggestion

2007-04-17 Thread Jean-Paul Calderone
read is the single reader, it will dead >lock if the queue happens to be full at the moment the gui thread >want to add another item. > This is pretty easily solved: def sendToGUI(event): if isInGUIThread(): gui.scheduleCall(event) else: guiQueue.put(event) Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Parameterize formatting string

2007-09-21 Thread Jean-Paul Calderone
ething like : >> >> a = 16 >> "%ai" % 12 >> >> But it is not correct. >> >> Any Idea ? > >("%i" % 12).rjust(a) > >Or, more ugly: > >"%%%di" % a % 12 > >The first % (after quotes) builds this string: &quo

Re: Python 3.0 migration plans?

2007-09-28 Thread Jean-Paul Calderone
Higher Order Functions and would >like to see exactly how you do it and to verify the contention. > Perhaps you could do a bit of independent research. Then your messages to the group could contain more thoughtful questions and responses. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Python + Shoutpy + Twisted Locks

2007-10-09 Thread Jean-Paul Calderone
that >>> I have to re-think a lot. But in the end I suppose it will pay off. >>> >>> Thanks for taking the time and reading my little essay Gabriel ;) >>> >> >> Using Twisted won't help if the libshout calls are really blocking the >> main

Re: Native class methods

2007-10-09 Thread Jean-Paul Calderone
#x27;m really trying to do this without any dependencies on external >libraries. The ctypes way looks interesting but I had really hoped for >something more JNI-like :-/ > JNI is awful. I can't imagine why you'd want something like it. However, since you do, why don't you

Re: unpickle from URL problem

2007-10-10 Thread Jean-Paul Calderone
rican.edu/econ/notes/hw/example2')) > >Why the difference? You shouldn't unpickle things you get from the network, since pickle can execute arbitrary code: http://jcalderone.livejournal.com/15864.html Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Error on base64.b64decode() ?!

2007-10-12 Thread Jean-Paul Calderone
If you get an incorrect padding error, try appending a "=" and decoding again. If you get the error again, try appending one more "=". If it still doesn't work, then you might be out of luck. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP idea: Instrumented Python

2007-10-12 Thread Jean-Paul Calderone
t you can connect >to the app and explore its current state. Take a look at the >evalexception module in Paste to see what he does. > Or manhole in Twisted. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Automatically organize module imports

2007-10-15 Thread Jean-Paul Calderone
dule name for every class/function that I use >(quite unhandy)? > Pyflakes will tell you which imports aren't being used (among other things). I don't know if an existing tool which will automatically rewrite your source, though. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Get the instance name from a list by Reflection

2007-10-20 Thread Jean-Paul Calderone
>>> from twisted.python.reflect import objgrep, isSame >>> for elem in aList: ... objgrep(__main__, elem, isSame) ... ['.aList[0]', '.elem', '.a1'] ['.aList[1]', '.elem', '.a2'] >>> Don't see how this could help, Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: python with braces pre-processor

2007-10-22 Thread Jean-Paul Calderone
_pp.py It's just some throw-away code, but it at least manages to indent code properly. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: pure python data compression (zip)

2007-10-23 Thread Jean-Paul Calderone
t/, which is written in >C. Unfortunately this is not solution for me, because my target "only" >has a python interpreter > >I have "googled" for a while, but I don't have found anything useful. What is your target, that it can only run programs written in Python, not C?

Re: Adding idle timeout capabilities to asyncore

2007-10-23 Thread Jean-Paul Calderone
really useful in any real-world sense, but I still wouldn't characterize time.time as "relatively inexpensive." Of course, for any real-world work, one would want to profile the application to determine if removing calls to time.time() could make a worthwhile difference. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3   4   5   6   7   >