Python code written in 1998, how to improve/change it?

Chris Mellon arkanes at gmail.com
Thu Jan 19 22:03:34 EST 2006


On 19 Jan 2006 15:53:54 -0800, Petr Jakes <petr at tpc.cz> wrote:
> Thanks for your comments,
> The mentioned "8 years old" code actually works somehow.
>
> I am trying to solve very similar problem about FSM as the code in the
> example does and I do not want to be overburden by the if/elif stuff or
> by declaring state functions (which IMHO is very similar approach as
> if/elif).
>

I'm not sure why nobody else in this thread said it, but the most
common way of implementing state machines I've seen in Python (unless
theres only a couple states you can manage with if/elif) is to use a
dict to map states to callables.



> Because of above mentioned, something like FSM-generator looks as a way
> to go for me (if I can judge with my poor skills).
>
> I am using Steve's book "Python Web Programming" which is actually the
> best I have found about OOP, classes etc. but as a newbie I am just
> lost with subclass and mapping attributes etc. while trying to study
> the code in the example (http://tinyurl.com/a4zkn).
>
> All I wanted to know, if, thanks to the improvements in the Python
> functionality over the years, it is possible to simplify somhow the old
> code.
>
> Otherwise I have to dig through :)
>
> Petr Jakes
>
> PS:
> I agree and I do understand the reasons why NOT to use GOTO statements
> in the code (aka spaghetti code).
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list