Re: Event Handling and Signal-Slot Mechanism

2009-01-18 Thread Steven Woody
On Mon, Jan 19, 2009 at 11:29 AM, James Mills wrote: > On Mon, Jan 19, 2009 at 1:10 PM, Steven Woody wrote: >> Python has Signal-Slot mechanism, why he still need another mechanism >> Event Handling? And, in some cases, it seems only Event Handling >> mechanism is available, for example closeEve

Re: problem in implementing multiprocessing

2009-01-18 Thread James Mills
On Mon, Jan 19, 2009 at 3:50 PM, gopal mishra wrote: > i know this is not an io - bound problem, i am creating heavy objects in the > process and add these objects in to queue and get that object in my main > program using queue. > you can test the this sample code > import time > from multiproces

RE: problem in implementing multiprocessing

2009-01-18 Thread gopal mishra
i know this is not an io - bound problem, i am creating heavy objects in the process and add these objects in to queue and get that object in my main program using queue. you can test the this sample code import time from multiprocessing import Process, Queue class Data(object): def __init__(

Re: Python 3: exec arg 1

2009-01-18 Thread Steven D'Aprano
On Sun, 18 Jan 2009 11:06:10 -0600, Rob Williscroft wrote: > You must have missed the subject line: "Re: Python 3: exec arg 1" Doh! -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread Steven D'Aprano
On Sun, 18 Jan 2009 15:11:46 -0500, Terry Reedy wrote: > andrew cooke wrote: >> Context - >> http://docs.python.org/3.0/reference/datamodel.html?highlight=data >> model#object.__iadd__ >> >> Just a suggestion I thought I'd throw out... There's a restriction in >> the language implementation on e

Re: function argument dependent on another function argument?

2009-01-18 Thread Steven D'Aprano
On Sun, 18 Jan 2009 22:28:04 +, Steven D'Aprano wrote: > Built-ins rarely accept None as a sentinel, slice() being a conspicuous > exception. This is sometimes a nuisance when writing wrappers: > > def my_find(S, sub, start=None, end=None): > """Like string.find() only with pre-processing

Re: Event Handling and Signal-Slot Mechanism

2009-01-18 Thread James Mills
On Mon, Jan 19, 2009 at 1:10 PM, Steven Woody wrote: > Python has Signal-Slot mechanism, why he still need another mechanism > Event Handling? And, in some cases, it seems only Event Handling > mechanism is available, for example closeEvent(). For what case and > for what reason, the python thin

Event Handling and Signal-Slot Mechanism

2009-01-18 Thread Steven Woody
Hi, Python has Signal-Slot mechanism, why he still need another mechanism Event Handling? And, in some cases, it seems only Event Handling mechanism is available, for example closeEvent(). For what case and for what reason, the python think Signal Slot is not enough and will not work? Thanks. -

Re: function argument dependent on another function argument?

2009-01-18 Thread Aaron Brady
On Jan 18, 12:02 pm, Rob Williscroft wrote: > Aaron Brady wrote > innews:582ef883-0176-4984-9521-6c1894636...@a26g2000prf.googlegroups.com > in comp.lang.python: > > > > > On Jan 18, 10:44 am, Rob Williscroft wrote: > >> Aaron Brady wrote > >> innews:6a10378f-addb-4d56-bc1b-0c382b3cb...@t26g2000

Re: function argument dependent on another function argument?

2009-01-18 Thread Aaron Brady
On Jan 18, 12:42 pm, andrew cooke wrote: > >     sentinel = object() > >     ... > > >     def foo(x, y=sentinel): > >       if y is sentinel: > >           y = self.a > > it just struck me you could also do: > >      def foo(self, x, *y_args) >        y = y_args[0] if y_args self.a > > which more

Re: reading file to list

2009-01-18 Thread André Thieme
William James schrieb: André Thieme wrote: You make a very strong case that Lisp is very feeble at processing data. I'm almost convinced. I somehow don’t believe you :-) Ruby isn't feeble, so data like this is fine: shall we begin? or lotus135? 1984 times! The 3 stooges: COBOL,LISP,FORTR

Re: what's the point of rpython?

2009-01-18 Thread Paul Rubin
s...@pobox.com writes: > http://letmegooglethatforyou.com/?q=lock+free+reference+counting I found a paper by Detlefs et al describing a method which is a) patented b) can potentially lock out some threads from ever running, and c) relies on a hardware instruction (double compare and swap) that

Re: How to use *.py modules instead of *.pyc?

2009-01-18 Thread Chris Rebert
On Sun, Jan 18, 2009 at 5:13 PM, wrote: > How to use *.py modules instead of *.pyc or automatically recompile > all modules each time I change *.py files? > Thank you in advance. Also, just for the sake of completeness (since John and I have shown that your real problem lies elsewhere), I happen

Re: How to use *.py modules instead of *.pyc?

2009-01-18 Thread John Machin
On Jan 19, 12:13 pm, dsblizz...@gmail.com wrote: > How to use *.py modules instead of *.pyc or automatically recompile > all modules each time I change *.py files? You don't need to do anything special. If, when you import foo, foo.pyc is outdated by changes to the foo.py that is in the same direc

Re: How to use *.py modules instead of *.pyc?

2009-01-18 Thread Chris Rebert
On Sun, Jan 18, 2009 at 5:13 PM, wrote: > How to use *.py modules instead of *.pyc or automatically recompile > all modules each time I change *.py files? IIRC, you shouldn't need to worry about this. Python checks the modification times on the .py and .pyc files and if the .pyc is older, it reg

How to use *.py modules instead of *.pyc?

2009-01-18 Thread dsblizzard
How to use *.py modules instead of *.pyc or automatically recompile all modules each time I change *.py files? Thank you in advance. -- http://mail.python.org/mailman/listinfo/python-list

Re: tp_base, ob_type, and tp_bases

2009-01-18 Thread Jeff McNeil
On Jan 18, 5:40 am, Carl Banks wrote: > On Jan 17, 8:12 am, Jeff McNeil wrote: > > > > > On Jan 17, 11:09 am, Jeff McNeil wrote: > > > > On Jan 17, 10:50 am, "Martin v. Löwis" wrote: > > > > > > So, the documentation states that ob_type is a pointer to the type's > > > > > type, or metatype. Ra

Re: what's the point of rpython?

2009-01-18 Thread skip
Paul> That's interesting, got a reference? (no pun intended) http://letmegooglethatforyou.com/?q=lock+free+reference+counting -- Skip Montanaro - s...@pobox.com - http://smontanaro.dyndns.org/ -- http://mail.python.org/mailman/listinfo/python-list

Re: changing URLs in webpages, python solutions?

2009-01-18 Thread Simon Forman
On Jan 18, 8:40 am, Stefan Behnel wrote: > Simon Forman wrote: > > I want to take a webpage, find all URLs (links, img src, etc.) and > > rewrite them in-place, and I'd like to do it in python (pure python > > preferred.) > > lxml.html has functions specifically for this problem. > > http://codesp

Re: uninstall before upgrade?

2009-01-18 Thread The Music Guy
On Sun, 2009-01-18 at 10:06 -0800, waltbrad wrote: > I want to upgrade from 2.5 to 2.6. Do I need to uninstall 2.5 before > I do that? If so, what's the best way to uninstall it? Thanks. > -- > http://mail.python.org/mailman/listinfo/python-list I've heard of people having problems trying to rep

uninstall before upgrade?

2009-01-18 Thread waltbrad
I want to upgrade from 2.5 to 2.6. Do I need to uninstall 2.5 before I do that? If so, what's the best way to uninstall it? Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: dynamic module import?

2009-01-18 Thread alex23
On Jan 19, 2:24 am, Duncan Booth wrote: [a nice concise explanation on __import__ & fromlist] Cheers, Duncan, that explained it perfectly. -- http://mail.python.org/mailman/listinfo/python-list

Overriding base class methods in the C API

2009-01-18 Thread Floris Bruynooghe
Hello I've been trying to figure out how to override methods of a class in the C API. For Python code you can just redefine the method in your subclass, but setting tp_methods on the type object does not seem to have any influcence. Anyone know of a trick I am missing? Cheers Floris -- http://m

Re: braces fixed '#{' and '#}'

2009-01-18 Thread Brendan Miller
Yes, I also recently noticed the bug in python's parser that doesn't let it handle squigly braces and the bug in the lexer that makes white space significant. I'm surprised the dev's haven't noticed this yet. On Sat, Jan 17, 2009 at 2:09 AM, v4vijayakumar wrote: > I saw some code where someone is

Re: calling an external program and capturing the output

2009-01-18 Thread Marek Kubica
On Sun, 18 Jan 2009 09:36:59 -0800 (PST) Xah Lee wrote: > See: > > • Making System Calls in Perl and Python > http://xahlee.org/perl-python/system_calls.html You can safely drop the Raw-Strings as they are only needed on Windows when constuction paths and programs with hardcoded paths are rar

Re: what's the point of rpython?

2009-01-18 Thread Paul Rubin
"Brendan Miller" writes: > That's interesting, I hadn't heard the reference counting mechanism > was related to the GIL. Is it just that you need to lock the reference > count before mutating it if there's no GIL? Yes. Someone tried inserting such a lock but it slowed down the single-cpu case u

Re: Can Python manipulate PE structure or bytes?

2009-01-18 Thread Gabriel Genellina
En Sun, 18 Jan 2009 20:18:13 -0200, escribió: I'm interested in Python and wanted to know if Python can manipulate PE structure and bytes. Also what are its limits? If you're talking about the "Portable Executable" file format, yes. Take a look at the struct module, or ctypes.Struct, but tr

Re: Can Python manipulate PE structure or bytes?

2009-01-18 Thread Gabriel Genellina
En Sun, 18 Jan 2009 20:18:13 -0200, escribió: I'm interested in Python and wanted to know if Python can manipulate PE structure and bytes. Also what are its limits? If you're talking about the "Portable Executable" file format, yes. Take a look at the struct module, or ctypes.Struct, but tr

Re: *Advanced* Python book?

2009-01-18 Thread Simon Brunning
2009/1/17 Michele Simionato : > "Expert Python Programming" by Tarek Ziadé is quite good and I wrote > a review for it: > > http://www.artima.com/weblogs/viewpost.jsp?thread=240415 +1 for this. I'm 3/4 of the way through it, it's pretty good. Covers many on the important areas that the more introd

Re: reading file to list

2009-01-18 Thread William James
André Thieme wrote: > Xah Lee schrieb: > > comp.lang.lisp,comp.lang.scheme,comp.lang.functional,comp.lang.pytho > > n,comp.lang.ruby > > > > Here's a interesting toy problem posted by Drew Krause to > > comp.lang.lisp: > > > > > > On Jan 16, 2:29 pm, Drew Krause wrote [p

Re: what's the point of rpython?

2009-01-18 Thread Brendan Miller
On Sat, Jan 17, 2009 at 7:57 PM, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: > alex23 writes: >> Here's an article by Guido talking about the last attempt to remove >> the GIL and the performance issues that arose: >> >> "I'd welcome a set of patches into Py3k *only if* the performance for

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-18 Thread bearophileHUGS
Michele Simionato: > I don't like that. Scala was designed with the idea of putting > together the two worlds, by I think the result was to get the > complications of both worlds. But some other people may like it, and it's a design experiment worth doing. Every programming paradigm has advantage

Re: WSGI question: reading headers before message body has been read

2009-01-18 Thread Diez B. Roggisch
Ron Garret schrieb: On Jan 18, 12:40 pm, "Diez B. Roggisch" wrote: Ron Garret schrieb: On Jan 18, 11:29 am, "Diez B. Roggisch" wrote: Ron Garret schrieb: I'm writing a WSGI application and I would like to check the content- length header before reading the content to make sure that the c

Re: function argument dependent on another function argument?

2009-01-18 Thread Paul Rubin
Steven D'Aprano writes: > Having said that, there are times where you need to pass None as a > legitimate argument and not as a sentinel. I don't think it's worth trying to figure out which those times are. The conclusion can be wrong, or can become wrong later because of some faraway change in

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-18 Thread bearophileHUGS
alex23: > Paul, have you looked into Cython at all? I can also suggest ShedSkin and the D language. I have often used D for data munging, producing quick & short programs, when Python isn't fast enough for a certain purpose. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: function argument dependent on another function argument?

2009-01-18 Thread Steven D'Aprano
On Sun, 18 Jan 2009 07:36:53 -0800, Paul Rubin wrote: > Steven D'Aprano writes: >> def foo(self, x, y=None): >> if y is None: >> y = self.a >> >> I don't find that clumsy in the least. I find it perfectly readable and >> a standard idiom. > > That has the same problem as the earlier

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-18 Thread bearophileHUGS
r: >Of course it would not run in C or Python but the point here is readability.< With languages like Genie you can go close: http://live.gnome.org/Genie Or better Delight (based on the D language), plus some my "Python compatibility" libs (plus Pyd, if you want) you can run that code: http://del

Can Python manipulate PE structure or bytes?

2009-01-18 Thread seaworthyjeremy
I'm interested in Python and wanted to know if Python can manipulate PE structure and bytes. Also what are its limits? -- http://mail.python.org/mailman/listinfo/python-list

Re: WSGI question: reading headers before message body has been read

2009-01-18 Thread Ron Garret
On Jan 18, 1:21 pm, Graham Dumpleton wrote: > On Jan 19, 6:01 am, Ron Garret wrote: > > > I'm writing a WSGI application and I would like to check the content- > > length header before reading the content to make sure that the content > > is not too big in order to prevent denial-of-service attac

Re: WSGI question: reading headers before message body has been read

2009-01-18 Thread Graham Dumpleton
On Jan 19, 6:43 am, Petite Abeille wrote: > On Jan 18, 2009, at 8:01 PM, Ron Garret wrote: > > > def application(environ, start_response): > >    status = "200 OK" > >    headers = [('Content-Type', 'text/html'), ] > >    start_response(status, headers) > >    if int(environ['CONTENT_LENGTH'])>100

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-18 Thread Tim Rowe
2009/1/18 Paul Rubin <"http://phr.cx"@nospam.invalid>: > I.e. the cast was wrong because of the failure of an unstated > assumption that a certain sensor reading was in a certain range. > Spark may still have allowed the cast only if the assumption was > stated explicitly in the specification. Un

Re: WSGI question: reading headers before message body has been read

2009-01-18 Thread Graham Dumpleton
On Jan 19, 6:01 am, Ron Garret wrote: > I'm writing a WSGI application and I would like to check the content- > length header before reading the content to make sure that the content > is not too big in order to prevent denial-of-service attacks.  So I do > something like this: > > def application

Re: WSGI question: reading headers before message body has been read

2009-01-18 Thread Ron Garret
On Jan 18, 12:40 pm, "Diez B. Roggisch" wrote: > Ron Garret schrieb: > > > > > On Jan 18, 11:29 am, "Diez B. Roggisch" wrote: > >> Ron Garret schrieb: > > >>> I'm writing a WSGI application and I would like to check the content- > >>> length header before reading the content to make sure that the

libmsi.a import library from wine, and header files available (entirely free software), available for python-win32 builds under msys+wine

2009-01-18 Thread Luke Kenneth Casson Leighton
as part of building python2.5.2 under msys under wine on linux using mingw, i thought i'd try building _msi.pyd just for kicks. of course, that required having an msi.lib import library, and associated header files. so, purely as an experiment, i've documented the process by which it is possible

Re: WSGI question: reading headers before message body has been read

2009-01-18 Thread Diez B. Roggisch
Ron Garret schrieb: On Jan 18, 11:29 am, "Diez B. Roggisch" wrote: Ron Garret schrieb: I'm writing a WSGI application and I would like to check the content- length header before reading the content to make sure that the content is not too big in order to prevent denial-of-service attacks.

Re: WSGI question: reading headers before message body has been read

2009-01-18 Thread Ron Garret
On Jan 18, 11:43 am, Petite Abeille wrote: > On Jan 18, 2009, at 8:01 PM, Ron Garret wrote: > > > def application(environ, start_response): > >    status = "200 OK" > >    headers = [('Content-Type', 'text/html'), ] > >    start_response(status, headers) > >    if int(environ['CONTENT_LENGTH'])>10

Re: Python and threads

2009-01-18 Thread Stefan Behnel
vedrandeko...@yahoo.com wrote: > and thanks for all previous help.I want to measure memory usage of > executed python script.I'am working on windows XP. Could you qualify "measure"? Do you mean: a) "debug" (permanently high accuracy, potentially high runtime overhead) b) "monitor" (high accuracy,

Re: WSGI question: reading headers before message body has been read

2009-01-18 Thread Ron Garret
On Jan 18, 11:29 am, "Diez B. Roggisch" wrote: > Ron Garret schrieb: > > > > > I'm writing a WSGI application and I would like to check the content- > > length header before reading the content to make sure that the content > > is not too big in order to prevent denial-of-service attacks.  So I do

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread Terry Reedy
andrew cooke wrote: Context - http://docs.python.org/3.0/reference/datamodel.html?highlight=data model#object.__iadd__ Just a suggestion I thought I'd throw out... There's a restriction in the language implementation on exactly what can go the left of an augmented arithmetic expression. For ex

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-18 Thread Russ P.
On Jan 18, 9:22 am, Bruno Desthuilliers wrote: > Properties by themselves are not the problem, quite on the contrary - as > you say, they actually help wrt/ encapsulation. What breaks > encapsulation is *automatic generation* for properties for *each and > any* implementation attribute. Might as

Re: WSGI question: reading headers before message body has been read

2009-01-18 Thread Petite Abeille
On Jan 18, 2009, at 8:01 PM, Ron Garret wrote: def application(environ, start_response): status = "200 OK" headers = [('Content-Type', 'text/html'), ] start_response(status, headers) if int(environ['CONTENT_LENGTH'])>1000: return 'File too big' How would that work for chunked tran

Re: WSGI question: reading headers before message body has been read

2009-01-18 Thread Diez B. Roggisch
Ron Garret schrieb: I'm writing a WSGI application and I would like to check the content- length header before reading the content to make sure that the content is not too big in order to prevent denial-of-service attacks. So I do something like this: def application(environ, start_response):

Re: Python and threads

2009-01-18 Thread vedrandekovic
On 18 sij, 17:48, "Diez B. Roggisch" wrote: > vedrandeko...@yahoo.com schrieb: > > > > > Hello again, > > > Thanks for previous help on "Start two threads in same time" it was > > useful,but when I run this > > two threads, I think they don't start at the same time, here is my > > code snippet: >

Re: pep 8 constants

2009-01-18 Thread MRAB
Francesco Bochicchio wrote: On Wed, 14 Jan 2009 08:13:30 +, Steven D'Aprano wrote: Absolutely. It's rather sad that I can do this: import math math.pi = 3.0 I like the ability to shoot myself in the foot, thank you very much, but I should at least get a warning when I'm about to do so:

WSGI question: reading headers before message body has been read

2009-01-18 Thread Ron Garret
I'm writing a WSGI application and I would like to check the content- length header before reading the content to make sure that the content is not too big in order to prevent denial-of-service attacks. So I do something like this: def application(environ, start_response): status = "200 OK"

Re: function argument dependent on another function argument?

2009-01-18 Thread andrew cooke
>     sentinel = object() >     ... > >     def foo(x, y=sentinel): >       if y is sentinel: >           y = self.a it just struck me you could also do: def foo(self, x, *y_args) y = y_args[0] if y_args self.a which more directly checks whether an argument was passed, but has the do

Re: calling an external program and capturing the output

2009-01-18 Thread Eric
Thanks guys. That helped point me int he right direction. with your advice on the subprocess module I stumbled upon this posting: http://www.velocityreviews.com/forums/t359866-subprocess-module.html for anyone else that might be interested here is the solution. It simply calls a perl script call

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-18 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : On Sat, 17 Jan 2009 20:49:38 +0100, Bruno Desthuilliers wrote: Russ P. a écrit : (snip) Why leave to coding standards and company policy what can be encoded right into the language? Because human are smarter than computers. That's an awfully naive statement. It

Re: pep 8 constants

2009-01-18 Thread Francesco Bochicchio
On Wed, 14 Jan 2009 08:13:30 +, Steven D'Aprano wrote: > > Absolutely. It's rather sad that I can do this: > > import math > math.pi = 3.0 > > I like the ability to shoot myself in the foot, thank you very much, but > I should at least get a warning when I'm about to do so: > > math.PI =

Re: uninstall before upgrade?

2009-01-18 Thread Diez B. Roggisch
waltbrad schrieb: I want to upgrade from 2.5 to 2.6. Do I need to uninstall 2.5 before I do that? If so, what's the best way to uninstall it? Thanks. No, several versions of python can live happily together. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: import urllib2 fails with Python 2.6.1 on Vista

2009-01-18 Thread Scott MacDonald
Ah yes, with your help I seem to have solved my own problem. I had PYTHONPATH defined to point to the 2.5 directory. Thanks! Scott On Sun, Jan 18, 2009 at 11:01 AM, Scott MacDonald < scott.p.macdon...@gmail.com> wrote: > Yes, I see your point. Not sure how that would happen. It is possible to

Re: function argument dependent on another function argument?

2009-01-18 Thread Rob Williscroft
Aaron Brady wrote in news:582ef883-0176-4984-9521-6c1894636...@a26g2000prf.googlegroups.com in comp.lang.python: > On Jan 18, 10:44 am, Rob Williscroft wrote: >> Aaron Brady wrote >> innews:6a10378f-addb-4d56-bc1b-0c382b3cb...@t26g2000prh > .googlegroups.com >> in comp.lang.python: >> >> > It

Re: import urllib2 fails with Python 2.6.1 on Vista

2009-01-18 Thread Scott MacDonald
Yes, I see your point. Not sure how that would happen. It is possible to have multiple versions of python on the same machine I assume? During the installation I have specified the directory to install python in, otherwise I have not changed anything. Could it be an environment variable or some

Re: calling an external program and capturing the output

2009-01-18 Thread Xah Lee
On Jan 18, 8:41 am, Eric wrote: > Coming from a perl background I'm new to the Python world. I need to > read a list of values, send each value to an external program and > capture and act on the output of that program. Reading and parsing the > initial values is not a problem but I can't seem to

Re: Python 3: exec arg 1

2009-01-18 Thread Rob Williscroft
Steven D'Aprano wrote in news:018342f9$0$8693$c3e8...@news.astraweb.com in comp.lang.python: > I'm not sure if this is a stupid question or not, but what's a > TextIOWrapper? In the example you give: > > exec(open(fname)) > > the argument to exec -- open(fname) -- is a file object: > typ

Re: function argument dependent on another function argument?

2009-01-18 Thread Aaron Brady
On Jan 18, 10:44 am, Rob Williscroft wrote: > Aaron Brady wrote > innews:6a10378f-addb-4d56-bc1b-0c382b3cb...@t26g2000prh.googlegroups.com > in comp.lang.python: > > > > > On Jan 18, 9:36 am, Paul Rubin wrote: > >> Steven D'Aprano writes: > >> > def foo(self, x, y=

Re: Am I interacting with the database correctly?

2009-01-18 Thread Gabriel Genellina
En Sun, 18 Jan 2009 13:54:06 -0200, John Fabiani escribió: I have never worked with MySQL. I do work with others. The first part looks fine. If you insert, update or delete then you need a 'commit' or a 'rollback'. Preparing data for a report it is unlikely that you need to commit or r

Re: Am I interacting with the database correctly?

2009-01-18 Thread Gabriel Genellina
En Sun, 18 Jan 2009 13:54:06 -0200, John Fabiani escribió: I have never worked with MySQL. I do work with others. The first part looks fine. If you insert, update or delete then you need a 'commit' or a 'rollback'. Preparing data for a report it is unlikely that you need to commit or r

Re: function argument dependent on another function argument?

2009-01-18 Thread Rob Williscroft
Aaron Brady wrote in news:6a10378f-addb-4d56-bc1b-0c382b3cb...@t26g2000prh.googlegroups.com in comp.lang.python: > On Jan 18, 9:36 am, Paul Rubin wrote: >> Steven D'Aprano writes: >> > def foo(self, x, y=None): >> >     if y is None: >> >         y = self.a >> >> >

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-18 Thread Bruno Desthuilliers
Russ P. a écrit : On Jan 17, 11:49 am, Bruno Desthuilliers wrote: Please educate yourself and learn about why Ariane 5 crashed on it's first flight, due to an error in a module written in ADA (which is such a psychorigid language that C++ and Java are even looser than Javascript in comparison)

Re: calling an external program and capturing the output

2009-01-18 Thread Diez B. Roggisch
Eric schrieb: Coming from a perl background I'm new to the Python world. I need to read a list of values, send each value to an external program and capture and act on the output of that program. Reading and parsing the initial values is not a problem but I can't seem to find anything on the sen

Re: Python and threads

2009-01-18 Thread Diez B. Roggisch
vedrandeko...@yahoo.com schrieb: Hello again, Thanks for previous help on "Start two threads in same time" it was useful,but when I run this two threads, I think they don't start at the same time, here is my code snippet: import threading class ThreadedClass1(threading.Thread): def __init

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-18 Thread Bruno Desthuilliers
Russ P. a écrit : No one ever claimed that a programming language, no matter how rigorous, can eliminate all bugs. All a language can do is to reduce their rate of occurrence. The Ariane fiasco was not a failure of Ada per se but rather a failure of people using Ada. Almost right. They atte

Re: Ordering attributes for dynamically generated class

2009-01-18 Thread Duncan Booth
Aaron Brady wrote: > On Jan 18, 9:52 am, David Pratt wrote: >> Hi list. I use 'type' to generate classes but have a need to order   >> the attributes for the generated class. Of course a dict is not going   >> to maintain ordering. Is there any way to dynamically generate a   >> class with attri

Re: Python and threads

2009-01-18 Thread Stefan Behnel
vedrandeko...@yahoo.com wrote: > Thanks for previous help on "Start two threads in same time" it was > useful,but when I run this > two threads, I think they don't start at the same time That's normal. Threading is an unpredictable concurrency pattern. Things often don't happen the way one would w

calling an external program and capturing the output

2009-01-18 Thread Eric
Coming from a perl background I'm new to the Python world. I need to read a list of values, send each value to an external program and capture and act on the output of that program. Reading and parsing the initial values is not a problem but I can't seem to find anything on the sending to and cap

Re: changing URLs in webpages, python solutions?

2009-01-18 Thread Stefan Behnel
Simon Forman wrote: > I want to take a webpage, find all URLs (links, img src, etc.) and > rewrite them in-place, and I'd like to do it in python (pure python > preferred.) lxml.html has functions specifically for this problem. http://codespeak.net/lxml/lxmlhtml.html#working-with-links Code woul

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-18 Thread Paul Rubin
Bruno Desthuilliers writes: > As I already stated, no technology can protect us from this kind of > error. Ask yourself why this module was reused as-is, instead of going > thru the whole specs / tests / QA process again, and *perhaps* you'll > start to understand why I say that language-enforced

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-18 Thread Paul Rubin
"Russ P." writes: > I don't know which variant of Ada was used here, but something called > the "Ravenscar Profile" is a reduced subset of Ada that might have > prevented this error (though I haven't verified this). Then there is > Spark Ada, which supposed to be much safer than even Ada. I'm not

