Is there putTll as a method for dict in python?

Is there a method like putAll () for a dict in python? I did not find a method in the document that seems to do this. Of course, I can iterate over a set of keys and put everything into a new dict, but I think there might be a better way.

Also (this could be another question), is the "Python Library Reference" discussed in the python API document? I'm more used to javadoc as an API document that has a list of classes and methods. With the Python Library Reference, I always wonder if all the methods of the class are listed and there is no link that I can skip to see the parameter definition and return type.

+6
source share
2 answers

If you are talking about Java putAll for maps, dict.update would be the equivalent in Python:

 >>> d1 = { 1: 2, 3: 4 } >>> d2 = { 5: 6, 3: 1 } >>> d1.update(d2) >>> d1 {1: 2, 3: 1, 5: 6} 

Regarding documentation, there is a review that links all documentation for a particular module. In your specific case, you then click Match Types - dict and browser through the available operations.

+7
source

Regarding documentation, a link to a library is a link to documentation. The global module index is another place that lists all the modules so you can quickly find something.

The pages linked to the library link list all the class methods, and this is pretty complete. However, if you want a javadoc style browser, consider using pydoc . It should come with your standard Python installation. Typing pydoc -p 8080 will open a server on port 8080, which you can browse and browse. It appears that the version http://pydoc.org/ is posted.

0
source

Source: https://habr.com/ru/post/911715/


All Articles