- Python is an interpreted language
- In python, variables are never explicitly typed
- Python doesn't let you reference a variable that has never been used
- Lists are mutable and tuples are immutable
- Python is object oriented. In python everything is an object in the sense that is can be assigned to a variable or passed as an argument to a function.
- In python functions, modules, classes and individual instances of class are first-class-objects.
- You can pass an entire module as an argument to a function
- Python has no begin or end statement, no curly braces to say where the function (or any other code block) starts and where it end. The only delimiter is : ( def function_name () : ) and indentation
- There are no subroutines in python. Everything is a function and all the functions return a value even if it is 'None'.
- Function is also an object
- All the functions start with 'def'
- Python functions doesn't define a return datatype. Python functions so not specify the datatype of their return value ; they don't even specify whether they return a value. In fact, every python function returns a value ; if the function ever executes a return statement, it will return that value ; otherwise, it will return None, the python null value.
- Python keeps track of the datatype internally
- The docstring (what ever is between """ and the next """ ) is available as an attribute of the function at runtime (.__doc__)
- __name__ will give you the module name (actually the file name) without the directory path. By default, it is __main__ . If you do "import os ; print(os.__name__)" , you'll get "os" as the output
- Python searches the directories defined in sys.path when you try to import a module. You can make it search a new path by using sys.path.insert(0, <new_path>)
- Python uses try...except blocks to handle exceptions and raise statement to generate exceptions
- The Boolean value for an empty tuple/list is false.
- sets are unique bag of values. Example: a_set={1,2,3}. If you try to add a duplicate value to a set, it is ignored and you wouldn't even get an error.
Search This Blog
Showing posts with label Facts of python. Show all posts
Showing posts with label Facts of python. Show all posts
Sunday, March 16, 2014
Facts of python
Subscribe to:
Posts (Atom)