Skip to content

Commit

Permalink
chore: 📄 add recap section
Browse files Browse the repository at this point in the history
coworkers -> colleagues
  • Loading branch information
ringohoffman committed Sep 5, 2023
1 parent 55240ef commit 766f158
Showing 1 changed file with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ resources:

## Background and Motivation

I recently had a conversation with a few of my coworkers where I had mentioned that Python is a strongly typed language. One of them didn't think that it was, and another explained that strong typing means that every object has a type, which is true about Python but is not the definition of strong typing. It surprised me to realize that even though my coworkers and I are experienced Python developers, none of us had a clear understanding of strong typing. This inspired me to write this post to help disambiguate Python and its runtime and static type systems.
I recently had a conversation with a few of my colleagues where I had mentioned that Python is a strongly typed language. One of them didn't think that it was, and another explained that strong typing means that every object has a type, which is true about Python but is not the definition of strong typing. It surprised me to realize that even though my colleagues and I are experienced Python developers, none of us had a clear understanding of strong typing. This inspired me to write this post to help disambiguate Python and its runtime and static type systems.

## Compiled vs. Interpreted Languages

Expand Down Expand Up @@ -310,6 +310,28 @@ go_flying(duck) # OK
go_flying(person) # static typing error: "fly" is not present
```

## Recap

> Is Python an interpreted language?
Python is considered an interpreted language because its reference implementation, CPython, compiles Python code into bytecode at runtime before interpreting it.

> Is Python a dynamically typed language?
Python is a dynamically typed language because it allows variables to be reassigned to values of different types.

> Is Python a strongly typed language?
Python is considered a strongly typed language because most type changes require explicit conversions.

> Is Python's static type system nominally or structurally typed?
Python's static type system is generally nominally typed, but `collections.abc` provides a collection of useful structural types, and `typing.Protocol` provides a way to define custom structural types.

> Is Python a duck typed language?
Python's runtime type system is duck typed because it determines type compatibility by checking only the parts of an object's structure that are accessed at runtime.

## Sources

<a id="1"></a>[1] [Wikipedia: Interpreter (computing)](https://en.wikipedia.org/wiki/Interpreter_(computing))
Expand Down

0 comments on commit 766f158

Please sign in to comment.