atlas news
    
Peterbe : Python
22  juillet     14h29
Converting Celsius to Fahrenheit round-up
   In the last couple of days, I’ve created variations of a simple algorithm to demonstrate how Celcius and Fahrenheit seem to relate to each other if you mirror the number . It wasn’t supposed to be about the programming language. Still, I used Python in the first one and I noticed that since the...
12  juillet     15h08
Converting Celsius to Fahrenheit with Python
   Starting at C, add to the Celcius and mirror the number to get the Fahrenheit number.
17  mars     13h58
How do you thousands-comma AND whitespace format a f-string in Python
   Use my large integer:
14  mars     20h24
Leibniz formula for Ï in Python, JavaScript, and Ruby
   Different ways to calculate the value of Ï using the Leibniz formula
14  février     03h09
How to avoid a count query in Django if you can
   Suppose you have a complex Django QuerySet query that is somewhat costly in other words slow . And suppose you want to return: The first N results A count of the total possible results So your implementation might be something like this: def get results queryset, fields, size : count ...
21  septembre     16h11
Pip-Outdated.py with interactive upgrade
   Last year I wrote a nifty script called Pip Outdated.py Pip Outdated.py a script to compare requirements.in with the output of pip list outdated . It basically runs pip list outdated but filters based on the packages mentioned in your requirements.in. For people familiar with Node, it’s like...
22  décembre     13h14
Pip-Outdated.py - a script to compare requirements.in with the output of pip list --outdated
   Simply by posting this, there’s a big chance you’ll say Hey Didn’t you know there’s already a well known script that does this Better. Or you’ll say Hey That’ll save me hundreds of seconds per year The problem Suppose you have a requirements.in file that is used, by pip compile to generate...
22  août     22h47
Join a list with a bitwise or operator in Python
   Use functools.reduce operators.or , my list to join my list with a bitwise OR.
03  avril     19h34
How to sort case insensitively with empty strings last in Django
   Imagine you have something like this in Django: class MyModel models.Models : last name models.CharField max length , blank True ... The most basic sorting is either: queryset.order by ’last name’ or queryset.order by ’ last name’ . But what if you want entries with a blank string...
30  mars     12h33
How to close a HTTP GET request in Python before the end
   Does you server barf if your clients close the connection before it’s fully downloaded Well, there’s an easy way to find out. You can use this Python script: import sys import requests url sys.argv assert x ;: x ; in url, url r requests.get url, stream True if r.encoding is None...