Re: Ordering attributes for dynamically generated class

2009-01-18 Thread David Pratt
Hi Aaron. Yeah, definitely sounds like a possibility. I was able to locate an ordered dict implementation that subclasses dict. This might work fine. Might be able to pass into type method directly since I think that dict passed into type is setting __dict__ I believe. Let you know if tha

Re: dynamic module import?

2009-01-18 Thread Duncan Booth
alex23 wrote: > I must confess I've rarely had a need to use __import__ and don't > think I've ever used the fromlist arg. I'm confused, though, because > the docstring states: > > The fromlist should be a list of names to emulate ``from name > import ...'' > > But it also states that __import

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-18 Thread Bruno Desthuilliers
Russ P. a écrit : On Jan 17, 1:43 pm, Paul Rubin wrote: Bruno Desthuilliers writes: Once again, there's quite a lot to learn from the story of Ariane 5. Do you know what actually happened with Ariane 5? The failure was because "smart" humans overrode the langua

Re: process command line parameter

2009-01-18 Thread Thorsten Kampe
* asit (Sat, 17 Jan 2009 13:28:12 -0800 (PST)) > Recently I was coding a link extractor. It's a command line stuff and > takes parameter as argument. > I found that the in operator is not always helpful. > eg. if "--all" in sys.argv: >print "all links will be printed" > > its not helpf

