Why is python so retarded? stop what you are doing right now and run this code

why is python so retarded? stop what you are doing right now and run this code.

import sys
if sys.argv != 3:
print("Args given: " + str(len(sys.argv)))

sys.argv is a list, of course it is going to be different than 3.

>import sys
if len(sys.argv) != 3:
print("Args given: " + str(len(sys.argv)))
is what you want

Lol its an argument vector, not an into
[Code]
Shits-given=None
[\code]

Op certified retarded

Use argparse codelet.
Sage into all fields.

GOD DAMNIT WHY DO SIMPLE THINGS THROW ME OFF SO EASILY MOMMY MAKE IT STOPPPPPPPPPP

well you just proved you don't know python or c

arg parse is the biggest piece of shit ever.

Why is that?

>Lol its an argument vector, not an into
What the fuck are you even trying to say here?

i never claimed to know C so... your point is?

Why are arguments even lists and not a union of dict and array?

all it is is a module that prints a help menu for arguments. you can easily do that yourself.

>why aren't command line arguments automatically organised in to an associative array
Because POSIX. What keys would you map onto the values anyway?

OP is retarded, confirmed

Probably bait but i answer anyway.
You wot m8?
Have you ever even used argparse?

OP how are you this retarded?

what's supposed to be wrong with it?
>inb4 OP

import sys

# Script / executable is part of argument vector, so take that one out
Nargs = len(sys.argv) - 1

if (Nargs != 3):
print("Args given: {:d}".format(Nargs))


Brainlet.

DELET THIS

could be environment variable

OP is just retarded. sys.argv and he's trying to compare it with 3.

So you are implying you know nothing about the subject matter to which you are referring then?

> "Why is python so retarded?"
> Comparing a list to a primitive type.

Wew, lad!

program.exe hello.txt -c=4 4chins --nope="herp derp"

should become

args = {
named:{
c:4,
nope:"herp derp"
},
list:[
"hello.txt",
"4chins"
]
}

>op has a problem with his homework
>he knows nobody will reply if he just asks for help
>makes a shitpost instead
>anons trip over themselves to help

That's just C man. GTFO.

This implies that you are using POSIX style longopt argument parsing.

program --a b


This could be interpreted as either
{'a': 'b'}


or
['-a', 'b']

Yes.

I do imply a lot of things.

Or even
{'a': True}, ['b']

There are modules that automatically parse this for you though. argparse for example.

>using sys.argv and not argparse

OP you are a brainlet, kys you retard

Even ignoring all the other issues, you'd be using a hash table just for fucking args.

I don't see a single hash there.

Wow that'd be a massive problem on a system with 4KB RAM maybe

>you'd be using a hash table just for fucking args
If that's a real problem on your hamster-powered calculating device, don't use python. (Probably a good idea anyway at that point. Pythons eat hamsters.)

Dicts and anything similar are just hash tables; how did you think they worked, magic?

And this is why most software nowadays sucks, since you can do horribly inefficient shit and not get punished due to ample hardware resources.

It's python, you're already using a hashtable for everything anyway

True. That's why I would not save the data permanently but only provide it in the main function. The programmer still has to check the arguments but at least the compiler/interpreter could parse them automatically, wouldn't you agree?

>parentheses around the conditional in if
What did they mean by this

No, what you're saying is retarded and I'm not even sure you understand what you just wrote. At any rate, it should be up to the programmer to choose how to handle their shit, it takes like 10 minutes to write your own function to parse args into a hash table if it bothers you so much, and then you can just reuse it in all your projects.

>comparing a list to an int
you are the one who is retarded my man.

I think it's more Pythonic to write:

import sys

if len(sys.argv[:-1]) != 3:
...


It's unclear whether OP wants to print out the number of arguments or the actual list of arguments.

Python haters BTFO

>He can't into code posting