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
#7
(Jun-22-2018, 07:17 PM)micseydel Wrote: Yes, you showed good use of is. When I say type checking is discouraged, I mean using type(x) == blah. Using is with an object (None) is very normal. (When you really need it, isinstance is used instead.)

Okay I think I understand. I sort of understand when I would use isinstance, I think:

    if isinstance(loc,LatLong):
      loc = loc.UTM()
as opposed to:

if type(loc) == types.InstanceType and loc.__class__ == LatLong:
            loc = loc.UTM()
Reply


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

Forum Jump:

User Panel Messages

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