Re: Techniques to extend code without modifying it? (besides modules and decorators)

2020-05-01 Thread Christian Seberino
Paul Thanks! I'm glad there is theory about my concern. I knew I wasn't the only one with that question. cs > > https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle > > Also: > > https://en.wikipedia.org/wiki/Expression_problem -- https://mail.python.org/mailman/listinfo/python-lis

Re: Techniques to extend code without modifying it? (besides modules and decorators)

2020-04-29 Thread Christian Seberino
> > a pattern like: > if : > elif : > > Thanks. I really like this simple yet powerful suggestion you made. See this... import new_code ... if foo: new_code.do_new_stuff(..) We can massively modify existing code by *ONLY* adding one import and a 2 line if snippet!!! Very nice! cs -

Re: Techniques to extend code without modifying it? (besides modules and decorators)

2020-04-29 Thread Christian Seberino
If you want to know, I'm trying to add metaprogramming (macros!) to a tiny Lisp interpreter I wrote. I'm hesitant to mess with all that nice debugged code to add this new stuff. -- https://mail.python.org/mailman/listinfo/python-list

Techniques to extend code without modifying it? (besides modules and decorators)

2020-04-29 Thread Christian Seberino
I have some code I'd like to extend without modifying it. I'm sure this is a common pattern. I wondered what the options were for "extending without modifying (much)". I'm aware one can import a module and add functions to decorators. Are there other ways? Thanks! chris -- https://mail.python