Re: Any python scripts to do parallel downloading?

2007-01-31 Thread Jean-Paul Calderone
On 31 Jan 2007 08:23:57 -0800, Frank Potter <[EMAIL PROTECTED]> wrote: >I want to find a multithreaded downloading lib in python, >can someone recommend one for me, please? >Thanks~ There are no threads, but perhaps http://jcalderone.livejournal.com/24285.html would be interestin

Re: What is the dummy statement that do nothing in Python?

2007-01-31 Thread Jean-Paul Calderone
x27;t just leave the space blank after if statement because there will be >error message. > >Does anybody know what to insert there? http://python.org/doc/tut/node6.html#SECTION00650 Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Any python scripts to do parallel downloading?

2007-01-31 Thread Jean-Paul Calderone
end one for me, please? >> > Thanks~ >> >> Why do you want to use threads for that? Twisted is the >> obvious solution for your problem, > >Overkill? Just to download a few web pages? You've got to be >kidding. Better "overkill" (whatever that

Re: Any python scripts to do parallel downloading?

2007-01-31 Thread Jean-Paul Calderone
On Wed, 31 Jan 2007 13:52:35 -0800, "Carl J. Van Arsdall" <[EMAIL PROTECTED]> wrote: >Jean-Paul Calderone wrote: >> On 31 Jan 2007 12:24:21 -0800, Carl Banks <[EMAIL PROTECTED]> wrote: >> >>> Michele Simionato wrote: >>> >>&g

Re: Any python scripts to do parallel downloading?

2007-01-31 Thread Jean-Paul Calderone
On Wed, 31 Jan 2007 15:13:59 -0800, "Carl J. Van Arsdall" <[EMAIL PROTECTED]> wrote: >Jean-Paul Calderone wrote: >> [snip] >>> >>> >> >> You're right. Learning new things is bad. My mistake. >> >> Jean-Paul >>

Re: Any python scripts to do parallel downloading?

2007-01-31 Thread Jean-Paul Calderone
On Wed, 31 Jan 2007 17:19:07 -0800, "Carl J. Van Arsdall" <[EMAIL PROTECTED]> wrote: >Jean-Paul Calderone wrote: >> On Wed, 31 Jan 2007 15:13:59 -0800, "Carl J. Van Arsdall" <[EMAIL >> PROTECTED]> wrote: >> >>> Jean-Paul Calderone

Re: Any python scripts to do parallel downloading?

2007-01-31 Thread Jean-Paul Calderone
On 31 Jan 2007 19:12:59 -0800, Aahz <[EMAIL PROTECTED]> wrote: >In article <[EMAIL PROTECTED]>, >Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: >> >>You misunderstand. I wasn't expressing a lack of confidence in Python >>threads, but in the faci

Re: Any python scripts to do parallel downloading?

