Re: reading file to list

2009-01-18 Thread Xah Lee
On Jan 17, 10:25 am, Tino Wildenhain wrote: > > [[int(x) for x in line.split()] for line in open("blob.txt")] Nice (python code). Few comments: • the above code is borderline of atypical. e.g. it is not a average python code would produce or one'd seen in corporate python code. • voodoo like t

Re: tp_base, ob_type, and tp_bases

2009-01-18 Thread Carl Banks
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. Rather, this is a pointer to the new type's > > > > m

Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread andrew cooke
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 example: >>> a = 3 >>> a

Re: dynamic module import?

2009-01-18 Thread James Stroud
Lawson Hanson wrote: So is there any way to get Python to import the named module without just doing "from dummy import *", because I will not know that the user wants to use the "dummy" module until run-time ... I'm trying to import control data for different run scenarios which

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread Chris Rebert
On Sun, Jan 18, 2009 at 2:56 AM, 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

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread andrew cooke
> Therefore, Python requires you to rewrite the code in some other way > that makes your intentions more clear. For instance, why not use the > << operator instead? Right, but you're guessing what the context is. Within a DSL it often makes a lot of sense to use operators for reasons that weren't

Re: Dynamic Loading Modules

2009-01-18 Thread Laszlo Nagy
Riley Porter írta: Hello all, This is the first time I have posted to this group. That being said if I am in the wrong place for this kind of support please let me know. OK, So I am writing a log parsing program and wish to allow for the community to write "parsers". Basically, what I ha

Re: dynamic module import?

2009-01-18 Thread alex23
On Jan 17, 3:55 pm, Steven D'Aprano wrote: > Both very good points, but consider that you're not comparing apples with > apples. > > >>> __import__("os", fromlist=["system"]) > >>> system > Traceback (most recent call last): >   File "", line 1, in > NameError: name 'system' is not defined I mu

Re: what's the point of rpython?

2009-01-18 Thread andrew cooke
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 something like that is obvious. But there's a que

Re: Totally confused by the str/bytes/unicode differences introduced in Pythyon 3.x

2009-01-18 Thread John Machin
On Jan 18, 2:02 pm, Terry Reedy wrote: > John Machin wrote: > > On Jan 18, 9:10 am, Terry Reedy wrote: > >> Martin v. Löwis wrote: > > Does he intend to maintain two separate codebases, one 2.x and the > > other 3.x? > I think I have no other choice. > Why? Is theoretically poss

Am I interacting with the database correctly?

2009-01-18 Thread Hussein B
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 iterate over rows cursor.execute

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread Chris Rebert
On Sun, Jan 18, 2009 at 3:42 AM, andrew cooke wrote: >> Therefore, Python requires you to rewrite the code in some other way >> that makes your intentions more clear. For instance, why not use the >> << operator instead? > > Right, but you're guessing what the context is. Within a DSL it often >

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread andrew cooke
Not sure if you were saying this, but the underlying technical reason for this issue is that they are treated as assignment rather than operators in the language spec - http://docs.python.org/3.0/reference/simple_stmts.html#augmented-assignment-statements I think this explains why they are not li

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread andrew cooke
On Jan 18, 9:01 am, Chris Rebert wrote: > Indeed. Python happens to in this case draw the line at using the > augmented assignment operators for non-assignment. I personally see > this as reasonable because the = symbol has a consistent meaning in > Python (assignment) whereas the other plain oper

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread Marc 'BlackJack' Rintsch
On Sun, 18 Jan 2009 04:24:04 -0800, andrew cooke wrote: > my argument was that *= is not treated as = and *, but as a completely > new operator (the docs even say that the implementation need not return > self which suggests some pretty extreme semantics were envisaged). What do you mean by "sugg

is there something like a module decorator ?

