A clean way to program an interface
steven.klass at gmail.com
Mon Jul 9 15:56:39 CEST 2007
On Jul 9, 3:53 am, "Diez B. Roggisch" <d... at nospam.web.de> wrote:
> THROW IT AWAY!!!!
> Seriously. That's one of the most convoluted, incomprehensible pieces of
> python I've seen. Ever.
> All the sys._getframe()-stuff has to go. Really. There are about a dozen
> pieces of code worldwide that are allowed to have that in them. Maybe two
> And while I'm having difficulties grasping what you actually mean by " I
> represent each function as a class or should I keep the code
> I have below?", I've done my fair share of serial programming. And I would
> say that having one class that exposes different methods for commands is
> the way to go.
> But first - throw that code away. Fast. Faster.
Totally understand your confusion with sys._getframe().f_code.co_name
- that was borne out of the fact that I was creating a method for each
serial function and it was repeating.. over and over.. So I got tired
of changing the three items that differentiated each method so I
simplified it a bit. Perhaps too much. So can I ask you to show or
point me to a good interface example? I think we both can agree that
fundamentally this is pretty simple but I want to do it right and an
solid class example of interface programming would be nice.
More information about the Python-list