Re: Pre-PEP: Dictionary accumulator methods - typing initialising

2005-03-20 Thread Kay Schluehr
Matteo Dell'Amico wrote: Kay Schluehr wrote: Why do You set d.defaultValue(0) d.defaultValue(function=list) but not d.defaultValue(0) d.defaultValue([]) ? I think that's because you have to instantiate a different object for each different key. Otherwise, you would

Re: For loop extended syntax

2005-03-20 Thread Kay Schluehr
George Sakkis wrote: This would be very useful for list/generator comprehensions, for example being able to write something like: [x*y-z for (x,y,z=0) in (1,2,3), (4,5), (6,7,8)] Looks very appealing, but what to do with [x*y-z for (x=0,y,z) in (1,2,3), (4,5), (6,7,8)] ? Should it raise

Re: For loop extended syntax

2005-03-20 Thread Kay Schluehr
George Sakkis wrote: Looks very appealing, but what to do with [x*y-z for (x=0,y,z) in (1,2,3), (4,5), (6,7,8)] ? Should it raise an exception due to a pattern mismatch? I didn't have in mind to generalize the syntax even more than the respective for function signatures, therefore

Re: Variable Variable

2005-03-19 Thread Kay Schluehr
Tanteauguri wrote: Hi List, is there in python a variable variable like in PHP ($$var)? What I want to do is something like that: pc=[a,b,c] for i in pc: i = anyclass() a.shutdown() b.update() Any Ideas? def seq(n,cls,*args,**kw): create a sequence of n objects of type

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Kay Schluehr
Raymond Hettinger wrote: I would like to get everyone's thoughts on two new dictionary methods: def count(self, value, qty=1): try: self[key] += qty except KeyError: self[key] = qty def appendlist(self, key, *values):

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Kay Schluehr
George Sakkis wrote: -1 form me. I'm not very glad with both of them ( not a naming issue ) because i think that the dict type should offer only methods that apply to each dict whatever it contains. count() specializes to dict values that are addable and appendlist to those that are

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Kay Schluehr
*pling* ! I'm sometimes a bit slow :) Regards Kay -- http://mail.python.org/mailman/listinfo/python-list

Re: Why tuple with one item is no tuple

2005-03-18 Thread Kay Schluehr
Antoon Pardon wrote: for instance I have written once somekind of vector class where it was natural for these vectors to be added as well as te be concatenated. Unfortunately python uses + for both so I had no way to have both operators in a natural way in python. Yes this is a quite common

Re: Python becoming less Lisp-like

2005-03-17 Thread Kay Schluehr
Paul Boddie wrote: The principal advantage of the property function was to permit the definition of active attributes without having a huge if...elif...else statement in the __getattr__ method. So the motivation was seemingly to externalize the usually simple logic in __getattr__ so that one

Re: Python becoming less Lisp-like

2005-03-16 Thread Kay Schluehr
Torsten Bronger wrote: Hallöchen! Moin! [First, I wanted to say descriptors instead of decorators (I superseded my post).] The goal is to trigger function calls when attributes are accessed. This is called properties in C# (and maybe in Ruby, too). Python now also has this concept. What

Lisp-likeness

2005-03-15 Thread Kay Schluehr
Maybe You can answer my question what this simple LISP function does ? (defun addn (n) #'(lambda (x) (+ x n))) This is correct LISP-syntax if You bear in mind LISPs powerwull macro language... I think Guido and python-dev are very carefull in adding new power to Python.

Re: Overriding properties - Javaesque property rant

2004-12-12 Thread Kay Schluehr
There are several ways to fix it. The simplest would be to create a new property object in CC's definition: class CC(C): def set_value(self, val): if val 0: self.__val = 1 else: self.__val = val value = property(C.get_value,

rexec and bastion

2004-12-05 Thread Kay Schluehr
Cited from Python-doc ( v.2.3 ) [Warning: In Python 2.3 these modules have been disabled due to various known and not readily fixable security holes. The modules are still documented here to help in reading old code that uses the rexec and Bastion modules.] My question about rexec and bastion

<    3   4   5   6   7   8