¾È³çÇϼ¼¿ä
python ±âÃÊ°Á ¼ö°ÁßÀÔ´Ï´Ù.
>>>lst1=[1,2,'aaa','bbb']
>>>lst2=[3,4,'aaa','bbb']
>>>id(lst1[2])
~~~~
>>>id(lst2[2])
~~~~
ÀÌ·¸°Ô Çϸé lst1[2]¿Í lst2[2]°¡ 'aaa'·Î µ¿ÀÏÇϱ⠋š¹®¿¡ µ¿ÀÏÇÑ id°¡ Ãâ·ÂµË´Ï´Ù. ´ç¿¬È÷...¤¾
±Ùµ¥ ¾Æ·¡ÀÇ °æ¿ì¿¡
>>>lst1=[1,2,'Hello World','bbb']
>>>lst2=[3,4,'Hello World','bbb']
>>>id(lst1[2])
~~~~
>>>id(lst2[2])
~~~~
lst1[2]¿Í lst2[2]°¡ 'Hello World'·Î µ¿ÀÏÇÔ¿¡µµ ºÒ±¸ÇÏ°í ¼·Î ´Ù¸¥ id°¡ Ãâ·ÂµË´Ï´Ù.
´ç¿¬È÷ µ¿ÀÏÇÑ ÇϳªÀÇ ¹®ÀÚ¿À̱⋚¹®¿¡ °°Àº id°¡ Ãâ·ÂµÇ´Â°Ô ¸Â´Ù°í °»ç´ÔÀÌ ±×·¯½Ã´Âµ¥....
¿Ö ´Ù¸£°Ô ³ª¿À´ÂÁö ¸ð¸£½Ã°Ú´Ù°í¤¾¤¾
Ȥ½Ã ¶ç¾î¾²±â ‹š¹®ÀÏ±î ½Í¾ú´Âµ¥ ÇѱÛÀº ¶ç¾î¾²±â ³Ö¾îµµ µ¿ÀÏÇÑ id°¡ ³ª¿À³×¿ä...
¿Ö ÀÌ·±Áö ¾Æ½Ã´Â °í¼ö´Ô °è½Ç±î¿ä??^^;; | |
|
>>> d = 'aaa'
>>> c = 'ccc'
>>> a = 'aaa'
>>> id(d)
4465827672
>>> id(a)
4465827672
>>> d = 'aaaa'
>>> a = 'aaaa'
>>> id(d)
4465856016
>>> id(a)
4465856016
>>> d = 'aaaaaaa'
>>> a = 'aaaaaaa'
>>> id(d)
4465855968
>>> id(a)
4465855968
>>> d = 'aaaaaaa aa'
>>> a = 'aaaaaaa aa'
>>> id(d)
4465855872
>>> id(a)
4465856112
Á¦°¡ Å×½ºÆ® Çϸé ÀÌ·±½ÄÀ¸·Î ³ª¿À´Âµ¥¿ä ½ºÆäÀ̽º°¡ µé¾î°¡¸é ÁÖ¼Ò°ªÀÌ ¹Ù²î³×¿ä.
integer ÀÏ °æ¿ì¿¡´Â °ªÀÌ Ä¿¹ö¸®¸é ij½¬¿¡ µé¾î°¡±â Èûµé´Ù°í ÀÎÅÍÇÁ¸®ÅÍ°¡ ÆÇ´ÜÇÏ¸é ´Ù¸¥°÷¿¡ °¢°¢ ÀúÀåÇÑ´Ù°í Çϴ±º¿ä
http://stackoverflow.com/questions/3402679/identifying-objects-why-does-the-returned-value-from-id-change
¿©±â±Û Âü°í Çϼ¼¿ë
¹«Á¶°Ç ´Ù Çؽ¬Å×ÀÌºí¿¡ ³ÖÀ»¼ö ÀÖ´Ù¸é ÁÁ°ÚÁö¸¸ µ¥ÀÌÅÍ°¡ Ä¿Áö°Å³ª escape°¡ µÇ´Â ij¸¯ÅÍ°¡ µé¾î°¡°Ô µÇ¸é ´Ù¸£°Ô ÀúÀåµÇ³ªºÁ¿ä ½ºÅ©¸³Æ®·©±ÍÁö Ư¡»ó ¸Þ¸ð¸® ¾ó·ÎÄÉÀ̼ÇÀ» ¸¶±¸ÀâÀÌ·Î Çϴϱñ µ¥ÀÌÅÍ Å¸ÀÔ¿¡ µû¶ó ´ÜÀ§°¡ ¹Ù²î¾î¼ ±×·²¼öµµ ÀÖÀ»°Å¶ó »ý°¢ÇÕ´Ï´Ù.