Re: Attributes and built-in types

2005-04-01 Thread "Martin v. Löwis"
Dave Opstad wrote: Is it just an implementation limitation that attributes cannot be assigned to instances of internal types? No, not "just". Some types have a fixed set of attributes by design, whereas others allow addition of attributes. There are several reasons for this design. Performance is

Re: Grouping code by indentation - feature or ******?

2005-04-01 Thread Javier Bezos
"Steve Holden" <[EMAIL PROTECTED]> escribió en el mensaje news:[EMAIL PROTECTED] [Discussion on Python slices and the off-by-one issue deleted] > While this may be an interesting philosophical (or should that be > philological) discussion, since Python has worked this way for donkey's > year

Re: Simple thread-safe counter?

2005-04-01 Thread Artie Gold
Skip Montanaro wrote: Paul> I'd like to have a function (or other callable object) that Paul> returns 0, 1, 2, etc. on repeated calls. ... Paul> There should never be any possibility of any number getting Paul> returned twice, or getting skipped over, even if f is being called

Re: Queue.Queue-like class without the busy-wait

2005-04-01 Thread Paul Rubin
Nick Craig-Wood <[EMAIL PROTECTED]> writes: > I believe futex is the thing you want for a modern linux. Not > very portable though. That's really cool, but I don't see how it can be a pure userspace operation if the futex has a timeout. The kernel must need to keep track of the timeouts. Howeve

Re: How To Do It Faster?!?

2005-04-01 Thread Simo Melenius
[EMAIL PROTECTED] writes: > Every user of thsi big directory works on big studies regarding oil > fields. Knowing the amount of data (and number of files) we have to > deal with (produced by simulators, visualization tools, and so on) > and knowing that users are usually lazy in doing clean up of

Re: Translation review?

2005-04-01 Thread Michele Simionato
This is spectacular! :) Is there a way to make it to work from environments (such as emacs) where stdin is special? Michele Simionato -- http://mail.python.org/mailman/listinfo/python-list

Re: Installing Python on a Windows 2000 Server

2005-04-01 Thread Steve Holden
Mike Moum wrote: Hi, I'm a civil engineer who also doubles as chief programmer for technical applications at my company. Most of our software is written in Visual Basic because our VP in charge of I.T. likes to have "consistency", and at the moment we're a Microsoft shop. He has assigned me the

Re: that is it is not it (logic in Python)

2005-04-01 Thread Steve Holden
F. Petitjean wrote: [...] *I* wrote the original post. and am pretty sure it is not faked. And I run it before posting to be sure not to say anything wrong. it is a kind of relief to learn that computers in 2005 (even Python powered) are humor-impaired and follow the « ref manual » every time even

Re: Queue.Queue-like class without the busy-wait

2005-04-01 Thread Nick Craig-Wood
Paul Rubin wrote: > Antoon Pardon <[EMAIL PROTECTED]> writes: > > I'm not sure that this would be an acceptable approach. I did the man > > semop and it indicates this is part of system V IPC. This makes me > > fear that semaphores will use file descriptors or other resources > > that are only av

Re: Lambda: the Ultimate Design Flaw

2005-04-01 Thread Steve Holden
alex goldman wrote: Daniel Silva wrote: At any rate, FOLD must fold. I personally think GOTO was unduly criticized by Dijkstra. With the benefit of hindsight, we can see that giving up GOTO in favor of other primitives failed to solve the decades-old software crisis. What software crisis? Knuth (

Re: Lambda: the Ultimate Design Flaw

2005-04-01 Thread Steve Holden
Aahz wrote: In article <[EMAIL PROTECTED]>, =?iso-8859-1?Q?Fran=E7ois?= Pinard <[EMAIL PROTECTED]> wrote: [Sunnan] [...] for Pythons ideal of having one canonical, explicit way to program. No doubt it once was true, but I guess this ideal has been abandoned a few years ago. My honest feeling is th

Re: Simple thread-safe counter?

2005-04-01 Thread Paul Rubin
Tim Peters <[EMAIL PROTECTED]> writes: > The GIL is your friend here: > > import itertools > f = itertools.count().next Thanks, I was hoping something like this would work but was not sure I could rely on it. > A similar thing can be done with xrange. But either way sucks if you > call

Re: Simple thread-safe counter?

2005-04-01 Thread Skip Montanaro
Paul> I'd like to have a function (or other callable object) that Paul> returns 0, 1, 2, etc. on repeated calls. ... Paul> There should never be any possibility of any number getting Paul> returned twice, or getting skipped over, even if f is being called Paul> from multipl

Re: property and virtuality

2005-04-01 Thread Michele Simionato
Diez B. Roggisch: > On second thoughts, a metaclass _might_ help here - but it would be rather > elaborate: look in the baseclasses for properties that have getters and > setters of the same name as some methods in the current class, and replace > them, or create a new property with them (I'm not

Re: Simple thread-safe counter?

2005-04-01 Thread Tim Peters
[Paul Rubin] > I'd like to have a function (or other callable object) that returns > 0, 1, 2, etc. on repeated calls. That is: > >print f() # prints 0 >print f() # prints 1 >print f() # prints 2 ># etc. > > There should never be any possibility of any number getting returned

Re: New to programming question

2005-04-01 Thread Joal Heagney
Joal Heagney wrote: Steve Holden wrote: I suppose this would be far too easy to understand, then: pr =['Guess my name', 'Wrong, try again', 'Last chance'] for p in pr: name = raw_input(p+": ") if name == "Ben": print "You're right!" break else: print "Loser: no more tries for you" reg

Re: Lambda: the Ultimate Design Flaw

2005-04-01 Thread François Pinard
[Aahz] > =?iso-8859-1?Q?Fran=E7ois?= Pinard <[EMAIL PROTECTED]> wrote: > >No doubt it once was true, but I guess this ideal has been > >abandoned a few years ago. My honest feeling is that it would be a > >mis-representation of Python, assertng today that this is still one > >of the Python's ide

Simple thread-safe counter?

2005-04-01 Thread Paul Rubin
I'd like to have a function (or other callable object) that returns 0, 1, 2, etc. on repeated calls. That is: print f() # prints 0 print f() # prints 1 print f() # prints 2 # etc. There should never be any possibility of any number getting returned twice, or getting skipped

Re: boring the reader to death (wasRe: Lambda: the Ultimate Design Flaw

2005-04-01 Thread Tim Peters
[Aahz] >> "The joy of coding Python should be in seeing short, concise, readable >> classes that express a lot of action in a small amount of clear code -- >> not in reams of trivial code that bores the reader to death." --GvR [Sunnan] > Can anyone please point me to the text that quote was taken

Re: Queue.Queue-like class without the busy-wait

2005-04-01 Thread Paul Rubin
Have you looked at this? A paper about adding asynchronous exceptions to Python. http://www.cs.williams.edu/~freund/papers/02-lwl2.ps -- http://mail.python.org/mailman/listinfo/python-list

Re: Python plug-in Frameworks like Eclipse RCP...

2005-04-01 Thread Jim Hargrave
Hum, maybe my question was too specific. What I would really like to know is what is the best way to implement a Python application with a pluggable architecture. In particular, I would like to use wxPython and have plug ins automatically register themselves with the GUI by adding themselves to

Re: New to programming question

2005-04-01 Thread Joal Heagney
Steve Holden wrote: Joal Heagney wrote: Bengt Richter wrote: On Fri, 01 Apr 2005 07:46:41 GMT, Joal Heagney <[EMAIL PROTECTED]> wrote: Oh goddammmni. I seem to be doing this a lot today. Look below for the extra addition to the code I posted. Joal Heagney wrote: Here's my contribution anyc

Re: New to programming question

2005-04-01 Thread Ben
Joal was right. It is a bit beyond me. But I appreciate your response. -- http://mail.python.org/mailman/listinfo/python-list

Re: New to programming question

2005-04-01 Thread Ben
Thanks for your reply. -- http://mail.python.org/mailman/listinfo/python-list

Re: New to programming question

2005-04-01 Thread Ben
Thanks for your input. -- http://mail.python.org/mailman/listinfo/python-list

Re: New to programming question

2005-04-01 Thread Ben
Thanks for your help. It is much appreciated. -- http://mail.python.org/mailman/listinfo/python-list

Re: [Newbie] Search-and-delete text processing problem...

2005-04-01 Thread Bengt Richter
On Fri, 1 Apr 2005 17:33:59 -0800, "Todd_Calhoun" <[EMAIL PROTECTED]> wrote: >I'm trying to learn about text processing in Python, and I'm trying to >tackle what should be a simple task. > >I have long text files of books with a citation between each paragraph, Most text files aren't long enough

Re: Pseudocode in the wikipedia

2005-04-01 Thread Sunnan
James Stroud wrote: bob == (carol = 2): if bob = (bob or carol): bob == 4 But no one could figure out what bob was supposed to equal anyway. Wouldn't bob equal the boolean result of the expression (carol = 2)? -- http://mail.python.org/mailman/listinfo/python-list

Re: Ternary Operator in Python

2005-04-01 Thread Robert Kern
Sunnan wrote: Terry Reedy wrote: Gee, what about 0.0 < a < 1.0 < b < 2.0? I see both as synthesized multinary operators, but your are right in that this combination does act differently than a+b+c. Is < really multinary in python? It looks binary to me, just like +. (a+b)+c (((0.0 < a) < 1.0) <

Re: Ternary Operator in Python

2005-04-01 Thread Sunnan
Terry Reedy wrote: Gee, what about 0.0 < a < 1.0 < b < 2.0? I see both as synthesized multinary operators, but your are right in that this combination does act differently than a+b+c. Is < really multinary in python? It looks binary to me, just like +. (a+b)+c (((0.0 < a) < 1.0) < b ) < 2.0 Sunn

boring the reader to death (wasRe: Lambda: the Ultimate Design Flaw

2005-04-01 Thread Sunnan
Aahz wrote: "The joy of coding Python should be in seeing short, concise, readable classes that express a lot of action in a small amount of clear code -- not in reams of trivial code that bores the reader to death." --GvR Can anyone please point me to the text that quote was taken from? I tried

Re: Search-and-delete text processing problem...

2005-04-01 Thread M.E.Farmer
My apologies you did indeed use writelines correctly ;) dohhh! I had a gut reaction to this. Py>f = ['hij\n','efg\n','abc\n'] Py> for i in f: ... if i.startswith('a'): ... i == '' Py> f ['hij\n', 'efg\n', 'abc\n'] Notice that it does not modify the list in any way. You are trying to loo

Re: Lambda: the Ultimate Design Flaw

2005-04-01 Thread Bengt Richter
On 1 Apr 2005 20:00:13 -0500, [EMAIL PROTECTED] (Aahz) wrote: >In article <[EMAIL PROTECTED]>, >=?iso-8859-1?Q?Fran=E7ois?= Pinard <[EMAIL PROTECTED]> wrote: >>[Sunnan] >>> >>> [...] for Pythons ideal of having one canonical, explicit way to >>> program. >> >>No doubt it once was true, but I gues

(win32) speedfan api control

2005-04-01 Thread tlviewer
hello, If you run the Mainboard monitor, speedfan, here is an ActivePython script to force automatic fan control. http://www.almico.com/speedfan.php It's a great example of how clean the WinApi interface is in ActivePython. The script sets focus to the checkbox of interest and toggles the

Module subprocess: How to "communicate" more than once?

2005-04-01 Thread Edward C. Jones
I have a program named "octave" (a Matlab clone). It runs in a terminal, types a prompt and waits for the user to type something. If I try # Run octave. oct = subprocess.Popen("octave", stdin=subprocess.PIPE) # Run an octave called "startup". oct.communicate("startup") # Change directory inside o

Re: Search-and-delete text processing problem...

2005-04-01 Thread M.E.Farmer
Strings have many methods that are worth learning. If you haven't already discovered dir(str) try it. Also I am not sure if you were just typing in some pseudocode, but your use of writelines is incorrect. help(file.writelines) Help on built-in function writelines: writelines(...) writelines(s

Re: Decorater inside a function? Is there a way?

2005-04-01 Thread Ron_Adam
On Fri, 01 Apr 2005 16:46:14 -0500, Jeremy Bowers <[EMAIL PROTECTED]> wrote: >On Fri, 01 Apr 2005 19:56:55 +, Ron_Adam wrote: > >> On Fri, 01 Apr 2005 13:47:06 -0500, Jeremy Bowers <[EMAIL PROTECTED]> >> wrote: >>>Is this an April Fools gag? If so, it's not a very good one as it's quite >>>in

Re: Case-insensitive dict, non-destructive, fast, anyone?

2005-04-01 Thread Terry Reedy
"Raymond Hettinger" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > More important than the percentage is the clarity of the resulting code > and the > avoidance of continous reinvention of workarounds. > > Separating tool features into a basic and an advanced version is common >

Installing Python on a Windows 2000 Server

2005-04-01 Thread Mike Moum
Hi, I'm a civil engineer who also doubles as chief programmer for technical applications at my company. Most of our software is written in Visual Basic because our VP in charge of I.T. likes to have "consistency", and at the moment we're a Microsoft shop. He has assigned me the task of developi

FAM and Python? (was Re: How To Do It Faster?!?)

2005-04-01 Thread Jeremy Bowers
On Sat, 02 Apr 2005 02:02:31 +0200, andrea_gavana wrote: > Hello Jeremy & NG, > Every user of thsi big directory works on big studies regarding oil fields. > Knowing the amount of data (and number of files) we have to deal with > (produced > by simulators, visualization tools, and so on) and know

Re: Search-and-delete text processing problem...

2005-04-01 Thread lostboard2001
Close: > if line[:4] == 'Bill': . ^^ > line == ' ' > -- http://mail.python.org/mailman/listinfo/python-list

Re: Ternary Operator in Python

2005-04-01 Thread gene . tani
The good ol' DiveInto says: http://diveintopython.org/power_of_introspection/and_or.html#d0e9975 http://aspn.activestate.com/ASPN/Python/Cookbook/Recipe/52310 Diez B. Roggisch wrote: > praba kar wrote: > > > Dear All, > > I am new to Python. I want to know how to > > work with ternary opera

Re: Lambda: the Ultimate Design Flaw

2005-04-01 Thread Tom Breton
Daniel Silva <[EMAIL PROTECTED]> writes: [...] > So now FOLD. This is actually the one we've always hated most, > because, apart from a few examples involving + or *, almost every time > we see a FOLD call with a non-trivial function argument, we have to > grab pen and paper and imagine the *res

[Newbie] Search-and-delete text processing problem...

2005-04-01 Thread Todd_Calhoun
I'm trying to learn about text processing in Python, and I'm trying to tackle what should be a simple task. I have long text files of books with a citation between each paragraph, which might be like "Bill D. Smith, History through the Ages, p.5". So, I need to search for every line that starts

Re: unittest vs py.test?

2005-04-01 Thread Roy Smith
In article <[EMAIL PROTECTED]>, Peter Hansen <[EMAIL PROTECTED]> wrote: > As for Roy's comments: I use a small internally > developed driver script which uses os.walk to find > all the files matching tests/*_unit.py or tests/story*.py > in all subfolders of the project, and which runs them > in s

Re: Ternary Operator in Python

2005-04-01 Thread Carl Banks
Terry Reedy wrote: > "Carl Banks" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >> A unary operator has one operand; a binary operator has two operands; > >> ternary operator has three operands. Python has none built-in, > > > > Not so fast, my friend. What about the expression

Re: Lambda: the Ultimate Design Flaw

2005-04-01 Thread Aahz
In article <[EMAIL PROTECTED]>, =?iso-8859-1?Q?Fran=E7ois?= Pinard <[EMAIL PROTECTED]> wrote: >[Sunnan] >> >> [...] for Pythons ideal of having one canonical, explicit way to >> program. > >No doubt it once was true, but I guess this ideal has been abandoned a >few years ago. > >My honest feeling

Re: Help with splitting

2005-04-01 Thread RickMuller
Thanks to everyone who responded!! I guess I have to study my regular expressions a little more closely. -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for Benchmarklets to improve pyvm

2005-04-01 Thread Skip Montanaro
Stelios> I'm collecting small testlets to benchmark it, discover Stelios> bottlenecks and improve it. They should be small and not use Stelios> any crazy modules. Only [sys, os, itertools, thread, Stelios> threading, math, random] for now. Take a look around for Marc Andre Lembu

Re: unittest vs py.test?

2005-04-01 Thread Peter Hansen
Raymond Hettinger wrote: BTW, the above code simplifies to: from py.test import raises assert a == b raises(Error, func, args) This is pretty, but I *want* my tests to be contained in separate functions or methods. The trivial amount of extra overhead that unittest requires fits with the way I wan

Re: unittest vs py.test?

2005-04-01 Thread Raymond Hettinger
[Peter Hansen] > unittest can really be rather light. Most of our > test cases are variations on the following, with > primarily application-specific code added rather than > boilerplate or other unittest-related stuff: > > import unittest > > class TestCase(unittest.TestCase): > def test01(s

Re: StopIteration in the if clause of a generator expression

2005-04-01 Thread Raymond Hettinger
> I assumed that all standard sequence consumers (including list, of course) would intercept > the StopIteration of a sequence given them in the form of a generator expression, so your > lyst example would have an analogue for other sequence consumers as well, right? > I.e., there's not a hidden li

Re: Case-insensitive dict, non-destructive, fast, anyone?

2005-04-01 Thread Raymond Hettinger
> >Taken together, these six attributes/methods could cover many wished for > >features for the 10% of the cases where a regular dictionary doesn't provide the > >best solution. > You think as much as 10% ? Rounded up from 9.6 ;-) More important than the percentage is the clarity of the resultin

Re: New to programming question

2005-04-01 Thread Steve Holden
Joal Heagney wrote: Bengt Richter wrote: On Fri, 01 Apr 2005 07:46:41 GMT, Joal Heagney <[EMAIL PROTECTED]> wrote: Oh goddammmni. I seem to be doing this a lot today. Look below for the extra addition to the code I posted. Joal Heagney wrote: Here's my contribution anycase: count = 0 # Get

Re: [python-perl] Translation review?

2005-04-01 Thread Steve Holden
Traceback (most recent call last): File "", line 19, in ? IOError: [Errno 2] No such file or directory: '' (in both Windows 2.4 and Cygwin 2.4) regards Steve TSO wrote: Hi there, I've recently tried to translate some Perl code into Python - code is below. Is there a more Pythonic form? Also, is

How To Do It Faster?!?

2005-04-01 Thread andrea_gavana
Hello Jeremy & NG, >Yes, clearer, though I still don't know what you're *doing* with that data :-) Every user of thsi big directory works on big studies regarding oil fields. Knowing the amount of data (and number of files) we have to deal with (produced by simulators, visualization tools, and so

Re: Grouping code by indentation - feature or ******?

2005-04-01 Thread Steve Holden
Javier Bezos wrote: "Myles Strous" <[EMAIL PROTECTED]> escribió en el mensaje news:[EMAIL PROTECTED] satisfy some handy properties, the first of which being: l[:n] + l[n:] = l I don't think l[:5] + l[5:] = l is a handy property and to me is clearly counterintuitive. Further, It can be quite useful

Re: Ternary Operator in Python

2005-04-01 Thread Roy Smith
In article <[EMAIL PROTECTED]>, "Carl Banks" <[EMAIL PROTECTED]> wrote: > Terry Reedy wrote: > > "praba kar" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > Dear All, > > >I am new to Python. I want to know how to > > > work with ternary operator in Python. I cannot >

Re: that is it is not it (logic in Python)

2005-04-01 Thread Terry Reedy
"F. Petitjean" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Le Fri, 1 Apr 2005 13:39:47 -0500, Terry Reedy a écrit : >> Reread the ref manual on chained comparison operators. >And see the date of the post :-) Ditto for the reply ;-) TJR -- http://mail.python.org/mailman/li

Re: Case-insensitive dict, non-destructive, fast, anyone?

2005-04-01 Thread Bengt Richter
On Fri, 01 Apr 2005 23:04:42 GMT, "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: >[Bengt Richter] >> I wonder if a dict with a general override hook for hashing all keys would be >useful. >> E.g., a dict.__keyhash__ that would take key as arg and default as now >returning key.__hash__() >> but th

Re: System bell

2005-04-01 Thread Trent Mick
[Mr6 wrote] > It's a weird thing. But if I run print "\a" from idle it does not work. > But if I save as a file, say, sound.py. Then run that with python > sound.py it does. > > Why is that? The IDLE stdout/stderr handling is not invoking a system bell when it sees '\a'. I suppose that one coul

Re: How To Do It Faster?!?

2005-04-01 Thread Jeremy Bowers
On Sat, 02 Apr 2005 01:00:34 +0200, andrea_gavana wrote: > Hello Jeremy & NG, > ... > I hope to have been clearer this time... > > I really welcome all your suggestions. Yes, clearer, though I still don't know what you're *doing* with that data :-) Here's an idea to sort of come at the problem

Re: unittest vs py.test?

2005-04-01 Thread Roy Smith
Peter Hansen <[EMAIL PROTECTED]> wrote: > unittest can really be rather light. Most of our > test cases are variations on the following, with > primarily application-specific code added rather than > boilerplate or other unittest-related stuff: > > import unittest > > class TestCase(unittest.Tes

Re: Ternary Operator in Python

2005-04-01 Thread Terry Reedy
"Carl Banks" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >> A unary operator has one operand; a binary operator has two operands; >> ternary operator has three operands. Python has none built-in, > > Not so fast, my friend. What about the expression "0.0 < a < 1.0"? Gee, what a

Re: Help with splitting

2005-04-01 Thread Jeremy Bowers
On Fri, 01 Apr 2005 18:01:49 -0500, Brian Beck wrote: > py> from itertools import groupby > py> [''.join(g) for k, g in groupby(' test ing ', lambda x: x.isspace())] > [' ', 'test', ' ', 'ing', ' '] > > I tried replacing the lambda thing with an attrgetter, but apparently my > understanding of

Re: Help with splitting

2005-04-01 Thread Raymond Hettinger
[Brian Beck]> > py> from itertools import groupby > py> [''.join(g) for k, g in groupby(' test ing ', lambda x: x.isspace())] > [' ', 'test', ' ', 'ing', ' '] Brilliant solution! That leads to a better understanding of groupby as a tool for identifying transitions without consuming them. > I

Re: unittest vs py.test?

2005-04-01 Thread Peter Hansen
Colin J. Williams wrote: unittest seems rather heavy. I don't like mixing tests with documentation, it gives the whole thing a cluttered look. unittest can really be rather light. Most of our test cases are variations on the following, with primarily application-specific code added rather than b

Re: that is it is not it (logic in Python)

2005-04-01 Thread F. Petitjean
Le Fri, 01 Apr 2005 17:42:30 -0500, Jeremy Bowers a écrit : > On Fri, 01 Apr 2005 22:01:25 +, F. Petitjean wrote: > >> Le Fri, 1 Apr 2005 13:39:47 -0500, Terry Reedy a écrit : >>> This is equivalent to '(that is it) and (it is not it)' which is clearly >>> false. >>> False # What ? >>

Re: Queue.Queue-like class without the busy-wait

2005-04-01 Thread David Bolen
"Paul L. Du Bois" <[EMAIL PROTECTED]> writes: > Has anyone written a Queue.Queue replacement that avoids busy-waiting? > It doesn't matter if it uses os-specific APIs (eg > WaitForMultipleObjects). I did some googling around and haven't found > anything so far. This isn't a Queue.Queue replaceme

Re: Case-insensitive dict, non-destructive, fast, anyone?

2005-04-01 Thread Raymond Hettinger
[Bengt Richter] > I wonder if a dict with a general override hook for hashing all keys would be useful. > E.g., a dict.__keyhash__ that would take key as arg and default as now returning key.__hash__() > but that you could override. Seems like this could potentially be more efficient than key wrap

Re: Help with splitting

2005-04-01 Thread Brian Beck
RickMuller wrote: There's a chance I was instead thinking of something in the re module, but I also spent some time there without luck. Could someone point me to the right function, if it exists? The re solution Jeremy Bowers is what you want. Here's another (probably much slower) way for fun (wit

How To Do It Faster?!?

2005-04-01 Thread andrea_gavana
Hello Jeremy & NG, >* Poke around in the Windows API for a function that does what you want, >and hope it can do it faster due to being in the kernel. I could try it, but I think I have to explain a little bit more my problem. >If you post more information about how you are using this data, I ca

Re: System bell

2005-04-01 Thread Mr6
Bengt Richter wrote: On Fri, 01 Apr 2005 02:06:07 -0500, Steve Holden <[EMAIL PROTECTED]> wrote: Trent Mick wrote: [Baza wrote] Am I right in thinking that >>>print "\a" should sound the system, 'bell'? It works on the shell on Windows for me (WinXP). Trent Interesting. From a Cygwin bash shell

Re: unittest vs py.test?

2005-04-01 Thread Colin J. Williams
Grig Gheorghiu wrote: In my mind, practicing TDD is what matters most. Which framework you choose is a function of your actual needs. The fact that there are 3 of them doesn't really bother me. I think it's better to have a choice from a small number of frameworks rather than have no choice or have

Re: that is it is not it (logic in Python)

2005-04-01 Thread Jeremy Bowers
On Fri, 01 Apr 2005 22:01:25 +, F. Petitjean wrote: > Le Fri, 1 Apr 2005 13:39:47 -0500, Terry Reedy a Ãcrit : >> This is equivalent to '(that is it) and (it is not it)' which is clearly >> false. >> >>> False # What ? >> >> Reread the ref manual on chained comparison operators. > > And s

Re: Help with splitting

2005-04-01 Thread Jeremy Bowers
On Fri, 01 Apr 2005 14:20:51 -0800, RickMuller wrote: > I'm trying to split a string into pieces on whitespace, but I want to > save the whitespace characters rather than discarding them. > > For example, I want to split the string '12' into ['1','','2']. > I was certain that there was a

Help with splitting

2005-04-01 Thread RickMuller
I'm trying to split a string into pieces on whitespace, but I want to save the whitespace characters rather than discarding them. For example, I want to split the string '12' into ['1','','2']. I was certain that there was a way to do this using the standard string functions, but I just sp

Re: Pseudocode in the wikipedia

2005-04-01 Thread Ivan Van Laningham
Hi All-- Jeremy Bowers wrote: > Your ass is your identity function. > > Python 2.3.5 (#1, Mar 3 2005, 17:32:12) > [GCC 3.4.3 (Gentoo Linux 3.4.3, ssp-3.4.3-0, pie-8.7.6.6)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> 25 > 25 > >>> (_ | _) > 25 > >>>

Re: Case-insensitive dict, non-destructive, fast, anyone?

2005-04-01 Thread Bengt Richter
On Fri, 01 Apr 2005 18:52:00 GMT, "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: >[Ville Vainio] >> I need a dict (well, it would be optimal anyway) class that stores the >> keys as strings without coercing the case to upper or lower, but still >> provides fast lookup (i.e. uses hash table). > > >

Re: that is it is not it (logic in Python)

2005-04-01 Thread F. Petitjean
Le Fri, 1 Apr 2005 13:39:47 -0500, Terry Reedy a écrit : > > "F. Petitjean" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > iterable = range(10) > it = iter(iterable) > that = iter(it) > that is it >> True# Good! > that is it is not it > > This is equiv

Re: Lambda: the Ultimate Design Flaw

2005-04-01 Thread Ulrich Hobelmann
alex goldman wrote: Daniel Silva wrote: At any rate, FOLD must fold. I personally think GOTO was unduly criticized by Dijkstra. With the benefit of hindsight, we can see that giving up GOTO in favor of other primitives failed to solve the decades-old software crisis. The fault of goto in imperati

Re: decorator syntax polling suggestion

2005-04-01 Thread D H
Jeremy Bowers wrote: On Fri, 01 Apr 2005 16:52:52 -0500, Jeremy Bowers wrote: Oops, sorry, some "send later" messages I thought were gone got sent. Sorry. Didn't mean to revive dead threads. At least it happened on April Fool's. Or should I say: @aprilfools def happened: at least -- http://mail

Re: decorator syntax polling suggestion

2005-04-01 Thread Jeremy Bowers
On Fri, 01 Apr 2005 16:52:52 -0500, Jeremy Bowers wrote: Oops, sorry, some "send later" messages I thought were gone got sent. Sorry. Didn't mean to revive dead threads. -- http://mail.python.org/mailman/listinfo/python-list

Re: decorator syntax polling suggestion

2005-04-01 Thread Jeremy Bowers
On Fri, 13 Aug 2004 16:49:53 +1000, Anthony Baxter wrote: > The > people who hate pie-decorators post a _lot_ - most people seem to either > not care, or else post once or twice and then disappear. I just posted on another mailing list about how posting the same message, over and over, is fundamen

Re: How To Do It Faster?!?

2005-04-01 Thread Jeremy Bowers
On Thu, 31 Mar 2005 13:38:34 +0200, andrea.gavana wrote: > Hello NG, > > in my application, I use os.walk() to walk on a BIG directory. I > need > to retrieve the files, in each sub-directory, that are owned by a > particular user. Noting that I am on Windows (2000 or XP), this is wha

Re: Pseudocode in the wikipedia

2005-04-01 Thread Jeremy Bowers
On Fri, 01 Apr 2005 16:02:53 -0500, Gabriel Cooper wrote: > Ron_Adam wrote: > >>To me ":=" could mean to create a copy of an object... or should it >>be "=:" ? >> >>Or how about ":=)" to mean is equal and ":=(" to mean it's not. >> >>Then there is ";=)", to indicate 'True', and ':=O' to indicate

Re: try / except not worknig correctly

2005-04-01 Thread Jeremy Bowers
On Sat, 12 Mar 2005 17:06:17 -0800, '@'.join([..join(['fred','dixon']),..join(['gmail','com'])]) wrote: I'd also suggest validInput = "ABCDEFGHIJKL" # and there are more clever ways to do this, # but this will do myInput = raw_input(" ".join(validInput) + "?") if len(

Re: Decorater inside a function? Is there a way?

2005-04-01 Thread Jeremy Bowers
On Fri, 01 Apr 2005 19:56:55 +, Ron_Adam wrote: > On Fri, 01 Apr 2005 13:47:06 -0500, Jeremy Bowers <[EMAIL PROTECTED]> > wrote: >>Is this an April Fools gag? If so, it's not a very good one as it's quite >>in line with the sort of question I've seen many times before. "I have >>a hammer, how

Re: Ternary Operator in Python

2005-04-01 Thread Carl Banks
Terry Reedy wrote: > "praba kar" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Dear All, > >I am new to Python. I want to know how to > > work with ternary operator in Python. I cannot > > find any ternary operator in Python. So Kindly > > clear my doubt regarding this >

Re: redundant importr

2005-04-01 Thread Peter Hansen
max(01)* wrote: Peter Hansen wrote: Not required except for performance reasons. If the .pyc files don't exist, the .py files are recompiled and the resulting bytecode is simply held in memory and not cached and the next startup will recompile all over again. but the other files *are* compiled, ri

Re: numeric module

2005-04-01 Thread David M. Cooke
"coffeebug" <[EMAIL PROTECTED]> writes: > I cannot import "numarray" and I cannot import "numeric" using python > 2.3.3 numarray and Numeric are separate modules available at http://numpy.sourceforge.net/ If you're doing anything numerical in Python, you'll want them :-) -- |>|\/|< /-

Re: numeric module

2005-04-01 Thread David M. Cooke
[EMAIL PROTECTED] writes: > Hello, > What's the problem with this code? I get the following error message: > > File "test.py", line 26, in test > print tbl[wi][bi] > IndexError: index must be either an int or a sequence > > ---code snippet > > from Numeric import * > tbl = zeros((32, 16))

Who said that? (was Re: string goes away)

2005-04-01 Thread Peter Hansen
Ivan Van Laningham wrote: Tim Peters sayeth, "Premature Optimization is the Root of All Evil." And he is not kidding. And just to forestall another long thread about who actually said that originally, it was really Mark Twain, quoting Churchill. Tim just added a . -Peter -- http://mail.python.org

Re: Ternary Operator in Python

2005-04-01 Thread Erik Max Francis
Ron_Adam wrote: I've used boolean opperations to do it. result = (v == value) * first + (v != value) * second Same as: if v == value: result = first else: result = second No, it isn't, because it isn't short circuiting. If first or second had side effects, then the two would not be equiv

Re: StopIteration in the if clause of a generator expression

2005-04-01 Thread Bengt Richter
On Fri, 01 Apr 2005 16:34:32 GMT, "Raymond Hettinger" <[EMAIL PROTECTED]> wrote: >[Peter Otten] >> a StopIteration raised in a generator expression >> silently terminates that generator: >> >> >>> def stop(): raise StopIteration >> ... >> >>> list(i for i in range(10) if i < 5 or stop()) >> [0, 1,

Re: Attributes and built-in types

2005-04-01 Thread Sidharth
You might find this usefull specifically the stuff on subclassing built-in types. http://www.python.org/2.2/descrintro.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Pseudocode in the wikipedia

2005-04-01 Thread Gabriel Cooper
Ron_Adam wrote: To me ":=" could mean to create a copy of an object... or should it be "=:" ? Or how about ":=)" to mean is equal and ":=(" to mean it's not. Then there is ";=)", to indicate 'True', and ':=O' to indicate 'False' Not to mention "(_ | _)" for asserts! -- http://mail.python.org/m

Attributes and built-in types

2005-04-01 Thread Dave Opstad
Is it just an implementation limitation that attributes cannot be assigned to instances of internal types? --- >>> x = 4 >>> type(x) >>> class Test(int): ... pass ... >>> y = Test(4) >>> type(y) >>> y.someattr = 10 >>> x.someattr = 10 Traceback (most recent call last)

Re: how to close a gzip.GzipFile?

2005-04-01 Thread Sidharth
GzipFile has a parameter 'fileobj' which you could use. GzipFile( [filename[, mode[, compresslevel[, fileobj) For iteratng over the file how about : line = oldfileobj.readline() while line !="": oldmd5.update(line) line = oldfileobj.readline() -- http://mail.python.org/mailman/listinf

Re: Pseudocode in the wikipedia

2005-04-01 Thread Ron_Adam
On Fri, 1 Apr 2005 12:15:35 -0800, James Stroud <[EMAIL PROTECTED]> wrote: >Is anybody else bothered by those stupid pascal-like ":=" assignment >operators? > >Maybe, for the sake of adding more variety to the world, wiki should come up >with a new assignment operator, like "==". I like that one

  1   2   3   >