Argparse for CLI - Intermediate Python Programming p.3

preview_player
Показать описание
Welcome to part 3 of the intermediate Python programming tutorial series. In this part, we're going to talk about the standard library called argparse. Argparse is a parser for command-line options, arguments, and sub-commands.

In the basics series, we actually just used the sys library, which can also work, but isn't quite as extensive.

Рекомендации по теме
Комментарии
Автор

Loving this intermediate series so far. I've been using python for a couple of years now and I've learnt so many things from different places which has lead to a lot of gaps in my skills. I'd never heard of argparse before so this is going to be a huge help. Keep up the great work!

Box-of-hats
Автор

LoL every time you say pep 8 I hear pepe and frog people go through my head.

dagda
Автор

Great video, would love a follow up about required and optional arguments

johnnysim
Автор

when you do `operation = args.operation` you are not copying the variable but just giving it another label. In fact it can be smart to do this, for example when the body of your function is a loop doing this can make the lookups faster. You would however be copying the variable if you were to alter it like `operation = args.operation.lower()` because strings are immutable python would then create a new string and since the old string still has a reference (args.operation) this would mean having two strings in memory.

JustinTermaat
Автор

Hi, just little note. You probably should leave calc function as it was before. You just made calc function aware of args, it would be clearer if you wrap it with some another function. So than calc fn is reusable. I know this is only a showcase, but it is also called intermediate so I think it is a valid point.
Looking forward for next episode, like this series so far. Good job!

Somin
Автор

Thank you for your videos. I learn a lot watching them and practicing with your examples.

Amirely
Автор

What is the benefit of using arg parse instead of simply "input()"?

neelm
Автор

Thank you
Thank you
Thank you
Thank you
THANK YOU

itsyaboichipsahoy
Автор

Thank you very much, even though I watch it now, I can still learn a lot from this series

rotrose
Автор

Please what does it mean to parse an argument?

thevictoriaabia
Автор

--x works, - x works, but x doesn't. why is that ? Is that double minus something significant ? What is it called ?

turboromy
Автор

hey sentdex, I followed the code but not getting anything printed out in cmd whatsoever. What do you think the problem is? Thank you

larrydu
Автор

Could you perhaps elaborate on why you said sometimes "print" won't work and you'll have to use "system out" instead?

ahmed
Автор

sir, in my shell screen there is an error showing cannot assign to operator what does that mean. And also why we put args. in front of everything thing in the calc func.

prathamtaneja
Автор

At 5:35, could we just call 'calc' on 'args.x, args.y, args.operation', instead of changing the function interface? Or am I missing something?

_adaldo
Автор

I'm still confused as to what this line is doing:
if __name__ == '__main__':
main()

MrBigmit
Автор

Awesome. Are you doing 1 video a day in this series?

ahmed
Автор

so what's the difference between Argparse and sys.argv?

iPerfection
Автор

can you suggest really good intermediate Python book?

mm
Автор

Please why are there two hyphens in front of the argument we want to parse.

That is why is it --x, --y, --operator instead of x, y, operator?

thevictoriaabia