Boston Linux & UNIX was originally founded in 1994 as part of The Boston Computer Society. We meet on the third Wednesday of each month at the Massachusetts Institute of Technology, in Building E51.

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss] SQLAlchemy Has Annoyances



Richard Pieri <richard.pieri at gmail.com> writes:

> On 2/5/2015 11:47 AM, Mike Small wrote:
>> Does Python's MOP let you add and remove members from classes or are
>> they immutable once created?
>
> If an object (variable, list, class, whatever) isn't a constant then
> it is mutable. Scope may restrict what changes are permitted.

So in his case could he use only one class and map it to many tables?
i.e. when finished with one temporary table and moving on to a second
one, could he sweep out all the old class members (member variables or
methods -- I don't know how the mapping to columns is done here) and add
new ones corresponding to the new set of columns? Would that save this
accumulation of useless classes?  Or would the old members or a snapshot
of the old classes with those members be retained somewhere?  

Now that I think about it, it's kind of puzzling to remove a method or
attribute from a class definition.  E.g. if you remove an attribute from
the class definition after you've created an instance of that class with
a value for that attribute, what kind of object is that object now? Is it
still of the type that class represents or is it of the class before
your change to its definition was made? Or when you remove the attribute
from the class does it find all the instances and release the values
bound to that attribute on each one? Or does Python really let you edit
a class definition in this way at all?

-- 
Mike Small
smallm at panix.com



BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org