shunwang / numexpr

Automatically exported from code.google.com/p/numexpr
MIT License
0 stars 0 forks source link

support for class instant variables. (self.abc) #46

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
class t:
    def __init__(self):
        self.t = 1
    def test(self, a):
        numexpr.evaluate('a + self.t')
test = t()
t.test(2)

I think evaluate() should be able to process 'self.t' but it doesn't

Original issue reported on code.google.com by kkb...@gmail.com on 20 Feb 2011 at 8:34

GoogleCodeExporter commented 9 years ago
class t:
    def __init__(self):
        self.t = 1
    def test(self, a):
        numexpr.evaluate('a + self.t')
test = t()
test(2) #This is right. sorry for mistyping

Original comment by kkb...@gmail.com on 20 Feb 2011 at 8:36

GoogleCodeExporter commented 9 years ago
You can get the answer you want using the optional local_dict parameter:

numexpr.evaluate('a + t', local_dict = {'a': a, 't': self.t})

Original comment by yanb...@gmail.com on 24 Feb 2011 at 9:28

GoogleCodeExporter commented 9 years ago
Thank you!

Original comment by kkb...@gmail.com on 24 Feb 2011 at 3:06

GoogleCodeExporter commented 9 years ago
but isn't it natural to support it directly?? It seems it's just a matter of 
parsing

Original comment by kkb...@gmail.com on 1 Mar 2011 at 2:58

GoogleCodeExporter commented 9 years ago
Well, sorry but I don't think this should be implemented. If enough other 
people think it's a good idea *and* somebody submit a patch, I might apply it. 
Until then I'll close this issue as Wontfix.

Original comment by gdemen...@gmail.com on 6 Sep 2011 at 10:30

GoogleCodeExporter commented 9 years ago
I feel like this is important. I understand if you don't have time, but I'd 
like to see this ability also. Array slicing is more important, though!

Original comment by wbuck...@beatsmusic.com on 15 Aug 2013 at 8:49