Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread Seebs
On 2010-11-07, Nobody wrote: > I'm arguing that the reference manual reads too much like a specification. > E.g. look at "5.2.4. List displays" and tell me whether you consider that > it adequately /explains/ list displays to someone wishing to use them. Seems pretty explanatory to me. I mean, m

Re: subclassing str

2010-11-06 Thread Chris Rebert
On Sat, Nov 6, 2010 at 10:43 PM, not1xor1 (Alessandro) <" "@libero.it> wrote: > Hi, > > I'd like to know what is the best way to subclass str > I need to add some new methods and that each method (both new and str ones) > return my new type > > For instance I've seen I can do: > > class mystr(str):

Re: Allowing comments after the line continuation backslash

2010-11-06 Thread Lawrence D'Oliveiro
In message , Roy Smith wrote: > In article , > Lawrence D'Oliveiro wrote: > >> In message <8jd3m9fr5...@mid.individual.net>, Neil Cerutti wrote: >> >> > On 2010-11-03, Ben Finney wrote: >> > >> >> styles = [ >> >> ("normal", "image", MainWindow.ColorsNormalList), >> >>

Re: sigaction?

2010-11-06 Thread Lawrence D'Oliveiro
In message , Neal Becker wrote: > I'm interested in trying sigaction with SA_RESTART to prevent interrupted > system calls. Worse-is-better strikes again ... -- http://mail.python.org/mailman/listinfo/python-list

subclassing str

2010-11-06 Thread not1xor1 (Alessandro)
Hi, I'd like to know what is the best way to subclass str I need to add some new methods and that each method (both new and str ones) return my new type For instance I've seen I can do: class mystr(str): def between(self, start, end): i = self.index(start) + len(start) j = se

python test frameworks

2010-11-06 Thread Rustom Mody
There are a large number of test frameworks in/for python. Apart from what comes builtin with python there seems to be nose, staf, qmtest etc etc. Is there any central place where these are listed with short descriptions? 'Test framework' means widely different things in different contexts. Any e

Re: Compare source code

2010-11-06 Thread Seebs
On 2010-11-07, Steven D'Aprano wrote: > On Sun, 07 Nov 2010 14:53:45 +1300, Lawrence D'Oliveiro wrote: >> In message , Seebs wrote: >>> Four spaces followed by a tab nearly always actually means "eight >>> spaces" to most editors (and Python seems to treat it that way), but >>> it's hard to tell.

Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread Nobody
On Sun, 07 Nov 2010 00:06:25 +, Steven D'Aprano wrote: >> A reference manual tells you how to use the language. A specification >> tells you how to implement it. > > Surely a tutorial tells you *how* to use the language. I wouldn't expect > a reference manual to teach me how to run and edit

Re: Compare source code

2010-11-06 Thread Steven D'Aprano
On Sun, 07 Nov 2010 14:53:45 +1300, Lawrence D'Oliveiro wrote: > In message , Seebs wrote: > >> Specifically: >> >> Four spaces followed by a tab nearly always actually means "eight >> spaces" to most editors (and Python seems to treat it that way), but >> it's hard to tell. Worse, a tab may hav

Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread Seebs
On 2010-11-07, Roy Smith wrote: > Any self-respecting C++ programmer would have given > up the scavenger hunt by now. Just kept throwing typecasts at your code > until it compiles, and move on. That does not sound like a self-respecting programmer of anything. -s -- Copyright 2010, all wrong

Re: how to handle network failures

2010-11-06 Thread Aahz
In article <7bee5155-f1a1-44aa-90f6-eaabb3617...@v6g2000prd.googlegroups.com>, harryos wrote: > >class DataGrabber(threading.Thread): >def __init__(self,url): >threading.Thread.__init__(self) >self.url=url >def run(self): >data=self.get_page_data() >process

Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread Roy Smith
In article <87fwve53ve@xemacs.org>, Hrvoje Niksic wrote: > It's not a matter of quality, but of intended audience. To most > ordinary programmers the standards documents such as the C standard, the > C++ standard, or the Python reference are quite dense and hard to use as > a reference, and

