Section | Video Links |
---|---|
Flyweight Overview | |
Flyweight Use Case | |
String Justification |
... Refer to Book or Design Patterns In Python website to read textual content.
... Refer to Book or Design Patterns In Python website to read textual content.
... Refer to Book or Design Patterns In Python website to read textual content.
python ./flyweight/flyweight_concept.py
abracadabra
abracadabra has 11 letters
FlyweightFactory has 5 flyweights
... Refer to Book or Design Patterns In Python website to read textual content.
python ./flyweight/client.py
-----------------------------------------
|abra | 112233 | cadabra|
|racadab | 12345 | 332211|
|cadabra | 445566 | aa 22 bb|
-----------------------------------------
FlyweightFactory has 12 flyweights
In /flyweight/column.py, there are commands center()
, ljust()
and rjust()
.
These are special commands on strings that allow you to pad strings and align them left, right, center depending on total string length.
eg,
>>> "abcd".center(10)
' abcd '
>>> "abcd".rjust(10)
' abcd'
>>> "abcd".ljust(10)
'abcd '
... Refer to Book or Design Patterns In Python website to read textual content.