Re: conditional running of code portion

2012-08-04 Thread Steven D'Aprano
On Sat, 04 Aug 2012 21:16:04 -0700, JW Huang wrote: > Hi, > > How can I implement something like C++'s conditional compile. > > if VERBOSE_MODE: print debug information else: do nothing > > But I don't want this condition to be checked during runtime as it will > slow down the code. You've pr

Re: On-topic: alternate Python implementations

2012-08-04 Thread Stefan Behnel
Jürgen A. Erhard, 05.08.2012 01:25: > On Sat, Aug 04, 2012 at 08:40:16AM +0200, Stefan Behnel wrote: >> Steven D'Aprano, 04.08.2012 08:15: >>> Most people are aware, if only vaguely, of the big Four Python >>> implementations: >> >> And not to forget Cython, which is the only static Python compile

Re: On-topic: alternate Python implementations

2012-08-04 Thread Stefan Behnel
Paul Rubin, 05.08.2012 03:38: > Steven D'Aprano writes: >> Runtime optimizations that target the common case, but fall back to >> unoptimized code in the rare cases that the optimization doesn't apply, >> offer the opportunity of big speedups for most code at the cost of >> trivial slowdowns whe

Re: when an iterable object is exhausted or not

2012-08-04 Thread Ramchandra Apte
An important use of range repeating. one_to_10 = range(1,10) one_to_5 = range(1,5) for x in one_to_5: for x in one_to_10:pass if range wasn't repeatable, range would have to be called 5 times compared with 1! On 5 August 2012 07:43, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote

Re: conditional running of code portion

2012-08-04 Thread Ramchandra Apte
Try pypreprocessor . Better idea: You should be using the loggingmodule if you want to print debug information quickly.It uses threads and is optimized to run fast. On 5 August 2012 09:46, JW Huang wrote: > H

conditional running of code portion

2012-08-04 Thread JW Huang
Hi, How can I implement something like C++'s conditional compile. if VERBOSE_MODE: print debug information else: do nothing But I don't want this condition to be checked during runtime as it will slow down the code. Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list

Re: Object Models - decoupling data access - good examples ?

2012-08-04 Thread shearichard
> > Just out of curiosity, why do you eschew ORMs? > Good question ! I'm not anti-ORM (in fact in many circs I'm quite pro-ORM) but for some time I've been working with a client who doesn't want ORMs used (they do have quite good reasons for this although probably not as good as they think).

Re: dbf.py API question

2012-08-04 Thread Ole Martin Bjørndalen
On Thu, Aug 2, 2012 at 5:55 PM, Ethan Furman wrote: > SQLite has a neat feature where if you give it a the file-name of ':memory:' > the resulting table is in memory and not on disk. I thought it was a cool > feature, but expanded it slightly: any name surrounded by colons results in > an in-memo

Re: On-topic: alternate Python implementations

2012-08-04 Thread Steven D'Aprano
On Sat, 04 Aug 2012 18:38:33 -0700, Paul Rubin wrote: > Steven D'Aprano writes: >> Runtime optimizations that target the common case, but fall back to >> unoptimized code in the rare cases that the optimization doesn't apply, >> offer the opportunity of big speedups for most code at the cost of >

Re: when an iterable object is exhausted or not

2012-08-04 Thread Steven D'Aprano
On Sat, 04 Aug 2012 21:20:36 +0200, Franck Ditter wrote: > Two similar iterable objects but with a different behavior : [...] > IMHO, this should not happen in Py3k. What is the rationale of this (bad > ?) design, which forces the programmer to memorize which one is > exhaustable and which one is

Re: On-topic: alternate Python implementations

2012-08-04 Thread Paul Rubin
Steven D'Aprano writes: > Runtime optimizations that target the common case, but fall back to > unoptimized code in the rare cases that the optimization doesn't apply, > offer the opportunity of big speedups for most code at the cost of > trivial slowdowns when you do something unusual. The pr

Re: Object Models - decoupling data access - good examples ?

2012-08-04 Thread Roy Smith
In article , shearich...@gmail.com wrote: > I should say I'm talking relational database here and, for various reasons, > ORMs are not involved. Just out of curiosity, why do you eschew ORMs? On the other hand, you really haven't. All you've done is rolled your own. So, the real question is

