vsergeev / python-periphery

A pure Python 2/3 library for peripheral I/O (GPIO, LED, PWM, SPI, I2C, MMIO, Serial) in Linux.
MIT License
519 stars 139 forks source link

Add kernel version check #49

Closed CrazyIvan359 closed 3 years ago

CrazyIvan359 commented 3 years ago

Fixes #48 as discussed

vsergeev commented 3 years ago

Sorry about the delay. Thanks. Cherry-picked in 9c1a4f3 in devel.

CrazyIvan359 commented 3 years ago

Just saw that you change from my list comprehension to the * sequence expansion, I don't think that works in Python 2 which is why I used list comp in the error message.

vsergeev commented 3 years ago

@CrazyIvan359 Are you thinking of an older Python 2? It works in Python 2.7:

Python 2.7.18 (default, Sep  5 2020, 11:17:26) 
[GCC 10.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> version = (1, 2)
>>> "foobar {}.{}".format(*version)
'foobar 1.2'
>>> 
CrazyIvan359 commented 3 years ago

Hmm... Maybe it's lists you can't do it with then? I remember I've had errors thrown at me for using that operator in 2.7 before. If it works here then all good!

vsergeev commented 3 years ago

Lists work too. Maybe you ran into this one: https://stackoverflow.com/questions/22257930/python-2-tuple-list-unpacking-using-star-throws-syntaxerror , which is Python 3 only. In any case, I tested the current code with both 2 and 3, so we should be good.

CrazyIvan359 commented 3 years ago

That looks familiar, yes.