Thx, St. Larry, for the Beauty of Sigilsby msouth (Sexton)
|on Jul 26, 2019 at 17:12 UTC||Need Help??|
TL;DR Thanks, Larry, for sigils
I recently took a job at a Python shop, helping out a friend. I have tried to be patient with the new-to-me language and to realize that there are different ways of doing things and that I should expect some mental friction simply due to my unfamiliarity. But, man, I just can't escape the idea that sigils were a good idea.
I needed to access a dynamically specified method and run a dynamically specified method against that method's result. Python can't tell the difference between a variable you created that contains a method name and a method name itself. You have to use a function called getattr to cumbersomely retrieve the reference you want. And if you go any deeper than one, it gets ugly very quickly. In my case, I have something like
(I'm using ridiculously long variable names for clarity about what the variables contain.)
With sigils to let Perl know that I mean 'grab the contents of the variable and execute the method having that name', I can do:
With the ridiculous names it may be less clear how much nicer this is, but look at:
I hate going to the inside and working my way out, trying to remember what I picked up along the way.
I realize that Python people hate having to type sigils all over the place, and that they would find it ironic that this would be the thing I would write in praise of. But I am doing a lot of work right now with dynamic method/attribute names and it really seems to me that Larry made the right call on this.