Python 101: Learn the 5 Must-Know Concepts

preview_player
Показать описание

If you're interested in becoming a developer that writes any type of code in python, then you need to understand these 5 Python concepts. In today's video, I'm going to break down 5 key Python concepts for any aspiring developer. Master Python, elevate your skills.

🎬 Timestamps
00:00 | Introduction
00:38 | Sponsor
01:43 | Mutable vs Immutable
06:20 | List Comprehensions
08:22 | Function Argument & Parameter Types
14:44 | if __name__ == "__main__"
16:34 | Global Interpreter Lock (GIL)

◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️

◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️

⭐️ Tags ⭐️
- Tech With Tim
- Top 5 Python Concepts
- Master Python

⭐️ Hashtags ⭐️
#techwithtim #top5python #pythonprogramming
Рекомендации по теме
Комментарии
Автор

Working as a python dev and in my 1 year of practicing python... no one ever explained this well... you're a GEM TIM

Gaurav-gcpm
Автор

I wanted to mention that the if name is main thing is frequently used for test code for libraries. Your code may have some functions to import elsewhere, then you can do examples in the main of how to use them, or try various failure cases, illustrate how to catch exceptions, etc.
Also, to those getting into programming, please do yourself a favor and leave a comment in your code as to what it's for. The most likely person to be reading your code later is you, but if you wrote it 6 months ago, it might as well have been written by someone else, so be kind to yourself.

TonyHammitt
Автор

At around the 4 minute mark you are confusing immutability with references. When you do 'y = x' what you are doing is assigning the reference of the object that x is pointing to, to y. When you assign a new object to x it drops the old reference and now refers to a new object, meanwhile y still refers to the original object. You use tuples in this example, but this is true for lists and dicts. When you change to lists, all you are really demonstrating is that x and y refer to the same object.

With your get_largest_numbers() example, if you were to pass a tuple into the function you would get an AttributeError because you were passing an immutable object which doesn't have the sort method.

apmcd
Автор

Some details skipped about *args and **kwargs:
A forward slash "/" can be used to force parameters to be positional only, thereby making them required when calling and not by name. So, def function(a, b, /, c, d, *args, e, f = False, **kwargs) means a and b cannot have default values, are required to be passed when calling function, AND can't be supplied with their parameter names. e must also be supplied with a value when called.

Naming the first * is not required. Doing so simply allows the function to take an arbitrary amount of positional parameters. def function(a, b, /, c, d, *, e, f = False) would require at least 5 arguments (no more than 6) passed to it: a and b are required, c and d are also required and optionally passed as keywords, e must be passed as keyword, f is completely optional, and nothing else is allowed.

/ must always come before *. * must always come before **kwargs. **kwargs must always be last if used.

zecuse
Автор

The GIL can be bypassed by using parallelism which offers about the same capabilities as threads in other languages. This is more of a naming convention issue rather than an actual thing that you can't do in Python. Python threads are still useful for IO and similar async tasks, but they're simply not traditional threads.

It's important to highlight these kinds of things even for beginners so that they don't go out into the world thinking that you can't do parallelism in Python. You absolutely can. It's just called something else.

TohaBgood
Автор

Because of the GIL, Python multi-threading is not useful for processor-bound computing, but it is still great for I/O bound computing (processor waits for input and output; example: disk read/write or networked data). Multiprocessing is a great way to get around the GIL, when you need to.

Gruuvin
Автор

Thank you so much. There is a lack of content on the internet about this. In addition to making things clear, it helped me in my programming midterm too.

MuhammetTaskin
Автор

Please do a global interpretor lock, love your explanation style, clear and concise. Keep it up

pharrison
Автор

Absolutely brilliant for beginners. Crystal clear. I had countless errors due to the lack of understanding of mutable vs immutable variables

zedascouve
Автор

Great video! It might have been worth it to mention multiprocessing in Python as a way to overcome the multithreading limitation that you reviewed towards the end.

Raven-bixn
Автор

Dude!!! That was a great tutorial. There are so many "beginner" python tutorials out there and it makes it hard to find the more advanced ones. I learnt a bunch! Thanks!!!

craigsievewright
Автор

Great content. Keep it up. However, I believe there is a mistake at 3:34. You mention that we have some sort of automatic "copying" going on with "y = x" when using immutable types. This is actually not correct. The assignment still works exactly like with any other object - the reference x is assigned to y. Identifiers x and y are simply referring to the same 2-tuple object. After that, you change what identifier x is referring to (another 3-tuple) and print out the two individual objects. The identifiers are still references - even if using immutable objects.

koflerkohime
Автор

There is an error in the time stamps, names of function arguments and if __ are interchanged

narutoxboruto
Автор

This is a great video for someone who is learning python as a second, third, or nth language. These are very python specific implementations of universal concepts and I had been wondering about their purpose when seeing python code.

yerneroneroipas
Автор

Really quality content and you can see that Tim really put some effort in explaining things, making topics captivating, and clear. Thanks!!

Jose-diwc
Автор

HI Tim, Just getting into coding: as you know (motivation level throught the roof - then realise html is not a stepping stone but a foundation of things to understand) Well Done on your coding journey! 😅🧐💫💫

craigdawkins
Автор

Thank you you are right on point, we miss these understandings and start scratching our head when we get errors.

basavarajus
Автор

I am currently doing Python courses and i struggle a lot, i like that you distinguished parameters and arguments correctly and basically everything else what you've said is exactly the same things, that i got myself/what i've been told. But it is good to refresh upon those conceprts and methods to proceed with my further studying, because i when i am given a task almost everytime i find it hard to came up with the right solution and fail to get the right approach to it. Thank you for the video. Subscribed!

Eeatch
Автор

I initially rushed through learning of Python's fundamentals. Whilst these things were mentioned, I didn't grasp the concepts until this video. Thanks.

jennyudai
Автор

Certainly! In addition to multithreading, Python also provides the multiprocessing module, which allows for true parallel execution across multiple processor cores. Unlike multithreading, multiprocessing bypasses the limitations imposed by the Global Interpreter Lock (GIL) since each process gets its own Python interpreter and memory space.

By utilizing multiprocessing, you can take advantage of multiple processor cores and achieve parallelism, which can significantly improve performance in computationally intensive tasks. Each process operates independently, allowing for efficient utilization of available CPU resources.

However, it's important to consider that multiprocessing comes with some overhead due to the need for inter-process communication. Data exchange between processes can be more involved and slower compared to sharing data between threads within a single process. As a result, multiprocessing may not always be the best choice for every situation.

To determine whether to use multithreading or multiprocessing, it's crucial to evaluate the specific requirements and characteristics of your application. If the task at hand is primarily CPU-bound and can benefit from true parallel execution, multiprocessing can be a suitable option. On the other hand, if the workload consists of I/O-bound operations or requires a high degree of coordination and shared state, multithreading might be more appropriate.

In summary, the multiprocessing module in Python offers a way to achieve true parallelism by leveraging multiple processor cores. While it circumvents the limitations of the GIL, it introduces additional overhead for inter-process communication, which may impact performance. Careful consideration of the specific requirements and trade-offs is necessary to determine the most suitable approach for your use case.

mariof.