Re: How to test if a module exists?

2010-11-06 Thread Roy Smith
In article , Jon Dufresne wrote: > I went ahead and implemented this and it now works. I even uncovered a > bug I wasn't previously seeing because now the program was failing > early! :) Excellent. Fail early and often, that's what I say. -- http://mail.python.org/mailman/listinfo/python-list

Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread Seebs
On 2010-11-07, Hrvoje Niksic wrote: > It's not a matter of quality, but of intended audience. To most > ordinary programmers the standards documents such as the C standard, the > C++ standard, or the Python reference are quite dense and hard to use as > a reference, and yet they are considered qu

Re: Compare source code

2010-11-06 Thread Seebs
On 2010-11-07, Lawrence D'Oliveiro wrote: > In message , Seebs wrote: >> Four spaces followed by a tab nearly always actually means "eight spaces" >> to most editors (and Python seems to treat it that way), but it's hard to >> tell. Worse, a tab may have been intended to be the same thing as four

Re: How to test if a module exists?

2010-11-06 Thread Jon Dufresne
On Sat, Nov 6, 2010 at 1:52 PM, Roy Smith wrote: > > import sys > try: >    import xx > except ImportError: >    tb = sys.exc_traceback >    while tb: >        print tb >        tb = tb.tb_next > I went ahead and implemented this and it now works. I even uncovered a bug I wasn't previously seeing

Re: Compare source code

2010-11-06 Thread Lawrence D'Oliveiro
In message , Seebs wrote: > Specifically: > > Four spaces followed by a tab nearly always actually means "eight spaces" > to most editors (and Python seems to treat it that way), but it's hard to > tell. Worse, a tab may have been intended to be the same thing as four > spaces, and someone was ex

Re: ANN: PyQt v4.8.1 Released

2010-11-06 Thread Lawrence D'Oliveiro
In message , Robert Kern wrote: > On 11/6/10 2:34 AM, Steve Holden wrote: > >> On 11/5/2010 6:14 PM, Lawrence D'Oliveiro wrote: >> >>> In message, Дамјан >>> Георгиевски wrote: >>> >> PyQt is available under the GPL and a commercial license. > > Surely you mean “proprietary” rather th

Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread Hrvoje Niksic
Seebs writes: > On 2010-11-06, Hrvoje Niksic wrote: >> I don't speak for "Nobody", but to me a reference manual would be a >> document intended for the user of the language. The thing for the >> language lawyer is something intended for the implementor, or possibly >> for the very advanced user

Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread Seebs
On 2010-11-07, Steven D'Aprano wrote: > Surely a tutorial tells you *how* to use the language. I wouldn't expect > a reference manual to teach me how to run and edit programs -- the *how* > of using the language. There's a sort of fuzzy boundary about how the term "reference manual" is used. S

Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread Mark Wooding
Steven D'Aprano writes: > If you want to argue that the Python reference manual is aimed at the > wrong level of sophistication, specifically that the BNF syntax stuff > should be ripped out into another document, then I might agree with > you. But to argue that it's entirely the wrong "kind" of

Re: How to test if a module exists?

2010-11-06 Thread Seebs
On 2010-11-06, Roy Smith wrote: > from __future__ import bugs Now I want this. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nos...@seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get ed

Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread Steven D'Aprano
On Sat, 06 Nov 2010 23:19:18 +, Nobody wrote: > On Fri, 05 Nov 2010 22:51:10 +, Seebs wrote: > >>> IMHO, the lack of a reference manual for the language itself is a >>> major hole in Python's documentation. >> >> I'm a bit lost here. Could you highlight some of the differences >> betwee

Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread Nobody
On Fri, 05 Nov 2010 22:51:10 +, Seebs wrote: >> IMHO, the lack of a reference manual for the language itself is a major >> hole in Python's documentation. > > I'm a bit lost here. Could you highlight some of the differences between > "a reference manual for the language itself" and "somethin

