Re: [Tutor] Import module function using variable

2018-06-13 Thread Slater, Joseph C.
> On Jun 13, 2018, at 3:37 AM, Peter Otten <__pete...@web.de> wrote: > > Slater, Joseph C. wrote: > >> Dear friends, >> >> I am trying to import a function in a module by variable name. The >> specific example is that my function allows the user to select which >> function my code will use (i

Re: [Tutor] Import module function using variable

2018-06-13 Thread Mats Wichmann
On 06/13/2018 08:35 AM, Mats Wichmann wrote: > On 06/13/2018 01:37 AM, Peter Otten wrote: >> Slater, Joseph C. wrote: >> >>> Dear friends, > > as others have said, I'll also say: your problem statement is fuzzy. Sorry folks, this was obviously in reply to a different thread, operator error! ([Tut

Re: [Tutor] Import module function using variable

2018-06-13 Thread Mats Wichmann
On 06/13/2018 01:37 AM, Peter Otten wrote: > Slater, Joseph C. wrote: > >> Dear friends, as others have said, I'll also say: your problem statement is fuzzy. if your data looks like this: > d23 87 9 NA 67 5 657 NA 76 8 87 78 90 800 > er 21 8 908 9008 9 7 5 46 3 5 757 7 5 is it meaningful that

Re: [Tutor] Import module function using variable

2018-06-13 Thread Peter Otten
Slater, Joseph C. wrote: > Dear friends, > > I am trying to import a function in a module by variable name. The > specific example is that my function allows the user to select which > function my code will use (in this case, which optimizer in scipy). There > is a default for a named variable. I

Re: [Tutor] Import module function using variable

2018-06-13 Thread Alan Gauld via Tutor
On 13/06/18 02:52, Slater, Joseph C. wrote: > I am trying to import a function in a module by variable name. I'd suggest getattr(): >>> import sys >>> xt = getattr(sys,exit) >>> xt() Alternatively, if its a fixed set of options (and it sound as if it is) set up a dictionary: funcs = {'exit':

[Tutor] Import module function using variable

2018-06-13 Thread Slater, Joseph C.
Dear friends, I am trying to import a function in a module by variable name. The specific example is that my function allows the user to select which function my code will use (in this case, which optimizer in scipy). There is a default for a named variable. I have thing working in a quite uncl