Python Chat
@PythonChat
Live webcasts for #Python developers. Tweets by @treyhunner.
내가 좋아할 만한 콘텐츠
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. 🐍💼 pythonmorsels.com/all-python-exe…
pythonmorsels.com
Python skill-building for professional developers
Practice a new intermediate-level Python concept every week
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 💬
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. treyhunner.com/2021/10/whats-…
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 ▸ trey.io/U92hu3 #Python
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". pythonmorsels.com/topics/callabl…
pythonmorsels.com
The meaning of "callable" in Python
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.
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). pythonmorsels.com/topics/callabl…
pythonmorsels.com
The meaning of "callable" in Python
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.
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. pythonmorsels.com/topics/passing…
pythonmorsels.com
Passing functions as arguments to other functions
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.
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. pythonmorsels.com/topics/breakin…
pythonmorsels.com
Breaking up long lines of code in Python
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".
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. pythonmorsels.com/topics/turning…
pythonmorsels.com
Turning a for loop into a list comprehension
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.
What is a list comprehension in #Python? What are they used for and how are they different from a for loop? pythonmorsels.com/topics/what-ar…
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). 🐍🍪
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. pythonmorsels.com/topics/python-…
pythonmorsels.com
Does Python have constants?
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.
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). pythonmorsels.com/topics/callabl…
pythonmorsels.com
The meaning of "callable" in Python
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.
Need an attribute that updates its value automatically? Use a property! In the #Python world, we tend to prefer properties over getter methods. pythonmorsels.com/topics/making-…
pythonmorsels.com
Making an auto-updating attribute
We don't use getter methods in Python, instead we use the property decorator to make make automatically updating attributes. Properties allow us to customize what happens when you access an attribute.
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. pythonmorsels.com/topics/python-…
pythonmorsels.com
Does Python have constants?
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.
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. pythonmorsels.com/topics/truthin…
pythonmorsels.com
Truthiness
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.
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 pythonmorsels.com/topics/tuple-u…
pythonmorsels.com
Tuple unpacking in Python
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.
When you import a module in #Python, you'll get access to a module object with attributes representing each of the variables in that module. pythonmorsels.com/topics/importi…
pythonmorsels.com
Importing a module in Python
When you import a module in Python, you'll get access to a module object with attributes representing each of the variables in that module. Python comes bundled with a bunch of modules.
Let's look at different techniques for counting the number of times things appear in a list. Read more 👉 trey.io/wV2O5R #python
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. pythonmorsels.com/topics/inherit…
Classes, modules, and functions are all mutable objects in #Python 🤯
In #Python, everything is an object. Classes are objects. Modules are objects. Functions are objects. In fact, they're all mutable objects! pythonmorsels.com/topics/everyth…
pythonmorsels.com
Everything is an object
In Python, everything is an object. Classes are objects, instances of classes are objects, modules are objects, and functions are objects. Anything that you can point a variable to is an object.
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") pythonmorsels.com/topics/what-is…
pythonmorsels.com
What is __init__ in Python?
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.
United States 트렌드
- 1. Australia 498K posts
- 2. Hanukkah 159K posts
- 3. Good Sunday 70.5K posts
- 4. Ahmed al Ahmed 17.8K posts
- 5. Brown University 269K posts
- 6. #HealingServiceDay 11.7K posts
- 7. Muhammad Qasim 23.8K posts
- 8. Naveed Akram 72K posts
- 9. #sundayvibes 4,241 posts
- 10. Gunther 101K posts
- 11. Globalize the Intifada 11.9K posts
- 12. Blessed Sunday 19.4K posts
- 13. Guns 101K posts
- 14. Chabad 15.8K posts
- 15. #SundayThoughts 1,100 posts
- 16. Rabbi Eli Schlanger 8,946 posts
- 17. Chrisean 9,473 posts
- 18. #SundayMotivation 1,837 posts
- 19. Spurs 79.1K posts
- 20. Rhode Island 64.6K posts
내가 좋아할 만한 콘텐츠
-
Talk Python Podcast
@TalkPython -
Michael Kennedy
@mkennedy -
Trey Hunner
@treyhunner -
PythonAnywhere
@pythonanywhere -
Pybites
@pybites -
Matt Makai | Full Stack Python | Plushcap
@fullstackpython -
Daily Python Tip 🐍🐧
@python_tip -
Python Trending 🇺🇦
@pythontrending -
EuroPython
@europython -
PyCon US
@pycon -
Dan Bader
@dbader_org -
Bob Belderbos
@bbelderbos -
Hynek Schlawack
@hynek -
Kenneth Reitz
@kennethreitz42 -
Ankur Gupta
@getpy
Something went wrong.
Something went wrong.