2007-02-01 Thread Jean-Paul Calderone
ress bar in Tkinter using threads is >definitely less obvious than running >an iterator in the main loop, as I discovered the hard way. Writing a >facility to run iterators in Twisted >is a three-liner, but it is not already there, nor standard :-( > Have you seen the recently introd

Re: Any python scripts to do parallel downloading?

2007-02-01 Thread Jean-Paul Calderone
On 1 Feb 2007 06:14:40 -0800, Carl Banks <[EMAIL PROTECTED]> wrote: >On Jan 31, 3:37 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: >> On 31 Jan 2007 12:24:21 -0800, Carl Banks <[EMAIL PROTECTED]> wrote: >> >> >Michele Simionato wrote: >> >>

Re: Any python scripts to do parallel downloading?

2007-02-01 Thread Jean-Paul Calderone
On 1 Feb 2007 06:41:56 -0800, Carl Banks <[EMAIL PROTECTED]> wrote: >On Feb 1, 9:20 am, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: >> On 1 Feb 2007 06:14:40 -0800, Carl Banks <[EMAIL PROTECTED]> wrote: >> >> >> >> >On Jan 31, 3:37 pm, Jean

Re: asyncore DoS vulnerability

2007-02-02 Thread Jean-Paul Calderone
every asyncore-based server can be shut down more or less at the whim of the public internet. Doesn't that problem merit some attention (maybe it doesn't, I don't know - that's why I'm asking)? Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess stdin encoding

2007-02-05 Thread Jean-Paul Calderone
estion asked, it isn't really a correct answer overall. I hope no one actually goes off and does this. Doing so will result in completely unportable code with very difficult to track down bugs. Instead, use the str and unicode methods "encode" and "decode". Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess stdin encoding

2007-02-05 Thread Jean-Paul Calderone
m "ascii" to "utf-8"? You don't need to change the default encoding. You just need to encode the unicode string you are sending to the child process. Try: tokenized_text, errs = tokenize.communicate(t.encode('utf-8')) Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: when will python 2.5 take in mainstream?

2007-02-05 Thread Jean-Paul Calderone
On Mon, 05 Feb 2007 10:19:26 +0100, Laurent Pointal <[EMAIL PROTECTED]> wrote: >[EMAIL PROTECTED] a écrit : >> When they have to ... >> >> One of the big things about Python is that its penetration slows it >> down. There's more legacy code and interdependant systems around now >> that Python is mo

Re: Python 3.0 (Was: when will python 2.5 take in mainstream?)

2007-02-05 Thread Jean-Paul Calderone
ses which haven't happened yet, but that remains to be seen. And 3.0 won't be "largely compatible" with any _existing_ 2.x release, but hopefully a future 2.x release will add a usable transition path. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: when will python 2.5 take in mainstream?

2007-02-05 Thread Jean-Paul Calderone
On Mon, 05 Feb 2007 17:07:15 +0100, Laurent Pointal <[EMAIL PROTECTED]> wrote: >Jean-Paul Calderone a écrit : >> On Mon, 05 Feb 2007 10:19:26 +0100, Laurent Pointal >> <[EMAIL PROTECTED]> wrote: >>> [EMAIL PROTECTED] a écrit : >>>> When they have to

Re: when will python 2.5 take in mainstream?

2007-02-06 Thread Jean-Paul Calderone
On 6 Feb 2007 04:45:35 -0800, Ben Sizer <[EMAIL PROTECTED]> wrote: >On Feb 5, 4:15 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: >> It's very easy to maintain compatibility in the C API. I'm much more >> interested in compatibility at the Python layer,

Re: huge amounts of pure Python code broken by Python 2.5?

2007-02-06 Thread Jean-Paul Calderone
On Tue, 06 Feb 2007 08:40:40 -0700, Steven Bethard <[EMAIL PROTECTED]> wrote: >Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > > Huge amounts of my pure Python code was broken by Python 2.5. > >Interesting. Could you give a few illustrations of this? (I didn't r

Re: Python editor

2007-02-06 Thread Jean-Paul Calderone
on-send-region Command: Send the region to the inferior Python process. python-send-region-and-go Command: Send the region to the inferior Python process. python-send-string Command: Evaluate STRING in inferior Python process. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: help on packet format for tcp/ip programming

2007-02-08 Thread Jean-Paul Calderone
ke this, instead.. struct.pack('!IIL', len(buffer), count, offset) + buffer Then it is a simple matter to unpack it once the receiving side, by waiting for struct.calcsize('!IIL') bytes, using struct to get len(buffer), count, and offset: length, count, offset = str

Re: postgres backup script and popen2

2007-02-08 Thread Jean-Paul Calderone
ts for a password. It thought i >> > could solve this by using popen2. >> >> Use pexpect:http://pexpect.sourceforge.net/ > >pexpect could work. But a better way would be to supply the password >on the command line. So that it shows up in `ps' output to anyone on the system? :) Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: postgres backup script and popen2

2007-02-08 Thread Jean-Paul Calderone
On 8 Feb 2007 09:18:26 -0800, Gabriel Genellina <[EMAIL PROTECTED]> wrote: >On 8 feb, 13:29, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: >> On 8 Feb 2007 08:23:49 -0800, Gabriel Genellina <[EMAIL PROTECTED]> wrote: >> >On 8 feb, 10:27, Maël Benjam

Re: Help with Optimization of Python software: real-time audio controller

2007-02-12 Thread Jean-Paul Calderone
ven some existing Python applications which deal with sound and manage to work with ~20ms samples. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: How to print the variable?

2007-02-14 Thread Jean-Paul Calderone
ode' with value 'print "${rc}".' print rc print dir(rc) print type(rc) help(rc) http://python.org/doc/tut/ Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: try...except...finally problem in Python 2.5

2007-02-14 Thread Jean-Paul Calderone
by that attribute does not exist, then the finally suite will execute before f has been bound, and the UnboundLocalError will mask the real error. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: AUX File Writing Error

2007-02-15 Thread Jean-Paul Calderone
uot; or "AUX.csv", but it requires special spelling. I don't remember the details at present, but presumably if you are interested you can dig it up on MSDN. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Pep 3105: the end of print?

2007-02-16 Thread Jean-Paul Calderone
on't. I think some people are confused that the language "Python 3.x" has "Python" in its name, since there is already a language with "Python" in its name, with which it is not compatible. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Pep 3105: the end of print?

2007-02-16 Thread Jean-Paul Calderone
On Sat, 17 Feb 2007 02:17:23 +1100, Steven D'Aprano <[EMAIL PROTECTED]> wrote: >On Fri, 16 Feb 2007 09:49:03 -0500, Jean-Paul Calderone wrote: > >> On Sat, 17 Feb 2007 01:32:21 +1100, Steven D'Aprano >>> [snip] >>> >>>I don't think that f

Re: Pep 3105: the end of print?

2007-02-16 Thread Jean-Paul Calderone
On Fri, 16 Feb 2007 16:49:05 +0100, BJörn Lindqvist <[EMAIL PROTECTED]> wrote: >On 2/16/07, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: >>I was just pointing out that some people might be confused. I didn't make >>any judgement about that fact. You seem to be

Re: Declare a variable global

2007-02-19 Thread Jean-Paul Calderone
colorIndex = 0 def test(): print colorIndex test() [EMAIL PROTECTED]:~$ python foo.py 0 [EMAIL PROTECTED]:~$ The global keyword lets you rebind a variable from the module scope. It doesn't have much to do wi

Re: converting u'11\xa022' to '11\xa022'

2007-02-20 Thread Jean-Paul Calderone
On Tue, 20 Feb 2007 18:12:42 -0600, alf <[EMAIL PROTECTED]> wrote: >Hi, >is there a more elegant way to do that: > >''.join([chr(ord(i)) for i in u'11\xa022' ]) > u'11\xa022'.encode('charmap') Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: plugin development best practices

2007-02-22 Thread Jean-Paul Calderone
ere are quite a few available already. Most likely, at least one of them is suitable for your application. Here are a couple starting points: http://twistedmatrix.com/projects/core/documentation/howto/plugin.html http://peak.telecommunity.com/DevCenter/setuptools#dynamic-discovery-of-service

Re: plugin development best practices

2007-02-22 Thread Jean-Paul Calderone
mation. >>> import someplugins >>> dir(someplugins) ['__builtins__', '__doc__', '__file__', '__name__', '__path__'] >>> Hey, where's my plugin? This most trivial test would have demonstrated the

Re: Creating a daemon process in Python

2007-02-23 Thread Jean-Paul Calderone
ing logic. I'd never seen it before in a deamonizer either, but it caught my eye in this one. I haven't had time to investigate further though. I hope Eirikur will explain. :) Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: getting terminal display size?

2007-02-25 Thread Jean-Paul Calderone
ng like what's being done here: http://twistedmatrix.com/trac/browser/trunk/twisted/conch/scripts/conch.py#L361 Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: How to update DNS record

2007-03-01 Thread Jean-Paul Calderone
to specify which DNS server software needs to be reconfigured. You might also want to include an example of what kind of change you want to make. For example, do you want to add and delete records? Do you want to change the address of associated with an existing A record? Are all your chan

Re: GIS Shape file upload to FTP server

2007-03-01 Thread Jean-Paul Calderone
;ffile = open('c:/test/wuppnt.shp', 'r') Perhaps the problem is that you did not open the file in binary mode here? Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Poor python and/or Zope performance on Sparc

2007-11-03 Thread Jean-Paul Calderone
idle. The T1000 isn't a very good machine for general server purposes. It has advantages when running software with a lot of hardware-level parallelism, but Zope isn't such a piece of software. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic ORM with support for composite primary/foreign keys?

2007-11-06 Thread Jean-Paul Calderone
t;, maybe even some of the PostgreSQL-specific features >(such as e.g. composite types)? storm supports composite primary keys. I'm not sure if it supports composite foreign keys, but I suspect it does. It's also pretty good overall. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Insane crazy question - printing commands

2007-11-06 Thread Jean-Paul Calderone
) > self.context.set_source_rgb(1, 0, 0) > self.context.rectangle(0, 00, 50, 50) > self.context.fill() > >Box.draw() draws a red box, all fine. But, I *also* want it to output the >actual commands within the draw def to the console (or a file). See inspect.getsource(). Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Confused about closures and scoping rules

