Rodrigo ๐Ÿ๐Ÿš€ Profile Banner
Rodrigo ๐Ÿ๐Ÿš€ Profile
Rodrigo ๐Ÿ๐Ÿš€

@mathsppblog

Followers
43,841
Following
390
Media
2,382
Statuses
17,341

Take your Python ๐Ÿ skills to the next level ๐Ÿš€! @mathsppblog @fosstodon .org

๐Ÿ๐Ÿš€ Free Python book ๐Ÿ‘‰
Joined July 2020
Don't wanna be here? Send us removal request.
Explore trending content on Musk Viewer
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
9 months
@clcoding print( """* * * * * * * * * * * * * * * * * * * * * * * * *""" )
71
88
3K
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
I learned Python ๐Ÿ on the Internet for free. That's why my Pydon'ts book is free: ๐Ÿ‘‰ +300 pages ๐Ÿ‘‰ +25 chapters ๐Ÿ‘‰ Available for $0 ๐Ÿ‘‰ Always growing I can't do the hard work for you, but I can make it *easier*! Link on my profile!
39
524
3K
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
This is a complete diagram of how you define a function in Python ๐Ÿ
Tweet media one
25
238
1K
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Hey there ๐Ÿ‘‹ If you are interested in ๐Ÿ Python ๐Ÿ’ป Programming ๐Ÿ Python ๐Ÿง  Mathematics ๐Ÿค– Machine Learning ๐Ÿ and some more Python, Follow me. โœ” I share daily ๐Ÿ“… content that you won't want to miss. (โš  DISCLAIMER: Sometimes I also tweet about Python ๐Ÿ)
25
104
1K
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Do you want to take your Python ๐Ÿ skills to your next level? I can't do the hard work for you, but I can make it *easier*! That's why I am working on a Python book that teaches you the core language. ๐Ÿ‘‰ +400 pages ๐Ÿ‘‰ +25 chapters ๐Ÿ‘‰ Available for $0 Link on my profile! ๐Ÿ˜Š
50
214
1K
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Sorry folks, I've been busy.
Tweet media one
156
24
1K
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
1 year
As a Python ๐Ÿย programmer, I spend my day inside my IDE. After all, it's my job! Here are 6 VS Code @code shortcuts that save me HOURS every week. ๐Ÿš€ A thread with video examples. ๐Ÿ‘‡
Tweet media one
31
232
1K
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
1 year
All Python ๐Ÿย developers should know about this module. The module `collections` will make you 10x more productive*! ๐Ÿš€ What is your favourite `collections` tool? Let me show you some of its goodies in this thread. ๐Ÿ‘‡ (*Actual numbers may vary. ๐Ÿคก)
Tweet media one
42
199
1K
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Hey there ๐Ÿ‘‹ If you are interested in ๐Ÿ Python ๐Ÿ’ป Programming ๐Ÿ‘€ Learning in public ๐Ÿ Python ๐Ÿง  Mathematics ๐Ÿค– Machine Learning ๐Ÿ and more Python, Follow me. โœ” I share daily ๐Ÿ“… content that you won't want to miss. (โš  DISCLAIMER: Sometimes I also tweet about Python ๐Ÿ)
25
97
1K
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Hi ๐Ÿ‘‹ if you are interested in: ๐Ÿ Python ๐Ÿ’ป Programming ๐Ÿ Python ๐Ÿง  Mathematics ๐Ÿค– Machine Learning ๐Ÿ and some more Python, Follow me. โœ” I'm planning on using Twitter to share a lot of content that you won't want to miss. ๐ŸŽ‰
24
88
1K
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Did you know that Python ๐Ÿย has over 240 modules in the standard library? Here is a MEGA thread ๐Ÿงตwith a super high level overview of those modules... ... but before that, I challenge you to name as many modules by heart as possible! ๐Ÿ’ฌ๐Ÿ‘‡ Let's see who gets more!
20
238
951
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Here is a thing I see beginners do all the time when learning computer programming. They use a conditional statement (an if-statement) to decide whether to return `True` or `False` from a function. Don't use a conditional, RETURN the condition ๐Ÿ‘ Example in Python ๐Ÿ:
Tweet media one
40
125
841
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
1 year
How did I not know this?! You can style your Python ๐Ÿ matplotlib plots like an @xkcd comic! I think I'll be using this for presentations from now on! ๐Ÿš€ What do you think?
Tweet media one
25
124
844
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Do you want to master Python ๐Ÿ list comprehensions? Do you want to become more proficient working with lists in Python ๐Ÿ? If you answered with โ€œyesโ€, then here's a cheatsheet of mine to help you out. This is also a thread ๐Ÿ‘‡๐Ÿงต that breaks it down and explains everything:
Tweet media one
21
194
828
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
I started learning Python ๐Ÿ almost 10 years ago. When I started out, I _only_ used free resources. After all, I was just a kid and didn't even have money! Those generous people taught me almost everything I know! I want to give back, and that's why MY Python book is free.
11
102
754
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
New in Python 3.10 ๐Ÿ is the `pairwise` function from `itertools`. The `pairwise` function allows you to iterate over an iterable, while accessing consecutive pairs of items. (Like a sliding window of size 2, if you know what that means.) Here's an example ๐Ÿ‘‡
Tweet media one
25
100
719
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Have you ever seen anything like this in Python ๐Ÿ loops?? I just saw this being used for the first time, ever, and I decided to figure out what the heck this was... And so here goes the explanation ๐Ÿ‘‡๐Ÿงต 1/
Tweet media one
21
149
723
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
1 year
The Python ๐Ÿย module `pathlib` is amazing. Learning about it will make you 10x more productive*! ๐Ÿš€ If you want to work with files, you need to know about it! Let me show 5 of the most useful tools in this module ๐Ÿ‘‡ (*Actual numbers may vary. ๐Ÿคก)
Tweet media one
16
99
554
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Someone just DM'd me, asking how to start learning Python ๐Ÿ Here's what I replied ๐Ÿ‘‡
16
130
527
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
1 year
Python ๐Ÿย decorators are often considered an โ€œadvancedโ€ topic. But they don't need to be hard. Let me explain ๐Ÿ‘‡ย how decorators are an elegant and powerful tool. ๐Ÿš€
Tweet media one
16
93
513
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
I just came up with the perfect analogy to help you understand asyncio in Python ๐Ÿ You can thank me later ๐Ÿ˜Š Buckle up ๐Ÿš€
Tweet media one
18
102
520
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Would you like me to teach you how to write Python ๐Ÿ code that is more elegant, more effective, and more expressive than what you have been writing until now... for free? I am looking to teach Python to people who want to master Python to the best of their abilities.
Tweet media one
17
79
506
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
I remember it took me a couple of years to really _understand_ recursion. When I first started learning computer programming, it just didn't click! Now, recursion feels natural to me. Here's how I think of it ๐Ÿ‘‡
Tweet media one
30
76
487
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
1 year
Python ๐Ÿย developers can use `property` to supercharge their classes. ๐Ÿš€ With `property`, you can write attributes that are computed dynamically. Let me show you how it works in this thread. ๐Ÿ‘‡
Tweet media one
20
86
482
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Do you use VS Code in your Python ๐Ÿ programming? I just discovered that you can CTRL + click on multiple locations to edit multiple locations at the same time! @vscodetips , how about that?
32
72
483
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Do you struggle with list comprehensions in Python ๐Ÿ? I know I did. That's why I have lined up a series of tweets on the subject. For the next 100 ๐Ÿ˜ฑ days I will share a daily tip or exercise about list comprehensions. So, what should you do..?
7
71
481
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Do you use Python ๐Ÿ? I often like to suggest people get acquainted with the function `itertools.product`. Handy, for example, to flatten 2 or more nested `for` loops.
Tweet media one
9
72
458
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
1 year
Every Python ๐Ÿย programmer should learn about `itertools`. It's a great module with lots of elegant and efficient tools! ๐Ÿš€ You'll write better code with these ๐Ÿ‘‡
Tweet media one
18
82
453
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Here is an interesting way to get *both* the smallest and largest element of an iterable in Python ๐Ÿ
Tweet media one
8
57
457
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
I have gotten multiple requests to explain recursion. Recursion is a maths/computer science concept and it goes beyond Python ๐Ÿ, or JavaScript, or whatever language you use. Let me explain recursion with an example ๐Ÿ‘‡
33
87
434
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
๐Ÿ—“๏ธ the weekend is coming ๐Ÿฅณ If you want, use it to rest! You deserve it! Or, make this a memorable weekend: Let this be the weekend you implement your first neural network ๐Ÿง  from scratch, in Python ๐Ÿ Here's the roadmap ๐Ÿ›ฃ๏ธ ๐Ÿ‘‡๐Ÿงต
Tweet media one
5
81
430
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Python ๐Ÿ functions take positional and keyword arguments. You can tell Python to force arguments to be either positional-only or keyword-only. Here is how ๐Ÿ‘‡
Tweet media one
Tweet media two
Tweet media three
Tweet media four
8
81
413
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Here is some Python ๐Ÿ code using - decorators - callable classes - custom operators - โ€œfunctionalโ€ function composition - arbitrary args and kwargs Here is a breakdown of everything that is going on ๐Ÿ‘‡
Tweet media one
9
76
423
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Have you ever had a hard time debugging ๐Ÿž a Python ๐Ÿ script? If you say you haven't, you're lying! ๐Ÿ˜† Let me show you something that you're gonna love me for! Run your script with the `-i` flag! By doing so, you get a REPL when the script finishes, EVEN with errors ๐Ÿ’ฃ 1/4
Tweet media one
10
115
417
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
๐Ÿ๐Ÿ”ฆ Python under the hood. ๐Ÿ‘‡๐Ÿงต Here's a thread on the dunder method `__init__`. You can't say you **know** Python if you don't know this, so... In this thread we will cover the dunder method `__init__` and its role in Python OOP. Here we go ๐Ÿš€
Tweet media one
16
81
396
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
1 year
I've been doing Python ๐Ÿย for +11 years. ๐Ÿš€ Here's a roadmap to learn 6 major topics you can't miss:
11
83
371
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Now you can run Python ๐Ÿ code in your HTML! You just need to use the <py-script> tag, and that's it! I wrote a short TIL describing how you can start using it. The post itself uses PyScript to print a timestamp formatted with Python's `datetime`.
15
76
373
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Here is some Python ๐Ÿ code with a bunch of interesting things going on: ๐Ÿ“Œ decorators ๐Ÿ“Œ callable classes ๐Ÿ“Œ custom operators ๐Ÿ“Œ โ€œfunctionalโ€ function composition ๐Ÿ“Œ arbitrary args and kwargs Pick this code apart and study it! I'll explain it in a thread later ๐Ÿ˜‰
Tweet media one
18
60
364
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
How do you create a Python ๐Ÿ package? How to publish it? How to set up CI/CD? How do you check code coverage? Most importantly, how do you add those cute badges to your README file? I was writing a thread on this, now I turned it into an article ๐Ÿ‘‡
7
77
369
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Yesterday, @nedbat tweeted a really weird piece of code and there was a lot to learn from there! String formatting is used very often in Python. Did you know you can implement formatting for your own objects as well? Just implement the dunder method `__format__` ๐Ÿ‘‡
Tweet media one
9
41
359
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
I have a challenge for you ๐Ÿง  Here is a sequence of some numbers: - 1 - 11 - 21 - 1211 - 111221 - 312211 Can you guess the next number? Bonus Q: can you write a program that computes the next term of the sequence?
77
43
357
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
There is more than one way to skin a cat. In Python ๐Ÿ, there is more than one way to create a dictionary. However, I claim not all ways are equally good. Here ๐Ÿ‘‡ is a situation where I show 4 different ways of creating a dict, showing a progression in knowledge/techniques.
Tweet media one
9
68
345
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Here's a cool Python ๐Ÿ tip ๐Ÿ’ก! Use `...` in places where you haven't finished writing your code. For example, inside a function or a class!
Tweet media one
24
39
328
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
The Python ๐Ÿ Standard Library is one of the reasons I love ๐Ÿ’™ Python. ๐Ÿ“‚๐Ÿ” dealing with your filesystem is super simple. All you have to do is use the `pathlib` module. This short thread is a mini `pathlib` cookbook ๐Ÿณ, showing some example usages of `pathlib`. Ready ๐Ÿš€?
Tweet media one
5
51
326
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Have you heard that Python ๐Ÿ 3.10 will be released soon? Are you ready for when it drops ๐Ÿ’ฃ๐Ÿ”ฅ? Python 3.10 will ship with the new โœจ match statement, and I created a cheatsheet just for that. This is also a thread ๐Ÿ‘‡๐Ÿงต that breaks it down and explains everything:
6
73
325
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Best tip to ace that Python ๐Ÿ interview question:
Tweet media one
11
29
315
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
What's the best computer programming book you've ever read, and why was it the best? No need for consensual replies, I just want honest opinions. It can be about a language, like Python or JavaScript, a tool or framework, or anything related to programming. I'll start ๐Ÿ‘‡
93
69
318
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
This happens to me all the time: I start charging ๐Ÿ”Œโšก my laptop while using it, and then forget about it! When I notice, the battery's been full ๐Ÿ”‹ for a long time! Use this Python ๐Ÿ script to periodically check if charging is done, and to notify ๐Ÿ”” you when it is!
Tweet media one
24
46
316
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Python ๐Ÿ indexing supports slicing with `[:]` and `[::]`... But did you know you can create `slice` objects? You can even name your slices! ๐Ÿ‘‡
Tweet media one
6
30
314
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
@PrasoonPratham That's a nice problem. Using `divmod` we can successively group the leftover days in the longer time frames:
Tweet media one
12
15
308
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
`for` loops are the bread and butter of Python ๐Ÿ programming, right? And yet... They are misunderstood by many because people lack an *intuitive understanding* of how `for` loops work. Let me help ๐Ÿ‘‡
Tweet media one
11
83
306
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Everyone knows that giving proper names to variables and functions is the true programmer's bane. Here's a thread ๐Ÿ‘‡๐Ÿงต with do's and don'ts for naming things in Python ๐Ÿ We can only hold a small number of simultaneous ideas in our ๐Ÿง , so proper naming can really help us!
Tweet media one
5
74
299
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
๐Ÿค” If you are learning Python ๐Ÿ, I want to do an experiment: Here's a thread ๐Ÿ‘‡๐Ÿงต teaching you conditional expressions. BUT, I will teach you with NO words ๐Ÿ˜ถ I will only show code snippets and examples. Check the thread out carefully ๐Ÿ” and then give me your feedback!
20
48
294
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
There's an interesting โ€œmistakeโ€ I see beginners do all the time when learning computer programming. When using conditions, they compare directly to Booleans! Often, there's no need to compare to Boolean values, just use the condition directly ๐Ÿ˜‰ Here's a Python ๐Ÿ example:
Tweet media one
16
40
287
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
1 year
Error handling in Python ๐Ÿย made simple. ๐Ÿš€ ๐Ÿ‘‡
Tweet media one
18
58
282
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
In the last 6 hours, more than 1200 people downloaded my free Python ๐Ÿ book. It is an honour that YOU are trusting ME to help you master Python! Also, huge shout-out to @svpino for helping me reach a massive audience! Let's go ๐Ÿš€
@svpino
Santiago
2 years
A book that will teach you how to write elegant Python code. โ€ข 100% free โ€ข Over 10,000 readers โ€ข All 5-star reviews The book is free today, but it may not last. Get your copy right away!
Tweet media one
29
277
1K
8
43
280
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Do you know what's a good replacement for nested `for` loops in Python ๐Ÿ ? `itertools.product` is! With `product` you can combine all items of one sequence with all items of another sequence (and it works with 3 or more sequences as well!).
Tweet media one
11
38
279
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Careful with mutability in Python ๐Ÿ I already knew this, and yet I made this mistake in my code! When you multiply a list of lists in Python, you are not creating copies of the sublists. The sublists are actually all the same. That's why this happens ๐Ÿ‘‡
Tweet media one
10
38
278
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
1 year
The Python ๐Ÿย module datetime is your best friend if you want to work with dates and times. ๐Ÿš€ Here are some of the cool things it does:
Tweet media one
11
49
272
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
๐Ÿ’ก Here's a cool Python ๐Ÿ tip for you. Run Python with the `-i` modifier to get an interpreter after the script is done. This gives access to the variables ๐Ÿ”Ž that were defined by the time the script is done... This even works if the program is interrupted with an exception!
Tweet media one
6
47
272
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
1 year
If you are learning Python ๐Ÿ you will eventually encounter list comprehensions. List comprehensions are a convenient way of creating lists. ๐Ÿš€ There are three main benefits associated with using themโ€ฆ But below I just share an example list comprehension.
Tweet media one
2
47
268
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Always be aware of mutability in your Python ๐Ÿ code. It's not difficult to understand how it works... But if you don't pay attention ๐Ÿ”Ž, it may produce seemingly surprising results ๐Ÿ‘‡๐Ÿ˜ฒ
Tweet media one
11
28
261
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Did you know that, in Python ๐Ÿ, it only takes 2 lines of code to open your browser in your favourite website? The module `webbrowser` comes in the standard library and its `open` method opens the URL you pass it.
Tweet media one
13
36
264
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
If you're ever in a Python ๐Ÿ interview and you are asked to implement the factorial function... You know what to do! Ask them if you _really_ have to reinvent the wheel ๐Ÿ™ƒ
Tweet media one
12
36
257
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Did you know that Python ๐Ÿ comes with a simple `statistics` module? One of the functions in there is the `median` function. The `median` takes a series of numerical values and computes the number that lies in the middle of all of them. ๐Ÿ‘‡ (The data doesn't need to be sorted.)
Tweet media one
6
53
258
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Good morning to the folks who do Python ๐Ÿ debugging with `print`.
25
17
263
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
What's the BEST way to learn Python ๐Ÿ? I've been writing Python for 10 years and taught 100s of people. Here is a FAQ with actionable advice ๐Ÿ‘‡๐Ÿงต But everyone is different, so share your thoughts as well ๐Ÿ‘‡๐Ÿ’ฌ to help as many as possible!
Tweet media one
16
87
255
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Today I spent the day playing with sockets in Python ๐Ÿ Here is you can get two sockets to communicate with each other. All you have to do is open two Python instances and type the code I show in the images. The socket on the left reverses the messages it receives ๐Ÿคช
Tweet media one
Tweet media two
6
46
254
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
The Python ๐Ÿ string methods `.lstrip` and `.removeprefix` look very similar. But they do very different things! Let me explain.
Tweet media one
8
42
253
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Did you know that Python ๐Ÿ can actually use semicolons ( `;` ) to separate statements? ๐Ÿคฏ Granted, those pesky things do not usually belong in your code... But they can be quite handy in the REPL, to group statements together, to make it easier to re-execute them later.
Tweet media one
13
33
251
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Look who made it to the front page of Hacker News ๐Ÿ˜›
Tweet media one
15
12
255
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
1 year
Python ๐Ÿ f-strings can align a value inside a slot with a fixed width. And you can even what character fills the remaining space! ๐Ÿš€
Tweet media one
6
51
249
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
I like functional programming, do you? I use some functional patterns in Python ๐Ÿ a lot, while others not so much. For example, how do you usually compose two functions in Python? Do you do it like in the top or in the bottom?
Tweet media one
19
31
240
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
I'm building a Python ๐Ÿ course for kids aged 15~18. What are some modules/tools they can use that allow them to create things they can see, interact with, show others? E.g., pygame, streamlit, and what more?
46
24
244
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Today, I'm spending the day learning in public about socket programming (in Python ๐Ÿ). My starting point is this: โ€œI think sockets are like tunnels/roads that allow different programs to talk to each other directly.โ€ This ๐Ÿงต will evolve as I learn and experiment ๐Ÿ‘‡
12
28
245
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Do you want to check if a Python ๐Ÿ variable matches one of several possible values? Instead of writing a big chain of `or` and equalities `==`, use the `in` operator!
Tweet media one
8
36
243
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
1 year
Here is a complete diagram of a Python ๐Ÿ function definition. ๐Ÿš€
Tweet media one
7
41
247
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
How did you learn programming? University ๐ŸŽ“, books ๐Ÿ“š, online resources ๐ŸŒ? Paid, or free ๐Ÿ’ธ? I learned online from free resources. Now I want to give back to the Python ๐Ÿ community, and that's why I'm making my Python book free ๐Ÿ‘‡
15
38
242
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
How do you set up a Python ๐Ÿ package? How do you set up CI/CD with testing and code coverage? How do you publish a package to PyPI? I don't know ๐Ÿคท But today I'll be finding out and tweeting my findings in this thread. Come join me ๐Ÿ˜‰
Tweet media one
10
36
241
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Are you a Python ๐Ÿ developer? If you are, you can - and SHOULD - get rich, quick. Just do pip install rich I took 9 years to get rich, but you can get rich TODAY! It's such an awesome package which lets you style your outputs beautifully!
12
38
248
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Working with dates in Python ๐Ÿ? If you are, you probably know the module `datetime`. If you need to know what time it is โ€œnowโ€, use the method `now`:
Tweet media one
6
40
238
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Day 2/100 of learning and practising Python ๐Ÿ list comprehensions! Let's go ๐Ÿš€ Here's an exercise for you ๐Ÿ“–โœ๏ธ Run the two snippets of code. What do their results look like? What parts of the code are different in the snippets? And what parts are the same?
Tweet media one
Tweet media two
13
31
237
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
I love that Python ๐Ÿ comes with batteries included. One of my favourite modules is `collections`, with which you can do a lot of cool stuff! Using `collections.deque`, it's really easy to get the last N lines of a file! Check it out ๐Ÿ‘‡
Tweet media one
4
36
243
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
1 year
Doesnโ€™t this look cool? ๐Ÿ๐Ÿš€
Tweet media one
25
14
240
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
๐Ÿ’ก Here is a naming tip that you can use in Python ๐Ÿ, JavaScript, or any other programming language you use. ๐Ÿ‘‰ use verbs (actions) for function names ๐Ÿ‘‰ use nouns for variables/data ๐Ÿ‘‰ use adjectives for Boolean values Remember that good naming conventions are important!
Tweet media one
6
45
237
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Here is a diagram showing various types of function signatures in Python ๐Ÿ
Tweet media one
7
42
233
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Playing around with Python ๐Ÿ? Need to inspect an instance of a custom object..? Use `vars`! It will show you the instance attributes and values.
Tweet media one
11
42
239
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
I just found another Python ๐Ÿ monstrosity. This one was brought to you by the infamous @dabeaz ... But what does it do? Sit tight, here we go ๐Ÿง‘โ€๐Ÿš€
Tweet media one
7
39
233
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
10 months
@tdinh_me One of my favourite sayings is that โ€œluck happens when opportunity meets preparationโ€. Maybe you got โ€œluckyโ€, but that's only because you spent all those years preparing. Others, presented with the same opportunity, wouldn't get lucky because they weren't prepared.
10
21
233
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
1 year
Python ๐Ÿย developers can use `property` to supercharge their classes. ๐Ÿš€ With `property`, you can write attributes that are computed dynamically. Properties can also be updated dynamically. Let me show you how in this thread. ๐Ÿ‘‡
Tweet media one
10
48
227
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
Have you ever tried to optimise your Python ๐Ÿ code, but weren't able to tell which alternative implementation was faster? Let me teach you how to use the `timeit.timeit` method to measure execution time of small code snippets. A thread ๐Ÿ‘‡๐Ÿงต
Tweet media one
11
36
232
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
1 year
Every Python ๐Ÿย programmer uses the ICPO rule. ๐Ÿš€ Even if you don't know what it is. Let me tell you what the ICPO rule is and what it does ๐Ÿ‘‡
Tweet media one
8
52
229
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
It's amazing how frequently I get to use the collections.Counter in my Python ๐Ÿ programs... Get acquainted with the tools in the module `collections`, you won't regret it!
Tweet media one
11
28
224
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
@__mharrison__ Hey Matt I'm Rodrigo I'm from Portugal I like reading fantasy books technical books
7
0
224
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Day 99/100 of learning and practising Python ๐Ÿ list comprehensions! This is the toughest exercise so far! I think..? This code aggregates anagrams from a bag of words. Let's go ๐Ÿš€
Tweet media one
7
36
218
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Day 20/100 of learning and practising Python ๐Ÿ list comprehensions! Let's go ๐Ÿš€ List comprehensions can include filters. These filters let you only use the values that you want. Here is a diagram comparing the loop + if + append to a list comprehension ๐Ÿ‘‡
Tweet media one
4
28
218
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
๐Ÿค” Do you ever write some Python ๐Ÿ, look at it, and get the feeling there MUST be a better โœจ way to do that..? I get that ALL the time! ๐Ÿ˜… That's why I started researching and writing articles to help me (and you!) write better code. Here's all 28 of them (so far!) ๐Ÿ‘‡๐Ÿงต
8
48
218
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
1 year
Python ๐Ÿย f-strings are the best. ๐Ÿš€ Use an `=` inside your f-string to print the value AND the expression that produced the value! โœจ
Tweet media one
8
30
218
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
3 years
I love the `enumerate` Python ๐Ÿ built-in! I love it because your `for` loops become much more readable โœจ if you know how to use it. Here's a thread ๐Ÿ‘‡๐Ÿงต on how `enumerate` will make your Python code so much better. Let's go ๐Ÿš€
Tweet media one
8
45
213
@mathsppblog
Rodrigo ๐Ÿ๐Ÿš€
2 years
Merging two dictionaries in Python ๐Ÿ In 3 ways: ๐ŸŸข using the splat operator `**` ๐ŸŸก using the pipe operator `|` (Python 3.9+) ๐Ÿ”ด updating a dict in-place with `|` (also Python 3.9+)
Tweet media one
6
29
220