Telegram Group & Telegram Channel
Что выведет этот код?

Строки длиной до 4096 (до версии 3.7 длиной до 21) кэшируются.
s1 = "a" * 4096
s2 = "a" * 4096

print(s1 is s2) # True

s1 = "a" * 4097
s2 = "a" * 4097

print(s1 is s2) # False


Строки не кэшируются, если они созданы в рантайме:
s1 = "python"
s2 = "".join(["p", "y", "t", "h", "o", "n"]) # выражение выполняется в рантайме

print(s1 is s2) # False


Так же следует понимать, что это может поменяться в любой момент и лучше сравнивать строки через ==, а не через is.

#string #строки



tg-me.com/pythrone/9
Create:
Last Update:

Что выведет этот код?

Строки длиной до 4096 (до версии 3.7 длиной до 21) кэшируются.
s1 = "a" * 4096
s2 = "a" * 4096

print(s1 is s2) # True

s1 = "a" * 4097
s2 = "a" * 4097

print(s1 is s2) # False


Строки не кэшируются, если они созданы в рантайме:
s1 = "python"
s2 = "".join(["p", "y", "t", "h", "o", "n"]) # выражение выполняется в рантайме

print(s1 is s2) # False


Так же следует понимать, что это может поменяться в любой момент и лучше сравнивать строки через ==, а не через is.

#string #строки

BY PyThrone




Share with your friend now:
tg-me.com/pythrone/9

View MORE
Open in Telegram


PyThrone Telegram | DID YOU KNOW?

Date: |

What is Telegram?

Telegram is a cloud-based instant messaging service that has been making rounds as a popular option for those who wish to keep their messages secure. Telegram boasts a collection of different features, but it’s best known for its ability to secure messages and media by encrypting them during transit; this prevents third-parties from snooping on messages easily. Let’s take a look at what Telegram can do and why you might want to use it.

Start with a fresh view of investing strategy. The combination of risks and fads this quarter looks to be topping. That means the future is ready to move in.Likely, there will not be a wholesale shift. Company actions will aim to benefit from economic growth, inflationary pressures and a return of market-determined interest rates. In turn, all of that should drive the stock market and investment returns higher.

PyThrone from kr


Telegram PyThrone
FROM USA