What is this if name == "__main__": at the end of a #Python script?
It's typically used to include code that ONLY should run if the module / script is called directly and NOT upon importing it.
Example:
It's typically used to include code that ONLY should run if the module / script is called directly and NOT upon importing it.
Example:
#Snippet
Useful constants in #python
Using #Python's calendar module + the enumerate built-in to make a mapping of month names -> numbers
Useful constants in #python
Using #Python's calendar module + the enumerate built-in to make a mapping of month names -> numbers
>>> import calendar
>>> MONTH_NAMES_TO_NUMBERS = {
... v: k for k, v in enumerate(calendar.month_abbr[1:], start=1)
... }
>>> MONTH_NAMES_TO_NUMBERS
{'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6, 'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12}Forwarded from Information for IT Students
How to send a tweet with #Python and TweePy in under 10 lines of code
🐍🔥
For more information, refer the Twitter thread given below👇🏻
🐍🔥
For more information, refer the Twitter thread given below👇🏻
#Python's print() built-in is more powerful than you might think
#Python has lots of great packages. Here are just a few:
🐍Textual - TUI
🤖Playright - Web testing
📄OpenPyXL - Read / Write Excel
🌐ReportLab - Create PDFs
🐍Numpy - Mathematics
🐼Pandas - Data Analysis
👓OpenCV - Computer vision
🔦PyTorch - ML
🔥Kivy - Mobile apps
🐍Textual - TUI
🤖Playright - Web testing
📄OpenPyXL - Read / Write Excel
🌐ReportLab - Create PDFs
🐍Numpy - Mathematics
🐼Pandas - Data Analysis
👓OpenCV - Computer vision
🔦PyTorch - ML
🔥Kivy - Mobile apps
#Python Pop Quiz 🐍❓
What does this code do?
A) NameError
B) SyntaxError
C) prints out None
D) What is this madness?
What does this code do?
A) NameError
B) SyntaxError
C) prints out None
D) What is this madness?