Python Forum
why is my dictionary not recognized as such
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
why is my dictionary not recognized as such
#5
I must admit that Python comparisons and matches begin to drive me nuts:
       self.driver_id = supported_drivers[self.driver] if self.driver in supported_drivers else None
        print (self.driver, "\n", supported_drivers)

        print (self.driver, "  ", self.dbengine, "  ", self.driver_id, "\n\n")
        if 'Sybase' == self.driver:
            print ('Sybase', ' is equal ', self.driver)
            if self.dbengine == 'ASE':
                self.driver_id = 4
            elif self.dbengine == 'IQ':
                self.driver_id = 5
            elif self.dbengine != '':
                print(self.driver, "\n\n")
                sys.exit(self.dbengine)
        else:
            print ('Sybase', ' is not equal ', self.driver)
results:

'Sybase'
{'SQLite': 1, 'Sybase': 3, 'SybaseASE': 4, 'SybaseIQ': 5, 'SQLserver': 7, 'Oracle': 8, 'MongoDB': 10, 'DynamoDB': 11}
'Sybase' 'BLA' None


Sybase is not equal 'Sybase'

-------
as you see, self.driver is 'Sybase' and it is IN supported_drivers, yet Python says it is NOT.
And then it is NOT EQUAL to 'Sybase'...
What the heck is going here?

Now I do compare strings unless you tell me that in Python a string is also not a string under certain circumstances

Thank you
ZA
Reply


Messages In This Thread
RE: Dictionnaries - Equality - by zatlas1 - Jan-13-2019, 04:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  is import cointegration_analysis a recognized module mitcht33 1 440 Nov-06-2023, 09:29 PM
Last Post: deanhystad
  The term 'pip' is not recognized as the name of a cmdlet, function michaelnicol 1 642 Jul-16-2023, 11:12 PM
Last Post: deanhystad
  Index Function not recognized in Python 3 Peter_B_23 1 1,250 Jan-08-2023, 04:52 AM
Last Post: deanhystad
  TypeError: size; expecting a recognized type filling string dict a11_m11 0 2,544 Feb-10-2020, 08:26 AM
Last Post: a11_m11
  matplotlib isn't recognized after installation Pavel_47 5 2,855 Sep-18-2019, 07:01 PM
Last Post: snippsat
  how do i get y to be recognized in this comprehension? Skaperen 5 3,144 Aug-26-2019, 07:43 PM
Last Post: Skaperen
  pyserial-master installed bbut not recognized elwolv1 0 1,992 Jan-04-2019, 08:37 PM
Last Post: elwolv1
  How do I calculate the smallest value that is recognized as a difference when compari AFoeee 1 2,798 Oct-28-2018, 10:48 PM
Last Post: Gribouillis
  'videodigest' is not recognized as an internal or external command MM2018 2 2,792 Oct-12-2018, 02:43 PM
Last Post: MM2018
  Class attribute not recognized\working J125 1 5,402 Dec-19-2016, 01:05 AM
Last Post: Yoriz

Forum Jump:

User Panel Messages

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