Not a Typed Language

Recently I have gone down the rabbit hole into the land of Python.  While I am dizzy with all the pythonic wiz bangs flying by I am left with a puzzle. 

As I studied the language, it was made abundantly clear that Python is a strong, dynamically typed language.  In other words, Python will determine the type based on the variable value that it is passed at the time of execution and it will not arbitrarily change, which can happen in Pearl.

In practice, this is pretty easy to see.  For example, when you have a number and string, the difference is obvious.

a = 5 // integer
a = ‘Hi there!’ // string

My roots are in C and C++, which translates to knowing what you want and being very clear from the instantiation.  Do I want an integer, float, or double?  Python takes that complicated decision away from and puts a number into the best “parking space” based on the value.  

This seems like a sound plan, who wants to park a mini cooper in a space designed for a semi tractor-trailer.  What a waste of space!  Same applies for variables.

Where I protest is telling me it is a dynamically typed language, but then turn around and pull this out of the hat. 

my_list = [“true”,1,”banana”,3.0]

my_tuple = (1, ‘apple’ , 2, ‘banana’)

my_tuple2 = 1, ‘apple’, 2, ‘banana’

my_dictionary = {‘apple’: 10, ‘orange’: 6, ‘banana’: 9}

In Python, it is not necessary to preclude the variable name with the type; however, you must remember if you instantiate with a square bracket, parenthesis, or a curly brace.  In the rare instance you just give up and list a bunch of items, that’s ok, it will be born as a tuple. 

Is this not typing the data structure and taking the power of the dynamic typing away?

I digress, as languages are always full of quirks and inconsistancies.  It s easy to see how dynamic typing is easy with a simplistic variable and where it becomes impossible with a more complex data structure. 

However; I still contend that remembering to put a keyword defining what I want before the variable name is easier than trying to remember which esoteric bracting system I need to use. 

Today’s challenges are only tomorrows masteries. 

Onward and upwards I go.      




No comments yet.

Leave a Reply