Welcome To Snipplr


Everyone's Recent Python Snippets Tagged list



« Prev 1 Next »
This shows how to convert values from a dictionary and make them a list.
0 982 posted 7 years ago by GabrielTheodoulos
Flatten a list of lists (or tuple of tuples, list of tuples, etc.) to any depth of nesting using no mutable objects.
1 1051 posted 9 years ago by alces
use flatten to reduce a given list to non-list elements. All elements that are no list will be kept and the lists will be expanded...
0 527 posted 12 years ago by abstraktor
0 783 posted 12 years ago by magicrebirth
0 530 posted 12 years ago by silviud
The resulting tree is represented through a dict where each father gets a key (with all the children as args)
0 810 posted 13 years ago by magicrebirth
Turning a dictionary into a list or an iterator is easy. To get a list of keys, you can just cast the dict into a list. It's cleaner, though to call .keys() on the dictionary to get a list of the keys, or .iterkeys() to get an iterator. Similarly, yo...
0 482 posted 13 years ago by magicrebirth
This function takes a list of string and sorts them based on their similarity. The percent at which they match can be defined in the second parameter (default 75%).
0 793 posted 14 years ago by gdvickery
create a dictionary from the data in two lists
0 703 posted 14 years ago by magicrebirth
// Is there a way in python to convert a list say [1,2,3,4] to a string and // also how to convert a string to a list? // use str() or repr() to convert to a string. // eval() will convert back to a list.
0 493 posted 14 years ago by magicrebirth
1 821 posted 14 years ago by magicrebirth
Turns the list [1,2,3] to ['1','2','3']
0 554 posted 14 years ago by fnurl
I made this ;) Python's operator class is what you need to know if you want to avoid using lambda functions or define your own helper functions in many cases.
1 731 posted 14 years ago by fnurl
1 747 posted 17 years ago by whitetiger
« Prev 1 Next »