[Tutor] get name of calling class at runtime
Alan Gauld
alan.gauld at btinternet.com
Sat Aug 22 23:45:40 CEST 2009
"Kent Johnson" <kent37 at tds.net> wrote
> I think it does makes sense to keep SQL confined to well-defined
> locations. This can be per class - each class holds its own SQL - or a
> single class that does all database access so all SQL and database
> dependencies are in one place.
My vote for the class every time. I hate having to make changes
in two places when I add an attribute etc. Especially if they are in
two separate files or the classes are beiong used in multiple projects.
All that regression testing becomes a headache.
> class DataSources(object):
> def getAdata(self):
> # execute sql for callerA
> def getBdata(self):
> #execute sql for callerB
You might as well just put them as functions in a module, but
you still have the double file maintenance issue.
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list