Re: functions, list, default parameters

2010-11-06 Thread Steven D'Aprano
On Sat, 06 Nov 2010 12:37:42 +, Mark Wooding wrote: >> > _missing = ['missing'] >> >> A curious choice for the sentinel value. We're not using Python 1.5 any >> longer > > Two reasons. Firstly, this comes from my Lisp background: making a list > is the obvious way of producing an unf

Re: execute shell script from python, needs sys.argv

2010-11-06 Thread Tim Roberts
Benjamin Kaplan wrote: > >Python is not the shell. Shell commands are not python commands. You >need either a string or a list of strings, so any literal have to be >in quotes. Also, subprocess can't handle the redirection. You need to >run it as two commands. > >proc1 = subprocess.Popen(["cat", s

Re: How to test if a module exists?

2010-11-06 Thread Roy Smith
In article <4cd5d8a3$0$30004$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > > Since when does Python have translated error messages? > > Since Python 3.2.4. Or will it be 3.3.5? I will forget. > > *wink* from __future__ import bugs :-) -- http://mail.python.org/mailman/listin

Re: How to test if a module exists?

2010-11-06 Thread Mark Wooding
Chris Rebert writes: > Since when does Python have translated error messages? It doesn't yet. How much are you willing to bet that it never will? ;-) -- [mdw] -- http://mail.python.org/mailman/listinfo/python-list

Re: How to test if a module exists?

2010-11-06 Thread Steven D'Aprano
On Sat, 06 Nov 2010 13:54:09 -0700, Chris Rebert wrote: > On Sat, Nov 6, 2010 at 1:01 PM, Mark Wooding > wrote: >> Chris Rebert writes: >> >>>     if err.message != "No module named extension_magic_module": >> >> Ugh!  Surely this can break if you use Python with different locale >> settings! >

Re: How to test if a module exists?

2010-11-06 Thread Chris Rebert
On Sat, Nov 6, 2010 at 11:50 AM, Jon Dufresne wrote: > On Sat, Nov 6, 2010 at 11:35 AM, Chris Rebert wrote: >> Here's what I came up with: >> >> try: >>     import extension_magic_module >> except ImportError as err: >>    if err.message != "No module named extension_magic_module": >>        rais

Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread Seebs
On 2010-11-06, rantingrick wrote: > On Nov 5, 5:51?pm, Seebs wrote: >> I'm a bit lost here. ?Could you highlight some of the differences >> between "a reference manual for the language itself" and "something >> written for language lawyers"? > In a word HUMOR! Huh? > Obviously the commentator

Re: How to test if a module exists?

2010-11-06 Thread Roy Smith
In article , Chris Rebert wrote: > On Sat, Nov 6, 2010 at 11:22 AM, Jon Dufresne wrote: [...] > > However, if the the extension module exists but throws an ImportError, > > due to a bug in the extension this idiom will mask the error and I > > will never see it. Later on in the program I will g

Re: How to test if a module exists?

2010-11-06 Thread Chris Rebert
On Sat, Nov 6, 2010 at 1:01 PM, Mark Wooding wrote: > Chris Rebert writes: > >>     if err.message != "No module named extension_magic_module": > > Ugh!  Surely this can break if you use Python with different locale > settings! Since when does Python have translated error messages? Cheers, Chri

Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread Steve Holden
On 11/6/2010 10:45 AM, D'Arcy J.M. Cain wrote: >> I realize that the Python Foundation doesn't have infinite resources >> > to work with, so maybe they'd love to create & maintain a more readable >> > language reference if they had time/money/people. I don't hear anyone >> > talk about it, though.

Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread rantingrick
On Nov 5, 5:51 pm, Seebs wrote: > On 2010-11-05, Nobody wrote: > > > However, it's still written for language lawyers. > > IMHO, the lack of a reference manual for the language itself is a major > > hole in Python's documentation. > > I'm a bit lost here.  Could you highlight some of the differen

