You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The argparse module is a bit heavy handed for most purposes. In most cases, it is faster and easier to use sys.argv. Surprisingly, it was a little hard to find good, simple examples of sys.argv on a site that isn't riddled with popups, but I think this site should do. sys.argv is simply a list of arguments given to a python program, with the name of the program at index 0.
This comprehensive python cheatsheet should be included in the resources. Between this cheatsheet, google, and practice practice practice, you have the recipe for a good time learning python. For a less terse, more example-driven reference, I like learnXinYminutes
The awk tutorial in the references is not very learner friendly for several reasons. It would be good to establish the usual awk 'condition {action}; another condition {another action}' file structure and then talk about possible conditions and actions in increasing complexity using examples. There are some ok tutorials out there, like this one, although this one makes a huge oversight in not mentioning regular expressions and piping into other commands like sort or uniq. Basically, I think it's worth fleshing out awk a bit.
First with regex, like printing out field 3 of lines matching a regex:
awk '/^A[bc]+/ {print "The third field of this matching line is ",$3}' file.txt
Then get into examples of the built in variables NR,FNR,NF,FS,OFS to do things like averages.
Then maybe get into BEGIN{} END{}, variables and associative arrays (using BEGIN rather than -v).
Then some basic flow control.
Then show the possibilities of piping into sort -rn, uniq -c, etc.
All of this, of course, driven by examples. I think that would give a strong enough foundation to tackle to parsing exercises.
The text was updated successfully, but these errors were encountered:
In chapter 2, I have a couple of notes:
sys.argv
. Surprisingly, it was a little hard to find good, simple examples ofsys.argv
on a site that isn't riddled with popups, but I think this site should do.sys.argv
is simply a list of arguments given to a python program, with the name of the program at index 0.Notes for chapter 3:
The awk tutorial in the references is not very learner friendly for several reasons. It would be good to establish the usual
awk '
condition
{
action
};
another condition
{
another action
}' file
structure and then talk about possible conditions and actions in increasing complexity using examples. There are some ok tutorials out there, like this one, although this one makes a huge oversight in not mentioning regular expressions and piping into other commands likesort
oruniq
. Basically, I think it's worth fleshing out awk a bit.NR,FNR,NF,FS,OFS
to do things like averages.BEGIN{} END{}
, variables and associative arrays (usingBEGIN
rather than-v
).sort -rn
,uniq -c
, etc.The text was updated successfully, but these errors were encountered: