> Il giorno 13 gen 2020, alle ore 09:35, ㎝ <c...@python.it> ha scritto:
> 
> Il giorno lun 13 gen 2020 alle ore 09:09 Giovanni Porcari
> <giovanni.porc...@softwell.it> ha scritto:
>> 
>> Marco ho fatto una prova che non mi riesco a spiegare: tu ne hai una ragione 
>> ?
>> 
>> (python 3.7.5)
>>>> a='xy'
>>>>> b='xy'
>>>>> a is b
>> True
>> 
>>>>> a='x y'
>>>>> b='x y'
>>>>> a is b
>> False
>> 
>>>>> a='x_y'
>>>>> b='x_y'
>>>>> a is b
>> True
>>>>> 
>> 
>> Hai spiegazioni ?
> 
> Se la stringa segue le regole sintattiche di un identificatore, viene
> intern()ata automaticamente.
> 


Non sapevo che le strinche ammesse come identificatori fossero auto 
sys.intern().

Però se fai:
>>> a='cosi'
>>> b='cosi'
>>> a is b
True

>>> a='così'
>>> b='così'
>>> a is b
False

>>> così=99
>>> print (così)
99

Il che mi farebbe pensare che seppure in Python3 'così' sia un identificatore 
valido che però non viene intern()at0.

Misteri pythonici!

G
> ```
>>>> import sys
>>>> a = sys.intern("a b")
>>>> b = sys.intern("a b")
>>>> a is b
> True
> ```
> 
> 👋
> ㎝
> 
> --
> !!!! THE 🍺-WARE LICENSE (Revision ㊷):
>    <㎝@🐍.it> wrote this 📧. As long as you retain this notice you can
>    do whatever you want with this stuff. If we meet some day, and you
>    think this stuff is worth it, you can buy me a 🍺 in return. — ㎝
> _______________________________________________
> Python mailing list
> Python@lists.python.it
> https://lists.python.it/mailman/listinfo/python

_______________________________________________
Python mailing list
Python@lists.python.it
https://lists.python.it/mailman/listinfo/python

Rispondere a