Re: How to test if a module exists?

2010-11-06 Thread Mark Wooding
Chris Rebert writes: > if err.message != "No module named extension_magic_module": Ugh! Surely this can break if you use Python with different locale settings! -- [mdw] -- http://mail.python.org/mailman/listinfo/python-list

Re: functions, list, default parameters

2010-11-06 Thread Mark Wooding
Dennis Lee Bieber writes: > On Sat, 06 Nov 2010 12:37:42 +, m...@distorted.org.uk (Mark Wooding) > declaimed the following in gmane.comp.python.general: > > > > > Two reasons. Firstly, this comes from my Lisp background: making a > > list is the obvious way of producing an unforgeable objec

Re: How to test if a module exists?

2010-11-06 Thread Rob Williscroft
Jon Dufresne wrote in news:aanlktikr5euhqpupa3yrid98oas92zfhk8u9lha5y...@mail.gmail.com in gmane.comp.python.general: > try: > import extension_magic_module > except ImportError: > pass > else: > handle_extension_magic_module() > > > However, if the the extension module exists but

Re: *** FBI gets a warm welcome in Chicago for their EXCELLENTperformance - cheers to NEW CONS ***

2010-11-06 Thread Gunner Asch
On Sat, 06 Nov 2010 08:59:06 -0600, F. George McDuffee wrote: >On Tue, 02 Nov 2010 20:33:18 -0700, Gunner Asch > wrote: > >>On Tue, 02 Nov 2010 13:58:16 -0700, Rich Grise >>wrote: >> >>>On Tue, 02 Nov 2010 14:17:29 -0700, Gunner Asch wrote: But...shrug..there will be far less after th

Re: How to test if a module exists?

2010-11-06 Thread Jon Dufresne
On Sat, Nov 6, 2010 at 11:35 AM, Chris Rebert wrote: > Here's what I came up with: > > try: >     import extension_magic_module > except ImportError as err: >    if err.message != "No module named extension_magic_module": >        raise err > else: >    handle_extension_magic_module() > It seems

Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread Ned Deily
In article <11a0f261-1bf4-4c35-83fa-c47bf968d...@semanchuk.com>, Philip Semanchuk wrote: > On Nov 6, 2010, at 12:33 AM, Steven D'Aprano wrote: > > On Fri, 05 Nov 2010 23:21:11 -0400, Philip Semanchuk wrote: > > > >> Take the OP's question. How is one supposed to find out about bitwise > >> opera

Re: How to test if a module exists?

2010-11-06 Thread Chris Rebert
On Sat, Nov 6, 2010 at 11:22 AM, Jon Dufresne wrote: > Hi, > > My python program has an extension system where the extension can have > a optional magic python modules. Meaning if the extension module > exists, the program will use it and if not, it will continue without > the module. So my progra

How to test if a module exists?

2010-11-06 Thread Jon Dufresne
Hi, My python program has an extension system where the extension can have a optional magic python modules. Meaning if the extension module exists, the program will use it and if not, it will continue without the module. So my program tests if a module exists, if so use it, otherwise continue. Thi

Re: How find all childrens values of a nested dictionary, fast!

2010-11-06 Thread Alexander Gattin
Hello, On Thu, Nov 04, 2010 at 09:20:04PM +, Arnaud Delobelle wrote: > Tough requirement, but I think I've got it. Two > lambdas, one reduce, one map ;) > > >>> a = {'a' : {'b' :{'/' :[1,2,3,4], 'ba' :{'/' :[41,42,44]}, 'bc' > >>> :{'/':[51,52,54], 'bcd' :{'/':[68,69,66]}}},'c' :{'/' :[5,6,

Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread Seebs
On 2010-11-06, Hrvoje Niksic wrote: > I don't speak for "Nobody", but to me a reference manual would be a > document intended for the user of the language. The thing for the > language lawyer is something intended for the implementor, or possibly > for the very advanced user who argues with the i

