https://github.com/abhimanyuhk/classdemo.py
https://github.com/abhimanyuhk/classdemo.py
python python-standard-library python27 python3
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/abhimanyuhk/classdemo.py
- Owner: AbhimanyuHK
- Created: 2018-12-12T12:32:45.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-12T13:05:55.000Z (about 7 years ago)
- Last Synced: 2025-01-05T12:28:46.564Z (about 1 year ago)
- Topics: python, python-standard-library, python27, python3
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### ClassDemo.py
## Import libraries
``` import os ```
``` from sys import stdout ```
```
try:
from src.main.python import MyClass1 as test
except ImportError:
import MyClass1 as test
```
## Class Docs
```
class MyClass(object):
'''
classdocs : MyClass is demo class for docs
'''
```
## Method Docs
```
def method(self, a, b):
'''
method : addition operation by a and b.
a : int => input to the method.
b: int => input and output to the method.
Exception : Exception
return : int,
'''
```
### Try - Catch
```
try:
b = b + a
except Exception as e:
return e
else:
return b
```
## List Comprevension
```
sqre = [item*item for item in list]
```
## Demo Class
```
'''
Demo Class.
Created on Dec 12, 2018
@author: abhimanyu_h_k
'''
# System Level
import os
import sys
# Third Party Level
import boto3
# Local Level
try:
from src.main.python import MyClass1 as test
except ImportError:
import MyClass1 as test
class MyClass(object):
'''
classdocs : MyClass is demo class for docs
'''
def __init__(self, param1, param2):
'''
Constructor : initializing the MyClass with param1, param2.
param1 : this is string.
param2 : this is list.
'''
self.par1 = param1
self.par2 = param2
def method(self, a, b):
'''
method : addition operation by a and b.
a : int => input to the method.
b: int => input and output to the method.
Exception : Exception
return : int,
'''
try:
b = b + a
except Exception as e:
return e
else:
return b
```