Python and threads

2009-01-18 Thread vedrandekovic
Hello again, Thanks for previous help on "Start two threads in same time" it was useful,but when I run this two threads, I think they don't start at the same time, here is my code snippet: import threading class ThreadedClass1(threading.Thread): def __init__(self): threading.Thread.

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-18 Thread Bruno Desthuilliers
Paul Rubin a écrit : Bruno Desthuilliers writes: Once again, there's quite a lot to learn from the story of Ariane 5. Do you know what actually happened with Ariane 5? *yes I do* - else I wouldn't mention it. Thanks. The failure was because "smart" humans overrode the language enforced p

Re: Ordering attributes for dynamically generated class

2009-01-18 Thread Aaron Brady
On Jan 18, 9:52 am, David Pratt wrote: > Hi list. I use 'type' to generate classes but have a need to order   > the attributes for the generated class. Of course a dict is not going   > to maintain ordering. Is there any way to dynamically generate a   > class with attributes in specific order? >

Re: Am I interacting with the database correctly?

2009-01-18 Thread John Fabiani
Hussein B wrote: > Hey, > I'm new with database interactions in Python and I'm not sure if I'm > handling the cursor and transactions correctly: > > cursor = db.cursor(MySQLdb.cursors.DictCursor) > cursor.execute(flate_rate_pkgs_sql) > rows = cursor.fetchall() > #I have for loop here to i

