Тёмный
James Clare
James Clare
James Clare
Подписаться
My name is James and I work as a software engineer in the UK. I do coding videos, released every Friday.
-----------------
Looking to learn Python?

- I run a Udemy course with 16+ hours of video, 32+ coding assignments, 20 quizzes, and 5 projects which can be included in your first portfolio. This is updated monthly with a new job interview style question!

- I also run a functional Python course which focuses on using List, Set, Dict and generator comprehensions. It's full of exercises, quizzes and is updated monthly with a challenging question.


How to Spot Burnout as a Programmer
9:26
Месяц назад
Can you actually Master Python?
12:14
2 месяца назад
Imposter Syndrome in Programming
12:30
4 месяца назад
Atomic Habits For Coding Productivity
17:46
4 месяца назад
Avoiding Coding Burnout with Slow Productivity
11:19
5 месяцев назад
5 Crucial Habits for Python Success
18:17
5 месяцев назад
Ruff is a Game Changer for your Python Code!
15:10
6 месяцев назад
Python 3 - The Quirky Starmap Function
13:48
6 месяцев назад
Комментарии
@MultiSteve1978
@MultiSteve1978 12 часов назад
This is really terrible … a class is only a dictionary and mutable by default … 😮
@pythonwithjames
@pythonwithjames 10 часов назад
__slots__ aren't commonly used, but I do believe they have their moment for specific use cases!
@bloom945
@bloom945 19 часов назад
Neat! I suppose you could calculate a prefix-sum by accumulating with addition? If so, that's very handy because I am getting tired of doing it manually every time
@pythonwithjames
@pythonwithjames 10 часов назад
Yes that's true! Glad you found this useful :)
@mattayres9748
@mattayres9748 6 дней назад
Understood
@pythonwithjames
@pythonwithjames 6 дней назад
Good to hear!
@nicolasguardo3962
@nicolasguardo3962 7 дней назад
Hi James, hope you are doing fine and nice video! I followed the steps of creating the virtual environment (in my case I used the command "python -m venv <envname>"), installing poetry, creating the project (poetry new <name>) and adding the dependencies to the .toml file but I'm having a little issue. When I create the main.py file and try to import fastapi, apparently it is not install within the virtual env. Should I do something else? I'm running it on Windows, I suppose there should not be a problem right? Thanks and look forward to hearing from you.
@Germisstucklmao
@Germisstucklmao 7 дней назад
So it's a shorthand while loop with break in it? Ngl I feel like that makes it unnecessary, especially with the lambda (and I like lambda calculus)
@pythonwithjames
@pythonwithjames 7 дней назад
Hello, you’re right yes, it can be seen as a while loop with an automatic breaking mechanism. You could achieve this with a normal loop but I quite enjoy these neat one liner functions :)
@murphygreen8484
@murphygreen8484 10 дней назад
Oh! Wished I had seen the contest. I definitely would have submitted a solution!
@pythonwithjames
@pythonwithjames 10 дней назад
I'll have the September one out this week :)
@murphygreen8484
@murphygreen8484 10 дней назад
@@pythonwithjames thanks! I'm subbed to your IG now. Subbed? Followed? Gram'd? I'm old... lol
@AbhishivSaxena-e4z
@AbhishivSaxena-e4z 11 дней назад
great! Didn't knew python was so cool.
@pythonwithjames
@pythonwithjames 10 дней назад
Glad you liked it!
@narendraaureddula4639
@narendraaureddula4639 16 дней назад
Please provide code github link
@dmbrv
@dmbrv 28 дней назад
great video
@pythonwithjames
@pythonwithjames 28 дней назад
thank you :)
@LeoTheGermanRottweiler
@LeoTheGermanRottweiler 29 дней назад
Great video
@pythonwithjames
@pythonwithjames 29 дней назад
Glad you enjoyed it
@LeoTheGermanRottweiler
@LeoTheGermanRottweiler Месяц назад
Hello, how are you?
@pythonwithjames
@pythonwithjames 29 дней назад
Alright Mr Leo!
@vimdiesel
@vimdiesel Месяц назад
Doesn't using lambda over list comprehension have perf costs?
@pythonwithjames
@pythonwithjames Месяц назад
It depends on how the lambda is used. In a list comprehension everything is computed at once and stored in memory. If we use map/lambda then we get an iterator, so it means that items are only computed when they are 'asked' for, such as using the next() function on the iterator.
@Carberra
@Carberra Месяц назад
I was one of the people who voted "Don't know" on the poll, and now watching this, I genuinely think I'd vote "No" if i were to vote again. I consider myself a perfectionist, but I honestly can't say I've experienced those symptoms. Sounds like an outlier in that 😅
@pythonwithjames
@pythonwithjames Месяц назад
Very interesting! I’ve heard that from a few people actually, I guess some people just don’t ever really experience it which is pretty cool :)
@Sproute-RL
@Sproute-RL Месяц назад
oo thats quite useful
@pythonwithjames
@pythonwithjames Месяц назад
thank you!
@SERGEX42069
@SERGEX42069 Месяц назад
My boss absolutely hates the slow productivity approach. He would rather us work ourselves into a coma.
@pythonwithjames
@pythonwithjames Месяц назад
Do you work in Agile, or something else?
@murphygreen8484
@murphygreen8484 Месяц назад
How would you annotate the lambda?
@pythonwithjames
@pythonwithjames Месяц назад
It can be done yes, but it's a touch unsightly! from typing import Callable add: Callable[[int, int], int] = lambda x, y: x + y
@murphygreen8484
@murphygreen8484 Месяц назад
@@pythonwithjames thanks!
@fishcurrency
@fishcurrency Месяц назад
Rightyo, James
@garazaadsf6921
@garazaadsf6921 Месяц назад
numpy
@zxastaxz1548
@zxastaxz1548 Месяц назад
good video thank you :)
@pythonwithjames
@pythonwithjames Месяц назад
No problem, glad you enjoyed it!
@claycreate
@claycreate Месяц назад
How is this better than [name for name in names if name.istitle()]
@pythonwithjames
@pythonwithjames Месяц назад
It's quite similar! But doing it as a list comprehension means the everything is computed at once. Using filter allows us to only compute the items as needed, and we can use the next() function to retrieve the filtered items one by one.
@nicolasguardo3962
@nicolasguardo3962 Месяц назад
Hi! Hope you are doing well! I understand you can use context manager not only for handling files, but for example, connecting to a database and automatically close the connection when you are done. I have also seen some cases where you instantiate a class with context managers, what is the purpose here? Thank you.
@pythonwithjames
@pythonwithjames Месяц назад
If you wanted to use a context manager with a custom class.. I would suggest that this is done with classes that specifically operate on files, database connections etc.. This is not super common however, as we do generally have tools that can operate on files/database connections for us :) I wanted to show the example class in the video to give a deeper understanding as to how the __enter__ & __exit__ methods are called :)
@Carberra
@Carberra Месяц назад
One good use for this is API clients, especially asynchronous ones which need to close any async sessions and event loops and such. Otherwise it can just a nice syntax honestly.
@krzysiekkrzysiek9059
@krzysiekkrzysiek9059 Месяц назад
Why don't you use `self` (self.end_time) in __exit__ method despite it's the part of the given class and you use one instance of that class?
@pythonwithjames
@pythonwithjames Месяц назад
Hello :) So I chose to keep end_time a local variable to the __exit__ method because I’m only using it in the scope of that method. although, there would be no harm in making it an instance attribute!
@Carberra
@Carberra Месяц назад
Awesome, I didn't know about any of these!
@pythonwithjames
@pythonwithjames Месяц назад
Glad you like them!
@Carberra
@Carberra Месяц назад
Wow that xor solution is amazing! I always forget these unary operations exist and probably would've gravitated towards either the first or third solutions myself. Nice one!
@pythonwithjames
@pythonwithjames Месяц назад
the XOR is neat isn't it. Always really nice when a problem like this can be solved in a simple one-liner, elegant haha!
@Carberra
@Carberra Месяц назад
Nice video my guy! Now having seen how Tox works, looks like the main difference between it and Nox is that the latter is all set up in Python. Much of the rest of the functionality looks to be very similar though.
@pythonwithjames
@pythonwithjames Месяц назад
Thanks mate! Ooh thats interesting, I'll have to check out Nox, it sounds pretty good.
@jakepatel1610
@jakepatel1610 Месяц назад
MANNN GREAT VIDEO!!!🎉learnt so much waiting for the next one! keep up the good work dude..
@pythonwithjames
@pythonwithjames Месяц назад
Hi Jake, thanks for that, much appreciated!
@douglaspiresmartins2955
@douglaspiresmartins2955 Месяц назад
Excellent content James. Do you prefer Ruff or Black?
@pythonwithjames
@pythonwithjames Месяц назад
Thanks! I personally prefer Ruff
@douglaspiresmartins2955
@douglaspiresmartins2955 Месяц назад
@@pythonwithjames I just saw your video about Ruff, and a had a look at the documentation, it’s amazing how useful the library is. Usually in my projects, I use black and isort, I’ll start using ruff from now on.
@pythonwithjames
@pythonwithjames Месяц назад
Ruff is wonderful, I was using a combination of linters up until I saw Ruff. It's definitely the way forward for me.
@dmbrv
@dmbrv Месяц назад
great video
@pythonwithjames
@pythonwithjames Месяц назад
Glad you enjoyed it!
@murphygreen8484
@murphygreen8484 2 месяца назад
Would the function not return the full name if it didn't have the decorator?
@pythonwithjames
@pythonwithjames 2 месяца назад
So if it didn't have the decorator it would be a regular method. So it would be called like: instance.method() Which might be acceptable for some use cases, but I think it's generally better to reserve methods for 'actions' a class can do (think of the list.append() & list.extend() methods). A property acts more like an attribute. Hope I've cleared it up :)
@murphygreen8484
@murphygreen8484 2 месяца назад
@@pythonwithjames It did, thanks!
@pythonwithjames
@pythonwithjames 2 месяца назад
Great :)