php equivalents?

Daniel Dittmar daniel.dittmar at sap.com
Thu Apr 24 17:48:08 CEST 2003


Kevin Howe wrote:
>> register_shutdown($func)
>
> This is basically a "cleanup" function. Just before a script ends, it
> will invoke all functions registered using register_shutdown(). This
> can be used to close database connections, clear sessions, save data,
> etc.

As the notion of 'script' could be very different between PHP and Python,
have a look at the try-finally statement. The code in the finally part is
executed, whether the rest of the code executes normally or is aborted
through an exception.

>> var_export($var)
>
> This function converts a variable to a text string of valid code
> which can be reevaluated at any time. Python has pickle/cPickle, and
> also has modules that can dump/load to XML, however, none of these
> create actual code, but instead create a formatted data string.

repr () is the equivalent function, at least for the builtin types.

Daniel







More information about the Python-list mailing list