Re: On-topic: alternate Python implementations

2012-08-04 Thread Steven D'Aprano
On Sat, 04 Aug 2012 08:59:18 -0700, Paul Rubin wrote: > C isn't so great for high-assurance stuff either, compared to (say) Ada. > People do use it in critical apps, but that's just because it is (or > anyway used to be) so ubiquitous. And then they are shocked, SHOCKED I say!, when their app has

Re: when an iterable object is exhausted or not

2012-08-04 Thread Steven D'Aprano
On Sat, 04 Aug 2012 12:44:07 -0700, Tim Roberts wrote: >>$$$ i = filter(lambda c : c.isdigit(), 'a1b2c3') >>$$$ for x in i : print(x,end=' ') >>1 2 3 >>$$$ for x in i : print(x,end=' ')# i is exhausted >>$$$ >> >>IMHO, this should not happen in Py3k. > > It's interesting that it DOESN'T

Re: [newbie] Looking for a good introduction to object oriented programming with Python

2012-08-04 Thread shearichard
One reason you may be having difficulty is that unlike some languages (C++/Java) object-orientation is not a be all and end all in Python, in fact you could work with Python for a long time without really 'doing it' at all (well other than calling methods/properties on existing API's). Having sa

Object Models - decoupling data access - good examples ?

2012-08-04 Thread shearichard
I'm interested in best practice approaches to : decoupling data access code from application code; and translations between database structures and domain objects. For some time I've done database access by in a particular way and while I think it's OK it's not very pythonic so I'd be intereste

Re: On-topic: alternate Python implementations

2012-08-04 Thread Jürgen A . Erhard
On Sat, Aug 04, 2012 at 08:40:16AM +0200, Stefan Behnel wrote: > Steven D'Aprano, 04.08.2012 08:15: > > Most people are aware, if only vaguely, of the big Four Python > > implementations: > > > > And not to forget Cython, which is the only static Python compiler that is > widely used. Compiles a

Re: On-topic: alternate Python implementations

2012-08-04 Thread jwp
On Friday, August 3, 2012 11:15:20 PM UTC-7, Steven D'Aprano wrote: > WPython - another optimizing version of Python with wordcodes instead of > bytecodes. > > http://code.google.com/p/wpython/ I remember reading about this a while ago. I thought this was eventually going to be committed to CPy

Re: On-topic: alternate Python implementations

2012-08-04 Thread Stefan Behnel
Paul Rubin, 04.08.2012 22:43: > Stefan Behnel writes: >>> Calling CPython hardly counts as compiling Python into C. >> CPython is written in C, though. So anything that CPython does can be >> done in C. It's not like the CPython project used a completely unusual >> way of writing C code. > > CPyth

Re: when an iterable object is exhausted or not

2012-08-04 Thread Terry Reedy
On 8/4/2012 4:24 PM, Tim Chase wrote: On 08/04/12 14:20, Franck Ditter wrote: Two similar iterable objects but with a different behavior : $$$ i = range(2,5) $$$ for x in i : print(x,end=' ') 2 3 4 $$$ for x in i : print(x,end=' ')# i is not exhausted 2 3 4 - Compare with :

Re: trouble with pyplot in os x

2012-08-04 Thread Eric
On Saturday, August 4, 2012 8:11:44 AM UTC-5, William R. Wing (Bill Wing) wrote: > On Aug 3, 2012, at 11:12 PM, Eric wrote: > > > > > I'm just starting to futz around with matplotlib and I tried to run this > > > example from the matplotlib doc page (it's the imshow() example): > > > > > >

Re: On-topic: alternate Python implementations

2012-08-04 Thread Paul Rubin
Stefan Behnel writes: >> Calling CPython hardly counts as compiling Python into C. > CPython is written in C, though. So anything that CPython does can be > done in C. It's not like the CPython project used a completely unusual > way of writing C code. CPython is a relatively simple interpreter,

Re: when an iterable object is exhausted or not

2012-08-04 Thread Tim Chase
On 08/04/12 14:20, Franck Ditter wrote: > Two similar iterable objects but with a different behavior : > > $$$ i = range(2,5) > $$$ for x in i : print(x,end=' ') > > 2 3 4 > $$$ for x in i : print(x,end=' ')# i is not exhausted > > 2 3 4 > > - Compare with : > > $$$ i = fi

