Telegram Group & Telegram Channel
Разница между __str__ и __repr__

Оба магических метода __str__ и __repr__ используются для получения строкового представления объекта. Давайте разберемся, в чем же собственно разница между ними.

Метод __str__ используется для создания вывода для конечного пользователя, а __repr__ в основном используется для отладки и разработки. Другими словами, цель __repr__ – быть однозначным, а __str__ – читабельным.

Функция print() и встроенная функция str() используют метод __str__ для отображения строкового представления объекта, а вот встроенная функция repr() использует для этого метод __repr__.

#классы #str #repr



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

Разница между __str__ и __repr__

Оба магических метода __str__ и __repr__ используются для получения строкового представления объекта. Давайте разберемся, в чем же собственно разница между ними.

Метод __str__ используется для создания вывода для конечного пользователя, а __repr__ в основном используется для отладки и разработки. Другими словами, цель __repr__ – быть однозначным, а __str__ – читабельным.

Функция print() и встроенная функция str() используют метод __str__ для отображения строкового представления объекта, а вот встроенная функция repr() использует для этого метод __repr__.

#классы #str #repr

BY Python Academy




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

View MORE
Open in Telegram


Python Academy Telegram | DID YOU KNOW?

Date: |

How Does Bitcoin Mining Work?

Bitcoin mining is the process of adding new transactions to the Bitcoin blockchain. It’s a tough job. People who choose to mine Bitcoin use a process called proof of work, deploying computers in a race to solve mathematical puzzles that verify transactions.To entice miners to keep racing to solve the puzzles and support the overall system, the Bitcoin code rewards miners with new Bitcoins. “This is how new coins are created” and new transactions are added to the blockchain, says Okoro.

That growth environment will include rising inflation and interest rates. Those upward shifts naturally accompany healthy growth periods as the demand for resources, products and services rise. Importantly, the Federal Reserve has laid out the rationale for not interfering with that natural growth transition.It's not exactly a fad, but there is a widespread willingness to pay up for a growth story. Classic fundamental analysis takes a back seat. Even negative earnings are ignored. In fact, positive earnings seem to be a limiting measure, producing the question, "Is that all you've got?" The preference is a vision of untold riches when the exciting story plays out as expected.

Python Academy from us


Telegram Python Academy
FROM USA