FAUN — Developer Community 🐾

We help developers learn and grow by keeping them up with what matters. 👉 www.faun.dev

Follow publication

Member-only story

Go For Python Developers

Part-3: Composite Datatypes

Umangshrestha
FAUN — Developer Community 🐾
4 min readDec 4, 2021

Lists

The List is the ordered collection of multiple elements. The equivalent in Go is Slice. The main feature of Slice is it dynamic size?

Array

Negative Indexing

Python list generally has more features compared to Slice in Go. Python supports negative indexing. For Go, we have to access it as follows:

Insert

Python also has an insert function that allows us to add value to any specific position. Go doesn’t have such abstraction.

Array

Array is a fixed sized Slice. The size is defined inside the square braces.

We can make the compiler find the size from the initialized value as:

The closest thing to the fixed size we have in python is a tuple. Tuple supports indexing but doesn’t allow the change in values.

>>> a = (0, 1, 2)
>>> a[1]
1
>>> a[1] = 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
>>>

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Published in FAUN — Developer Community 🐾

We help developers learn and grow by keeping them up with what matters. 👉 www.faun.dev

Written by Umangshrestha

I like computer and programming. I am currently trying to learn how to write articles for sharing what I know.

No responses yet

Write a response