[IPython-dev] ipipe news

Torsten Marek shlomme at gmx.net
Wed Mar 8 11:56:07 EST 2006

Fernando Perez schrieb:
> Walter Dörwald wrote:
>>I see: ipipe uses a new feature of eval() that makes it possible to pass 
>>a custom (non-dict) namespace. This makes it possible to directly 
>>reference the attributes of the object. For 2.3 compatibility I see 
>>several options:
>>1) Simply don't allow expression strings. This would only allow 
>>callables and
>>    iwalk | ifilter("name.endswith('.py')") | isort("size")
>>would turn into
>>    iwalk | ifilter(lambda _:_.name.endswith('.py')) | isort(lambda _:_size)
>>IMHO not so nice.
>>2) Pass a simple dictionary to eval() that just contains the object 
>>itself. The call would then look like this
>>    iwalk | ifilter("_.name.endswith('.py')") | isort("_.size")
>>3) Pass a dictionary that contains all the attributes from the list. 
>>This has the disadvantage that (for iwalk etc.) there will be many 
>>os.stat() calls, even if the result is never used (and you can't 
>>reference attributes that are not in the field list).
>>BTW, the reason why you got an empty browser was, because ifilter 
>>ignores all objects where evaluating the expression raises and 
>>Exception. And then the expression for isort never fails, because 
>>there's nothing left to sort.
>>Anyway, IMHO we should implement 2) and document the possibility to 
>>directly reference attributes as a "2.4 goodie".
> That sounds like  a good plan.  2.3 compatibility is important because a large 
> number of installed users still have that (Mac OSX and the 'enterprise' 
> versions of RedHat, amongst others) in their 'out of the box' configs.  But 
> it's OK if a few extra conveniences are only available for 2.4 when they they 
> can't be implemented in a backport, as long as the basic functionality (like 
> the example in the docstring :)  work with 2.3.


here's a patch for ipipe that works around the shortcomings of Python 2.3. I
don't know whether is satisfies the constraint in 3, but it works for the
examples mentioned here on the list.

best regards


Torsten Marek <shlomme at gmx.net>
ID: A244C858 -- FP: 1902 0002 5DFC 856B F146  894C 7CC5 451E A244 C858
Keyserver: subkeys.pgp.net

-------------- next part --------------
A non-text attachment was scrubbed...
Name: python2.3-eval-workaround.patch
Type: text/x-patch
Size: 730 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20060308/98b812eb/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20060308/98b812eb/attachment.sig>

More information about the IPython-dev mailing list