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 127 posted 3 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.
0 147 posted 5 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 69 posted 8 years ago by abstraktor
0 112 posted 9 years ago by magicrebirth
The resulting tree is represented through a dict where each father gets a key (with all the children as args)
0 94 posted 9 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 64 posted 10 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 98 posted 10 years ago by gdvickery
create a dictionary from the data in two lists
0 99 posted 10 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 65 posted 10 years ago by magicrebirth
1 205 posted 10 years ago by magicrebirth
0 40 posted 10 years ago by dorseye
0 43 posted 10 years ago by dorseye
0 71 posted 10 years ago by dorseye
0 54 posted 10 years ago by dorseye
Turns the list [1,2,3] to ['1','2','3']
0 76 posted 11 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 92 posted 11 years ago by fnurl
1 72 posted 13 years ago by whitetiger
« Prev 1 Next »