Welcome To Snipplr
Everyone's Recent Python Snippets Tagged list
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
« Prev 1 Next »
This shows how to convert values from a dictionary and make them a list.
0
961
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
1034
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
518
posted 12 years ago by abstraktor
The resulting tree is represented through a dict where each father gets a key (with all the children as args)
0
798
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
476
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
777
posted 14 years ago by gdvickery
// 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
485
posted 14 years ago by magicrebirth
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
710
posted 14 years ago by fnurl
« Prev 1 Next »