Telegram Group & Telegram Channel
Статические методы

Отличие статических методов от обычных в том, что они привязаны к классу, а не объекту. То есть они могут быть вызваны напрямую у класса.

Статический метод не принимает ни объект (self), ни класс (cls) в аргументах. То есть такие методы не могут модифицировать ни объект, ни сам класс. 

Реализовать статический метод можно двумя способами. Один из них — присвоить классу новый метод, напрямую передав изначальный метод в функцию staticmethod.

Но так делать не принято, поэтому чаще всего staticmethod используют в качестве декоратора при написании методов прямо в классе.

#staticmethod



tg-me.com/python_academy/954
Create:
Last Update:

Статические методы

Отличие статических методов от обычных в том, что они привязаны к классу, а не объекту. То есть они могут быть вызваны напрямую у класса.

Статический метод не принимает ни объект (self), ни класс (cls) в аргументах. То есть такие методы не могут модифицировать ни объект, ни сам класс. 

Реализовать статический метод можно двумя способами. Один из них — присвоить классу новый метод, напрямую передав изначальный метод в функцию staticmethod.

Но так делать не принято, поэтому чаще всего staticmethod используют в качестве декоратора при написании методов прямо в классе.

#staticmethod

BY Python Academy




Share with your friend now:
tg-me.com/python_academy/954

View MORE
Open in Telegram


Python Academy Telegram | DID YOU KNOW?

Date: |

Telegram announces Search Filters

With the help of the Search Filters option, users can now filter search results by type. They can do that by using the new tabs: Media, Links, Files and others. Searches can be done based on the particular time period like by typing in the date or even “Yesterday”. If users type in the name of a person, group, channel or bot, an extra filter will be applied to the searches.

How to Use Bitcoin?

n the U.S. people generally use Bitcoin as an alternative investment, helping diversify a portfolio apart from stocks and bonds. You can also use Bitcoin to make purchases, but the number of vendors that accept the cryptocurrency is still limited. Big companies that accept Bitcoin include Overstock, AT&T and Twitch. You may also find that some small local retailers or certain websites take Bitcoin, but you’ll have to do some digging. That said, PayPal has announced that it will enable cryptocurrency as a funding source for purchases this year, financing purchases by automatically converting crypto holdings to fiat currency for users. “They have 346 million users and they’re connected to 26 million merchants,” says Spencer Montgomery, founder of Uinta Crypto Consulting. “It’s huge.”

Python Academy from pl


Telegram Python Academy
FROM USA