Asymmetry in globals __getitem__/__setitem__

2014-06-12 Thread Robert Lehmann
Hi all, I have noticed there is a slight asymmetry in the way the interpreter (v3.3.5, reproduced also in v3.5.x) loads and stores globals. While loading globals from a custom mapping triggers __getitem__ just fine, writing seems to silently ignore __setitem__. class Namespace(dict): def __g

Re: how to overload operator "< <" (a < x < b)?

2009-08-07 Thread Robert Lehmann
On Fri, 07 Aug 2009 08:50:52 -0400, Benjamin Kaplan wrote: > On Fri, Aug 7, 2009 at 8:00 AM, dmitrey > wrote: >> hi all, >> is it possible to overload operator "<  <"? (And other like this one, >> eg "<=  <=", ">  >", ">=  >=") >> Any URL/example? >> Thank you in advance, D. > > That isn't an ope

Re: no sign() function ?

2008-12-22 Thread Robert Lehmann
On Mon, 22 Dec 2008 12:31:44 +0100, Pierre-Alain Dorange wrote: >> > I don't find any sign(x) function in the math library (return the >> > sign of the value). >> > I've read that math module is a wrapper to C math lib and that C math >> > lib has not sign(), so... [snip] > As my need is for a gam

Re: List Problem

2008-12-09 Thread Robert Lehmann
On Tue, 09 Dec 2008 21:40:08 -0800, dongzhi wrote: > I have one problem for List. Like that: > > format='just "a" ""little"" test' > part = format.split('"') > print part > > the result is : ['just ', 'a', ' ', '', 'little', '', ' test'] > > the list part have 7 element. > > If I execute part[

Re: multiple breaks

2008-11-15 Thread Robert Lehmann
On Thu, 13 Nov 2008 02:16:32 -0800, Chris Rebert wrote: > On Thu, Nov 13, 2008 at 2:07 AM, TP <[EMAIL PROTECTED]> > wrote: >> >> In the following example, is this possible to affect the two iterators >> to escape the two loops once one "j" has been printed: >> > Non-exception alternative: > > don

Re: My first Python program -- a lexer

2008-11-10 Thread Robert Lehmann
On Sun, 09 Nov 2008 15:53:01 +0100, Thomas Mlynarczyk wrote: > Arnaud Delobelle schrieb: > >> Adding to John's comments, I wouldn't have source as a member of the >> Lexer object but as an argument of the tokenise() method (which I would >> make public). The tokenise method would return what you

Re: Snippets management

2008-11-06 Thread Robert Lehmann
On Thu, 06 Nov 2008 05:23:25 -0600, Edwin wrote: [snip] > As I'm learning Python sometimes I look for different approaches to the > same problem so I use Git branches in order to save every try. It's > just that I'm looking for a 'global' place in my system where I can > save code ideas and useful

Re: Snippets management

2008-11-06 Thread Robert Lehmann
On Wed, 05 Nov 2008 19:55:51 -0600, Edwin wrote: > Hi there, > > I've been looking for a snippet manager and found PySnippet but it > requires PyGTK. Do you know any other option that doesn't need much? [snip] If you're looking for a snippet manager for actually *using* it (not educational purp

Re: contextlib.nested()

2008-11-06 Thread Robert Lehmann
On Thu, 06 Nov 2008 01:02:34 -0800, brasse wrote: > Hello! > > I have been running in to some problems when using contextlib.nested(). > My problem arises when using code similar to this: > > from __future__ import with_statement > > from contextlib import nested > > class Foo(object): > >

Re: Triple-quoted strings hath not the Python-nature

2008-10-21 Thread Robert Lehmann
On Tue, 21 Oct 2008 21:58:57 +1300, Lawrence D'Oliveiro wrote: > If triple-quoted strings had the Python-nature, then they would take > indentation into account. Thus: > > """this > is a > multi-line > string.""" > > would be equivalent to > > "this\n is a\n multi-line\nst

Re: Overloading operators

2008-10-15 Thread Robert Lehmann
On Wed, 15 Oct 2008 14:34:14 +0200, Mr.SpOOn wrote: > Hi, > in a project I'm overloading a lot of comparison and arithmetic > operators to make them working with more complex classes that I defined. > > Sometimes I need a different behavior of the operator depending on the > argument. For example

Re: Comparing float and decimal

2008-09-23 Thread Robert Lehmann
On Tue, 23 Sep 2008 07:20:12 -0400, D'Arcy J.M. Cain wrote: > I'm not sure I follow this logic. Can someone explain why float and > integer can be compared with each other and decimal can be compared to > integer but decimal can't be compared to float? In comparisons, `Decimal` tries to convert

Re: variable question

2008-07-11 Thread Robert Lehmann
On Fri, 11 Jul 2008 20:13:04 -0700, happy wrote: > Can a variable be considered the simplest of the data structures. I am > tutoring some kids about basics of programming using python. Not an > expert in computer sciences, but am a python enthusiast. Why do you need this additional layer of indir

Re: Ternary operator alternative in Ptyhon

2008-06-17 Thread Robert Lehmann
On Tue, 17 Jun 2008 23:18:51 -0700, kretik wrote: > I'm sure this is a popular one, but after Googling for a while I > couldn't figure out how to pull this off. > > Let's say I have this initializer on a class: > > def __init__(self, **params): Why not ``__init__(self, mykey=None)`` in the

Re: Name lookup inside class definition

2008-06-17 Thread Robert Lehmann
On Tue, 17 Jun 2008 23:05:56 -0700, WaterWalk wrote: > Hello. Consider the following two examples: class Test1(object): > att1 = 1 > def func(self): > print Test1.att1// ok > > class Test2(object): > att1 = 1 > att2 = Test2.att1 // NameError: Name Test2 is not defined

Re: generator functions: why won't this work?

2008-04-04 Thread Robert Lehmann
On Wed, 02 Apr 2008 19:04:30 -0300, Gabriel Genellina wrote: > En Wed, 02 Apr 2008 14:11:30 -0300, <[EMAIL PROTECTED]> escribió: > >> On Apr 1, 10:42 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: >>> En Tue, 01 Apr 2008 23:56:50 -0300, <[EMAIL PROTECTED]> >>> escribió: >>> >>>    yield *iter

Re: Running a python program as main...

2008-03-26 Thread Robert Lehmann
On Wed, 26 Mar 2008 13:05:55 -0300, Gabriel Genellina wrote: > En Wed, 26 Mar 2008 11:12:21 -0300, waltbrad <[EMAIL PROTECTED]> > escribió: > >> Stumbling through Mark Lutz's "Programming Python 3rd", he gives an >> example of a program that will automatically configure environment >> settings a