Re: when an iterable object is exhausted or not

2012-08-04 Thread MRAB
On 04/08/2012 20:20, Franck Ditter wrote: Two similar iterable objects but with a different behavior : $$$ i = range(2,5) $$$ for x in i : print(x,end=' ') 2 3 4 $$$ for x in i : print(x,end=' ')# i is not exhausted 2 3 4 - Compare with : $$$ i = filter(lambda c : c.isdigit()

Re: On-topic: alternate Python implementations

2012-08-04 Thread Tim Roberts
Steven D'Aprano wrote: > >Most people are aware, if only vaguely, of the big Four Python >implementations: > >CPython, or just Python, the reference implementation written in C. >IronPython, written in .NET. Technicality: .NET is not a language, it is a run-time framework. IronPython is written

Re: when an iterable object is exhausted or not

2012-08-04 Thread Tim Roberts
Franck Ditter wrote: > >Two similar iterable objects but with a different behavior : > >$$$ i = range(2,5) >$$$ for x in i : print(x,end=' ') > >2 3 4 >$$$ for x in i : print(x,end=' ')# i is not exhausted > >2 3 4 > >- Compare with : > >$$$ i = filter(lambda c : c.isdigit(),

when an iterable object is exhausted or not

2012-08-04 Thread Franck Ditter
Two similar iterable objects but with a different behavior : $$$ i = range(2,5) $$$ for x in i : print(x,end=' ') 2 3 4 $$$ for x in i : print(x,end=' ')# i is not exhausted 2 3 4 - Compare with : $$$ i = filter(lambda c : c.isdigit(), 'a1b2c3') $$$ for x in i : print(x,en

Re: On-topic: alternate Python implementations

2012-08-04 Thread MRAB
On 04/08/2012 20:06, Stefan Behnel wrote: Paul Rubin, 04.08.2012 20:18: Stefan Behnel writes: C is pretty poor as a compiler target: how would you translate Python generators into C, for example? Depends. If you have CPython available, that'd be a straight forward extension type. Calling CPy

Re: On-topic: alternate Python implementations

2012-08-04 Thread Stefan Behnel
Paul Rubin, 04.08.2012 20:18: > Stefan Behnel writes: >>> C is pretty poor as a compiler target: how would you translate Python >>> generators into C, for example? >> Depends. If you have CPython available, that'd be a straight forward >> extension type. > > Calling CPython hardly counts as compil

Re: On-topic: alternate Python implementations

2012-08-04 Thread Zero Piraeus
: On 4 August 2012 14:50, Mark Lawrence wrote: > > No. Next question? *plonk* -[]z. -- http://mail.python.org/mailman/listinfo/python-list

Re: On-topic: alternate Python implementations

2012-08-04 Thread Mark Lawrence
From: Zero Piraeus To: Mark Lawrence Cc: python-list@python.org Sent: Saturday, 4 August 2012, 19:42 Subject: Re: On-topic: alternate Python implementations : On 4 August 2012 14:24, Mark Lawrence wrote: > > With arrogance like that German by any chance

Re: On-topic: alternate Python implementations

2012-08-04 Thread Zero Piraeus
: On 4 August 2012 14:24, Mark Lawrence wrote: > > With arrogance like that German by any chance? I didn't give a monkeys about the beer conversation personally, but can we leave the national stereotypes out of it? -[]z. -- http://mail.python.org/mailman/listinfo/python-list

Re: On-topic: alternate Python implementations

2012-08-04 Thread Temia Eszteri
On Sat, 04 Aug 2012 19:24:12 +0100, Mark Lawrence wrote: >On 04/08/2012 11:59, Stefan Behnel wrote: >> Mark Lawrence, 04.08.2012 12:05: >>> I agree so it's off topic and can't be discussed here. Isn't that right, >>> Stefan? >> >> Hmm, in case you are referring to a recent friendly and diplomati

Re: On-topic: alternate Python implementations

