PythonChat Profile Banner
Python Chat Profile
Python Chat

@PythonChat

Followers
3K
Following
9
Media
9
Statuses
798

Live webcasts for #Python developers. Tweets by @treyhunner.

Joined April 2016
Don't wanna be here? Send us removal request.
@treyhunner
Trey Hunner
4 years
Does your company have an individual training budget that expires at the end of year? 💸 If you use #Python at work, sign up for the @PythonMorsels All Access plan and submit your training reimbursement before year end. 🐍💼 https://t.co/0YrJDd1jZ3
pythonmorsels.com
Practice a new intermediate-level Python concept every week
1
4
5
@treyhunner
Trey Hunner
4 years
Managing a #Python team and want to chat about your team's skill trajectory? I have ideas & opinions! I'd love to chat about: 1. On-boarding new hires 📋 2. Fostering kind code style discussions 🐕 3. Learning from each other regularly 👩‍🏫 4. Team learning in general 🤔 DM me 💬
0
2
8
@treyhunner
Trey Hunner
4 years
New blog post: What's great about #Python 3.10? There's some fun new features, but improved error messages are *the* winning Python 3.10 feature. https://t.co/6npvBe5sOU
8
46
121
@treyhunner
Trey Hunner
5 years
When we use keyword/named arguments, it's the name that matters, not the position Read the full article: Keyword (Named) Arguments in Python: How to Use Them ▸ https://t.co/1SjTH1gJPc #Python
0
2
3
@treyhunner
Trey Hunner
5 years
Our class instantiation syntax in Python is the same as our function call syntax. Instead of "new SomeClass()" we write "SomeClass()". Because of this we use the word "function" in a fuzzy way: "function" is often used to mean "callable". https://t.co/tawEdwYt0x
Tweet card summary image
pythonmorsels.com
A callable is a function-like object, meaning it's something that behaves like a function. The primary types of callables in Python are functions and classes, though other callable objects do exist.
@PythonMorsels
Python Morsels
5 years
A callable is an object that you can call. Functions are callables in #Python, but so are classes (many of the "built-in functions" are actually classes). https://t.co/4pPxKnELIi
2
3
14
@PythonMorsels
Python Morsels
5 years
In #Python, you can pass function objects as an argument to another function. In fact, some of the built-in functions, like sorted, specifically accept functions as an argument. https://t.co/QWTfJtYDzi
Tweet card summary image
pythonmorsels.com
In Python, you can pass functions (as an argument) to another function. Some of Python's built-in functions actually expect functions to be given as one or more of their arguments to call them later.
0
2
7
@PythonMorsels
Python Morsels
5 years
You can break up long lines of #Python code with implicit line continuation. PEP 8 recommends relying on implicit line continuation instead of putting a \ at the end of lines to continue them. https://t.co/2j6YvxxTs3
Tweet card summary image
pythonmorsels.com
Have a long line of code? If you don't have brackets or braces on your line yet, you can add parentheses wherever you'd like and put line breaks within them. We call this "implicit line continuation".
0
2
5
@PythonMorsels
Python Morsels
5 years
If you're new to list comprehensions in #Python, I recommend writing your comprehensions by copy-pasting your way from a "for" loop. This way you can anchor your understanding of comprehensions on your existing knowledge of "for" loops. https://t.co/Otrp481tlg
Tweet card summary image
pythonmorsels.com
If you're new to comprehensions, I recommend copy-pasting your way from a loop to comprehension to anchor your existing understanding of for loops with your new knowledge of comprehensions.
0
6
15
@treyhunner
Trey Hunner
5 years
Something folks often ask me in my Python trainings: are immutable objects the same as constants? 🤔 They're not! 😮 Immutable objects stop you from mutating an object but constants stop you from assigning to a variable (remember: variables are pointers in Python). 🐍🍪
@PythonMorsels
Python Morsels
5 years
We have immutable objects in Python but we don't have constant variables. The UPPERCASE_CONVENTION for constants is just a naming convention in #Python. It doesn't stop variables from being re-assigned. https://t.co/GvqjyiljH4
1
5
13
@PythonMorsels
Python Morsels
5 years
We have immutable objects in Python but we don't have constant variables. The UPPERCASE_CONVENTION for constants is just a naming convention in #Python. It doesn't stop variables from being re-assigned. https://t.co/GvqjyiljH4
Tweet card summary image
pythonmorsels.com
Variables point to objects. Constant variables in other languages cannot be reassigned. We don't have any equivalent of that in Python. We have immutable objects, but not constant variables.
0
2
5
@PythonMorsels
Python Morsels
5 years
Checking an object's truthiness checks for non-emptiness and non-zero-ness. FYI: the #Python docs don't mention "truthy" or "falsey" even once. The docs call it "truth value testing" but Pythonistas rarely use that phrase colloquially. https://t.co/1QY2qqVki9
Tweet card summary image
pythonmorsels.com
In Python, truthiness is asking the question, what happens if I convert an object to a boolean. Every Python object is truthy by default. Truthiness in Python is about non-emptiness and non-zeroness.
0
1
1
@PythonMorsels
Python Morsels
5 years
Instead of using hard-coded indices to get tuple elements, use tuple unpacking to give descriptive names to each item. Important items should have a name instead of a number. #Python https://t.co/fbLOIdU2lG
Tweet card summary image
pythonmorsels.com
Instead of using hard-coded indices to get tuple elements, use tuple unpacking to give descriptive names to each item. Important items should have a name instead of a number.
1
5
8
@treyhunner
Trey Hunner
5 years
Let's look at different techniques for counting the number of times things appear in a list. Read more 👉 https://t.co/PzgxGz04xg #python
0
5
9
@PythonMorsels
Python Morsels
5 years
Parentheses in #Python's class & function definitions mean different things In a function definition, parentheses after the name denote the functions' arguments. In a class definition, parentheses after the name denote the class' parent classes. https://t.co/3yPqpE1QFQ
Tweet card summary image
pythonmorsels.com
To inherit your class from another class, put parentheses after the class name and list parent classes. We allow multiple inheritance in Python, but we usually prefer single class inheritance.
0
2
1
@treyhunner
Trey Hunner
5 years
Classes, modules, and functions are all mutable objects in #Python 🤯
@PythonMorsels
Python Morsels
5 years
In #Python, everything is an object. Classes are objects. Modules are objects. Functions are objects. In fact, they're all mutable objects! https://t.co/ciqhn2FiMM
0
3
10
@PythonMorsels
Python Morsels
5 years
The first method you'll see in most #Python classes is the init method. This isn't a constructor method but an initializer method (because by the time init is called, a new class instance has already been "constructed") https://t.co/eJ2kQmk2Rt
Tweet card summary image
pythonmorsels.com
The __init__ method is used to initialize a class. The initializer method accepts self (the class instance) along with any arguments the class accepts and then performs initialization steps.
0
8
11