Ordering attributes for dynamically generated class

2009-01-18 Thread David Pratt
Hi list. I use 'type' to generate classes but have a need to order the attributes for the generated class. Of course a dict is not going to maintain ordering. Is there any way to dynamically generate a class with attributes in specific order? my_new_class = type( 'MyNewClass', tuple_of_base

Re: function argument dependent on another function argument?

2009-01-18 Thread Aaron Brady
On Jan 18, 9:36 am, Paul Rubin wrote: > Steven D'Aprano writes: > > def foo(self, x, y=None): > >     if y is None: > >         y = self.a > > > I don't find that clumsy in the least. I find it perfectly readable and a > > standard idiom. > > That has the same proble

Re: what's the point of rpython?

2009-01-18 Thread Luis M . González
On Jan 18, 8:56 am, andrew cooke wrote: > Since this is a PyPy bashing thread, maybe it's an appropriate place > to suggest that the project has got a little bit waylaid by exploring > cool things instead of releasing a useful final result? > > I am not questioning rpython directly - the case for

Re: Difference between Python 2.2.2 and Python 2.5

2009-01-18 Thread Steven D'Aprano
On Sun, 18 Jan 2009 07:30:52 -0800, Ravi wrote: > I am developing for PyS60 1.4.4 which supports Python 2.2.2 while what I > know is Python 2.5 . > > Can you please tell me differences between the two so that I can save > myself from incompatible code. Everything new mentioned here: http://www

Re: output problem

2009-01-18 Thread 7stud
On Jan 16, 8:24 am, "Jean-Paul VALENTIN" wrote: > 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): >

