refactoringguru / design-patterns-python Goto Github PK
View Code? Open in Web Editor NEWDesign Pattern Examples in Python
Home Page: https://refactoring.guru/design-patterns/python
License: Other
Design Pattern Examples in Python
Home Page: https://refactoring.guru/design-patterns/python
License: Other
В питоне есть модуль copy. Так же в объекте можно переопределить методы __copy__
и __deepcopy__
В статье - какая-то джава
https://refactoring.guru/ru/design-patterns/prototype/python/example
I tried, both in ruby and python, we only need to inherit from the Adaptee
class. Since python support duck typing
Pls reply if I'm wrong
Hello.
I am learning design patterns through the implementations in Python.
The Memento design pattern is supposed to restore previous states, while keeping the information about them, restricted to other objects.
However when implementing the code, I was able to get access to all the restricted states:
if __name__ == "__main__":
originator = Originator("Super-duper-super-puper-super.")
caretaker = Caretaker(originator)
caretaker.backup()
originator.do_something()
### this should not work in theory
for m in caretaker._mementos:
print(f"_state = {m.get_state()}")
as seen in the for loop:
I can print all the values of the previous states.
_state = Super-duper-super-puper-super.
_state = kTjoIhPwiBmqvJfuDENWZXKcdUMHtp
is there a way to actually hide these states in Python?
Thanks for your work teaching design patterns. I hope you can guide me on this subject.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.