support for built-in function vars()
-
- Posts: 12
- Joined: Tue Sep 27, 2016 2:29 pm
support for built-in function vars()
Hi, I am new to Micropython. Currently working on porting middleware named "calvin" from Ericsson on micropython platform. I came across a problem due to wrapt library that uses vars() bult-in function. Are you planning to provide the functionality? Any hint how to get around this?
Thanks in advance for the reply!
Thanks in advance for the reply!
-
- Posts: 12
- Joined: Tue Sep 27, 2016 2:29 pm
Error while using __get__ in a class
Hi, I am getting an error "AttributeError: 'function' object has no attribute '__get__' on calling "__get__" method of a class. Any help?
Re: Error while using __get__ in a class
Perhaps a description of what object, of which class, from which module you're trying to use etc., would be helpful. A short description of what your code is trying to achieve and a code snippet would be of even more assistance! It is difficult to say what you're trying to do just from what you've written alone.
Re: support for built-in function vars()
I can't speak for all the developers, but if you look at point 8 at https://github.com/micropython/micropyt ... ifferences you will see, that this omission is one of the more important differences from cpython, and it seems like it would require quite some work (and lost performance) to implement it.
Re: support for built-in function vars()
What is that program using `vars()` for?
Re: Error while using __get__ in a class
Are you sure you are creating a class (using the "class" keyword) and not a function (using the "def" keyword)? I've seen that error before...
-
- Posts: 12
- Joined: Tue Sep 27, 2016 2:29 pm
Re: Error while using __get__ in a class
Well, I think the error is because I can not assign attribute to function object. For example
please make use of the code blocks - platforma
Why I wanted this feature, because the middleware that I am trying to port on micropython, uses wrapt decorator to get information about the calling instance of a class. wrapt uses vars() built.in which also not supported by micropython. Then I wrote a class decorator that uses __get__ descriptor to know the information about the calling instance of the wrapped method.
For more info, one can follow the link: http://blog.dscpl.com.au/2014/01/implem ... r.html?m=1
Any help will be really appreciable!
Code: Select all
>>> def f():
... pass
>>> f.a = 1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'function' object has no attribute 'a'
Why I wanted this feature, because the middleware that I am trying to port on micropython, uses wrapt decorator to get information about the calling instance of a class. wrapt uses vars() built.in which also not supported by micropython. Then I wrote a class decorator that uses __get__ descriptor to know the information about the calling instance of the wrapped method.
For more info, one can follow the link: http://blog.dscpl.com.au/2014/01/implem ... r.html?m=1
Any help will be really appreciable!
-
- Posts: 12
- Joined: Tue Sep 27, 2016 2:29 pm
Re: support for built-in function vars()
I replied in another thread that the middleware that I want to port on micropython uses wrapt package (https://pypi.python.org/pypi/wrapt). And wrapt internally uses vars().
Re: support for built-in function vars()
The topics are now merged.
-
- Posts: 12
- Joined: Tue Sep 27, 2016 2:29 pm
Re: support for built-in function vars()
Thanks! Just wanted to give a brief info about the project. The idea is to run calvin on micropython for IoT applications. Calvin is a middleware and provides actor-based programming model to ease developers from complexity of distributed computing. One can follow https://github.com/EricssonResearch/calvin-base for more info.