2007-11-06 Thread Jean-Paul Calderone
me. This problem appeared deep inside a >complicated code and it took me almost two days to track down what was going >on... Lots of people ask about this. The behavior you observed is the expected (by the implementors, anyway) behavior. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: a simple tcp server sample

2007-11-07 Thread Jean-Paul Calderone
run() This doesn't have the bug your version has (where it randomly drops some data on the floor) and handles multiple clients. Check it out: http://twistedmatrix.com/ Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating a cell 'by hand'

2007-11-08 Thread Jean-Paul Calderone
ch: >>> def f(): ... x = 10 ... def g(): ... a = x ... return g ... >>> f().func_closure (,) >>> I don't know what your use-case is, so I have no idea if this is the kind of solution you're looking for. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Valgrind and Python

2007-11-09 Thread Jean-Paul Calderone
le blocks (those to which a pointer was found) are not shown. >==27082== To see them, rerun with: --show-reachable=yes > >A lot of those 713 errors occur in the various deallocation functions. > Did you use the suppression file? Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Using python as primary language

2007-11-16 Thread Jean-Paul Calderone
d habits they aquired. > +1 QOTW Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: sockets: why doesn't my connect() block?

2007-11-18 Thread Jean-Paul Calderone
ogram ends immediately after the call to >connect()--even though my server program does not call accept(): > Your platform's TCP implementation acknowledges the connection attempt before your application calls accept(). This is fairly usual. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Clean way to get one's network IP address?