Re: ANN: PyQt v4.8.1 Released

2010-11-06 Thread Robert Kern
On 11/6/10 2:34 AM, Steve Holden wrote: On 11/5/2010 6:14 PM, Lawrence D'Oliveiro wrote: In message, Дамјан Георгиевски wrote: PyQt is available under the GPL and a commercial license. Surely you mean “proprietary” rather than “commercial”. There is nothing about the GPL that prevents “comme

Re: Split iterator into multiple streams

2010-11-06 Thread Arnaud Delobelle
Steven D'Aprano writes: > Suppose I have an iterator that yields tuples of N items (a, b, ... n). > > I want to split this into N independent iterators: > > iter1 -> a, a2, a3, ... > iter2 -> b, b2, b3, ... > ... > iterN -> n, n2, n3, ... > > The iterator may be infinite, or at least too big to c

Symposium “Image Processing and Analysis in Biomed ical Engineering” within CompBioMed 2011 – Announce & Ca ll

2010-11-06 Thread tava...@fe.up.pt
Dear Colleague, Within the 2nd International Conference on Computational & Mathematical Biomedical Engineering (CompBioMed 2011), to be held in Washington D.C., USA, in 30th March - 1st April 2011 (www.compbiomed.net), we are organizing the Symposium “Image Processing and Analysis in Biomedical En

Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread D'Arcy J.M. Cain
On Sat, 6 Nov 2010 10:22:47 -0400 Philip Semanchuk wrote: > > The tutorial isn't meant as an exhaustive lesson on every single Python > > feature. > > I agree, and I don't expect otherwise. My point was that if the > tutorial doesn't mention a feature, the only other place to learn about > it (o

Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread Philip Semanchuk
On Nov 6, 2010, at 12:33 AM, Steven D'Aprano wrote: > On Fri, 05 Nov 2010 23:21:11 -0400, Philip Semanchuk wrote: > >> Take the OP's question. How is one supposed to find out about bitwise >> operators in Python? AFAICT they're not mentioned in the tutorial, and >> neither are decorators, assert

Re: *** FBI gets a warm welcome in Chicago for their EXCELLENTperformance - cheers to NEW CONS ***

2010-11-06 Thread F . George McDuffee
On Tue, 02 Nov 2010 20:33:18 -0700, Gunner Asch wrote: >On Tue, 02 Nov 2010 13:58:16 -0700, Rich Grise >wrote: > >>On Tue, 02 Nov 2010 14:17:29 -0700, Gunner Asch wrote: >>> >>> But...shrug..there will be far less after the Great Cull >> >>I think some people might be surprised as to ex

Get frame object of last called function

2010-11-06 Thread moerchendiser2k3
Hi, is there any chance to get the frame object of the previous called function? I just find the 'f_back' frame object but this is the frame object of the parent function, not the previous one. I try to get the line number of the exit point of the previous function. (0) def Test(): (1) print

Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread Hrvoje Niksic
Seebs writes: > I'm a bit lost here. Could you highlight some of the differences > between "a reference manual for the language itself" and "something > written for language lawyers"? I don't speak for "Nobody", but to me a reference manual would be a document intended for the user of the langu

Deditor 0.2.2

2010-11-06 Thread Kruptein
Hey, I released version 0.2.2 of my pythonic text-editor Deditor. It adds the use of projects, a project is a set of files which you can open all at once to make development much faster and easier. For more information visit launchpad: http://launchpad.net/deditor I also uploaded a video to int

Re: Compare source code

2010-11-06 Thread rustom
On Nov 6, 5:21 pm, m...@distorted.org.uk (Mark Wooding) wrote: > Rustom Mody writes: > > As for tools' brokeness regarding spaces/tabs/indentation heres a > > thread on the emacs list wherein emacs dev Stefan Monnier admits to > > the fact that emacs' handling in this regard is not perfect. > > >h

Re: functions, list, default parameters

