wolferacing, that's what I've been saying, the code assumes version is '02.0-dev', but it's '0.2.0'. What my code does is assume '-dev' isn't there.
-- Edit: Fri Dec 11, 2015 11:02 pm --
Like wolferacing says, the version of fretwork is defined in the file fretwork/version.py in fretwork-0.2.0-cp27-none-win32.whl. The code weirdpeople wrote is sound if the version is '0.2.0-dev'.
This is the first line he wrote:
Code: Select all
version, verType = fretwork.__version__.split('-') # remove 'dev' from ver
This line splits this string on the character '-', and creates two variables: version = '0.2.0', and verType = 'dev'. (If version is '0.2.0', this line fails, because it can't be split on the character '-' as the string doesn't contain this character.)
This is the second line:
Code: Select all
version = tuple([int(i) for i in version.split('.')])
This line basically splits the string '0.2.0' on the character '.' in three elements (using the counter i), converts the elements to the array (0, 2, 0), and assigns the array to the variable version (replacing the string '0.2.0'). The variable version at this point contains the current version as an array, and verType contains the string 'dev'.
The variable fretworkRequired has been defined as the array (0, 2, 0) earlier in line 76. The variable version is then compared to fretworkRequired, and if the current current version is lower than the required version 0.2.0, it prints an error message. If it's 0.2.0 or higher, it continues and runs the game.
Rockslide, I'm not an expert on Python by any means, but I don't think your code does what you want it to do. I hope you don't mind me explaining why I think that.
This is the first line you wrote:
Code: Select all
version, verType = fretwork, '__version__'.split('.') # remove 'dev' from ver.
In the origina line fretwork.__version__ is a variable in fretwork (that's the meaning of the '.' after fretwork. In your code, because you've replaced the '.' with a ',', it's the module fretwork, and the string '__version__'. The module is then assigned to variable verion, and '__version__' is assigned to verType.
This is your second line:
Code: Select all
version = tuple([int(2) for i in '__version__'.split('.')])
This is a bit harder to explain. Because of the quotes '__version__' is a string as well. You're splitting it on '.', and assigning the result to the variable version. But because of the 'int(2)' in this line, the result is always the number 2, regardless of the value of version. If you had used 'int(9)', the result would have been the number 9 every time.
I tried to correct the error by assuming the version had the value '0.2.0' instead of '0.2.0-dev'. That's why I changed the code by weirdpeople, I removed the first line (no need to remove '-dev'), and changed the second line like so:
Code: Select all
version = tuple([int(i) for i in fretwork.__version__.split('.')])
This modified line just splits version in three elements (i), and converts the elements to the array (0, 2, 0).
This way the version check runs correctly, and the game starts. However, like wolferacing said, we don't have to modify weirdpeople's code at all. We can also make the game run correctly by changing version.py. I've decided to do exactly that.