[Tutor] kernel serie

Max Noel maxnoel_fr at yahoo.fr
Fri May 20 00:25:14 CEST 2005


On May 19, 2005, at 23:28, Jonas Melian wrote:

> I want get the kernel serie, so 2.x only (2.6 or 2.4)
>
> info_kernel = platform.release() # get the kernel version
> info_kernel = '.'.join(info_kernel.split('.',2)[:2])
>
> is there any way of get it in one line only?

     Based on your code, that'd be:

info_kernel = '.'.join(platform.release().split('.',2))

     The [:2] is unnecessary, as you're limiting the number of splits  
to 2, so the resulting list from split() can't have more than 3  
elements.

     Also, note that this code will likely cause the program to crash  
on any system that isn't Linux. On my box (OS X 10.4.1), for example,  
sys.platform returns 'darwin'.

-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
"Look at you hacker... A pathetic creature of meat and bone, panting  
and sweating as you run through my corridors... How can you challenge  
a perfect, immortal machine?"



More information about the Tutor mailing list