"Python"의 두 판 사이의 차이
ph
								
												
				| 1번째 줄: | 1번째 줄: | ||
| − | == | + | =={{c|is}} and {{c|==}}== | 
| − | + | {{c|is}} is identity testing, {{c|==}} is equality testing. what happens in your code would be emulated in the interpreter like this: | |
| + |  >>> a = 'pub' | ||
| + |  >>> b = ''.join(['p', 'u', 'b']) | ||
| + |  >>> a == b | ||
| + |  True | ||
| + |  >>> a is b | ||
| + |  False | ||
| + | [http://stackoverflow.com/a/1504742/766330] | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | [http://stackoverflow.com/a/ | + | |
| + | ==Access index in {{c|for}} loop== | ||
| + |  for idx, val in enumerate(ints): | ||
| + |     print(idx, val) | ||
| + | [http://stackoverflow.com/a/522578/766330] | ||
| == == | == == | ||
2017년 4월 10일 (월) 10:40 판
is and {{{1}}}
is is identity testing, {{{1}}} is equality testing. what happens in your code would be emulated in the interpreter like this:
>>> a = 'pub' >>> b = .join(['p', 'u', 'b']) >>> a == b True >>> a is b False
Access index in for loop
for idx, val in enumerate(ints): print(idx, val)