developer

Get key by value in dictionary

Question: ❓❓❓ I made a function which will look up ages in dictionary and show the matching name: list = {'george':16,'amber':19} search_age = raw_input("Provide age") for age in list.values(): if age == search_age: name = list[age] print name I know how to compare and find the age I just don’t Read more…

By admin, ago
developer

What is monkey patching?

Question: ❓❓❓ I am trying to understand, what is monkey patching or a monkey patch? Is that something like methods/operators overloading or delegating? Does it have anything common with these things? Good Answer: 👌👌👌 No, it’s not like any of those things. It’s simply the dynamic replacement of attributes at Read more…

By admin, ago
developer

Does Python have an ordered set?

Question: ❓❓❓ Python has an ordered dictionary. What about an ordered set? Good Answer: 👌👌👌 There is an ordered set (possible new link) recipe for this which is referred to from the Python 2 Documentation. This runs on Py2.6 or later and 3.0 or later without any modifications. The interface Read more…

By admin, ago
developer

How to set the current working directory?

Question: ❓❓❓ How to set the current working directory in Python? Good Answer: 👌👌👌 Try os.chdir os.chdir(path)         Change the current working directory to path. Availability: Unix, Windows. Read More: 👉 https://stackoverflow.com/questions/1810743/how-to-set-the-current-working-directory

By admin, ago