This is a simple chat-like program using pub-sub pattern, backed by PostgreSQL's LISTEN/NOTIFY command.
publish message to foo channel from user nickname.
$ python pub.py foo nickname
PUBLISH to channel #foo
Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.
| import sys | |
| if not sys.gettrace(): | |
| # f_trace doesn't work if settrace isn't set | |
| sys.settrace(lambda a, b, c: None) | |
| def j(n): | |
| def hook(fr, event, arg): | |
| assert event == "opcode" | |
| fr.f_lineno += n |