On Thu, Dec 2, 2010 at 1:11 AM, Lorin Rivers <lriv...@mosasaur.com> wrote: > I tried making a generic function that created a table variable by > concatenating strings. > > myTable = tableBuilder('inverter',period=5) > > def tableBuilder(element,period=0): > if element == 'inverter': > if period = 0: > return 'db4.' + 'arraydata_table' > elif period = 1: > return 'db4.array_mins' > else: > return 'db4.array_' + period + 'mins'
def table_builder(e, p): if e == 'inverter': t = 'db4.' if p == 0: t += 'arraydata_table' elif p == 1: t += 'array_mins' else: t += '%smins' % period return t It's not a big improvement, but it's a bit nicer, I think. Plus you don't repeat 'db4.' three times inviting typos. -- Branko Vukelić bg.bra...@gmail.com stu...@brankovukelic.com Check out my blog: http://www.brankovukelic.com/ Check out my portfolio: http://www.flickr.com/photos/foxbunny/ Registered Linux user #438078 (http://counter.li.org/) I hang out on identi.ca: http://identi.ca/foxbunny Gimp Brushmakers Guild http://bit.ly/gbg-group