2012-08-04 Thread Mark Lawrence
On 04/08/2012 11:59, Stefan Behnel wrote: Mark Lawrence, 04.08.2012 12:05: I agree so it's off topic and can't be discussed here. Isn't that right, Stefan? Hmm, in case you are referring to a recent friendly and diplomatic request of mine regarding a couple of people who were burdening a publ

Re: On-topic: alternate Python implementations

2012-08-04 Thread Paul Rubin
Stefan Behnel writes: >> C is pretty poor as a compiler target: how would you translate Python >> generators into C, for example? > Depends. If you have CPython available, that'd be a straight forward > extension type. Calling CPython hardly counts as compiling Python into C. > For the yielding,

Re: python pynotify with textbox input

2012-08-04 Thread Miki Tebeka
> how can i made a notification for gnome-shell with a textbox input ?? > library: pynotify? You can do it in many ways. You can use one of the Python GUI frameworks - Qt, wx, GTK ... You can use utilities like zenity ... -- http://mail.python.org/mailman/listinfo/python-list

Re: On-topic: alternate Python implementations

2012-08-04 Thread Stefan Behnel
Paul Rubin, 04.08.2012 17:59: > Stefan Krah writes: >> In the free software world, apparently many people like C. C is also >> quite popular in the zero-fault software world: Several verification >> tools do exist and Leroy et al. are writing a certified compiler for >> C to plug the hole between t

Re: On-topic: alternate Python implementations

2012-08-04 Thread Paul Rubin
Stefan Krah writes: > In the free software world, apparently many people like C. C is also > quite popular in the zero-fault software world: Several verification > tools do exist and Leroy et al. are writing a certified compiler for > C to plug the hole between the verified source code and the gen

[newbie] Looking for a good introduction to object oriented programming with Python

2012-08-04 Thread Jean Dubois
I'm looking for a good introduction to object oriented programming with Python. I am looking for an introduction which only refers to Python. I have seen introductions where the authors make comparisons to other languages such as C++ and Java, but as I don't know these languages that doesn't help m

Re: keyerror '__repr__'

2012-08-04 Thread Chris Rebert
On Sat, Aug 4, 2012 at 7:48 AM, vijay shanker wrote: > hi > i have this class book > > class book: > def __init__(self,name,price): > self.name = name > self.price = price > > def __getattr__(self,attr): > if attr == '__str__': > print 'intercepting in-b

keyerror '__repr__'

