Python (web) 🌸
>>> __name__
'__main__'
def main():
list(map(lambda n: n * 2, [7, 8, 5, 6, 2, 1]))
strs = ['skk', 'py', 'py-saikia', 'python']
list(filter(lambda s: len(s) > 3, strs))
if __name__ == "__main__":
main()
I am comfortable in Python and have experience with Python for AI (pytorch/tensorflow2/opencv) / Data Science (numpy/pandas/matplotlib/geopandas) / Flask. I had healthy discussions with Guido Van Rossum (Father / Creator of Python) image at Stanford and python is my primary scripting language.
🌸 Python [ NOTES ]
Python Class | Python Generators |
---|---|
#!/usr/bin/python
class Employee:
'Common base class for all employees'
empCount = 0
def __init__(self, name, salary):
self.name = name
self.salary = salary
Employee.empCount += 1
def displayCount(self):
print("Total Employee %d" % Employee.empCount)
def displayEmployee(self):
print("Name : ", self.name, ", Salary: ", self.salary)
print(" 🌸 Employee.__doc__:", Employee.__doc__)
print(" 🌸 Employee.__name__:", Employee.__name__)
print(" 🌸 Employee.__module__:", Employee.__module__)
print(" 🌸 Employee.__bases__:", Employee.__bases__)
print(" 🌸 Employee.__dict__:", Employee.__dict__) |
# A simple generator for Fibonacci Numbers
def fib(limit):
# Initialize first two Fibonacci Numbers
a, b = 0, 1
# One by one yield next Fibonacci Number
while a < limit:
yield a
a, b = b, a + b
# Create a generator object
x = fib(5)
print(next(x))
print(next(x))
print(next(x))
print(next(x))
print(next(x))
print("\nUsing for in loop")
for i in fib(5):
print(i) |
Built-In Class Attributes : Every Python class keeps following built-in attributes and they can be accessed using dot operator like any other attribute:
-
__dict__
− Dictionary containing the class's namespace. -
__doc__
− Class documentation string or none, if undefined. -
__name__
− Class name. -
__module__
− Module name in which the class is defined. This attribute is "__main__
" in interactive mode. -
__bases__
− A possibly empty tuple containing the base classes, in the order of their occurrence in the base class list.
I did lot of EDA in python with numpy/pandas/geopandas and matplotlib/plotly [ example 1, example 2 ]. I have a professional python work report here @ py_anom.pdf to process and visualize time series anomaly data. In the project, fetched data from API, stored it as mongodb geojson document and worked on processing as well as anomaly detection of raw sensor data . Created plotly graph objects to visualize the pandas data frame objects interactively (visualize.html) :
I did py geo data work and my notes are @github/webappmap. Some important documents and notes to keep handy: py-chs and py-notebooks. I have been writing deep learning code in PyTorch and are @ PyTorch, TensorFlow and dl-code.
resources : py-notebooks, py-cheatsheets, py-deepdive, pep-8, py-design-patterns, python-patterns.guide, python-patterns ; py-pm: anaconda, mamba, pip, jupyter; csheets : py-libraries, pandas, numpy, matplotlib; What does if name == "main": do?. Opensource python libraries @[aitools-py], [google code style guide - python].