A couple of questions to the more experienced Python developers here. I have been working with my Fronius Symo solar inverter to extract data from the onboard API. It's actually a reasonably simple process of making a web request and then processing the resulting JSON.
There is one third party module, pyfronius, that has been written already that sort of performs these requests, but when I look inside the code I find myself asking lots of whys. There are a couple of things that the author has done that don't seem Pythonic and I was wondering if somebody could help clear up my thoughts. The two things I have noticed that I want to query 1) Everything in the __init__.py 2) Using Asynchronous web calls to the API Everything in the __init__.py file: The functional part of the module consists of a single __init__.py file. All the code is in this file. My understanding of the usage of this file is to provide a layout of the actual code files and perform global imports etc. The __init__.py references online never talk about putting actual code in there. Putting code in the file doesn't seem to be the right thing to do. I have seen this a couple of times with more obscure modules and my uninformed gut instinct is to say that the developer didnt quite know what they were doing. Using Asynchronous web calls to the API: The developer has used the asyncio module to perform the web queries and has used a lot of @asyncio.coroutine functions throughout the code. This doesn't seem... right for a module that simply goes to the web server and says "gime what you got... hmm.. yup.. thanks" This one is a little more along the lines of "developer choice" I think the method chosen overly complicates the design of the module. It seems something like requests could have been a better choice of module to use. Now, I'm not trying to point fingers at the original developer. There may be perfectly logical and sensible and Pythonic reasons for doing what they have done. I'm hoping a more experienced developer can hypothesis. I am writing my own module to talk to the inverter. Originally it was based on pyfronius but I have found myself completely reworking the methods to try and add exception handling and layout the code in a slightly better layout. I would be interested to know other peoples comments about the style.. David
_______________________________________________ melbourne-pug mailing list melbourne-pug@python.org https://mail.python.org/mailman/listinfo/melbourne-pug