Hi,
I try to get a set of lambda functions that allows me executing each
function code exactly once. Therefore, I would like to modify the set
function to compare the func_code properties (or the lambda
functions to use this property for comparison).
(The reason is that the real function list
On Sun, 25 May 2008 13:43:15 +0200, Martin Manns wrote:
Hi,
I try to get a set of lambda functions that allows me executing each
function code exactly once. Therefore, I would like to modify the set
function to compare the func_code properties (or the lambda functions to
use this property
On Sun, 25 May 2008 13:43:15 +0200, Martin Manns wrote:
Hi,
I try to get a set of lambda functions that allows me executing each
function code exactly once. Therefore, I would like to modify the set
function to compare the func_code properties (or the lambda functions to
use this property
On Sun, 25 May 2008 12:14:25 + (UTC)
Ivan Illarionov [EMAIL PROTECTED] wrote:
On Sun, 25 May 2008 13:43:15 +0200, Martin Manns wrote:
Maybe make a set of code objects?
func_code_set = set([f.func_code for f in funclist])
funclist = []
for fc in func_code_set:
f = lambda x: x
On Sun, 25 May 2008 13:43:15 +0200, Martin Manns wrote:
I try to get a set of lambda functions that allows me executing each
function code exactly once. Therefore, I would like to modify the set
function to compare the func_code properties (or the lambda functions to
use this property for
I V:
You might instead want to
wrap the lambdas in an object that will do the comparison you want:
This looks very nice, I haven't tried it yet, but if it works well
then it may deserve to be stored in the cookbook, or better, it may
become the built-in behavior of hashing functions.
Bye,
This may have some bugs left, but it looks a bit better:
from inspect import getargspec
class HashableFunction(object):
Class that can be used to wrap functions, to allow their
hashing,
for example to create a set of unique functions.
func_strings = ['x', 'x+1', 'x+2', 'x']
On Sun, May 25, 2008 at 1:43 PM, Martin Manns [EMAIL PROTECTED] wrote:
Hi,
I try to get a set of lambda functions that allows me executing each
function code exactly once. Therefore, I would like to modify the set
function to compare the func_code properties (or the lambda
functions to use
On Sun, May 25, 2008 at 1:43 PM, Martin Manns [EMAIL PROTECTED] wrote:
Hi,
I try to get a set of lambda functions that allows me executing each
function code exactly once. Therefore, I would like to modify the set
function to compare the func_code properties (or the lambda
functions to use
Denis Kasak wrote:
...
spam = []
for i in range(10):
... spam.append(lambda: i)
spam[0]()
9
spam[1]()
9
Manually creating the lambdas and appending them to a list works as
expected, naturally; I don't see a good reason why it wouldn't work
with a loop. Am I missing something?
Yes, you
Scott David Daniels wrote:
Denis Kasak wrote:
...
spam = []
for i in range(10):
... spam.append(lambda: i)
spam[0]()
9
spam[1]()
9
Manually creating the lambdas and appending them to a list works as
expected, naturally; I don't see a good reason why it wouldn't work
with a loop. Am I
On Sun, 25 May 2008 14:39:28 -0700 (PDT)
[EMAIL PROTECTED] wrote:
This may have some bugs left, but it looks a bit better:
[...]
self._hash = hash(self._func.func_code) ^ \
hash(tuple(signature[0]) + tuple(signature[1:3]))
def __eq__(self, other):
I V [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
| On Sun, 25 May 2008 13:43:15 +0200, Martin Manns wrote:
| I try to get a set of lambda functions that allows me executing each
I think it worth the reminder that Python has lambda *expressions* that
result in function objects
Martin Manns [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
| On Sun, 25 May 2008 14:39:28 -0700 (PDT)
| [EMAIL PROTECTED] wrote:
|
| This may have some bugs left, but it looks a bit better:
| [...]
| self._hash = hash(self._func.func_code) ^ \
|
Martin Manns wrote:
Hi,
I try to get a set of lambda functions that allows me executing each
function code exactly once. Therefore, I would like to modify the set
function to compare the func_code properties (or the lambda
functions to use this property for comparison).
(The reason is that
15 matches
Mail list logo