2007-11-21 Thread Jean-Paul Calderone
ally get the local address which will be used for traffic to a particular host by getting ready to send traffic to it with a UDP socket: >>> from socket import socket, SOCK_DGRAM, AF_INET >>> s = socket(AF_INET, SOCK_DGRAM) >>> s.connect(('google.com

Re: Looking to learn python willing to clean up code

2007-11-23 Thread Jean-Paul Calderone
x.com/trac/report And drop by #twisted on irc.freenode.net to chat about some tasks you might be able to tackle. Twisted development involves code review for all changes, so this would be a guaranteed way to get feedback on your work. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: read/write to java socket in python

2007-11-27 Thread Jean-Paul Calderone
print(buf.readLine()); Here, you tried you read a line from the socket. The peer never sent a whole line though, so readLine will never succeed. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Embedding Python - Passing by Reference

2007-11-29 Thread Jean-Paul Calderone
n extending Python? You misunderstand how parameters are passed in Python: >>> x = 10 >>> def foo(y): ... y = y + 1 ... >>> foo(x) >>> x 10 >>> So there's no behavior here to attempt to emulate when embedding or extending. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: reloading modules and isinstance()

2007-12-06 Thread Jean-Paul Calderone
w >where in all the world I keep references to that class? Thus it would >essentially have to scan all references to anything, all list contents, >all class-properties, all everything. Which is not feasible. Who says it isn't feasible? http://twistedmatrix.com/trac/browser/trunk/twisted/python/rebuild.py Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: reloading modules and isinstance()

2007-12-06 Thread Jean-Paul Calderone
e geared towards special cases, >not a general-purpose "now reloading really works" implementation. > What special cases? I won't argue that it works for every case, but the failure modes are really defined by special cases in Python, not the other way around. Maybe that&#x

Re: Error when executing the library reference echo server example

2007-12-10 Thread Jean-Paul Calderone
itions. It has other bugs as well, such as not checking the return value of socket.send(). Here's a different echo example: http://twistedmatrix.com/projects/core/documentation/examples/#auto0 Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Error when executing the library reference echo server example

2007-12-10 Thread Jean-Paul Calderone
ly on everything always going right all the time. Even if you stick with the socket module, you should make sure to handle exceptions from socket calls and always check the return value of the send method. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: DNS servers in Python - which ones are a good base for work?

2007-12-11 Thread Jean-Paul Calderone
gestions? > There's Twisted Names. I wrote a custom DNS server with it just last week. The documentation is a bit sparse, but it's not particularly complicated. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: help displaying pdf thru client/server

2007-12-19 Thread Jean-Paul Calderone
;t say if the Linux server was local or not. If local, you could use >SAMBA to create a SMB share and have the XP PC get to it that way. There are >other ways, but these should get you started. > >-Larry Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Using ctypes with lib not found via ldconfig

2007-12-20 Thread Jean-Paul Calderone
ld.so.conf, and they >won't be. Our IT dept. controls this, and won't make them normally >accessible for me. > >So, how do i steer ctypes towards these libs? Let's say this is one of >them: > >/home/me/otherLibs/libgaak.so.6 > This generally work

Re: Why does __builtins__ mean different things...

2007-12-20 Thread Jean-Paul Calderone
d of this is the behavior above. I'm guessing its a bug. > __builtins__ is "a CPython implementation detail". In other words, unless you are doing really funny stuff, you shouldn't use it. What you're probably looking for is the __builtin__ module (difference in spell

Re: socket in python with proxies

2007-12-21 Thread Jean-Paul Calderone
If you have a proxy which requires authentication, you must authenticate after you have established the connection by sending bytes over the socket. I don't know what kind of proxy you have, so I don't know what bytes you have to send. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: detecting property modification

2007-12-21 Thread Jean-Paul Calderone
classes). You don't need metaclasses. You do need a wrapper around the list so that you can intercept calls to __setitem__ (and whatever else) which are made onto it. You might also consider making Body new-style (subclass object) and using a property instead of a __setattr__ implementation. You still need a wrapper, but the implementation of the rest of the feature should be simpler. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: detecting property modification

2007-12-21 Thread Jean-Paul Calderone
On Fri, 21 Dec 2007 09:49:51 -0800 (PST), Mangabasi <[EMAIL PROTECTED]> wrote: > [snip] > >Hi Jean-Paul, > >Sorry, I should have spelled this out in my post but I did not. For >several reasons I do not wish to couple the pos object with the Body >instances. In my case,

Re: detecting property modification

2007-12-21 Thread Jean-Paul Calderone
On Fri, 21 Dec 2007 10:30:31 -0800 (PST), Mangabasi <[EMAIL PROTECTED]> wrote: >On Dec 21, 1:11 pm, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: >> On Fri, 21 Dec 2007 09:49:51 -0800 (PST), Mangabasi <[EMAIL PROTECTED]> >> wrote: >> > [snip] >&g

Re: Polling from keyboard

2006-05-02 Thread Jean-Paul Calderone
developed with Twisted in my blog: http://jcalderone.livejournal.com/10572.html http://jcalderone.livejournal.com/10988.html You can find examples of using these APIs in Twisted Conch's examples: http://twistedmatrix.com/projects/conch/documentation/examples/ Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Telnet linebreaks

2006-05-25 Thread Jean-Paul Calderone
hich will probably be rendered as "sword" on their terminal, which would be pretty confusing). >> > >> > buf += self.read() >> > >> > I'm suspecting that Gmud doesn't send '\x08', since from looking at some >> > old DIKU code, >> > I see that the if '\n' || '\r' are there as well, but there is no check >> > for '\x08'. If this is indeed >> > the cause of my problem, how would I go about doing it? It sounds to me as though the cause of the problem lies elsewhere. Twisted includes a rather complete telnet implementation (as well as an SSH implementation and a VT102 implementation). You may want to take a look at it, either to use for your server, or at least to see the correct way to gather input from your clients. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Secure Pickle-like module