2010-11-06 Thread Mark Wooding
Steven D'Aprano writes: > On Fri, 05 Nov 2010 12:17:00 +, Mark Wooding wrote: > > Right; so a half-decent compiler can notice this and optimize > > appropriately. Result: negligible difference. > > Perhaps the biggest cost is that now your language has inconsistent > semantics: some functio

Re: Allowing comments after the line continuation backslash

2010-11-06 Thread Roy Smith
In article , Lawrence D'Oliveiro wrote: > In message <8jd3m9fr5...@mid.individual.net>, Neil Cerutti wrote: > > > On 2010-11-03, Ben Finney wrote: > > > >> styles = [ > >> ("normal", "image", MainWindow.ColorsNormalList), > >> ("highlighted", "highlight", MainWindo

Re: Why "flat is better than nested"?

2010-11-06 Thread rustom
On Nov 6, 2:52 pm, Peter Otten <__pete...@web.de> wrote: > rustom wrote: > > If you take zen seriously you dont get it > > If you dont take zen seriously you dont get it > > You forgot: > > If you explain zen you don't get it I guess different communities have different settings for 'explanation-

Re: Compare source code

2010-11-06 Thread Mark Wooding
Rustom Mody writes: > As for tools' brokeness regarding spaces/tabs/indentation heres a > thread on the emacs list wherein emacs dev Stefan Monnier admits to > the fact that emacs' handling in this regard is not perfect. > > http://groups.google.com/group/gnu.emacs.help/browse_thread/thread/1bd0c

Re: Compare source code

2010-11-06 Thread Tim Chase
On 11/06/10 03:27, Seebs wrote: On 2010-11-06, Steve Holden wrote: If someone were to use a text editor which had always historically mangled whitespace I would find myself wondering why they found it necessary to restrict themselves to such stone-age tools. I have yet to find an editor that

Re: Silly newbie question - Carrot character (^)

2010-11-06 Thread Tim Chase
On 11/05/10 23:33, Steven D'Aprano wrote: As far as the OP's question, I'm kind of surprised that he wasn't told that Google is his friend. The very first hit for "python caret" answers his question. If he had spent even five seconds googling, he would have got his answer. http://www.google.co.u

Re: Why "flat is better than nested"?

2010-11-06 Thread J. Gerlach
Am 06.11.2010 02:36, schrieb Steven D'Aprano: > On Fri, 05 Nov 2010 14:19:47 +0100, J. Gerlach wrote: > >> Am 28.10.2010 03:40, schrieb Steven D'Aprano: >>> [ snip a lot of wise words ] >> >> Can I put this (translated) in the german python wiki? I guess it might >> help more people to understand

Re: Using Python for a demonstration in historical linguistics

2010-11-06 Thread Vlastimil Brom
2010/11/6 Dax Bloom : > Hello, > > In the framework of a project on evolutionary linguistics I wish to > have a program to process words and simulate the effect of sound > shift, for instance following the Rask's-Grimm's rule. I look to have > python take a dictionary file or a string input and rep

Re: What people are using to access this mailing list

2010-11-06 Thread Kev Dwyer
On Wed, 03 Nov 2010 11:17:32 +, Steven D'Aprano wrote: > On Wed, 03 Nov 2010 08:02:29 +, John Bond wrote: > >> Hope this isn't too O/T - I was just wondering how people read/send to >> this mailing list, eg. normal email client, gmane, some other software >> or online service? > > Usenet

Re: Using Python for a demonstration in historical linguistics

