Extracting the first two components of a version number
I can't think of a simpler way of doing the splitting.

The only thing that comes to mind is replacing [0:2] by [:2] to take the first two components of the version number, since the first index in the slice notation defaults to the beginning of a sequence object.

However, instead of using a string, you could use a namedtuple with integer elements to represent a version number, which would allow you to do comparisons more easily:

&gt;&gt;&gt; from collections import namedtuple
&gt;&gt;&gt; VersionNumber = namedtuple('VersionNumber', 'major minor')
&gt;&gt;&gt; version_str = '1.2.3.dev0'
&gt;&gt;&gt; version = VersionNumber(*map(int, version_str.split('.')[:2]))
&gt;&gt;&gt; print(version)
VersionNumber(major=1, minor=2)
&gt;&gt;&gt; if version.major &lt; 2:  # don't care about minor version
...     print('Need at least version 2.')


You could easily convert it back to a string:

&gt;&gt;&gt; '.'.join(map(str, version))
'1.2'