Does Python automatically scan for data types and take a best guess in some cases? In pandas I can understand why one date is bigger than another(because it's set as a date time index), for example in this case:
DT
2016-05-20 22:22:00
2016-05-20 22:22:01
But in Python:
dt1 = '2016-05-20 22:22:00'
dt2 = '2016-05-20 22:22:01'
if dt2 > dt1:
print dt2
>>'2016-05-20 22:22:01'
So am I right to assume Python is automatically recognizing these as dates, or is there just some kind of fluke comparison of strings going on? Hence, is it safe to do this?
EDIT This question might differ from the proposed duplicate answer "String Comparison Technique Used by Python" as it uses dates, times and colons. The proposed duplicate answer gives some theoretical insight into lexicographical ordering, with groups of letters used in the examples, and while it may well be complete, there may sill be some uncertainty as to whether comparing sting dates is fail safe.
Hence for anyone stumbling across this: YES, you can compare string dates, safely.