Let's first look at use cases. Probably the most common use cases for slicing are "get the first n items" and "get the next n items starting at i" (the first is a special case of that for i == the first index). It would be nice if both of these could be expressed as without awkward +1 or -1 compensations.
Using 0-based indexing, half-open intervals, and suitable defaults (as Python ended up having), they are beautiful: a[:n] and a[i:i+n]; the former is long for a[0:n].
Using 1-based indexing, if you want a[:n] to mean the first n elements, you either have to use closed intervals or you can use a slice notation that uses start and length as the slice parameters. Using half-open intervals just isn't very elegant when combined with 1-based indexing. Using closed intervals, you'd have to write a[i:i+n-1] for the n items starting at i. So perhaps using the slice length would be more elegant with 1-based indexing? Then you could write a[i:n]. And this is in fact what ABC did -- it used a different notation so you could write a@i|n.(See http://homepages.cwi.nl/~steven/abc/qr.html#EXPRESSIONS.)
But how does the index:length convention work out for other use cases? TBH this is where my memory gets fuzzy, but I think I was swayed by the elegance of half-open intervals. Especially the invariant that when two slices are adjacent, the first slice's end index is the second slice's start index is just too beautiful to ignore. For example, suppose you split a string into three parts at indices i and j -- the parts would be a[:i], a[i:j], and a[j:].
So that's why Python uses 0-based indexing.
My friend, Karthikeyan, tried to send an IM to me, but it ended up going to a totally different person. As you can see in the first pic, he messaged me saying
there's something wrong with my gtalk
But the Hangouts history shows that those IMs went to Aman Haji instead. Surprisingly they don't show up in his GTalk window. His reply saying "Haha Ok" shows that the message has indeed shown up on his side.
The second pic is just more proof of the same bug. This time GTalk sends the message to a totally different person.
The IM "mastered R" ends up going to Vijay Bhaskar instead of me.
This problem exists whomever he tries to contact, not only me. Also, he is using the old version of Google Talk. He hasn't upgraded to Google Hangouts yet.
This is a serious privacy breach on GMail's end and could have serious repercussions. My guess is that the recent updates to Hangouts could have caused some unknown bug.
- Amazon.comSDE Intern, 2012 - 2012
- Ozonetel Systems Pvt. LtdSummer Intern, 2011 - 2011
Did my undergrad in Computer Science and Engineering at Indian Institute of Technology - Kharagpur.
- Georgia Institute of TechnologyComputer Science (Machine Learning), present
- IIT KharagpurComputer Science and Engineering, 2009 - present
- FIITJEE Junior CollegeIntermediate, 2007 - 2009
- The Brigade School2004 - 2007
- Hyderabad Public School2000 - 2004
Why Free Software Is More Important Now Than Ever Before | Wired Opinion...
GNU just turned 30 years old. But much has changed since the beginning of the free software movement; now there's SaaS and more. Malware is
Any.DO: To Do List | Task List - Apps on Android Market
Any.DO Is a Crazy Intuitive, Gesture-Based To-Do App for Android (lifehacker) Any.DO is a free to-do list that helps you get things done wit
Google Now Commands for Jelly Bean Android 4.1 | Kickedface
Google Now tells you today's weather before you start your day, how much traffic to expect before you leave for work, when the next train wi