Stories
Slash Boxes
Comments
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

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Anonymous functions: Generally, if it's a small amount of logic, you can get away with using a lambda. Alternatively, you might be looking for a generator, depending on how you use your anonymous subroutines. A decent example is located here:
    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 de
    • Thanks for the reply!

      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
      • My apologies, I should have looked at the code you had written and previous posts first.

        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 in my place. ;D
        • Wow, the gc module looks like it would be obnoxious to use here, although it could surely do the job!

          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