doceme / py-spidev

MIT License
461 stars 203 forks source link

"with" statement support #32

Closed luxedo closed 9 years ago

luxedo commented 9 years ago

I've been searching for some documentation to implement with statement support for SpiDev and couldn't find much. Is there interest in adding this feature? If you point me some directions I can create a PR for that.

doceme commented 9 years ago

I think that's a good idea, but not something I'm planning to work on anytime soon. Feel free to create a PR for it if you get it working.

luxedo commented 9 years ago

I'm not quite comfortable writing python extensions in C, I'll take another look. Do you know any resources I can read about the with statement?

doceme commented 9 years ago

I don't expect you to implement it, but just wanted to warn you that I probably won't have time to add support for this soon. It looks like two new functions would need to be defined called "enter" and "exit". Have a look at this discussion: http://www.gossamer-threads.com/lists/python/python/949495 and this code as an example: https://github.com/jolicloud/python-apt/blob/master/python/lock.cc

Something similar would need to be added.

doceme commented 9 years ago

Looks like github strips out the underscores. There are supposed to be two underscore characters before and after the enter and exit above.

luxedo commented 9 years ago

ok! thanks!