in reply to Thx, St. Larry, for the Beauty of Sigils
because a variable is a bareword you can't just type ?
meth = "name" obj.meth()
In JS you could solve this with a bracket syntax to look up an attribute obj[meth]()
Console demo:
> obj = { name : function () {return "called" } } Object { name: name() } > meth ="name" "name" > obj[meth]() "called"
But in python you need a function getattr() ?
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Thx, St. Larry, for the Beauty of Sigils
by daxim (Curate) on Jul 29, 2019 at 08:56 UTC | |
by LanX (Saint) on Jul 29, 2019 at 16:09 UTC | |
by bliako (Abbot) on Jul 29, 2019 at 23:15 UTC | |
by LanX (Saint) on Jul 30, 2019 at 00:46 UTC | |
by daxim (Curate) on Jul 30, 2019 at 10:14 UTC | |
by LanX (Saint) on Jul 30, 2019 at 13:53 UTC |