7 Reusable Code Snippet Topics

Remove Filter
Member Avatar for
Member Avatar for vegaseat

We have had several snippets on the format() function. This one gives a condensed overview of the many options you have.

Member Avatar for BustACode
6
925
Member Avatar for Gribouillis

This snippet prints a python list of strings in multicolumn format (similarly to linux `ls` command). It uses module prettytable, available in [pypi](https://pypi.python.org/pypi/PrettyTable).

Member Avatar for Gribouillis
3
1K
Member Avatar for Gribouillis

The syntax of the [icode]str.format()[/icode] method described in [url=http://docs.python.org/library/string.html#formatstrings]the python 2.6 documentation[/url] looks both powerful and complex. The idea of this thread is to start a collection of nice formatting examples which will ease the task of mastering this function. Please post useful examples, and document them :)

Member Avatar for Gribouillis
3
3K
Member Avatar for TrustyTony

Here is my celebration post for entering level 3 in Project Euler. Again I left in my debug prints. I am in process of adapting myself to new .format style of formatting. I have commented out the prints though to get visible the running time of the functions own action. …

Member Avatar for TrustyTony
0
684
Member Avatar for vegaseat

Is it Mother Date and Father Time? Any way, getting all the different date and time displays working can be imperturbably perplexing at times. You take a look at it in this Windows Console Application.

Member Avatar for Tsawm
0
914
Member Avatar for Dingbats

Hello Everyone, my first post - so please don't shoot me if it goes wrong! I'd been looking for this for some time now and have seen a number of related queries but no solutions. I cannot take credit for the whole code here, but I did adapt it to …

0
499
Member Avatar for TrustyTony

Here is my newest baby, the pretty.py module, born today, which I start to use instead of pprint module. Reason to make this (in addition to that it is possible to do) is that I had this problem, sorry long, LONG example: UPDATE: take out the [CODE]or j[/CODE] that was …

Member Avatar for TrustyTony
0
1K

The End.