Consider a REPL with two tuples, a and b.
>>> type(a), type(b)
(<type 'tuple'>, <type 'tuple'>)
>>> a == b
True
So far, so good. But let's dig deeper...
>>> a[0] == b[0]
False
The tuples are equal, but their contents is not.
>>> a is b
True
In fact, there was only ever one tuple.
What is this madness?
>>> a
(nan,)
Welcome to the float zone.
Many parts of python assume that a is b implies a == b, but floats break this assumption. They also break the assumption that hash(a) == hash(b) implies a == b.
>>> hash(float('nan')) == hash(float('nan'))
True
Dicts handle this pretty elegantly:
>>> n = float('nan')
>>> {n: 1}[n]
1
>>> a = {float('nan'): 1, float('nan'): 2}
>>> a
{nan: 1, nan: 2}
Usually I never comment on blogs but your article is so convincing that I never stop myself to say something about it. You’re doing a great job Man learn Python Online Course
ReplyDeleteI am glad that I saw this post. It is informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward for your future posts. Python Projects for Students Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account. Project Center in Chennai
DeleteEnjoyed reading the article above, really explains everything in detail, the article is very interesting and effective. Thank you and good luck for the upcoming articles Python Programming Training
ReplyDeleteBest Job Courses after graduation course 100% Jobs CIITN
ReplyDeleteJob Guaranteed Professional courses after graduation Degree with job placement | CIITN
Courses after Bcom | Software engineer courses | 100% Jobs |CIITN
Guaranteed jobs near me.? | 100% Placements | CIITN
Software developer courses | 100% Placements | CIIT NOIDA
Software development courses training |100% Jobs| CIIT NOIDA
Best Job Courses after graduation course | 100% Jobs |CIITN
Job oriented short term courses after graduation | 100% Pleacements | CIITN
short term job oriented courses after graduation in India
6 month industrial training Institute |100% Placements|CIITN
Courses which guarantee a job
ReplyDeleteCourse with job guarantee
Courses that guarantee jobs
it training with job guarantee
100 job guarantee
job guarantee courses
job guarantee courses
Usually I never comment on blogs but your article is so convincing that I never stop myself to say something about it. You’re doing a great job Man learn Python Online Course
ReplyDeleteĐại lý vé máy bay Aivivu, tham khảo
ReplyDeletevé máy bay đi Mỹ hạng thương gia
vé máy bay từ mỹ về việt nam mùa dịch
giá vé máy bay từ anh về hà nội
vé máy bay từ pháp về việt nam