2009-01-18 Thread Stef Mientki
hello, I wonder if there's something like a module decorator. I could use it in debugging a large highly dynamical program. thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread andrew cooke
On Jan 18, 9:40 am, Marc 'BlackJack' Rintsch wrote: > On Sun, 18 Jan 2009 04:24:04 -0800, andrew cooke wrote: > > my argument was that *= is not treated as = and *, but as a completely > > new operator (the docs even say that the implementation need not return > > self which suggests some pretty e

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread andrew cooke
On Jan 18, 9:56 am, andrew cooke wrote: > either i have misundertstood you ah, i see your point. sorry, andrew -- http://mail.python.org/mailman/listinfo/python-list

is there something like a module decorator ?

2009-01-18 Thread Stef Mientki
hello, I wonder if there's something like a module decorator. I could use it in debugging a large highly dynamical program. thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list

Re: is there something like a module decorator ?

2009-01-18 Thread Diez B. Roggisch
Stef Mientki schrieb: hello, I wonder if there's something like a module decorator. I could use it in debugging a large highly dynamical program. No, there isn't. This has been discussed a while ago: http://groups.google.de/group/comp.lang.python/browse_thread/thread/215216a1e13ba2c6 Diez --

Re: is there something like a module decorator ?

2009-01-18 Thread Stef Mientki
Diez B. Roggisch wrote: Stef Mientki schrieb: hello, I wonder if there's something like a module decorator. I could use it in debugging a large highly dynamical program. No, there isn't. This has been discussed a while ago: http://groups.google.de/group/comp.lang.python/browse_thread/thread/

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread andrew cooke
http://bugs.python.org/issue4986 Sorry for the noise, Andrew -- http://mail.python.org/mailman/listinfo/python-list

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread Aaron Brady
On Jan 18, 6:56 am, andrew cooke wrote: > On Jan 18, 9:40 am, Marc 'BlackJack' Rintsch wrote: > > > On Sun, 18 Jan 2009 04:24:04 -0800, andrew cooke wrote: > > > my argument was that *= is not treated as = and *, but as a completely > > > new operator (the docs even say that the implementation ne

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

2009-01-18 Thread Russ P.
Wow! That was an instant classic! I just have a couple of points to add. The suggestion was made (not by you) that data hiding is worthless because it can be defeated anyway. According to that kind of reasoning, locks are worthless because they can be picked, cut, or just blown off. I know that th

Re: what's the point of rpython?

2009-01-18 Thread Matimus
The goals are listed here: http://codespeak.net/pypy/dist/pypy/doc/architecture.html Speed is mentioned, but as a secondary concern. The main goal seems to be to create a vehicle into exploring the concept of dynamic languages themselves. If that seems amorphous then it is because it is a researc

s=ascii(hexlify(urandom(10)))

2009-01-18 Thread gert
I expected that py3 did not converted the b'...' indication too ? b'afc76815e3fc429fa9d7' -- http://mail.python.org/mailman/listinfo/python-list

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

Re: English-like Python

2009-01-18 Thread The Music Guy
Wow, impressive responses. It sounds like the general consensus is that English would not be a good choice for programming even if there were an interpreter capable of turning human language into machine language. But that makes sense; even English professionals have trouble understanding each oth

bin = FieldStorage(fp=environ['wsgi.input'], environ=environ)

2009-01-18 Thread gert
in python3.0 this does not work File "/usr/python/lib/python3.0/email/feedparser.py", line 99, in push data, self._partial = self._partial + data, TypeError: Can't convert 'bytes' object to str implicitly So what do i need to wrap around environ['wsgi.input'] so it does work ? -- http://mail.pyth

Re: PyQt, Cannot send events to objects owned by a different thread?

2009-01-18 Thread icejobjob
AE•X‰ÍŠúA‚»‚ê‚à’´AE•X‰ÍŠú‚ÉŽ„‚½‚¿‚Í’¼–Ê‚µ‚Ä‚¢‚Ü‚· ‚±‚́A'AEŠˆ“®' (http://www.pwblog.com/user/xru01/syusyoku/)‚Í•À‘å’ï‚Ì“w—͂ł͏æ‚èØ‚邱‚Æ‚ª¢“ï‚ÆŒ¾‚í‚ê‚Ä‚¢‚Ü‚·B •葁AƒAƒƒŠƒJ‚̃Tƒuƒvƒ‰ƒCƒ€‚ð”çØ‚è‚Ɉø‚«‹N‚±‚³‚ꂽ¡‰ñ‚Ì•s‹µA‚»‚ꂱ‚»””NŠÔ‚ɂ킽‚Á‚āA¢ŠEŒoÏ‚ɃCƒ“ƒpƒNƒg‚ð—^‚¦‘±‚¯‚é‚Å‚

braces fixed '#{' and '#}'

2009-01-18 Thread v4vijayakumar
I saw some code where someone is really managed to import braces from __future__. ;) def test(): #{ print "hello" #} -- http://mail.python.org/mailman/listinfo/python-list

Re: Relax Syntax for Augmented Arithmetic?

2009-01-18 Thread andrew cooke
Improved link - http://docs.python.org/3.0/reference/datamodel.html#object.__iadd__ -- http://mail.python.org/mailman/listinfo/python-list

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

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

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: 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: 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

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: 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

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: 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: 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: 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: 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

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: 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

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: 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

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: 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

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: 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: 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: 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: 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: 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

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: 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

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: 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: 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: 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: 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: 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: 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 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: 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: 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: 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: 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
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: 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: 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: 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: 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: 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

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: 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:

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: 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: 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: 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: 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: 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: 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: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: 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.

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 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

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: 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: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: 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

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: 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

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
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 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: 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

  1   2   >