3 Reusable Code Snippet Topics
Remove Filter | |
I find that I occasionaally have special projects where it would be nice to have a context menu for files. I tend to write housekeeping scripts and it is convenient to be able to run these scripts against one or more files at a time without having to navigate and … | |
This snippet defines a context [icode]autofilename()[/icode] to create an existing temporary file with a new name in python. Unlike the methods in the [icode]tempfile[/icode] module, it only gives a filename which exists within a 'with' block, instead of an open file. This is useful for example when a program needs … | |
The with statement allows all sorts of syntactic sugar in python. This snippet defines two contexts: [icode]inevitably[/icode] and [icode]preferably[/icode] which register a function call to be executed at the end of a block of statement. Although they are not very useful (the function call could be written directly at the … |
The End.