NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Some Answers (Hopefully) (Score:1)
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/361452 [activestate.com]
Destructors: Destructors are present in Python. Within the class, the __del__(self) method provides this functionality. (Un)Fortunately, it gets called when the object is garbage-collected, so calling del varname removes the variable, not the referred-to object. If the reference count drops to zero, the object will get garbage-collected but you don't have much control. You might be able to call it manually (i.e.: varname.__del__()) but I don't know if that yields any nasty errors or other problems, so I wouldn't advise it. Again, example:
http://mail.python.org/pipermail/python-list/2000-January/019837.html [python.org]
Interpolation: Unfortunately, there's not much I can offer up on this. Because of the lack of sigils, it would be difficult to do interpolation reliably. In Python, explicit is better than implicit. So you're basically left with the print "%s %s %d" % var1, var2, var3 idiom. It's not necessarily as convenient as Perl but it's also easy to see what's being used in the string. (Shrugs)
I'm sorry if I haven't been much help or have repeated what you already knew. If you have questions, please feel free to contact me.
Reply to This
Re:Some Answers (Hopefully) (Score:1)
Generators are almost what I want, but not quite, and the same goes for lambdas. It may just be a matter of programming Python in Python, instead of what I'm doing now. I've used both, but sometimes I just want a coderef. I'd probably mind it less if I didn't feel it was one of the "don't give the programmer sharp tools" decisions (like "let's remove reduce!").
I know about and use destructors, even in the example. Unfortunately, their use not only occurs at garbage collection, but b
rjbs
Re:Some Answers (Hopefully) (Score:1)
The only thing I don't understand is why the destructors are not being called at the end of the program, as that should not happen. Everything is supposed to be cleaned up at the end.
You might want to check into the gc module. It provides an interface and debug options for garbage collection. Some doc is located here: http://docs.python.org/lib/module-gc.html [python.org]
And if I'm still telling you things you know, put me i
Re:Some Answers (Hopefully) (Score:1)
I asked on #python (freenode) about this a few days ago, and there was shock and horror at the suggestion of using a destructor to do object cleanup (or anything, for that matter). What the heck?
rjbs
Re:Some Answers (Hopefully) (Score:1)
I guess one of the things that still bugs me about python is the lack of an equivilent to "my". Errors in perl that would be caught at compile time wind up being runtime "UnboundLocal" ex