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

2006-10-26 Thread Michael B. Trausch
Kenneth McDonald wrote: > > With the most recent edition of PyDev, I find Eclipse works quite well > for me. > Since you mentioned it, I have a question that searching around and poking around has not solved for me, yet. Do you have auto-completion working with your setup? It does not seem to w

Re: Embedded python loading .so files?

2006-10-26 Thread jefishman
> You really need to do some debugging here. There must be more error > message than that, or there are some issues with libdl on the target > system. A common problem is that it gives an error message that > some symbols could not be found when loading the shared library, > and that these symbols

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

2006-10-26 Thread olive
Michael B. Trausch a écrit : > Kenneth McDonald wrote: > > > > With the most recent edition of PyDev, I find Eclipse works quite well > > for me. > > > > Since you mentioned it, I have a question that searching around and > poking around has not solved for me, yet. > > Do you have auto-completion

Too little comments,

2006-10-26 Thread march
There're too little comments, and too much Chinese characters, and maybe you should give us an introduction about what renju is. -- http://mail.python.org/mailman/listinfo/python-list

Re: Dealing with multiple sets

2006-10-26 Thread John Henry
Oh, great. Learn something new everyday. For this, what I did was to build up a string, and then use eval on the string. Very ugly. Now I can simply do a reduce. Thanks, Brian Beck wrote: > John Henry wrote: > > What's the cleanest way to say: > > > > 1) Give me a list of the items that are

Re: my first software

2006-10-26 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > #!C:\\Python25 Just from curiosity: Since when does the hash bang work in Windows? Regards, Björn -- BOFH excuse #417: Computer room being moved. Our systems are down for the weekend. -- http://mail.python.org/mailman/listinfo/python-list

Re: Printing Hidden Character in Python

2006-10-26 Thread Bjoern Schliessmann
Wijaya Edward wrote: > How can we print out the hidden character like > "\n", "\r" etc in Python? Try repr(var)[1:-1] CMIIW. :) Regards, Björn -- BOFH excuse #271: The kernel license has expired -- http://mail.python.org/mailman/listinfo/python-list

Re: [IronPython] [ANN] IronPython Community Edition r3

2006-10-26 Thread M. David Peterson
Yee Hah! :D  Thanks Seo! :D > http://www.oreillynet.com/xml/blog/2006/10/seo_sanghyeonipce_ironpython_c.html On 10/26/06, Sanghyeon Seo <[EMAIL PROTECTED]> wrote: This is the third release of IronPython Community Edition (IPCE).Get it here.http://sparcs.kaist.ac.kr/~tinuviel/download/IPCE-r3.zip Th

Re: question about True values

2006-10-26 Thread Donn Cave
In article <[EMAIL PROTECTED]>, Steve Holden <[EMAIL PROTECTED]> wrote: ... > Maybe so, but that "rule" (and let's not forget that the zen is not > actually a set of prescriptive rules but rather guidelines for the > informed) is immediately preceded by the most important "rule" of all: > "Beau

Re: my first software

2006-10-26 Thread Fredrik Lundh
Bjoern Schliessmann wrote: >> #!C:\\Python25 > > Just from curiosity: Since when does the hash bang work in Windows? cygwin? exemaker? some kind of web server? -- http://mail.python.org/mailman/listinfo/python-list

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

2006-10-26 Thread Michael Ströder
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 "issuer()" > return are strings,

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

2006-10-26 Thread Michael Ströder
Donn Cave wrote: > In article <[EMAIL PROTECTED]>, > John Nagle <[EMAIL PROTECTED]> wrote: >> >>Note that >> >>"OU=Terms of use at www.verisign.com/rpa (c)00" >> >>with a "/" in the middle of the value field. > > ... > >>Is there a workaround for this? Without rebuilding Python >>and becomi

Re: SSL follow up

2006-10-26 Thread Michael Ströder
Paul Rubin wrote: > > To dump out the certificate? Try: > >openssl x509 -text -in filename.crt > > if the cert is in a file. Omit that -in parameter if you want openssl > to read from stdin. Of course now you get this other text format > thing to parse, but it's not so bad. I wouldn't re

[ANN] NumPy 1.0 release

2006-10-26 Thread Travis E. Oliphant
We are very pleased to announce the release of NumPy 1.0 available for download at http://www.numpy.org This release is the culmination of over 18 months of effort to allow unification of the Numeric and Numarray communities. NumPy provides the features of both packages as well as comparable

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

2006-10-26 Thread Tim Chase
Tim Roberts wrote: >> C:\temp\foo\bar>cd .. >> C:\temp\foo>cd .. >> C:\temp>cd /foo/bar > > This one does not work for me, but as long as the initial slash is back, > the rest can be foreward: > > C:\tmp>cd /foo/bar > The system cannot find the path specified. > C:\tmp>cd \foo/bar >

SSL and confirming certs

2006-10-26 Thread Yogesh Chawla - PD
Hello All, Here is a script I wrote to validate the cert sent by the server. It just makes system calls to open ssl. This is because python support is inadequate in this area. Let me know if this is helpful. I monkeyed with twisted, m2crypto, pyopenssl, and found myself sinking into a deep depr

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

<    1   2   3   >