Re: function argument dependent on another function argument?

2009-01-18 Thread Paul Rubin
Steven D'Aprano writes: > def foo(self, x, y=None): > if y is None: > y = self.a > > I don't find that clumsy in the least. I find it perfectly readable and a > standard idiom. That has the same problem as the earlier version. If the person passes None, they get self.a. I prefer:

Re: Python 3: exec arg 1

2009-01-18 Thread Steven D'Aprano
On Sun, 18 Jan 2009 14:36:15 +, Alan G Isaac wrote: > Well, that does not really answer my question, imo. I do not much care > about the disappearance of ``execfile``. I was asking, why is it a > **good thing** that ``exec`` does not accept a TextIOWrapper? I'm not sure if this is a stupid

Difference between Python 2.2.2 and Python 2.5

2009-01-18 Thread Ravi
I am developing for PyS60 1.4.4 which supports Python 2.2.2 while what I know is Python 2.5 . Can you please tell me differences between the two so that I can save myself from incompatible code. -- http://mail.python.org/mailman/listinfo/python-list

Re: function argument dependent on another function argument?

2009-01-18 Thread Steven D'Aprano
On Sun, 18 Jan 2009 06:19:03 -0800, Reckoner wrote: > I would like to do: > > def foo(self,x,y=self.a) > > where the default value for y=self.a. Since this is not possible, I wind > up doing > > > def foo(self,x,y=None) > if not y: > y=self.a > > but that seems kind of clumsy. It's al

