Re: Misleading IOerror when opening a non-existent file for append?

2006-11-21 Thread Fredrik Lundh
jkn wrote: > This 'invalid mode: a' error message seems weird to me. Is this a bug > or am I missimg something? It depends on the underlying implementation of fopen(), which, on some platforms, doesn't set the right error code for bad mode strings. Python uses some simple heuristics to try to g

Re: Is time.time() < time.time() always true?

2006-11-21 Thread Fredrik Lundh
Ben Finney wrote: > Really? Where does Python guarantee that the left side *must* be > evaluated before the right side of a comparison? in the language reference: http://docs.python.org/ref/evalorder.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Caution newbie question: python window to stay open ?

2006-11-21 Thread Fredrik Lundh
mkengel wrote: > Problem: Python window closes immediately after executing a *.py file > (e.g. containing a "print..." command. > What do I have to do to keep it open to see the results ? Simple scripts that print to a console, or read from it, works best if you run them from a standard Command

Re: re.match -- not greedy?

2006-11-21 Thread Fredrik Lundh
EXI-Andrews, Jack wrote: > > that's a misunderstanding of what a regular expression is, though: > > conceptually, a RE describes a set of strings, and the RE engine is > > designed to answer the question "does this string belong to this > > set". > if that's so, what is the point of +? and *

Re: Is time.time() < time.time() always true?

2006-11-21 Thread Hendrik van Rooyen
"flamesrock" <[EMAIL PROTECTED]> wrote: 8<-- > since the statement itself > occurs at one time instant.. nothing, but nothing, can occur at one time instant - Hendrik -- http://mail.python.org/mailman/listinfo/python-list

Re: rpncalc-2.5 RPN Calculator for Python

2006-11-21 Thread Hendrik van Rooyen
"John Machin" <[EMAIL PROTECTED]> wrote: > Hendrik van Rooyen wrote: > > "John Machin" <[EMAIL PROTECTED]> WROTE: > > > > > Hendrik van Rooyen wrote: > > > > "Raymond L. Buvel" <[EMAIL PROTECTED]> wrote: > > > > > > > > > > > > > The rpncalc package adds an interactive Reverse Polish Notation (RPN)

re.match -- not greedy?

2006-11-21 Thread EXI-Andrews, Jack
>> I wrote: >> >> import re;re.match('(a+)(ab)','aaab').groups() >>> ('aa', 'ab') >>> >>> this is the sort of behaviour i'd expect from >>>'(a+?)(ab)' >>> >>> a+ should greedily consume a's at the expense of the string >>> not matching > > Fredrick wrote: > that's a misunderstanding of w

Re: Caution newbie question: python window to stay open ?

2006-11-21 Thread BartlebyScrivener
mkengel wrote: > Caution: newbie question If you're pretty sure it's a common newbie question, then begin by going to the Google repository at: http://groups.google.com/group/comp.lang.python Search in the box at upper right, on, say, keep cmd window open, or keep dos window open. Like so: ht

Re: Caution newbie question: python window to stay open ?

2006-11-21 Thread doobiz
mkengel wrote: > Caution: newbie question If you're pretty sure it's a common newbie question, then begin by going to the Google repository at: http://groups.google.com/group/comp.lang.python Search in the box at upper right, on, say, keep cmd window open, or keep dos window open. Like so: h

Re: filling forms automatically generated using javascript

2006-11-21 Thread David Golightly
John wrote: > Is there an automatic way of filling forms that have been generated > using javascript? > I tried to use python+mechanize but am having trouble with javascript > forms. > Yes, it depends on what you're trying to do of course, but usually you just set the input element's "value" prop

Re: Is there a list comprehension for this?

2006-11-21 Thread John Machin
Steven D'Aprano wrote: [snip] > def running_sum(dw): > """Return a list of the running sums of sequence dw""" > rs = [0]*len(dw) > for i in range(len(dw)): > rs[i] = dw[i] + rs[i-1] Please explain to the newbies why there is no exception raised when rs[i-1] is executed for i

filling forms automatically generated using javascript

2006-11-21 Thread John
Is there an automatic way of filling forms that have been generated using javascript? I tried to use python+mechanize but am having trouble with javascript forms. This is the way the form is created: Thanks in advance for your help, --j -- http://mail.python.org/mailman/listinfo/python-lis

Re: Is there a list comprehension for this?

2006-11-21 Thread Steven D'Aprano
On Tue, 21 Nov 2006 13:19:04 -0800, liam_herron wrote: > > Given: > dw = [ 1, -1.1, +1.2 ] > > Suppose I want to create a list 'w' that is defined as > > w[0] = dw[0], > w[1] = w[0] + dw[1], > w[2] = w[1] + dw[2] > > Is there a list comprehension or map expression to do it in one or 2 > lines.

Re: Note about getattr and '.'

2006-11-21 Thread Steven D'Aprano
On Tue, 21 Nov 2006 22:39:09 +0100, Mathias Panzenboeck wrote: > [EMAIL PROTECTED] wrote: >> There is an interesting skewness in python: >> >> class A(object): pass >> > a=A() > setattr(a, '$foo', 17) > getattr(a, '$foo') >> 17 >> >> But I can't write > a.'$foo' >> > > Yes, t

Re: Is time.time() < time.time() always true?

2006-11-21 Thread AndyR
Hi all: >From my experience with os's. Time is updated at intervals- they may be as low as 1mS See . So for that millisecond multiple readings of the time will always return the same result. Therefore time.time() < time.time() will be false for most readings. However the result could be true if

Caution newbie question: python window to stay open ?

2006-11-21 Thread mkengel
Caution: newbie question I am using python 2.4.3-11 on Windows XP. Problem: Python window closes immediately after executing a *.py file (e.g. containing a "print..." command. What do I have to do to keep it open to see the results ? "Interactive window" stays open. Thank you. Michael -- http:

wx.Process.Kill on Win32

2006-11-21 Thread Tom Plunket
Google indicates that wx.Process.Kill hadn't been implemented some time ago in wxPython for Win32. Is that still the case? It's kind of a drag since several sources (including wxPython wiki) strongly advise (by my reading and intended use) using wxProcess over the built-in stuff, but it's not ent

Re: Is time.time() < time.time() always true?

2006-11-21 Thread Noah Rawlins
Ben Finney wrote: > Really? Where does Python guarantee that the left side *must* be > evaluated before the right side of a comparison? (If the right side > were to be evaluated first, the left might end up with a greater > value.) > http://docs.python.org/ref/evalorder.html -- http://mail.pytho

Re: Is time.time() < time.time() always true?

2006-11-21 Thread Ben Finney
Gabriel Genellina <[EMAIL PROTECTED]> writes: > The only thing Python can guarantee, is that the left expression is > evaluated before the right one (5.13 Evaluation order, Language > Reference). Thanks, that answers my question asked elsewhere. -- \ "One thing vampire children have t

Re: Trying to understand Python objects

2006-11-21 Thread Ben Finney
Ben Finney <[EMAIL PROTECTED]> writes: > Or, the attributes are added to a specific instance (often in the > initialisation method) so that each instance has a separate attribute > with the same name:: The example here should have been:: class Point(object): spam = 4 def __in

Re: Trying to understand Python objects

2006-11-21 Thread George Sakkis
James Stroud wrote: > walterbyrd wrote: > > Reading "Think Like a Computer Scientist" I am not sure I understand > > the way it describes the way objects work with Python. > > > > 1) Can attributes can added just anywhere? I create an object called > > point, then I can add attributes any time, an

Re: Is time.time() < time.time() always true?

2006-11-21 Thread Ben Finney
"Delaney, Timothy (Tim)" <[EMAIL PROTECTED]> writes: > So long as the clock on the machine it's running on is not set > backwards between the two calls, you can guarantee that > >time.time() <= time.time() > > will always evaluate true. Really? Where does Python guarantee that the left side *

Re: Vim scripts for editing Python?

2006-11-21 Thread Rainy
Danny Colligan wrote: > On Nov 21, 11:48 am, "Danny Colligan" <[EMAIL PROTECTED]> wrote: > > Rainy wrote: > > > Hi, did anyone make a good set of scripts for editing Python in Vim? I > > > know there is one on vim.org but it isn't very advanced. thx..Here's what > > > google has to say about > >

Re: AVL Balancing

2006-11-21 Thread John Machin
[EMAIL PROTECTED] wrote: > Im working on an AVL tree Is this homework? > that consists of balancing the tree everytime > you add an object. That's a peculiar kind of AVL tree. Normally it is *not* necessary to balance the tree every time a node is added -- it's done only if a constraint is brea

Re: Trying to understand Python objects

2006-11-21 Thread Ben Finney
"walterbyrd" <[EMAIL PROTECTED]> writes: > Reading "Think Like a Computer Scientist" I am not sure I understand > the way it describes the way objects work with Python. Congratulations for taking the effort to figure it out, and for thinking about the questions you want answered. > 1) Can attrib

Re: Trying to understand Python objects

2006-11-21 Thread Robert Kern
Ben Finney wrote: > Or, the attributes are added to a specific instance (often in the > initialisation method) so that each instance has a separate attribute > with the same name:: > > class Point(object): > spam = 4 > def __init__(self): > eggs = 2 There's a typo