2010-11-06 Thread Peter Otten
Peter Otten wrote: s = """ > ... In the framework of a project on evolutionary linguistics I wish to > ... have a program to process words and simulate the effect of sound > ... shift, for instance following the Rask's-Grimm's rule. I look to have > ... python take a dictionary file or a stri

Best practice approach for trapping Tkinter exceptions

2010-11-06 Thread python
What is the best practice approach for trapping Tkinter exceptions? Example: When using the Text widget with undo=True, attempting an edit_undo or edit_redo raises a Tkinter exception when there are no actions to undo or redo. It doesn't look like there's a Tkinter specific exception being raised

Re: Using Python for a demonstration in historical linguistics

2010-11-06 Thread garabik-news-2005-05
Dax Bloom wrote: ... > I look to have > python take a dictionary file or a string input and replace the > consonants in it with the Grimm rule equivalent. ... > How easy is it to find the python functions > to do that? > http://code.activestate.com/recipes/81330-single-pass-multiple-replace/ --

Re: Exception handling with NameError

2010-11-06 Thread Peter Otten
Zeynel wrote: > On Nov 5, 1:26 pm, Peter Otten <__pete...@web.de> wrote: > >> Of course I'm only guessing because you don't provide enough context. >> >> Peter > > Thanks. > > This is the problem I am having, in general: > > K = [] # a container list > K = ["A", "B"] > > ARCHIVE = [] # a lis

Re: Using Python for a demonstration in historical linguistics

2010-11-06 Thread Steven D'Aprano
On Sat, 06 Nov 2010 11:09:34 +0100, Peter Otten wrote: > If you are using nonascii characters like θ you should use unicode > instead of str. Basically this means writing string constants as u"..." > instead of "..." Or using Python 3.1 instead of 2.x. -- Steven -- http://mail.python.org/ma

Re: Exception handling with NameError

2010-11-06 Thread Peter Otten
Dennis Lee Bieber wrote: >> The problem I am having is this: If I do: >> >> K = [] >> ARCHIVE = [] >> ARCHIVE.append(K) >> >> any time K is updated (user submits new input) the content of ARCHIVE >> is erased: >> > No, it is NOT erased... It is MUTATED... But he rebinds the ARCHIVE name. -- ht

Re: Using Python for a demonstration in historical linguistics

2010-11-06 Thread Peter Otten
Dax Bloom wrote: > Hello, > > In the framework of a project on evolutionary linguistics I wish to > have a program to process words and simulate the effect of sound > shift, for instance following the Rask's-Grimm's rule. I look to have > python take a dictionary file or a string input and replac

Re: Why "flat is better than nested"?

2010-11-06 Thread Peter Otten
rustom wrote: > If you take zen seriously you dont get it > If you dont take zen seriously you dont get it You forgot: If you explain zen you don't get it -- http://mail.python.org/mailman/listinfo/python-list

Re: Final state of underlying sequence in islice

2010-11-06 Thread Peter Otten
Raymond Hettinger wrote: > If the RightAnswer(tm) is obvious to you, I would > like to hear it. It isnt ;) > If I had to make a choice right > now, I would choose stopping at the earlier possible > point rather than scanning to the next natural > boundary. +1 Not because it leaves the underl

Re: Split iterator into multiple streams

2010-11-06 Thread Paul Rubin
Steven D'Aprano writes: > def split(iterable, n): > iterators = [] > for i, iterator in enumerate(itertools.tee(iterable, n)): > f = lambda it, i=i: (t[i] for t in it) > iterators.append(f(iterator)) > return tuple(iterators) > > Is this the right approach, or have I mi

Re: Split iterator into multiple streams

2010-11-06 Thread Peter Otten
Steven D'Aprano wrote: > Suppose I have an iterator that yields tuples of N items (a, b, ... n). > > I want to split this into N independent iterators: > > iter1 -> a, a2, a3, ... > iter2 -> b, b2, b3, ... > ... > iterN -> n, n2, n3, ... > > The iterator may be infinite, or at least too big to

Re: Split iterator into multiple streams

2010-11-06 Thread Raymond Hettinger
On Nov 6, 1:52 am, Steven D'Aprano wrote: > I tried changing the t[i] to use operator.itergetter instead, but no > luck. Finally I got this: > > def split(iterable, n): >     iterators = [] >     for i, iterator in enumerate(itertools.tee(iterable, n)): >         f = lambda it, i=i: (t[i] for t in

Re: Split iterator into multiple streams

2010-11-06 Thread Ian
On Nov 6, 2:52 am, Steven D'Aprano wrote: > My first attempt was this: > > def split(iterable, n): >     iterators = [] >     for i, iterator in enumerate(itertools.tee(iterable, n)): >         iterators.append((t[i] for t in iterator)) >     return tuple(iterators) > > But it doesn't work, as all

Split iterator into multiple streams

2010-11-06 Thread Steven D'Aprano
Suppose I have an iterator that yields tuples of N items (a, b, ... n). I want to split this into N independent iterators: iter1 -> a, a2, a3, ... iter2 -> b, b2, b3, ... ... iterN -> n, n2, n3, ... The iterator may be infinite, or at least too big to collect in a list. My first attempt was thi

Re: Compare source code

2010-11-06 Thread Seebs
On 2010-11-06, Steve Holden wrote: > If someone were to use a text editor which had always historically > mangled whitespace I would find myself wondering why they found it > necessary to restrict themselves to such stone-age tools. I have yet to find an editor that allows me to, well, *edit*, mo

Re: Allowing comments after the line continuation backslash

2010-11-06 Thread Steven D'Aprano
On Wed, 03 Nov 2010 12:42:49 +, Neil Cerutti wrote: > On 2010-11-03, Ben Finney wrote: >> I would do the same, but fix the indentation. Making indentation depend >> on the *length* of the previous line is needlessly making a maintenance >> burden. >> >> Instead, I'd do:: >> >> styles = [

Re: Why "flat is better than nested"?

2010-11-06 Thread rustom
On Oct 26, 12:11 am, kj wrote: > In Steve Holden > writes: > > > > >On 10/25/2010 10:47 AM, rantingrick wrote: > >> On Oct 25, 5:07 am, kj wrote: > >>> In "The Zen of Python", one of the "maxims" is "flat is better than > >>> nested"?  Why?  Can anyone give me a concrete example that illustrat

Re: Compare source code

2010-11-06 Thread Steve Holden
On 11/5/2010 4:09 PM, Seebs wrote: > On 2010-11-05, Grant Edwards wrote: >> On 2010-11-05, Seebs wrote: >>> On 2010-11-05, Emile van Sebille wrote: So, which of your tools are you married to that are causing your issues? > >>> Python. > >> I think you should quit using Python and choose a

Re: ANN: PyQt v4.8.1 Released

2010-11-06 Thread Steve Holden
On 11/5/2010 6:14 PM, Lawrence D'Oliveiro wrote: > In message , Дамјан Георгиевски > wrote: > PyQt is available under the GPL and a commercial license. >>> >>> Surely you mean “proprietary” rather than “commercial”. There is >>> nothing about the GPL that prevents “commercial” use. >> >> I t

Re: Allowing comments after the line continuation backslash

2010-11-06 Thread Lawrence D'Oliveiro
In message <8jd3m9fr5...@mid.individual.net>, Neil Cerutti wrote: > On 2010-11-03, Ben Finney wrote: > >> styles = [ >> ("normal", "image", MainWindow.ColorsNormalList), >> ("highlighted", "highlight", MainWindow.ColorsHighlightedList), >> ("selected","sel

Re: Using %x to format number to hex and number of digits

2010-11-06 Thread Steve Holden
On 11/5/2010 3:26 PM, Matty Sarro wrote: > It works, however I'm not sure if it'd be considered very "pythonic" or not. If working isn't pythonic then nothing is. > Thanks for your thoughts! There really are still some amazingly helpful people around here, I am pleased to note. regards Steve -

Re: Regular expression

2010-11-06 Thread John Bond
On 6/11/2010 2:16 AM, MRAB wrote: On 06/11/2010 01:25, Paul Hemans wrote: I need to extract the quoted text from : _("get this") The following works: re.compile( "_\(['\"]([^'\"]+)['\"]\)" ) However, I don't want to match if there is A-Z or a-z or 0-9 or _ immediately preceding the "_" so I hav