puffadder
puffadder copied to clipboard
A boiler plate reducing library for Python, inspired by Project Lombok for Java.
puffadder
A boiler plate reducing library for Python, inspired by Project Lombok for Java.
@to_string
Adds a str function to the class that returns all public instance attributes in a neatly formatted string.
Puffadder | Vanilla Python |
@to_string
class Student(object):
_private_attribute = "This will not be seen"
name = "Sally"
age = 22
full_time = True
|
class Student(object):
_private_attribute = "This will not be seen"
name = "Sally"
age = 22
full_time = True
|
@builder
Adds a constructor to the class that sets all public class attributes in the constructor. If a constructor was defined it is run after the generated constructor.
Puffadder | Vanilla Python |
@builder
class Student(object):
_private_attribute = "This will not be seen"
name = "Sally"
age = 22
full_time = True
|
class Student(object):
def __init__(self, name="Sally", age=22, full_time=True):
self.name = name
self.age = age
self.full_time = full_time
self._private_attribute = "This will not be seen"
|
@constructor
Adds all parameters defined in the constructor to the class's properties. If a constructor was defined it is run after the generated constructor.
Puffadder | Vanilla Python |
@contructor
class Student(object):
def __init__(self, name, age=22, full_time=True):
self._private_attribute = "private"
|
class Student(object):
def __init__(self, name, age=22, full_time=True):
self.name = name
self.age = age
self.full_time = full_time
self._private_attribute = "private"
|