Z
Z
zedzew2015-05-30 15:38:26
Flask
zedzew, 2015-05-30 15:38:26

What is the difference between methods=('GET', 'POST') and methods=['GET', 'POST']?

What is the difference between methods=('GET', 'POST') and methods=['GET', 'POST']? Except that a tuple and a list. What is the correct way to write?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya, 2015-05-30
@zedzew

What is more correct - depending on what you need to get. If this is an immutable enum, then you can hedge against changing it and make a tuple. If you later need to add / remove something in this list, then it is logical to take a sheet.
There is, of course, another difference, in that the tuple is a hashable type, which, for example, allows you to use it entirely as a dictionary key, but I think this is not very popular.

B
bromzh, 2015-06-20
@bromzh

It doesn't matter, anyway inside everything in set is distilled :
The list is used in the docks. When in doubt, do as in the docks.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question