Start a hangout

## Profile

Tasos Latsas

Works at e-Travel

Attended Kingston University

89 followers|86,998 views

AboutPostsPhotosYouTubeReviews

## Stream

### Tasos Latsas

Shared publicly -/bin/echo ' Είσαι έμπειρος sysadmin και σου αρέσει να δημιουργείς, να συντηρείς και να εξελίσσεις συστήματα; Έλα στην ομάδα μας! http://goo.gl/mVvDXo ' #jobs #career #sysadmin

1

Add a comment...

### Tasos Latsas

Shared publicly -I was asked on Twitter why Python uses 0-based indexing, with a link to a new (fascinating) post on the subject (http://exple.tive.org/blarg/2013/10/22/citation-needed/). I recall thinking about it a lot; ABC, one of Python's predecessors, used 1-based indexing, while C, the other big influence, used 0-based. My first few programming languages (Algol, Fortran, Pascal) used 1-based or variable-based. I think that one of the issues that helped me decide was slice notation.

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.

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.

1

Add a comment...

### Tasos Latsas

Shared publicly -Amazing photos of US cities in the early 1900s by airship: http://chi.mg/10IMAtq

The Chicago photographer George R. Lawrence shot incredible panoramic images of major events in US cities from his 17-kite Lawrence Captive Airship.

1

Add a comment...

### Tasos Latsas

Shared publicly -Some random photos from the amazing euruko 2013.

8 photos

1

Add a comment...

### Tasos Latsas

Shared publicly -**Meet the new Google Maps**: built to be smarter and more immersive. Each time you click or search, our new technology draws you a tailored map that highlights the information you need. Learn more: http://goo.gl/93IFB

Want to be among the first to experience the new desktop Google Maps? Request an invite at www.google.com/maps/preview

#newgooglemaps #io13 #googleio

1

Add a comment...

In his circles

141 people

### Communities

12 communities### Tasos Latsas

Shared publicly -Fixing good ol' reliable. This was my first laptop, and after 6 (I think) years it urgently needed some cleaning and thermal paste. It was getting hot, around 60-65°C when idle, just after the boot process.

The operation was a success as it now gets around 35° on idle and around 60° on high load. Hopefully in a few days it might drop a little more as the thermal paste reaches its optimal thermal conductivity.

The operation was a success as it now gets around 35° on idle and around 60° on high load. Hopefully in a few days it might drop a little more as the thermal paste reaches its optimal thermal conductivity.

4

3 comments

Nice, another achievement unlocked

Add a comment...

People

In his circles

141 people

Communities

12 communities

Education

- Kingston UniversityNetworking and Data Communications
- Technological Educational Institute of AthensComputer Science

Story

Introduction

Linux, Open Source, Hackerspaces, Web, APIs, CodeClubs, Beer, Music, Sci-Fi, Animes.

Work

Occupation

Software Engineer

Employment

- e-TravelSoftware engineer, present
- Flipnode LLCSoftware engineer, 2013 - 2014
- Technological Educational Institute of AthensDeveloper and Sysadmin, 2011 - 2012

Basic Information

Gender

Male

Other names

tasidus at freenode