Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

method for arg parsing #11

Closed
jedelman8 opened this issue Apr 1, 2014 · 5 comments
Closed

method for arg parsing #11

jedelman8 opened this issue Apr 1, 2014 · 5 comments

Comments

@jedelman8
Copy link
Owner

Yandy,
I started the work to create a method for arg parsing as mentioned earlier. Now you can see what I mean. The method is only used when running it as a program. Feel free to finish it....if not, I'll try to later in the week too... :)

@yandy-r
Copy link
Contributor

yandy-r commented Apr 1, 2014

I just finished submitting a pull-request seconds before getting this, looks similar, let me know what you think.

@yandy-r
Copy link
Contributor

yandy-r commented Apr 1, 2014

also, the parser is not an iterable item

@jedelman8
Copy link
Owner Author

Sys.argv is, no?

On Apr 1, 2014, at 5:40 PM, Yandy Ramirez notifications@github.com wrote:

also, the parser is not an iterable item


Reply to this email directly or view it on GitHub.

@yandy-r
Copy link
Contributor

yandy-r commented Apr 1, 2014

argparse library and sys.argv are way different.

argparse is meant to simplify command-line handling, not positional and can be required or optional.

if we use sys.argv, that's essentially a list of strings, so we're getting into manipulation of strings to find the place where -i is, where -m is and so forth.

something like

if sys.argv[1] == '-i' or sys.argv[1] == --ip_address:
 self.address = sys.argv[2] 
# 2 because 1 would be the position and 2 where the actual value you want would be, 
# but that's hoping.

and you can see the chaining of if statements that would require, even if we put it in a for loop, it's not efficient, how many times do we need to iterate to find the actual values?

hence why I structured it the way I did.

@jedelman8
Copy link
Owner Author

Yup. I knew they were different, just not sure how. Have heard very good things about argpasrse though!

Will take a look later. Thanks.

On Apr 1, 2014, at 6:10 PM, Yandy Ramirez notifications@github.com wrote:

argparse library and sys.argv are way different.

argparse is meant to simplify command-line handling, not positional and can be required or optional.

if we use sys.argv, that's essentially a list of strings, so we're getting into manipulation of strings to find the place where -i is, where -m is and so forth.

something like

if sys.argv[1] == '-i' or sys.argv[1] == --ip_address:
self.address = sys.argv[2]

2 because 1 would be the position and 2 where the actual value you want would be,

but that's hoping.

and you can see the chaining of if statements that would require, even if we put it in a for loop, it's not efficient, how many times do we need to iterate to find the actual values?

hence why I structured it the way I did.


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants