RE: Slurping All Content of a File into a Variable

2006-10-26 Thread Wijaya Edward
From: [EMAIL PROTECTED] on behalf of Wijaya Edward Sent: Thu 10/26/2006 11:47 PM To: python-list@python.org Subject: Slurping All Content of a File into a Variable Hi, How can we slurp content of a single file into one variable? I tried this: >>> myfile_

Slurping All Content of a File into a Variable

2006-10-26 Thread Wijaya Edward
Hi, How can we slurp content of a single file into one variable? I tried this: >>> myfile_content = open('somefile.txt') >>> print myfile_content, >>> But it doesn't print the content of the file. Regards, -- Edward WIJAYA SINGAPORE Institute For Infocomm Research - Dis

Re: NumPy 1.0 release

2006-10-26 Thread George Sakkis
Robert Kern wrote: > George Sakkis wrote: > > ImportError: > > /usr/local/lib/python2.4/site-packages/numpy/linalg/lapack_lite.so: > > undefined symbol: zheevd_ > > > > Googling for "undefined symbol: zheevd_" returned no hits, at which > > point I gave up for now; hopefully someone will have a su

Re: How to Split Chinese Character with backslash representation?

2006-10-26 Thread limodou
On 10/27/06, Cameron Walsh <[EMAIL PROTECTED]> wrote: > limodou wrote: > > On 10/27/06, Wijaya Edward <[EMAIL PROTECTED]> wrote: > >> > >> Thanks but my intention is to strictly use regex. > >> Since there are separator I need to include as delimiter > >> Especially for the case like this: > >> > >

Re: subprocess cwd keyword.

2006-10-26 Thread Leo Kislov
Ivan Vinogradov wrote: > Dear All, > > I would greatly appreciate a nudge in the right direction concerning > the use of cwd argument in the call function from subprocess module. > > The setup is as follows: > > driver.py <- python script > core/ <- directory >

Re: my first software

