"Python"의 두 판 사이의 차이
ph
								
												
				| 2번째 줄: | 2번째 줄: | ||
| <code>is</code> is identity testing, <code>==</code> is equality testing. what happens in your code would be emulated in the interpreter like this: | <code>is</code> is identity testing, <code>==</code> is equality testing. what happens in your code would be emulated in the interpreter like this: | ||
| − | <pre><code class='python'> >>> a = 'pub' | + | <pre><code class='python'>>>> a = 'pub' | 
| − | + | >>> b = ''.join(['p', 'u', 'b']) | |
| − | + | >>> a == b | |
| − | + | True | |
| − | + | >>> a is b | |
| − | + | False</pre></code> | |
| [http://stackoverflow.com/a/1504742/766330] | [http://stackoverflow.com/a/1504742/766330] | ||
| == == | == == | ||
2017년 4월 10일 (월) 01:34 판
is and ==
is is identity testing, == is equality testing. what happens in your code would be emulated in the interpreter like this:
<code class='python'>>>> a = 'pub' >>> b = ''.join(['p', 'u', 'b']) >>> a == b True >>> a is b False