Pull to refresh
  • by relevance
  • by date
  • by rating

Tips and tricks from my Telegram-channel @pythonetc, February 2019

VK corporate blog Python *Programming *
image

It is new selection of tips and tricks about Python and programming from my Telegram-channel @pythonetc.

Previous publications.

Structures comparing


Sometimes you want to compare complex structures in tests ignoring some values. Usually, it can be done by comparing particular values with the structure:
Read more →
Total votes 19: ↑18 and ↓1 +17
Views 1.5K
Comments 0

Tips and tricks from my Telegram-channel @pythonetc, June 2019

VK corporate blog Python *Programming *

It is a new selection of tips and tricks about Python and programming from my Telegram-channel @pythonetc.

Previous publications


The \ symbol in regular string have special meaning. \t is tab character, \r is carriage return and so on.

You can use raw-strings to disable this behaviour. r'\t' is just backslash and t.

You obviously can’t use ' inside r'...'. However, it still can be escaped by \, but \ is preserved in the string:
Read more →
Total votes 24: ↑20 and ↓4 +16
Views 2.4K
Comments 1

Tips and tricks from my Telegram-channel @pythonetc, July 2019

VK corporate blog Python *Programming *

It is a new selection of tips and tricks about Python and programming from my Telegram-channel @pythonetc.

Previous publications


You can’t mutate closure variables by simply assigning them. Python treats assignment as a definition inside a function body and doesn’t make closure at all.
Read more →
Total votes 22: ↑21 and ↓1 +20
Views 1K
Comments 1

Tips and tricks from my Telegram-channel @pythonetc, August 2019

VK corporate blog Python *Programming *


It is a new selection of tips and tricks about Python and programming from my Telegram-channel @pythonetc.

Previous publications


If an instance of a class doesn’t have an attribute with the given name, it tries to access the class attribute with the same name.

>>> class A:
...     x = 2
...
>>> A.x
2
>>> A().x
2
Read more →
Total votes 29: ↑27 and ↓2 +25
Views 1.4K
Comments 1

Tips and tricks from my Telegram-channel @pythonetc, November 2019

VK corporate blog Python *Programming *

Tips and tricks from my Telegram-channel @pythonetc, November 2019

It is a new selection of tips and tricks about Python and programming from my Telegram-channel @pythonetc.

Previous publications.



PATH is an environment variable that stores paths where executables are looked for. When you ask your shell to run ls, the shell looks for the ls executable file across all paths that are presented in PATH.
Read more →
Total votes 31: ↑30 and ↓1 +29
Views 1.9K
Comments 1

Tips and tricks from my Telegram-channel @pythonetc, December 2019

VK corporate blog Python *Programming *


It is a new selection of tips and tricks about Python and programming from my Telegram-channel @pythonetc.

Previous publications.


Different asyncio tasks obviously have different stacks. You can view at all of them at any moment using asyncio.all_tasks() to get all currently running tasks and task.get_stack() to get a stack for each task.
Read more →
Total votes 27: ↑26 and ↓1 +25
Views 1K
Comments 0

Tips and tricks from my Telegram-channel @pythonetc, January 2020

VK corporate blog Python *Programming *


It is a new selection of tips and tricks about Python and programming from my Telegram-channel @pythonetc.

Previous publications.


The order of except blocks matter: if exceptions can be caught by more than one block, the higher block applies. The following code doesn’t work as intended:
Read more →
Total votes 15: ↑15 and ↓0 +15
Views 947
Comments 0