Re: weakrefs and bound methods

2007-10-11 Thread Mathias Panzenboeck
Bruno Desthuilliers wrote: > Mathias Panzenboeck a écrit : > > About the lost weakref problem: in Python, methods are just tiny > wrappers around the object, class and function created at lookup time > (yes, on *each* lookup) (and WWAI, they are by the function object > itself

Re: weakrefs and bound methods

2007-10-07 Thread Mathias Panzenboeck
Alex Martelli wrote: > Mathias Panzenboeck <[EMAIL PROTECTED]> wrote: > >> Marc 'BlackJack' Rintsch wrote: >>> ``del b`` just deletes the name `b`. It does not delete the object. >>> There's still the name `_` bound to it in the interactive int

Re: weakrefs and bound methods

2007-10-07 Thread Mathias Panzenboeck
Marc 'BlackJack' Rintsch wrote: > ``del b`` just deletes the name `b`. It does not delete the object. > There's still the name `_` bound to it in the interactive interpreter. > `_` stays bound to the last non-`None` result in the interpreter. > Actually I have the opposite problem. The referen

Re: weakrefs and bound methods

2007-10-07 Thread Mathias Panzenboeck
Marc 'BlackJack' Rintsch wrote: > On Sun, 07 Oct 2007 16:51:33 +0200, Mathias Panzenboeck wrote: > >> import weakref >> >> class Wrapper(object): >> def __init__(self,x): >> self.x = weakref.ref(x) >> >> def

Re: weakrefs and bound methods

2007-10-07 Thread Mathias Panzenboeck
When I change the class Wrapper to following, the class Foo works: class Wrapper(object): def __init__(self,x): self.func_name = x.func_name self.x = weakref.ref(x.im_self) def __call__(self,*args,**kwargs): x = self.x()

weakrefs and bound methods

2007-10-07 Thread Mathias Panzenboeck
Hi. I have a problem with weak refs and bound methods. The best explanation for the problem is a short bit of code. I have the three classes Wrapper, Foo and Bar: import weakref class Wrapper(object): def __init__(self,x): self.x = weakref.ref(x) def __call__(sel

Re: Bragging about Python

2007-06-07 Thread Mathias Panzenboeck
Steve Howell schrieb: > --- "[EMAIL PROTECTED]" > <[EMAIL PROTECTED]> wrote: > >> Is there a resource somewhere on the net that can be >> used to quickly >> and effectively show Python's strengths to >> non-Python programmers? >> Small examples that will make them go "Wow, that >> _is_ neat"? >> >

Re: Yield

2007-01-09 Thread Mathias Panzenboeck
Fredrik Lundh schrieb: > Danny Colligan wrote: > >> Carsten mentioned that generators are more memory-efficient to use when >> dealing with large numbers of objects. Is this the main advantage of >> using generators? Also, in what other novel ways are generators used >> that are clearly superior

Re: Wow, Python much faster than MatLab

2006-12-30 Thread Mathias Panzenboeck
A other great thing: With rpy you have R bindings for python. So you have the power of R and the easy syntax and big standard lib of python! :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Quake 3 and the Python interpreter

2006-12-15 Thread Mathias Panzenboeck
Neil Toronto wrote: > > 2) Is there any way to restrict Python modules from accessing files > outside of a sandbox? > As far as I heard, there is no really working way. But maybe that has changed in python 2.5? Or it will in 3.0? I dunno. -- http://mail.python.org/mailman/listinfo/python-list

Re: merits of Lisp vs Python

2006-12-14 Thread Mathias Panzenboeck
Bruno Desthuilliers wrote: > Mathias Panzenboeck a écrit : >> Rob Thorpe wrote: >> >>> Mathias Panzenboeck wrote: >>> >>>> Mark Tarver wrote: >>>> >>>>> How do you compare Python to Lisp? What specific advantages do you &g

Re: call of __del__ non-deterministic in python 2.4 (cpython)?

2006-12-13 Thread Mathias Panzenboeck
Anthony Baxter wrote: > On 12/13/06, Holger Joukl <[EMAIL PROTECTED]> wrote: >> I did read this but didn't think it applied to my situation. I'm quite >> sure that the refcount of the local variable is 1 before the local scope >> is left. >> So let me rephrase the question: Even if I can make sure

Re: merits of Lisp vs Python

2006-12-09 Thread Mathias Panzenboeck
Rob Thorpe wrote: > Mathias Panzenboeck wrote: >> Mark Tarver wrote: >>> How do you compare Python to Lisp? What specific advantages do you >>> think that one has over the other? >>> >>> Note I'm not a Python person and I have no axes to grind

Re: merits of Lisp vs Python

2006-12-08 Thread Mathias Panzenboeck
Mark Tarver wrote: > How do you compare Python to Lisp? What specific advantages do you > think that one has over the other? > > Note I'm not a Python person and I have no axes to grind here. This is > just a question for my general education. > > Mark > I do not know much about Lisp. What I

Re: type(foo) == function ?

2006-12-01 Thread Mathias Panzenboeck
Chris Mellon wrote: > On 11/29/06, Tom Plunket <[EMAIL PROTECTED]> wrote: >> I'd like to figure out if a given parameter is a function or not. >> >> E.g. >> >> >>> type(1) >> >> >>> type(1) == int >> True >> >> implies: >> >> >>> def foo(): >> ... pass >> ... >> >>> type(foo) >> >> >>> type(foo

Re: Generator question

2006-11-26 Thread Mathias Panzenboeck
Robert Kern wrote: > Timothy Wu wrote: >> Hi, >> >> Using generator recursively is not doing what I expect: >> >> def test_gen(x): >> yield x >> x = x - 1 >> if x != 0: >> test_gen(x) > > The only thing that the last line does is *create* a new generator object. You > need to a

Re: my small hashlib - using pythons hash-functions

2006-11-25 Thread Mathias Panzenboeck
Fredrik Lundh wrote: > Mathias Panzenboeck wrote: > >> But the question is: *IS* this derived work? I mean, it's not copied >> code. >> It's the same hashing-logic, which I learned by watching pythons code. > > given that it's only a few lines of

Re: my small hashlib - using pythons hash-functions

2006-11-25 Thread Mathias Panzenboeck
Paul Rubin wrote: > Mathias Panzenboeck <[EMAIL PROTECTED]> writes: >> So, can this code be considered as derived and do I have to put my >> code under the GPL? I'd like to publish it under something less >> restrictive, like a BSD style license. But if GPL is

my small hashlib - using pythons hash-functions

2006-11-25 Thread Mathias Panzenboeck
Hi. I wrote a small hashlib for C. Because I'm new to hashes I looked at pythons implementation and reused *some* of the code... or more the mathematical "hash-function", not really the code. In particular I looked at pythons hash and lookup functions, so I came up with this (see the code un

a few extensions for the itertools

2006-11-19 Thread Mathias Panzenboeck
I wrote a few functions which IMHO are missing in python(s itertools). You can download them here: http://sourceforge.net/project/showfiles.php?group_id=165721&package_id=212104 A short description to all the functions: icmp(iterable1, iterable2) -> integer Return negative if iterable1 <