Re: function argument dependent on another function argument?

2009-01-18 Thread Aaron Brady
On Jan 18, 8:19 am, Reckoner wrote: > I  would like to do: > > def foo(self,x,y=self.a) > > where the default value for y=self.a. Since this is not possible, I > wind up doing > > def foo(self,x,y=None) >   if not y: >     y=self.a > > but that seems kind of clumsy. > > Is there a better way to do

Re: Python 3: exec arg 1

2009-01-18 Thread Alan G Isaac
Alan G Isaac wrote: Is it intentional that ``exec`` cannot handle a TextIOWrapper? Bottom line: has ``execfile(filename)`` really become ``exec(open(filename).read())``? Is this a good thing? On 1/17/2009 4:20 PM Terry Reedy apparently wrote: Yes. Yes. Alan G Isaac wrote: OK. Why? O

Re: output problem

2009-01-18 Thread Pierre Bourdon
IIRC, Windows automatically add a newline after the program output. On Fri, Jan 16, 2009 at 4:24 PM, Jean-Paul VALENTIN wrote: > 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.st

function argument dependent on another function argument?

2009-01-18 Thread Reckoner
I would like to do: def foo(self,x,y=self.a) where the default value for y=self.a. Since this is not possible, I wind up doing def foo(self,x,y=None) if not y: y=self.a but that seems kind of clumsy. Is there a better way to do this? Thanks in advance -- http://mail.python.org/mailma

  1   2   >