Python basics

Great Python introductory video for C# developers

__  (double underscore) Starting the attribute name with double underscore attribute makes it private. To expose the private attributes and methods



Code hierarchy

In Python indentation denotes the hierarchy of the instructions, not curly braces, like in C# or Java.


When you create a directory in your project, create an empty file in the new directory to be able to reference objects from that directory, and avoid

from MY_FOLDER.MY_FILE import MY_CLASS causes an error:
ImportError: No module named MY_FOLDER.MY_FILE


Predefined methods

__init__(self)  Initializer method (constructor)

__repr__(self)  Representation

__iter__(self)  Method to define hot to iterate through the object


@property  Exposes a method as a property of the class

from _04_anonymous.anonobject import AnonObject
ImportError: No module named _04_anonymous.anonobject

{(“Not importing directory ‘/Users/pinterl/Git/devops-scripts/Python_Tutorial/Python/Python_for_C_sharp_developers/_04_anonymous’: missing”, <type ‘exceptions.ImportWarning’>, 6): True}

Leave a Reply