10 Culture Shocks I felt while working on Python
Python is arguably one of the most intuitive, simple yet powerful programing languages that's being used almost everywhere.
Coming from a .NET background with experience on a strongly typed OOP language like C#, the following are the 10 culture shocks I felt when I started working on Python 🤯
1. There's no concept of braces ({}), just indentation to write blocks - classes, methods or even variables
2. There's nothing called namespaces - instead you have modules which are like everything that you put in a file. I really had hard time digesting this.
3. There are classes though, but you can still write functions and lines outside a class and still work with it.
4. Your constructor name is not your class name, you'll write a special method __init__, that is the constructor.
5. there are class variables, but you won't use a this keyword. Instead there's a variable 'self' that is passed as a parameter within the constructor or in functions.
6. Python is a scripting language, so your code is going to get interpreted directly and executed - instead of the compile/interpret stuff of the .NET Java world.
7. There is neither a default package.json nor a pom.xml to maintain dependencies. You'll put whatever deps you're using in a requirements.txt and install using the pip tool.
8. It's so secure, you can directly reference script files from a directory / a sub directory by default. You'll have to put a blank __init__.py file in a directory to be able to read and load script files from that directory.
9. You don't need to necessarily write code in script files to execute in python. You can type python in your command line and it'd start an interactive shell where you can type in all your script lines to execute.
10. Best of all - there's nothing called a main function that's the starting point. Python interpreter starts from line 1 of the file that is being executed - so you'll write a custom function called main that calls all other functions in your script and explicitly call the main function in a code block at the top of the script!
That's my top 10.
Would you like to add more to the list?
#pythonprogramming #developerlife #dotnet #codingjourney