Python Forum
Question about types and py2 to py3 diffrences
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question about types and py2 to py3 diffrences
#1
I have been reading a bit on some of the py2 to py3 changes. I am a bit confused on some of the changes, for instance if I write in py2:

        if type(speed)==types.NoneType:
            speed = self.data.speed
and then I convert that using py2to3 it gives me:

if type(speed)==type(None):
            speed = self.data.speed
So in py2 the type of None is: <type 'NoneType'> where in py3 the type of None is <class 'NoneType'>. I guess what confuses me (coming from the java world) when I think of objects I think of having access to said objects methods. However, there are no methods for NoneType so what was the point on making it a class?

Also, if speed is defined to be none:

speed = None
Then would:
if type(speed)==type(None):
            speed = self.data.speed
be == to:
        if speed == None:
          speed = self.data.speed
in both py2 and py3?
Reply


Messages In This Thread
Question about types and py2 to py3 diffrences - by Vysero - Jun-22-2018, 04:39 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020