Never Use [ ] as a Default Argument in Python...
Unlock all features
FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.
Unlock all features
FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.
Unlock all features
FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.
Unlock all features
FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.
Unlock all features
FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.
Related videos
DuckDB in Python - The Next Pandas Killer?
NeuralNine
48.3k views
MongoDB in Python - NoSQL Document Database
NeuralNine
70.9k views
Advanced Dictionaries: defaultdict in Python
NeuralNine
35.7k views
Use OpenAI's ChatGPT in Python
NeuralNine
117.7k views
PostgreSQL in Python - Crash Course
NeuralNine
118.2k views
Modern Graphical User Interfaces in Python
NeuralNine
1.8m views
Secure Login System in Python
NeuralNine
125.3k views
Motion Detection Alarm System in Python
NeuralNine
45.3k views
Voice Assistant with Wake Word in Python
NeuralNine
111.6k views
Selenium Browser Automation in Python
NeuralNine
259.6k views
Top Comments (10)
that was a well thought language design decision for sure
Never knew this about python, thank you so much for this video!
I have in big programms very offen as default value at parameters [] (that for an programmer is the data type more intuitive clear), If you set anything at the optional parameter then know the programmer intuitive this must be a list. And only if a optimal argument is set 'work' internal a function with the list (e.g. create/return other list, or do willful manipulate the given list by side-effect). However, If you know what you do is the list at the parameter never manipulated. The exampe in the video ist a little "artifical", my opinion
Thank you so much
Thank you.
If we make a copy of the inventory (6:44), doesn't it make sense to go back to using an empty list as default argument for inventory?
we need a video about RAGflow , please
Brilliant, cut to the chase explanation as always. .👍👍 My easy way around the issue is to pass None as the default, and stuff the value later. def my_func (arg1: int = 0, arg2: [list | None] = None): real_arg2 = [] if arg2 is None else arg2 return real_arg2[arg1] I included type hinting out of good habit. Like most programming, there's more than one solution that often comes down to personal choice. As long as one is consistent, it's all good though. ❤❤❤ 🖖😎👍
can you make a course on backend web dev but with js now
Good demonstration. And don't forget to mention about call by value and call by reference action happening under the hood.
Unlock the Data Inside
Turn Videos into Knowledge
- Get FREE 10/day: transcripts, summaries, chats
- Chat with videos, export text & PDF
- $1 free API credit for RAG, chatbots & research
Free forever plan • All features unlocked
Top Comments (10)
that was a well thought language design decision for sure
Never knew this about python, thank you so much for this video!
I have in big programms very offen as default value at parameters [] (that for an programmer is the data type more intuitive clear), If you set anything at the optional parameter then know the programmer intuitive this must be a list. And only if a optimal argument is set 'work' internal a function with the list (e.g. create/return other list, or do willful manipulate the given list by side-effect). However, If you know what you do is the list at the parameter never manipulated. The exampe in the video ist a little "artifical", my opinion
Thank you so much
Thank you.
If we make a copy of the inventory (6:44), doesn't it make sense to go back to using an empty list as default argument for inventory?
we need a video about RAGflow , please
Brilliant, cut to the chase explanation as always. .👍👍 My easy way around the issue is to pass None as the default, and stuff the value later. def my_func (arg1: int = 0, arg2: [list | None] = None): real_arg2 = [] if arg2 is None else arg2 return real_arg2[arg1] I included type hinting out of good habit. Like most programming, there's more than one solution that often comes down to personal choice. As long as one is consistent, it's all good though. ❤❤❤ 🖖😎👍
can you make a course on backend web dev but with js now
Good demonstration. And don't forget to mention about call by value and call by reference action happening under the hood.