Lessons about Python (page 17)
The links, tools and tips our engineers and designers share with each other, one “today I learned” at a time.
- lessons shared
- 353
- people sharing
- 27
- database started in
- 2016










Tech Insights· github.com
Awesome logging library for Python
Shared by
Read on github.com- Logging
- Python
stackoverflow.com
Be careful, Python lstrip and rstrip str methods may not behave as you think they do!
Flávio Juvenal
Tech Insights· stackoverflow.com
Be careful, Python lstrip and rstrip str methods may not behave as you think they do!
Shared by
Read on stackoverflow.com- Python




Tech Insights· realpython.com
Python Tricks Book from Dan Bader of Real Python blog
Shared by
Read on realpython.com- Python

twitter.com
Thread: How much code do you put in one statement?
#python tip: Q. How much code do you put in one statement? A. Statements should correspond to one complete thought expressible in a single sentence in plain English. English: I'll drive if it is raining; otherwise, I'll walk: Python: action = 'drive' if raining else 'walk'
Gustavo Carvalho

Tech Insights· twitter.com
Thread: How much code do you put in one statement?
From twitter.com
#python tip: Q. How much code do you put in one statement? A. Statements should correspond to one complete thought expressible in a single sentence in plain English. English: I'll drive if it is raining; otherwise, I'll walk: Python: action = 'drive' if raining else 'walk'
Shared by
Read on twitter.com- Python
- Link offline
docs.pytest.org · offline
pytest-xdistallows you to run failing tests in a loop inside a subprocess until it passes by looking for file changes to r...pytest-xdist allows you to run failing tests in a loop inside a subprocess until it passes by looking for file changes to re-run previously failing tests. You can take advantage of it by having pytest-xdist installed and passing the command line flag -f or --looponfail to your pytest command. For more info see: #xdist-pytest-distributed-testing-plugin
Carlos Coelho
Link offlineTech Insights· docs.pytest.org
pytest-xdistallows you to run failing tests in a loop inside a subprocess until it passes by looking for file changes to r...pytest-xdistallows you to run failing tests in a loop inside a subprocess until it passes by looking for file changes to re-run previously failing tests. You can take advantage of it by havingpytest-xdistinstalled and passing the command line flag-for--looponfailto your pytest command. For more info see: #xdist-pytest-distributed-testing-pluginShared by
The original link on docs.pytest.org is no longer available.
Look for it on the Wayback Machine- Pytest
- Python
- Test

docs.djangoproject.com
If you wanna know if your get_or_create was actually created the object instead of retrieving it, pass "created" after your v...
If you wanna know if your get_or_create was actually created the object instead of retrieving it, pass "created" after your variable's name and receive a boolean with the status of your get_or_create #get-or-create
Amanda Savluchinske

Tech Insights· docs.djangoproject.com
If you wanna know if your get_or_create was actually created the object instead of retrieving it, pass "created" after your v...
If you wanna know if your get_or_create was actually created the object instead of retrieving it, pass "created" after your variable's name and receive a boolean with the status of your get_or_create #get-or-create
Shared by
Read on docs.djangoproject.com- Django
- Python

docs.python.org
If you want to mock a class' property method in your tests you should use PropertyMock #unittest.mock.PropertyMock
Source code: Lib/unittest/mock.py unittest.mock is a library for testing in Python. It allows you to replace parts of your system under test with mock objects and make assertions about how they hav...
Hugo Bessa

Tech Insights· docs.python.org
If you want to mock a class' property method in your tests you should use PropertyMock #unittest.mock.PropertyMock
From docs.python.org
Source code: Lib/unittest/mock.py unittest.mock is a library for testing in Python. It allows you to replace parts of your system under test with mock objects and make assertions about how they hav...
Shared by
Read on docs.python.org- Mock
- Python
- Tests

alysivji.github.io
Nice blogpost giving a detailed explanation about tests
The first post in a series that explores what it means to write tests for our code. This introduction provides a high-level overview of various testing concepts; the goal is to build a common vocabulary for future posts.
Gustavo Carvalho

Tech Insights· alysivji.github.io
Nice blogpost giving a detailed explanation about tests
From alysivji.github.io
The first post in a series that explores what it means to write tests for our code. This introduction provides a high-level overview of various testing concepts; the goal is to build a common vocabulary for future posts.
Shared by
Read on alysivji.github.io- Python
- Testing


Tech Insights· nedbatchelder.com
Careful with negative assertions:
Shared by
Read on nedbatchelder.com- Python
- Test

treyhunner.com
Asterisks in python what they are and how to use them
There are a lot of places you’ll see * and ** used in Python. These two operators can be a bit mysterious at times, both for brand new programmers...
Gustavo Carvalho

Tech Insights· treyhunner.com
Asterisks in python what they are and how to use them
From treyhunner.com
There are a lot of places you’ll see * and ** used in Python. These two operators can be a bit mysterious at times, both for brand new programmers...
Shared by
Read on treyhunner.com- Python

zdnet.com
Malicious python libraries found and removed from pypi
One package contained a clipboard hijacker that replaced victims' Bitcoin addresses in an attempt to hijack funds from users.
Rebeca Sarai

Tech Insights· zdnet.com
Malicious python libraries found and removed from pypi
From zdnet.com
One package contained a clipboard hijacker that replaced victims' Bitcoin addresses in an attempt to hijack funds from users.
Shared by
Read on zdnet.com- Libs
- Python


Tech Insights· github.com
You should try this lib in order to keep your Rest API safe
Shared by
Read on github.com- Python
- Security

iqbalnaved.wordpress.com
ipdb can also be used when debugging issues with environments other than your local one.
ipdb.runcallhelps one debug issues on method calls through and IPython shell, and it's as simple as:``` import ipdb import xpto_method # the method one wants to debug ipdb.runcall(xpto_method, 'method arg') (ipdb) ... ``` ipdb.runcall receives the method one wants to call as the first argument, and subsequent to that the target method arguments. For more usage examples, check:
Carlos Coelho

Tech Insights· iqbalnaved.wordpress.com
ipdb can also be used when debugging issues with environments other than your local one.
ipdb.runcallhelps one debug issues on method calls through and IPython shell, and it's as simple as:```
import ipdb import xpto_method # the method one wants to debug ipdb.runcall(xpto_method, 'method arg') (ipdb) ... ```
ipdb.runcallreceives the method one wants to call as the first argument, and subsequent to that the target method arguments.For more usage examples, check:
Shared by
Read on iqbalnaved.wordpress.com- Debug
- Ipdb
- Python
stackoverflow.com
Using Paramiko through their docs' examples might look complicated, but here's a simple 5 liner that works
Luca Bezerra
Tech Insights· stackoverflow.com
Using Paramiko through their docs' examples might look complicated, but here's a simple 5 liner that works
Shared by
Read on stackoverflow.com- Paramiko
- Python
- Sftp
- Ssh
Book a call
Found it useful?
Let’s put it to work.
Tell us about your product and the problem in front of you. We’ll bring what we’ve learned on real projects.
Tell us about your product, and we’ll bring what we’ve learned.
Still prefer the good old email? Contact us



