One #python tip per day. Do you have any? Send it to https://xitter.cf/t.co/AIPDodWr5i. Edited by @simecek, @karlafej, and... you?

Joined February 2017
Daily Python Tip 🐍🐧 retweeted
Here's an interesting Python brainteaser that came from a member asking a question on The Python Coding Place forum… Can you figure out why the outputs are the way they are for these two similar but not identical bits of code? The answer gives a great insight on iterators…
3
9
55
6,892
Daily Python Tip 🐍🐧 retweeted
New in #Python 3.12 -> math.sumprod() Return the sum of products of values from two iterables p and q. Given: >>> p = (1, 2, 3) >>> q = (4, 4, 4) Before: >>> import operator >>> import itertools >>> sum(itertools.starmap(operator.mul, zip(p, q, strict=True))) 24 (= 1*4 + 2*4 + 3*4) Now: >>> import math >>> math.sumprod(p, q) 24 #tips
2
14
1
87
16,375
Daily Python Tip 🐍🐧 retweeted
Iterable unpacking (star in a #python list) makes a list from multiple iterables. map() is a handy way to call functions (or classes!) on a set of values. Together they are powerful:
9
108
1
669
Daily Python Tip 🐍🐧 retweeted
"Is this an integer?" Three different #python meanings:
8
40
1
271
Daily Python Tip 🐍🐧 retweeted
Replying to @python_tip
Oh, and I heard list comprehensions are deprecated. This is going to be a huge release... xitter.cf/bascodes/status/150978…
+++ Breaking News +++ After adding Exception Groups and Task Groups, @ThePSF considers Python 3.11 ready for larger Workgroups. Along with the announced changes, the PSF launched a pre-launch campaign with a clean and modern rebranding.
1
8
Daily Python Tip 🐍🐧 retweeted
we are using this guy for years :) pretty similar, but has also configurable delay :)
1
3
43
Daily Python Tip 🐍🐧 retweeted
Replying to @python_tip
1
5
Daily Python Tip 🐍🐧 retweeted
Replying to @python_tip
unyt is another option and arguably has a simpler api >>> import unyt as u >>> print((3 * u.m + 7 * u.inch).to(u.m)) 3.1778 m
1
11
11
Daily Python Tip 🐍🐧 retweeted
Replying to @python_tip
Combine this with map, filter or reduce and it can be very handy
6
4
Daily Python Tip 🐍🐧 retweeted
Please check out dailypythontip.herokuapp.com… I created it to organize all the tips you post for the public. I can add a platform to it for submission of tips
1
3
7
Daily Python Tip 🐍🐧 retweeted
functions work that way too: >>> def f(): print('hi') ... >>> f.__call__() hi and even >>> f.__call__.__call__.__call__.__call__.__call__.__call__() hi
3
18
Daily Python Tip 🐍🐧 retweeted
Replying to @python_tip
You should try rich too github.com/willmcgugan/rich
5
24
Daily Python Tip 🐍🐧 retweeted
Help us map out an accurate landscape of the Python community – join the official Python Survey 2020. surveys.jetbrains.com/s3/c12…
2
43
3
59
Daily Python Tip 🐍🐧 retweeted
You probably mean #fastcore not #fastpages
1
3
4
Daily Python Tip 🐍🐧 retweeted
Replying to @python_tip
collections.Counter.most_common is faster afaik
2
6
Daily Python Tip 🐍🐧 retweeted
Replying to @python_tip
vars(obj) whats inside
2
2
Daily Python Tip 🐍🐧 retweeted
Replying to @python_tip
In cases where there are duplicate items, I find enumerate very helpful >>> a = ['car', 'bike', 'scooter', 'bike'] >>> [n for n,i in enumerate(a) if i == 'bike'] [1, 3]
4
4
23
Daily Python Tip 🐍🐧 retweeted
Replying to @python_tip
This Meetup with Wild Code School - Dublin @Wild_Dublin could be fun especially for #codenewbies: Creating pixel art while learning #HTML, #CSS and #javascript 👾 meetu.ps/e/HSxKv/Hkct1/d
4
3
Daily Python Tip 🐍🐧 retweeted
The #CfP for #PyConCZ 2020 is open! Would you like to recommend some #Python #libraries? Submit a talk cz.pycon.org/2020/cfp/ and join us in Ostrava in June! 🌞 #czech #python #conference #ostrava #june #pycon
Daily Python Tip 🐍🐧 retweeted
Replying to @python_tip
Wait till you try: >>> {float('nan') : 1, float('nan'): "Good night", float('nan'): "Bye"}
2
5
2
30