2006-10-26 Thread Leo Kislov
[EMAIL PROTECTED] wrote: > I am a beginner of programming and started to learn Python a week ago. > last 3 days, i write this little tool for Renju.if you have any advice > on my code,please tell me > s = '' > > for i in range (0,len(done) - 1): > s = s +str(done[i][0]) + str(done

Re: To Stop a Process that is Waiting on socket.accept()

2006-10-26 Thread mumebuhi
Hi Steve, The output is as the following (excluding the "---start---" and "---end---"): ---start--- die now Traceback (most recent call last): File "../../../scratch/python/tmp.py", line 39, in ? channel, details = server.accept() File "/usr/lib/python2.4/socket.py", line 169, in accept

Re: How to Split Chinese Character with backslash representation?

2006-10-26 Thread Fredrik Lundh
Wijaya Edward wrote: > Since there are separator I need to include as delimiter > Especially for the case like this: > str = '\xc5\xeb\xc7\xd5\xbc--FOO--BAR' field = list(str) print field > ['\xc5', '\xeb', '\xc7', '\xd5', '\xbc', '-', '-', 'F', 'O', 'O', '-', '-', > 'B', 'A', 'R'

Re: Obtaining SSL certificate info from SSL object - BUG?

2006-10-26 Thread John Nagle
Michael Ströder wrote: > John Nagle wrote: > >>The Python SSL object offers two methods from obtaining >>the info from an SSL certificate, "server()" and "issuer()". >>The actual values in the certificate are a series of name/value >>pairs in ASN.1 binary format. But what "server()" and "issu

Re: Cards deck problem

2006-10-26 Thread Cameron Walsh
[EMAIL PROTECTED] wrote: > Dennis Lee Bieber wrote: >> On Fri, 27 Oct 2006 03:48:25 GMT, Michael Naunton >> <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: >> >>> This may seem pendantic, but CS is mostly about thinking about (and thus >> Someday I should arrange to do a lost

Re: NumPy 1.0 release

2006-10-26 Thread Robert Kern
Robert Kern wrote: > George Sakkis wrote: >> By the way, it would be great if numpy's mailing list was mirrored to a >> google group; sourceforge and gmane are just horrible to use. > > Sorry, I don't think that Google Groups does mirroring like GMane does. Never mind. http://groups.google.c

Re: How to Split Chinese Character with backslash representation?

2006-10-26 Thread Cameron Walsh
limodou wrote: > On 10/27/06, Wijaya Edward <[EMAIL PROTECTED]> wrote: >> >> Thanks but my intention is to strictly use regex. >> Since there are separator I need to include as delimiter >> Especially for the case like this: >> >> >>> str = '\xc5\xeb\xc7\xd5\xbc--FOO--BAR' >> >>> field = list(str)

Re: NumPy 1.0 release

2006-10-26 Thread Robert Kern
George Sakkis wrote: > ImportError: > /usr/local/lib/python2.4/site-packages/numpy/linalg/lapack_lite.so: > undefined symbol: zheevd_ > > Googling for "undefined symbol: zheevd_" returned no hits, at which > point I gave up for now; hopefully someone will have a suggestion on > what to do next (ot

Re: doesnt seems to work can any help be provided

2006-10-26 Thread Fredrik Lundh
Ben Finney wrote: > Apparently that learning also didn't include the prohibitions against > colluding with others. Nevertheless, I'll bet they are still present. http://www.csu.edu.au/acad_sec/manuals/gcontm.htm Part G6 Collusion A student colludes when he or she works without

Re: To Stop a Process that is Waiting on socket.accept()

2006-10-26 Thread Steve Holden
mumebuhi wrote: > I am having problem to kill the following script completely. The script > basically does the following. The main thread creates a new thread, > which does a completely useless thing, and then starts excepting for a > connection via socket. > > # start > import pickle > import sig

Re: NumPy 1.0 release

2006-10-26 Thread George Sakkis
Travis E. Oliphant wrote: > We are very pleased to announce the release of NumPy 1.0 available for > download at http://www.numpy.org Congratulations for this great package and the tremendous effort that was put on it! Hopefully with this release, the 'array wars' are over; we may not be able to a

To Stop a Process that is Waiting on socket.accept()

2006-10-26 Thread mumebuhi
I am having problem to kill the following script completely. The script basically does the following. The main thread creates a new thread, which does a completely useless thing, and then starts excepting for a connection via socket. # start import pickle import signal import simplejson import soc

Re: Sentinel values for special cases

2006-10-26 Thread Ben Finney
"Paddy" <[EMAIL PROTECTED]> writes: > None is what Python readers would expect as a sentinel value, but if > any of your data fields could have None as a valid value then you may > have to switch to a module level constant. > Be wary of using sentinel values which are strings, if your data could >

Re: Cards deck problem

2006-10-26 Thread [EMAIL PROTECTED]
Dennis Lee Bieber wrote: > On Fri, 27 Oct 2006 03:48:25 GMT, Michael Naunton > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > > > This may seem pendantic, but CS is mostly about thinking about (and thus > >Someday I should arrange to do a lost-wax casting of a > /pe

Re: How to Split Chinese Character with backslash representation?

2006-10-26 Thread limodou
On 10/27/06, Wijaya Edward <[EMAIL PROTECTED]> wrote: > > Thanks but my intention is to strictly use regex. > Since there are separator I need to include as delimiter > Especially for the case like this: > > >>> str = '\xc5\xeb\xc7\xd5\xbc--FOO--BAR' > >>> field = list(str) > >>> print field > ['\x

Re: Tracing the execution of scripts?

2006-10-26 Thread Stephan Kuhagen
"Michael B. Trausch" <"mike$#at^&nospam!%trauschus"> wrote: > Basically, is there something that will log every line of Python code > executed, in its order of execution, to a text file so that I can see > what is (or isn't) happening that I am expecting? Python itself can do this for you. A __VE

RE: How to Split Chinese Character with backslash representation?

2006-10-26 Thread Wijaya Edward
Thanks but my intention is to strictly use regex. Since there are separator I need to include as delimiter Especially for the case like this: >>> str = '\xc5\xeb\xc7\xd5\xbc--FOO--BAR' >>> field = list(str) >>> print field ['\xc5', '\xeb', '\xc7', '\xd5', '\xbc', '-', '-', 'F', 'O', 'O', '-', '-'

Re: Search & Replace

2006-10-26 Thread Paddy
DataSmash wrote: > Hello, > I need to search and replace 4 words in a text file. > Below is my attempt at it, but this code appends > a copy of the text file within itself 4 times. > Can someone help me out. > Thanks! > > # Search & Replace > file = open("text.txt", "r") > text = file.read() > fil

Re: Sentinel values for special cases

2006-10-26 Thread Paddy
Ben Finney wrote: > Howdy all, > > Ned Batchelder blogged[0] about a debate over checking function > parameters, and to what extent dynamic typing should be relied upon. > > I was one of many who commented, but I wrote what purports to be a > comprehensive checklist when considering special-case in

Re: How to Split Chinese Character with backslash representation?

2006-10-26 Thread Cameron Walsh
Wijaya Edward wrote: > Hi all, > > I was trying to split a string that > represent chinese characters below: > > str = '\xc5\xeb\xc7\xd5\xbc' print str2, > ??? fields2 = split(r'\\',str) print fields2, > ['\xc5\xeb\xc7\xd5\xbc'] > > But why the split function here doesn't

Re: Insert Content of a File into a Variable

2006-10-26 Thread Cameron Walsh
Wijaya Edward wrote: > Hi, > > How can we slurp all content of a single file > into one variable? > > I tried this: > myfile_content = open('somefile.txt') print myfile_content, > > > > But it doesn't print the content of the file. >>> help(open) Help on built-in function ope

Re: Truth value of iterators [was: question about True values)

2006-10-26 Thread Carl Banks
Robert Kern wrote: > Ben Finney wrote: > > > Would it make sense to *define* a truth value for iterators? Or at > > least to enable those that *are* able to say "I'm empty" to do so in a > > way that boolean contexts can interpret as "false"? > > > > Perhaps allowing (but not requiring) an iterato

Fwd: How to Split Chinese Character with backslash representation?

2006-10-26 Thread limodou
-- Forwarded message -- From: limodou <[EMAIL PROTECTED]> Date: Oct 27, 2006 11:51 AM Subject: Re: How to Split Chinese Character with backslash representation? To: Wijaya Edward <[EMAIL PROTECTED]> On 10/27/06, Wijaya Edward <[EMAIL PROTECTED]> wrote: > > Hi all, > > I was trying

Re: Cards deck problem

2006-10-26 Thread Michael Naunton
On 26 Oct 2006 02:27:16 -0700, Arun Nair <[EMAIL PROTECTED]> wrote: It is clear your professor does not understand computer science. Switch to a new university now. As noted in the problem, a deck has 52 cards. cardsLeft(self) therefore always returns 52. This may seem pendantic, but CS is

Re: Truth value of iterators [was: question about True values)

2006-10-26 Thread Carl Banks
Ben Finney wrote: > "Carl Banks" <[EMAIL PROTECTED]> writes: > > > An iterator is not a sequence, and it's impossible to determine > > whether an iterator is "empty" in general, except by trying to get > > an item from it. [...] > > > > IMO, this is big time wart in the language. Iterators have n

How to Split Chinese Character with backslash representation?

2006-10-26 Thread Wijaya Edward
Hi all, I was trying to split a string that represent chinese characters below: >>> str = '\xc5\xeb\xc7\xd5\xbc' >>> print str2, ??? >>> fields2 = split(r'\\',str) >>> print fields2, ['\xc5\xeb\xc7\xd5\xbc'] But why the split function here doesn't seem to do the job for obtaining the desire

Re: Want to reduce steps of an operation with dictionaries

2006-10-26 Thread Michael Naunton
It does not look nice at all, mainly because you are asking either asking the question upside down, or not providing enough information. If a and b are of vastly different sizes, say so. Otherwise, think about your algorithm, and realize you are asking for things in b if they exist in a: > dict

Re: Truth value of iterators [was: question about True values)

2006-10-26 Thread Robert Kern
Ben Finney wrote: > Would it make sense to *define* a truth value for iterators? Or at > least to enable those that *are* able to say "I'm empty" to do so in a > way that boolean contexts can interpret as "false"? > > Perhaps allowing (but not requiring) an iterator object to grow a > 'len' metho

Re: subprocess cwd keyword.

2006-10-26 Thread attn . steven . kuo
Ivan Vinogradov wrote: > Dear All, > > I would greatly appreciate a nudge in the right direction concerning > the use of cwd argument in the call function from subprocess module. > > The setup is as follows: > > driver.py <- python script > core/ <- directory >

Re: Sorting by item_in_another_list

2006-10-26 Thread Cameron Walsh
Steven Bethard wrote: > > As you noted, you'll get an error if you try to concatenate B as a set > to the list. > > Steve Whoops, remind me to check things work before I type them. In the mean time, here are some more interesting timing results: With a larger data set, 500 elements instead o

Truth value of iterators [was: question about True values)

2006-10-26 Thread Ben Finney
"Carl Banks" <[EMAIL PROTECTED]> writes: > An iterator is not a sequence, and it's impossible to determine > whether an iterator is "empty" in general, except by trying to get > an item from it. [...] > > IMO, this is big time wart in the language. Iterators have no > calculatable truth value; fo

Re: question about True values

2006-10-26 Thread Carl Banks
Ben Finney wrote: > Gabriel Genellina <[EMAIL PROTECTED]> writes: > > > At Wednesday 25/10/2006 23:29, Paul Rubin wrote: > > >Steve Holden <[EMAIL PROTECTED]> writes: > > >I get that iter(()) is True (Python 2.3.4). > > > > It's False on 2.4.2 - and perhaps it's what one would expect, but > > since

Re: Tracing the execution of scripts?

2006-10-26 Thread Ben Finney
Jean-Paul Calderone <[EMAIL PROTECTED]> writes: > 1) Write unit tests for your code. Keep writing unit tests until > you have some that _don't pass_. Then fix your code so that they > do. When you do further development, write the tests first, then > implement the code that makes them pass. He

Re: Insert Content of a File into a Variable

2006-10-26 Thread Ben Finney
Ben Finney <[EMAIL PROTECTED]> writes: > The 'read' method of the resulting file object will return the > contents of the file. You may also want to read the documentation of > thile objects to see what else you can do with them. And ith you couldn't underthtand my thpeetch impediment, I meanth "

Re: Handling emails

2006-10-26 Thread Ben Finney
"Peter Decker" <[EMAIL PROTECTED]> writes: > On 10/26/06, Ben Finney <[EMAIL PROTECTED]> wrote: > > There is always the option to not send messages to this list using > > that mail server. I don't care what option is taken, so long as > > the useless and obnoxious headers on his messages stop. > >

Re: Insert Content of a File into a Variable

2006-10-26 Thread Ben Finney
Wijaya Edward <[EMAIL PROTECTED]> writes: > >>> myfile_content = open('somefile.txt') > >>> print myfile_content, > > >>> > > But it doesn't print the content of the file. That's right, because "the content of the file" is not what open() is documented to return; it is documented as returning a

Re: Tracing the execution of scripts?

2006-10-26 Thread Jean-Paul Calderone
On Thu, 26 Oct 2006 21:52:42 -0400, "Michael B. Trausch" wrote: >Alright, I seem to be at a loss for what I am looking for, and I am not >even really all that sure if it is possible or not. I found the 'pdb' >debugger, but I was wondering if there was something that would trace or >log the order

Re: Insert Content of a File into a Variable

2006-10-26 Thread Steve Holden
Wijaya Edward wrote: > Hi, > > How can we slurp all content of a single file > into one variable? > > I tried this: > > myfile_content = open('somefile.txt') print myfile_content, > > > > > > But it doesn't print the content of the file. > Because you haven't read it! data

Tracing the execution of scripts?

2006-10-26 Thread Michael B. Trausch
Alright, I seem to be at a loss for what I am looking for, and I am not even really all that sure if it is possible or not. I found the 'pdb' debugger, but I was wondering if there was something that would trace or log the order of line execution for a multi-module Python program. I am having a l

Re: Insert Content of a File into a Variable

2006-10-26 Thread Grant Edwards
On 2006-10-27, Wijaya Edward <[EMAIL PROTECTED]> wrote: > How can we slurp all content of a single file > into one variable? http://docs.python.org/tut/node9.html#SECTION00920 I suggest you read the rest of the tutorial as well. -- Grant Edwards grante

Insert Content of a File into a Variable

2006-10-26 Thread Wijaya Edward
Hi, How can we slurp all content of a single file into one variable? I tried this: >>> myfile_content = open('somefile.txt') >>> print myfile_content, >>> But it doesn't print the content of the file. Regards, -- Edward WIJAYA SINGAPORE Institute For Infocomm Research -

Re: Handling emails

2006-10-26 Thread Peter Decker
On 10/26/06, Ben Finney <[EMAIL PROTECTED]> wrote: > > I agree it's a pain, but Fulvio may not have it in his power to > > switch the header off. Mail admins do some incredibly stupid things. > > There is always the option to not send messages to this list using > that mail server. I don't care wh

Sentinel values for special cases

2006-10-26 Thread Ben Finney
Howdy all, Ned Batchelder blogged[0] about a debate over checking function parameters, and to what extent dynamic typing should be relied upon. I was one of many who commented, but I wrote what purports to be a comprehensive checklist when considering special-case inputs for functions. I thought

Weekly Python Patch/Bug Summary

2006-10-26 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 434 open ( +3) / 3430 closed ( +5) / 3864 total ( +8) Bugs: 929 open (+13) / 6285 closed (+12) / 7214 total (+25) RFE : 245 open ( +1) / 240 closed ( +0) / 485 total ( +1) New / Reopened Patches __ various d

Re: question about True values

2006-10-26 Thread Steve Holden
Ben Finney wrote: > Gabriel Genellina <[EMAIL PROTECTED]> writes: > > >>At Wednesday 25/10/2006 23:29, Paul Rubin wrote: >> >>>Steve Holden <[EMAIL PROTECTED]> writes: >>>I get that iter(()) is True (Python 2.3.4). >> No I didn't - that was Paul Rubin. >>It's False on 2.4.2 - and perhaps it's wh

Re: What's the best IDE?

2006-10-26 Thread [EMAIL PROTECTED]
I just meant that I was going to bed and didn't have time to do it the same night. I'll see if I can make it work, use it forever . . . I'll do it. -- http://mail.python.org/mailman/listinfo/python-list

Re: What's the best IDE?

2006-10-26 Thread [EMAIL PROTECTED]
What I mean was that it was late and I needed sleep. I'll work with Vim, but it's not like I can spend a week learning it anyway, I don't have that much time AND time to actualy program. And thanks all to have posted suggestions and comments thus far. -- http://mail.python.org/mailman/listinfo/py

Re: numpy numbers converted wrong

2006-10-26 Thread Travis Oliphant
robert wrote: > in Gnuplot (Gnuplot.utils) the input array will be converted to a Numeric > float array as shown below. When I insert a numpy array into Gnuplot like > that below, numbers 7.44 are cast to 7.0 > Why is this and what should I do ? Is this bug in numpy or in Numeric? > > > [Dbg]>

Re: Python segmentation fault?

2006-10-26 Thread Michael B. Trausch
Klaas wrote: > Michael B. Trausch wrote: >> Is there a way to debug scripts that cause segmentation faults? I can >> do a backtrace in gdb on Python, but that doesn't really help me all >> that much since, well, it has nothing to do with my script... :-P > > Yes. If you think it is a python inte

Re: question about True values

2006-10-26 Thread Gabriel Genellina
At Thursday 26/10/2006 19:57, Ben Finney wrote: Gabriel Genellina <[EMAIL PROTECTED]> writes: > At Wednesday 25/10/2006 23:29, Paul Rubin wrote: > >Steve Holden <[EMAIL PROTECTED]> writes: > >I get that iter(()) is True (Python 2.3.4). > > It's False on 2.4.2 - and perhaps it's what one would ex

Re: What's the best IDE?

2006-10-26 Thread Ben Finney
Harry George <[EMAIL PROTECTED]> writes: > John Salerno <[EMAIL PROTECTED]> writes: > > Yeah, it was all the customizing that I could never figure out. > > years ago this worked for people I was supporting: > set softtabstop=4 shiftwidth=4 expandtab That's all I've ever needed vim to do with my

Re: question about True values

2006-10-26 Thread Ben Finney
Gabriel Genellina <[EMAIL PROTECTED]> writes: > At Wednesday 25/10/2006 23:29, Paul Rubin wrote: > >Steve Holden <[EMAIL PROTECTED]> writes: > >I get that iter(()) is True (Python 2.3.4). > > It's False on 2.4.2 - and perhaps it's what one would expect, but > since this behavior is not documented

Re: doesnt seems to work can any help be provided

2006-10-26 Thread Ben Finney
Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > Arun Nair wrote: > > [more homework assignments, not working] > Do you really expect us to run your code, fix the bugs and send it > back? Yes, he apparently does. He's told us that it's homework, but that he hasn't learned enough from his teacher

Re: Handling emails

2006-10-26 Thread Ben Finney
Steve Holden <[EMAIL PROTECTED]> writes: > Please stop sending messages with obnoxious content like this. Yes, I guess I should have expected a response like that from someone :-) > If you insist on telling someone off publicly via a newsgroup, once > is enough. Apparently not. I tried initiall

subprocess cwd keyword.

2006-10-26 Thread Ivan Vinogradov
Dear All, I would greatly appreciate a nudge in the right direction concerning the use of cwd argument in the call function from subprocess module. The setup is as follows: driver.py <- python script core/ <- directory main<- fortran executab

Re: conditional computation

2006-10-26 Thread Bruno Desthuilliers
robert a écrit : (snip) > class MemoCache(dict): # cache expensive Objects during a session > (memory only) >def memo(self, k, f): >try: return self[k] >except IndexError: >return self.setdefault(k, f()) > cache=MemoCache() > ... > > o = cache.memo( complex-key-exp

Re: Search & Replace

2006-10-26 Thread Bruno Desthuilliers
DataSmash a écrit : > Hello, > I need to search and replace 4 words in a text file. > Below is my attempt at it, but this code appends > a copy of the text file within itself 4 times. > Can someone help me out. > Thanks! > > # Search & Replace > file = open("text.txt", "r") NB : avoid using 'file'

Re: numpy numbers converted wrong

2006-10-26 Thread Robert Kern
robert wrote: > in Gnuplot (Gnuplot.utils) the input array will be converted to a Numeric > float array as shown below. When I insert a numpy array into Gnuplot like > that below, numbers 7.44 are cast to 7.0 > Why is this and what should I do ? Is this bug in numpy or in Numeric? > > > [Dbg]>

Re: Search & Replace

2006-10-26 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, DataSmash wrote: > I need to search and replace 4 words in a text file. > Below is my attempt at it, but this code appends > a copy of the text file within itself 4 times. Because you `write()` the whole text four times to the file. Make the 4 replacements first and rebin

Re: Search & Replace

2006-10-26 Thread Tim Chase
> Below is my attempt at it, but this code appends > a copy of the text file within itself 4 times. > Can someone help me out. [snip] > file = open("text.txt", "w") > file.write(text.replace("Left_RefAddr", "FromLeft")) > file.write(text.replace("Left_NonRefAddr", "ToLeft")) > file.write(text.repla

Re: Python segmentation fault?

2006-10-26 Thread Markus Rosenstihl
On 2006-10-24 02:58:56 +0200, "Michael B. Trausch" <"mike$#at^&nospam!%trauschus"> said: > Is there a way to debug scripts that cause segmentation faults? I can > do a backtrace in gdb on Python, but that doesn't really help me all > that much since, well, it has nothing to do with my script...

Search & Replace

2006-10-26 Thread DataSmash
Hello, I need to search and replace 4 words in a text file. Below is my attempt at it, but this code appends a copy of the text file within itself 4 times. Can someone help me out. Thanks! # Search & Replace file = open("text.txt", "r") text = file.read() file.close() file = open("text.txt", "w")

Re: which one of these is better?

2006-10-26 Thread robert
Michael B. Trausch wrote: > Not really über-qualified to say anything, but I think that the > following would be better: > > try: > f = open('file.sql') > script = f.read() > f.close() > except IOError: > wx.MessageBox('Message', 'Message Title') > >> Do they both do the

Re: ANN: wxPython 2.7.1.3

2006-10-26 Thread robert
John Salerno wrote: > robert wrote: >> Robin Dunn wrote: >>> Announcing >>> -- >>> >>> The 2.7.1.3 release of wxPython is now available for download at >>> http://wxpython.org/download.php. This release is a yet another >>> quick-turnaround bugfix release designed to solve some problems, p

Re: my first software

2006-10-26 Thread Gabriel Genellina
At Thursday 26/10/2006 09:39, [EMAIL PROTECTED] wrote: def openfile(): global mark global step global done global interator global mainname global beensaved Too many globals for my taste... -- Gabriel Genellina Softlab SRL __

Re: ANN: wxPython 2.7.1.3

2006-10-26 Thread John Salerno
robert wrote: > Robin Dunn wrote: >> Announcing >> -- >> >> The 2.7.1.3 release of wxPython is now available for download at >> http://wxpython.org/download.php. This release is a yet another >> quick-turnaround bugfix release designed to solve some problems, plust >> some minor enhancemen

Re: my first software

2006-10-26 Thread John Salerno
Chelonian wrote: > [EMAIL PROTECTED] wrote: >> I am a beginner of programming and started to learn Python a week ago. >> last 3 days, i write this little tool for Renju... > > Tell you what, I will trade you my fluent English for your ability to > write that in 3 days as a beginning programmer who

compiling on AIX 5.3 with vacpp

2006-10-26 Thread pruebauno
I am trying to compile Python 2.5 on AIX 5.3. I used export PATH=/usr/bin:/usr/vacpp/bin OPT=-O2 ./configure --with-gcc="xlc_r -q64" --with-cxx="xlC_r -q64" --disable-ipv6 AR="ar -X64" make The following error stops make in its track: building '_locale' extension ./Modules/ld_so_aix xlc_r -q64

Re: which one of these is better?

2006-10-26 Thread John Salerno
Fredrik Lundh wrote: > This wasn't very difficult, was it? Well when you put it that way, no! :) But one thing that caught me up was what happens if the initial expression raises an exception? For example: with open('file.txt'): #do stuff If the file can't be opened for whatever reason,

Re: ANN: wxPython 2.7.1.3

2006-10-26 Thread robert
Robin Dunn wrote: > Announcing > -- > > The 2.7.1.3 release of wxPython is now available for download at > http://wxpython.org/download.php. This release is a yet another > quick-turnaround bugfix release designed to solve some problems, plust > some minor enhancements. This will likely

Re: Sorting by item_in_another_list

2006-10-26 Thread Steven Bethard
Paul Rubin wrote: > Steven Bethard <[EMAIL PROTECTED]> writes: >> Cameron Walsh wrote: >>> Which brings me to the question, would this solution: >>> B = set(B) >>> A = B + list(x for x in A if x not in B) >>> be faster than this solution: >>> B = set(B) >>> A.sort(key=B.__contains__, reverse=True)

Re: displaying \n-less prompts in a pythonic way

2006-10-26 Thread alf
Steve Holden wrote: > Or use raw_input(), which was designed for such situations: > thx, did not know about that ... -- http://mail.python.org/mailman/listinfo/python-list

Re: question about True values

2006-10-26 Thread Gabriel Genellina
At Wednesday 25/10/2006 23:29, Paul Rubin wrote: Steve Holden <[EMAIL PROTECTED]> writes: > Gabriel Genellina wrote: > > iter(()) I get that iter(()) is True (Python 2.3.4). It's False on 2.4.2 - and perhaps it's what one would expect, but since this behavior is not documented anywhere, one

Re: conditional computation

2006-10-26 Thread robert
Mike Kent wrote: > robert wrote: >> I want to use a computation cache scheme like >> >> >> o = CACHECOMPUTE complex-key-expr expensive-calc-expr >> >> >> frequently and elegantly without writing complex-key-expr or >> expensive-calc-expr twice. >> So its ugly: >> >> _=complex-key-expr;

Re: conditional computation

2006-10-26 Thread Fredrik Lundh
robert wrote: > I want to use a computation cache scheme like > > o = CACHECOMPUTE complex-key-expr expensive-calc-expr > > frequently and elegantly without writing complex-key-expr or > expensive-calc-expr twice. > So its ugly: > > _=complex-key-expr; o=cache.get(_) or > cache

Re: conditional computation

2006-10-26 Thread robert
Gabriel Genellina wrote: > At Thursday 26/10/2006 16:30, robert wrote: > >> I want to use a computation cache scheme like >> >> >> o = CACHECOMPUTE complex-key-expr expensive-calc-expr >> >> >> frequently and elegantly without writing complex-key-expr or >> expensive-calc-expr twice. >>

Re: conditional computation

2006-10-26 Thread Mike Kent
robert wrote: > I want to use a computation cache scheme like > > > o = CACHECOMPUTE complex-key-expr expensive-calc-expr > > > frequently and elegantly without writing complex-key-expr or > expensive-calc-expr twice. > So its ugly: > > _=complex-key-expr; o=cache.get(_) or > cache

numpy numbers converted wrong

2006-10-26 Thread robert
in Gnuplot (Gnuplot.utils) the input array will be converted to a Numeric float array as shown below. When I insert a numpy array into Gnuplot like that below, numbers 7.44 are cast to 7.0 Why is this and what should I do ? Is this bug in numpy or in Numeric? [Dbg]>>> m #numpy array ar

Re: which one of these is better?

2006-10-26 Thread Fredrik Lundh
John Salerno wrote: >> Not sure about the with-- I just went to read the PEP on it, and it >> confused me greatly. :-) So, I don't know. > > Ditto. :) No need to be confused; the "with" statement is actually very simple. Consider this piece of code: set things up try: do s

Re: What's the best IDE?

2006-10-26 Thread Harry George
John Salerno <[EMAIL PROTECTED]> writes: > Neil Cerutti wrote: > > On 2006-10-26, John Salerno <[EMAIL PROTECTED]> wrote: > >> [EMAIL PROTECTED] wrote: > >>> as I have yet to try Vim - maybe I'll try tomarrow. > >> Warning: Vim isn't something you just "try tomorrow" :) > > You can become profici

Re: conditional computation

2006-10-26 Thread Gabriel Genellina
At Thursday 26/10/2006 16:30, robert wrote: I want to use a computation cache scheme like o = CACHECOMPUTE complex-key-expr expensive-calc-expr frequently and elegantly without writing complex-key-expr or expensive-calc-expr twice. So its ugly: _=complex-key-expr; o=cach

Re: my first software

2006-10-26 Thread Chelonian
[EMAIL PROTECTED] wrote: > I am a beginner of programming and started to learn Python a week ago. > last 3 days, i write this little tool for Renju... Tell you what, I will trade you my fluent English for your ability to write that in 3 days as a beginning programmer who started learning Python a

Re: Embedded python loading .so files?

2006-10-26 Thread Martin v. Löwis
[EMAIL PROTECTED] schrieb: > I realize that this should include a ('.so','rb',3) entry (should it > not? 3->imp.C_EXTENSION) if it were going to locate the c extension. > Thus, my revised question would be what sets the suffixes for import? > How do/Can I change this? It depends on the target supp

conditional computation

2006-10-26 Thread robert
I want to use a computation cache scheme like o = CACHECOMPUTE complex-key-expr expensive-calc-expr frequently and elegantly without writing complex-key-expr or expensive-calc-expr twice. So its ugly: _=complex-key-expr; o=cache.get(_) or cache.setdefault(_,expensive-calc-

Re: which one of these is better?

2006-10-26 Thread John Salerno
Michael B. Trausch wrote: > Not really über-qualified to say anything, but I think that the > following would be better: > > try: > f = open('file.sql') > script = f.read() > f.close() > except IOError: > wx.MessageBox('Message', 'Message Title') I was thinking of somethi

Re: [OT] Win32 and forward/backslashes (was "The format of filename")

2006-10-26 Thread Neil Cerutti
On 2006-10-26, Tim Chase <[EMAIL PROTECTED]> wrote: > There's no "zip" in the "baz" directory, so let's copy it > there: > > C:\temp>copy foo/bar/zip foo/baz > foo\zip > Overwrite foo\zip? (Yes/No/All): y > The file cannot be copied onto itself. > 0 file(s) copied. > > What the [expletive]

Re: What's the best IDE?

2006-10-26 Thread Stephen Eilert
BartlebyScrivener wrote: > >> Vim > >> you'll be frustrated for about a week, > > You'll be frustrated for at least two weeks. But you'll use it forever > for everything from writing to programming, so who cares? > > Auto completion is called omni completion in VIM > > type ':h new-omni-completion

Re: which one of these is better?

2006-10-26 Thread Michael B. Trausch
John Salerno wrote: > def create_sql_script(self): > try: > with open('labtables.sql') as sql_script: > return sql_script.read() > except IOError: > wx.MessageBox('Could not locate the file "labtables.sql"', > 'Fi

Re: How to identify generator/iterator objects?

2006-10-26 Thread Paddy
Kenneth McDonald wrote: > I'm trying to write a 'flatten' generator which, when give a > generator/iterator that can yield iterators, generators, and other data > types, will 'flatten' everything so that it in turns yields stuff by > simply yielding the instances of other types, and recursively yi

ANN: wxPython 2.7.1.3

2006-10-26 Thread Robin Dunn
Announcing -- The 2.7.1.3 release of wxPython is now available for download at http://wxpython.org/download.php. This release is a yet another quick-turnaround bugfix release designed to solve some problems, plust some minor enhancements. This will likely be the last 2.7.1.x release. So

Re: PyDev + Eclipse (Was: Re: What's the best IDE?)

2006-10-26 Thread Michael B. Trausch
olive wrote: > > Did you try to set your PYTHONPATH properly with the same content in > both central AND project preferences ? > Yep. Still does it. And the kicker is, that it does it with things that it shouldn't have to wonder terribly much about -- classes that I have custom-built, where it

Re: which one of these is better?

2006-10-26 Thread Sybren Stuvel
John Salerno enlightened us with: > Hmm, looks like this doesn't work anyway if open() doesn't work, > because then f.close() raises an UnboundLocalError for obvious > reasons. Neither work 100% correct, actually. If the file can be located and opened, but not read, the message Could not loca

Re: which one of these is better?

2006-10-26 Thread John Salerno
John Salerno wrote: > def create_sql_script(self): > try: > f = open('labtables.sql') > sql_script = f.read() > except IOError: > wx.MessageBox('Could not locate the file "labtables.sql"', > 'File Not Found') >

which one of these is better?

2006-10-26 Thread John Salerno
def create_sql_script(self): try: with open('labtables.sql') as sql_script: return sql_script.read() except IOError: wx.MessageBox('Could not locate the file "labtables.sql"', 'File Not Found') OR

Re: What's the best IDE?

2006-10-26 Thread John Salerno
Neil Cerutti wrote: > On 2006-10-26, John Salerno <[EMAIL PROTECTED]> wrote: >> [EMAIL PROTECTED] wrote: >>> as I have yet to try Vim - maybe I'll try tomarrow. >> Warning: Vim isn't something you just "try tomorrow" :) > > You can become proficient enough for basic editing in about 20 > minutes

  1   2   3   >