2012-08-04 Thread vijay shanker
hi i have this class book class book: def __init__(self,name,price): self.name = name self.price = price def __getattr__(self,attr): if attr == '__str__': print 'intercepting in-built method call ' return '%s:%s' % (object.__getattribute__(s

Re: trouble with pyplot in os x

2012-08-04 Thread William R. Wing (Bill Wing)
On Aug 3, 2012, at 11:12 PM, Eric wrote: > I'm just starting to futz around with matplotlib and I tried to run this > example from the matplotlib doc page (it's the imshow() example): > > import numpy as np > import matplotlib.cm as cm > import matplotlib.mlab as mlab > import matplotlib.pyplot

Re: On-topic: alternate Python implementations

2012-08-04 Thread Stefan Behnel
Stefan Behnel, 04.08.2012 15:53: > Thomas Rachel, 04.08.2012 14:51: >> Am 04.08.2012 11:10 schrieb Stefan Behnel: >>> As long as you don't use any features of the Cython language, it's plain >>> Python. That makes it a Python compiler in my eyes. >> >> Tell that the C++ guys. C++ is mainly a supers

Re: On-topic: alternate Python implementations

2012-08-04 Thread Stefan Behnel
Thomas Rachel, 04.08.2012 14:51: > Am 04.08.2012 11:10 schrieb Stefan Behnel: >> As long as you don't use any features of the Cython language, it's plain >> Python. That makes it a Python compiler in my eyes. > > Tell that the C++ guys. C++ is mainly a superset of C. But nevertheless, C > and C++

Re: avlhqw avlhqeavlhqino ovfqalmw avlhqei avlhqeaivscunqw

2012-08-04 Thread Ramchandra Apte
Is this spam? If not, can you please explain the message better (I don't get it) and *Please* change the title, it look like spam. On 3 August 2012 21:58, Martin Michael Musatov wrote: > Thanks to technology, a memorandum of understanding (thanks from Tel > Aviva / s, F `u / n (I [I TO rotate HM

Re: On-topic: alternate Python implementations

2012-08-04 Thread Ramchandra Apte
The first time I did reply not 'reply all', so I'm posting again. ;-) I think Cython is a Python implementation because you can only use the Python features, not the extra features. C++ is different because of the different rules (C was in a time of assembly and costly computers, C++ was made in th

Re: On-topic: alternate Python implementations

2012-08-04 Thread Thomas Rachel
Am 04.08.2012 11:10 schrieb Stefan Behnel: As long as you don't use any features of the Cython language, it's plain Python. That makes it a Python compiler in my eyes. Tell that the C++ guys. C++ is mainly a superset of C. But nevertheless, C and C++ are distinct languages and so are Python a

Re: On-topic: alternate Python implementations

2012-08-04 Thread Stefan Behnel
Steven D'Aprano, 04.08.2012 12:54: > Berp is based on the Glasgow Haskell Compiler, which is a modern, > efficient, optimizing compiler capable of producing excellent quality > machine code on Windows, Mac, Linux and many Unixes. It gives you all the > advantages of a high-level language with hi

Re: On-topic: alternate Python implementations

2012-08-04 Thread Stefan Krah
Steven D'Aprano wrote: > Who would want to deal with C's idiosyncrasies, low-powered explicit type > system, difficult syntax, and core-dumps, when you could use something > better? In the free software world, apparently many people like C. C is also quite popular in the zero-fault software wor

Re: On-topic: alternate Python implementations

2012-08-04 Thread Stefan Behnel
Mark Lawrence, 04.08.2012 12:05: > I agree so it's off topic and can't be discussed here. Isn't that right, > Stefan? Hmm, in case you are referring to a recent friendly and diplomatic request of mine regarding a couple of people who were burdening a public high volume mailing list with a purely

Re: On-topic: alternate Python implementations

2012-08-04 Thread Steven D'Aprano
On Sat, 04 Aug 2012 16:34:17 +1000, Chris Angelico wrote: > On Sat, Aug 4, 2012 at 4:15 PM, Steven D'Aprano > wrote: >> CLPython, an implementation of Python written in Common Lisp. >> >> Berp - a compiler which works by translating Python to Haskell and >> compiling that. > > Okay. WHY? CLPytho

Re: On-topic: alternate Python implementations

2012-08-04 Thread Mark Lawrence
On 04/08/2012 08:49, Steven D'Aprano wrote: On Sat, 04 Aug 2012 08:40:16 +0200, Stefan Behnel wrote: And not to forget Cython, which is the only static Python compiler that is widely used. Compiles and optimises Python to C code that uses the CPython runtime and allows for easy manual optimisat

Re: On-topic: alternate Python implementations

2012-08-04 Thread Stefan Behnel
Steven D'Aprano, 04.08.2012 09:49: > On Sat, 04 Aug 2012 08:40:16 +0200, Stefan Behnel wrote: >> And not to forget Cython, which is the only static Python compiler that >> is widely used. Compiles and optimises Python to C code that uses the >> CPython runtime and allows for easy manual optimisatio

Re: python pynotify with textbox input

2012-08-04 Thread Mark Lawrence
On 03/08/2012 23:50, dark.k...@gmail.com wrote: how can i made a notification for gnome-shell with a textbox input ?? library: pynotify? Write some code and when you get problems with it post the code here and we'll gladly answer your questions. -- Cheers. Mark Lawrence. -- http://mail.p

Re: On-topic: alternate Python implementations

2012-08-04 Thread Steven D'Aprano
On Sat, 04 Aug 2012 08:40:16 +0200, Stefan Behnel wrote: > And not to forget Cython, which is the only static Python compiler that > is widely used. Compiles and optimises Python to C code that uses the > CPython runtime and allows for easy manual optimisations to get C-like > performance out of i

Re: Eclipse and the Python plugin

2012-08-04 Thread lipska the kat
On 04/08/12 00:29, Cousin Stanley wrote: lipska the kat wrote: I can now create, debug and test a simple IRC server written in Java and an IRC Bot that I am attempting to build in Python For a bit of inspiration python-irc-bot-wise you might look at supybot Yep, it's t