Re: Bulk Adding Methods Pythonically

2016-06-21 Thread Rob Gaddi
Steven D'Aprano wrote: > On Thu, 16 Jun 2016 04:39 am, Rob Gaddi wrote: > >>> class Channel: >>> frequency = mkmeasure('frequency', 'FREQ') >>> falltime = mkmeasure('falltime', 'FTIM') >> >> Thought about it, but whenever I'm dropping 20-someodd of those there's >> inevitably some place where I s

Re: Bulk Adding Methods Pythonically

2016-06-16 Thread Ethan Furman
On 06/16, Random832 wrote: > On Wed, Jun 15, 2016, at 15:03, Ethan Furman wrote: >> [1] https://docs.python.org/3/library/functions.html#locals >> Yes, returning the class namespace is a language gaurantee. > > How do you get a guarantee from that text? Oops, my bad -- the gaurantee is in t

Re: Bulk Adding Methods Pythonically

2016-06-16 Thread Steven D'Aprano
On Fri, 17 Jun 2016 01:53 am, Julien Salort wrote: > Ethan Furman wrote: > >> If that is all correct, then, as Random suggested, move that loop into >> the class body and use locals() [1] to update the class dictionary. >> Just make sure and delete any temporary variables.[ > [...] >> [1] https:

Re: Bulk Adding Methods Pythonically

2016-06-16 Thread Random832
On Wed, Jun 15, 2016, at 15:03, Ethan Furman wrote: > [1] https://docs.python.org/3/library/functions.html#locals > Yes, returning the class namespace is a language gaurantee. How do you get a guarantee from that text? I don't see any definition asserting that the "current local symbol table"

Re: Bulk Adding Methods Pythonically

2016-06-16 Thread Julien Salort
Ethan Furman wrote: > If that is all correct, then, as Random suggested, move that loop into > the class body and use locals() [1] to update the class dictionary. > Just make sure and delete any temporary variables.[ [...] > [1] https://docs.python.org/3/library/functions.html#locals > Yes,

Re: Bulk Adding Methods Pythonically

2016-06-15 Thread Lawrence D’Oliveiro
On Thursday, June 16, 2016 at 5:37:14 AM UTC+12, Rob Gaddi wrote: > I've got a whole lot of methods I want to add to my Channel class, all > of which following nearly the same form. The below code works, but > having to do the for loop outside of the main class definition feels > kludgey. No, tha

Re: Bulk Adding Methods Pythonically

2016-06-15 Thread Steven D'Aprano
On Thu, 16 Jun 2016 04:39 am, Rob Gaddi wrote: >> class Channel: >> frequency = mkmeasure('frequency', 'FREQ') >> falltime = mkmeasure('falltime', 'FTIM') > > Thought about it, but whenever I'm dropping 20-someodd of those there's > inevitably some place where I screw up the replication of the qu

Re: Bulk Adding Methods Pythonically

2016-06-15 Thread Ethan Furman
On 06/15/2016 10:37 AM, Rob Gaddi wrote: I've got a whole lot of methods I want to add to my Channel class, all of which following nearly the same form. The below code works, but having to do the for loop outside of the main class definition feels kludgey. Am I missing some cleaner answer? I

Re: Bulk Adding Methods Pythonically

2016-06-15 Thread Rob Gaddi
Random832 wrote: > On Wed, Jun 15, 2016, at 13:37, Rob Gaddi wrote: >> I've got a whole lot of methods I want to add to my Channel class, all >> of which following nearly the same form. The below code works, but >> having to do the for loop outside of the main class definition feels >> kludgey.

Re: Bulk Adding Methods Pythonically

2016-06-15 Thread Random832
On Wed, Jun 15, 2016, at 13:37, Rob Gaddi wrote: > I've got a whole lot of methods I want to add to my Channel class, all > of which following nearly the same form. The below code works, but > having to do the for loop outside of the main class definition feels > kludgey. Am I missing some cleane