creating class objects inside methods

Rhodri James rhodri at wildebst.demon.co.uk
Tue Oct 6 19:42:40 EDT 2009


On Sun, 04 Oct 2009 19:44:48 +0100, horos11 <horos11 at gmail.com> wrote:

[somehow managing to trim all other attributions: he's the innermost,
then me next]

>> > Thanks for the info, but a couple of points:
>>
>> >     1. it wasn't meant to be production code, simply a way to teach
>> > python.
>>
>> Speaking as someone who does teach Python, "Ew, no!"  If you start by
>> teaching people bad habits, every educator who comes along afterwards
>> will curse your name.  That includes teaching yourself.
>
> No offense, but I disagree. By programming without regards to pre-
> existing style or convention I learned far more than I otherwise would
> have if I had simply mimicked someone else.
>
> And I still think that unbridled assignment - especially assignment
> that can change the operational semantics of surrounding terms, at a
> distance no less - is a horrid thing.

[snip]

Thank you for providing a perfect example of my point.  How are you
getting on unlearning that assumption?

Pretty much every assignment in every language changes the operational
semantics of surrounding terms.  Most such changes are trivial, but for
an obvious example consider programs running finite state machines.
When you change the state variable, you change what the program will
do in the future, usually in fairly major ways that may not be visible
 from wherever your assignment takes place.

I'm hardly an expert in the area, but that does seem to be the point
of a lot of object-oriented design.

-- 
Rhodri James *-* Wildebeest Herder to the Masses



More information about the Python-list mailing list