To learn all about strings, head over to my extensive article on strings: python.land/introduction-to-…
Want to swap two variables? Python makes it incredibly easy thanks to tuple unpacking!
a = 5
b = 10
a, b = b, a
8
968
Erik retweeted
With Pyenv, you can start using Python 3.12 right away since they've added it to their list of supported versions as soon as it came out. Learn more about Pyenv here 👇
python.land/virtual-environm…
💡 Do you know #Python’s any() and all() functions? These are powerful tools for evaluating iterables! any() returns True if at least one element of an iterable is true. all() returns True only if all elements of an iterable are true.
👀 Use Python’s built-in help() function! It's an interactive way to explore documentation and learn more about Python objects and modules in the Python REPL! 📚
Examples:
help(str)
import os
help(os)
help(os.path)
etc.
🐍 #Python Tip: Want to remove the last letter from a word using slicing? Here's how:
word = "Python"
new_word = word[:-1]
print(new_word) # Outputs 'Pytho'
Learn more here: python.land/introduction-to-…
Yesterday, Python 3.12 was released. Many people won't use it for a while since most lag behind a few versions for various reasons. Nevertheless, you can check out what's new in this post: docs.python.org/3.12/whatsne…
2
376
One notable change: you can use the same quotes inside a nested f-string:
>>> f"Quotes inside a nested f-string: {"a string"}"
'Quotes inside a nested f-string now: a string'
I'm not sure what to think of this yet...
1
289
Another notable thing is using a per-interpreter GIL. The GIL ensures there is only one thread running at any time. Because only one thread can run at a time, using multiple processors with threads is impossible right now.
Read more here:
docs.python.org/3.12/whatsne…
262
🔄 Python’s itertools module is a collection of fast, memory-efficient tools that are useful for working with iterators (e.g., loops). Explore more: docs.python.org/3/library/it… #Itertools #Coding #Developer
Erik retweeted
🤖 Python #Trivia: The name 'Python' was not derived from the snake but from the British comedy series 'Monty Python’s Flying Circus'! 📺 What's your favorite Python fun fact? 🧠 #PythonProgramming #DidYouKnow
Erik retweeted
TIL about math.isclose() to compare floating-point numbers in #Python
I already knew about pytest's approx() which is similar, but turns out the Standard Library has you covered once more:
x = 0.1 + 0.2
print(x == 0.3) # False 😱
# need a small tolerance
import math
print(math.isclose(x, 0.3)) # True
So math.isclose() checks whether two numbers are close enough to each other, within a given tolerance, avoiding the pitfalls of floating-point comparison.
#tips #pythonprogramming
Erik retweeted
Optimus can now sort objects autonomously 🤖
Its neural network is trained fully end-to-end: video in, controls out.
Come join to help develop Optimus (& improve its yoga routine 🧘)
→ tesla.com/AI
After a few years of using Windows + Linux (dual boot), I returned to MacOS (Macbook Pro). Do you have any tips, tricks, or cool software I need to know about as a software developer?
3
2
393
Erik retweeted
Yeah, so I helped the Excel team with this. Excited that it's out! techcommunity.microsoft.com/…
9 Software Life Lessons You Must Experience Yourself to Truly Understand link.medium.com/2hwTMh8O4Bb


![>>> title = "python strings are awesome" >>> title.capitalize() 'Python strings are awesome' >>> title.title() 'Python Strings Are Awesome' >>> title.split() ['python', 'strings', 'are', 'awesome']](https://pbs.twimg.com/media/F7vnRh5WMAACUBH.png?name=small&format=webp)