2006-05-25 Thread Jean-Paul Calderone
far as security goes, no obvious problems jump out at me, either from the API for from skimming the code. I think early-binding __new__, __getstate__, and __setstate__ may be going further than is necessary. If someone can find code to set attributes on classes in your process space, they can probably already do anything they want to your program and don't need to exploit security problems in your serializer. On the other hand, early-binding may lead to confusing bugs, albeit only in nasty cases where people are expecting changes they make to class objects to have an effect on every part of the system. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamic DNS with a python script

2007-12-27 Thread Jean-Paul Calderone
ated :) > This depends on platform details. For example, some Linux distros include /etc/network/if-up.d/ which can contain arbitrary programs which will be run after an interface is brought up. Other platforms may have other ways to get notification of this event, or they may require you to poll

Re: How to refer to the current module?

2008-01-07 Thread Jean-Paul Calderone
sn't exist in main() line 1. If I 'import >driver' from the command line, then getattr(driver, ...) works, but >it's not bound here. > >Is there any way around this? Can I somehow scope the 'current >module' and give getattr(...) an object that will (at run time) have >the appropriate bindings? How about doing "import driver" and then using "getattr(driver, ...)"? Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Structure of packages

2008-01-09 Thread Jean-Paul Calderone
y, you'll be able to do the imports you want to do and they'll work just how you expected them to work. This isn't a complete description of Python's import system, but it should be enough to solve this problem you're having, and provide a good grounding for further learning. Hope this helps, Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: isgenerator(...) - anywhere to be found?

