Re: inheriting from long on Python2 or int on Python3

2020-03-21 Thread Terry Reedy
On 3/21/2020 1:19 PM, duncan smith wrote: Hello, I have a class I wrote for Python2 that needs to be made to work on Python3. On Python2 it inherited from long, so it needs to inherit from int on Python3. In general, if you want code to work on both 2 and 3, look into the bi-version

Re: inheriting from long on Python2 or int on Python3

2020-03-21 Thread Chris Angelico
On Sun, Mar 22, 2020 at 11:31 AM duncan smith wrote: > but (tentatively) opted for something that avoided creating new names at > the module level. If it doesn't look too terrible I might stick with it > for now (although I am quite tempted to go back to the above). Thanks > Skip and Chris. Nah,

Re: inheriting from long on Python2 or int on Python3

2020-03-21 Thread duncan smith
On 21/03/2020 21:55, Skip Montanaro wrote: >> import sys >> >> class C_hash(int if sys.version_info.major >= 3 else long): > ... > > There's nothing incorrect with your solution. Chris offered another. I > was going to suggest you consider running your code through 2to3 to > see what it does. I

Re: inheriting from long on Python2 or int on Python3

2020-03-21 Thread Skip Montanaro
> import sys > > class C_hash(int if sys.version_info.major >= 3 else long): ... There's nothing incorrect with your solution. Chris offered another. I was going to suggest you consider running your code through 2to3 to see what it does. I created a C_hash class similar to yours: class

Re: inheriting from long on Python2 or int on Python3

2020-03-21 Thread Chris Angelico
On Sun, Mar 22, 2020 at 4:21 AM duncan smith wrote: > > Hello, > I have a class I wrote for Python2 that needs to be made to work > on Python3. On Python2 it inherited from long, so it needs to inherit > from int on Python3. The following works, but I'm not sure it's the > cleanest

inheriting from long on Python2 or int on Python3

2020-03-21 Thread duncan smith
Hello, I have a class I wrote for Python2 that needs to be made to work on Python3. On Python2 it inherited from long, so it needs to inherit from int on Python3. The following works, but I'm not sure it's the cleanest solution. It's the first time I've wanted / needed to make a parent class