2008-01-22 Thread Jean-Paul Calderone
cial case for generators? If you just pass the object in question to iter(), instead, then you'll either get back something that you can iterate over, or you'll get an exception for things that aren't iterable. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: isgenerator(...) - anywhere to be found?

2008-01-22 Thread Jean-Paul Calderone
On Tue, 22 Jan 2008 15:15:43 +0100, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >Jean-Paul Calderone wrote: > >> On Tue, 22 Jan 2008 14:20:35 +0100, "Diez B. Roggisch" >> <[EMAIL PROTECTED]> wrote: >>>For a simple greenlet/tasklet/mic

Re: isgenerator(...) - anywhere to be found?

2008-01-22 Thread Jean-Paul Calderone
On Tue, 22 Jan 2008 15:52:02 +0100, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >Jean-Paul Calderone wrote: > > [snip] >> >> Sorry, I still don't understand. Why is a generator different from any >> other iterator? > >Because you can u

Re: twisted: problem with sftp-client

2008-01-23 Thread Jean-Paul Calderone
d.addCallback(self._cbReadFile, files, directory) >d.addErrback(self._ebRaeadFile, files, directory) You typo'd the errback method name above. This doesn't cause the problem you're having, though. There appears to be a bug in FX_EOF handling in filetransfer.py

Reflection and aspect programming in Python

2008-01-29 Thread Jean-François Houzard
Hello, I'm a student at UCL Belgium and I have to write a paper about reflection and introspection in Python. It is somewhat difficult to find advanced information about reflection in Python, not only introspection but also the other sides of reflection. I'm using the book: "Programming Python, T

Re: IronPython vs CPython: faster in 1.6 times?

2008-02-05 Thread Jean-Paul Calderone
close to a perfect language... That'd be pretty great, certainly. Work on the JIT is continuing and some PyPy developers have expressed some optimism about having something which is faster than CPython by the end of this year. Still, I'd be using PyPy for things today if it had the extension m

Re: Code block function syntax, anonymous functions decorator

2008-02-06 Thread Jean-Paul Calderone
a request for a piece of syntax. > >Besides, it's butt-ugly IMHO. But taste comes after proper definition... It's properly defined. Not that I'm endorsing this or anything. I'd rather not see half-assed syntax proposals at all, even if they're super great (and some of the syntax that's made it into Python is much worse than this). Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Why not a Python compiler?

2008-02-07 Thread Jean-Paul Calderone
gt; >http://cython.org/ > It's a not-quite-Python-to-C compiler. I don't think it is an optimizing compiler either. Can you provide a reference for this? Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: use 'with' to redirect stdout

2008-02-11 Thread Jean-Paul Calderone
an object and an attribute name. @contextmanager def redirect(fileholder, filename, newfile): orig = getattr(fileholder, filename) setattr(fileholder, filename, newfile) yield setattr(fileholder, filename, orig) with redirect(sys, 'stdout', open('st

Re: use 'with' to redirect stdout

2008-02-11 Thread Jean-Paul Calderone
On Mon, 11 Feb 2008 09:15:07 -0500, Neal Becker <[EMAIL PROTECTED]> wrote: >Is there a simple way to use a 'with' statement to redirect stdout in a >block? Do you mean "without writing a context manager to do the redirection"? Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: use 'with' to redirect stdout

2008-02-11 Thread Jean-Paul Calderone
On Mon, 11 Feb 2008 09:38:34 -0500, Neal Becker <[EMAIL PROTECTED]> wrote: >Jean-Paul Calderone wrote: > >> On Mon, 11 Feb 2008 09:15:07 -0500, Neal Becker <[EMAIL PROTECTED]> >> wrote: >>>Is there a simple way to use a 'with' statement to redirect

Re: linux disc space

2008-02-15 Thread Jean-Paul Calderone
fer, and I'm not sure how they ever would... > > [snip] > /: 27723000K free, 15817232K available It's common for some space to be reserved and only usable by the superuser. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Could WSGI handle Asynchronous response?

2008-02-18 Thread Jean-Paul Calderone
in h: >print >>stdout, k,'=',`v` >k=start_response("200 OK", [('Content-Type','text/plain')]) >for x in range(1, 100): >k(str(x)) >time.sleep(1) >return [stdout.getvalue()] You can do this, but notice that you use up a thread (or a process) for each client by doing so. This means you'll be limited to a fairly small number of concurrent clients. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Could WSGI handle Asynchronous response?

2008-02-18 Thread Jean-Paul Calderone
ould almost do full-dulex HTTP >communications, and ready-to-use server & client event-based code >library? There are a number. Two based on Twisted: Athena - http://divmod.org/trac/wiki/DivmodNevow/Athena python-cometd - http://svn.xantus.org/shortbus/trunk/cometd-twisted/ (I

Re: Is there any python lib for NAT transversal?

2008-02-21 Thread Jean-Paul Calderone
On Thu, 21 Feb 2008 14:50:50 +0800, hawk gao <[EMAIL PROTECTED]> wrote: >Is there any python lib for NAT transversal? Divmod Vertex is such a library (it does a few other things as well), but it is not nearly complete and has little documentation. http://divmod.org/trac/wiki/DivmodVer

Re: Python Telnet formatting?

2008-03-02 Thread Jean-Paul Calderone
n, then all of the telnet command sequences will be handled separately from the application data. It might help if you share some of your code. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: is there enough information?

2008-03-03 Thread Jean-Paul Calderone
use Windows' asynchronous I/O APIs is with threads. Actually, it is possible (and Twisted allows you) to use these as well without writing a threaded application. Perhaps you think it would be better to use them with threads, but that's certainly not the _only_ way to use them as you implied.

Re: mulithreaded server

2008-03-11 Thread Jean-Paul Calderone
'connection from',addr >cSocketlock=thread.allocate_lock() >thread.start_new_thread(sendData,(cSocket,)) >thread.start_new_thread(getData,(cSocket,)) >if p==0: >sSocket.close() > > > >In the above program, why there is an unhandeled exception ??? Just a guess. You should really include the traceback when you ask a question like this. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Does __import__ require a module to have a .py suffix?

2008-03-12 Thread Jean-Paul Calderone
#x27;t >tell for sure. It would be nice if someone more knowledgeable can >compare and contrast these two appraches. Another difference is that when you import a module, its code is (usually) only executed once. Each import after the first just returns a reference to the already-created module object. When you use execfile, the code is re-evaluated each time. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Psyco alternative

2008-03-27 Thread Jean-Paul Calderone
which isn't so much of a difference. A bigger obstacle is the availability of third-party extension modules which currently must be re-implemented in order to be available on PyPy. This could easily take half a decade without a full-time or otherwise concerted effort. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: Psyco alternative

2008-03-27 Thread Jean-Paul Calderone
nge(20) if i % 2) >print sum(nums) > Sure, it can be. That doesn't mean it will be. Someone has to do it. :) One reason attention is going to PyPy instead of Psyco is that PyPy's JIT doesn't require as much careful attention to support and maintain support for features l

Re: subprocess.Popen stalls

2009-01-12 Thread Jean-Paul Calderone
d the output. Otherwise, the process's stdout fills up and its write attempt eventually blocks, preventing it from continuing. If you use Twisted's process API instead, the reading will be done for you (without any of the race conditions that are likely when using the subprocess module), and things will probably "just work". Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: executing multiple functions in background simultaneously

2009-01-14 Thread Jean-Paul Calderone
might be to put two-tuples of the thread identifier and some other object. eg queue.put((threadID, obj)) Perhaps you can accomplish your goal that way, or perhaps a minor variation would be more suitable. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: *Advanced* Python book?

2009-01-16 Thread Jean-Claude Arbaut
mk wrote: Hello everyone, I looked for it I swear, but just can't find it. Most Python books seem to focus on examples of how to call functions from standard library. I don't need that, I have online Python documentation for that. IMHO, you don't need an advanced *python* book. If you kno

output problem

2009-01-18 Thread Jean-Paul VALENTIN
Feature? the output of below Hello program he0.py started from command line looks as follows: F:\prompt>he0.py Hello F:\prompt> 'Hello' was sent with sys.stdout.write, so "without newline". But why cannot be output (more logically): F:\prompt>he0.py HelloF:\prompt> Is it normal? Is there any mean

output problem

2009-01-19 Thread Jean-Paul VALENTIN
true, Windows automatically adds a newline after the program output. But maybe there is a workaround? When you launch x.bat containing no char, windows adds a newline after the program output. But when you launch x.bat finishing with at least one CRLF, windows does not add a newline after the progr

Re: wsgi silently swallows errors

2009-01-19 Thread Jean-Paul Calderone
a piece of software. The specification isn't swallowing the error, some piece of software is. What WSGI container are you using? Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: seeking to improve Python skills

2009-01-23 Thread Jean-Paul Calderone
e crazy accident, another exception gets raised, Python will take care of reporting it to the user, and it will do so with far more information - information that will make your job of debugging the problem vastly easier. values = MovingAvg(fname) values.extrfromfile() values.calc_sma(smalen = 10) (reslist, smalist, maxval) = values.return_results() gp = GnuplotWrapper(smalist, maxval) gp.plot() The most significant thing missing from this code is unit tests. Developing automated tests for your code will help you learn a lot. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

Re: seeking to improve Python skills

2009-01-23 Thread Jean-Paul Calderone
On Fri, 23 Jan 2009 16:57:16 +0100, mk wrote: Jean-Paul Calderone wrote: The most significant thing missing from this code is unit tests. Developing automated tests for your code will help you learn a lot. Thanks for all the remarks, I'll restructure my code. Probably the biggest mi

Re: Where to place imports

2009-01-23 Thread Jean-Paul Calderone
ne of them might find it that not everything is defined in the module exists when it tries to use it. What makes you say this? There is an import lock (beyond the GIL) which should prevent a thread from ever seeing a partially initialized module. Jean-Paul -- http://mail.python.org/mailman/lis

Re: Where to place imports

2009-01-23 Thread Jean-Paul Calderone
On Fri, 23 Jan 2009 22:49:34 +0100, Christian Heimes wrote: Jean-Paul Calderone schrieb: BTW, if you ever find you are starting to write multi-threaded applications then you'll really regret it if you reuse code which does imports from inside functions. If two or more threads try to imp

Re: unable to print Unicode characters in Python 3

2009-01-26 Thread Jean-Paul Calderone
ge the code page active in the console (<http://technet.microsoft.com/en-us/library/bb490874.aspx>). I've never tried this myself, though. Jean-Paul -- http://mail.python.org/mailman/listinfo/python-list

<    6   7   8   9   10   11   12   13   14   15   >