Re: [Tutor] What are all those letters after terminal commands?

2012-08-23 Thread Alan Gauld

On 23/08/12 22:14, William R. Wing (Bill Wing) wrote:


While all that is true, I'm pretty sure she is going to need enough knowledge

> of the simplest -NIX commands to

edit .py files,

> rename them occasionally,

organize them into appropriate directories

> and occasionally change a permission or two

But all of that can be done via the MacOS Finder and for
most casual Python programmers on a MAC that's all they need.


I agree that she may never need to do shell programming

> (OS-X uses bash), but knowing the basics WILL be needed.

The basics can all be done via the GUI. Knowing the shell alternatives 
will likely make her more productive but won't be essential. Whether the 
extra productivity merits the time invested in learning will

be a matter of circumstance.

As somebody once said "GUIs make easy things trivial and hard things 
impossible"


But most scientific Python programming doesn't require any "hard 
things", at least, not in terms of OS manipulation.


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What are all those letters after terminal commands?

2012-08-23 Thread William R. Wing (Bill Wing)
On Aug 23, 2012, at 12:59 PM, Steven D'Aprano  wrote:

> On 23/08/12 23:18, Cecilia Chavana-Bryant wrote:
> [...]
>> I found this command:
>> mkdir -p i/like/icecream. I am guessing that the -p stands for directory
>> path?
> 
> Ha, that's the trouble with command line interfaces -- they tend to end up
> being cryptic and painfully terse. In this case, -p actually stands for
> "parents", in the sense that mkdir is trying to create the folder "icecream"
> inside the parent folder "like", inside the grandparent folder "i". If any
> of the parent folders are missing, the -p option says to create the missing
> folders.
> 
> I don't want to put you off learning about the command line, because
> knowledge is good. I've never learned something and then thought "I wish
> I was more ignorant". But honestly, you don't need to be a command line
> expert to make use of Python's interactive interpreter. To get started,
> all you need is one command:
> 
> python
> 
> 
> and then press the ENTER key. That brings up Python's interactive
> interpreter, which uses Python syntax rather than the shell's rather
> cryptic commands and options.
> 

While all that is true, I'm pretty sure she is going to need enough knowledge 
of the simplest -NIX commands to edit .py files, rename them occasionally, 
organize them into appropriate directories ('/working', '/development', and 
'/archive' as possible examples), and occasionally change a permission or two 
(-x for example).  Ultimately, she will need to be able to examine her .profile 
(remember, she is running OS-X) file and possibly edit it.  Finally, there are 
at least a few things that can be done most expeditiously, even in python, by 
spawning a python subtask and running a UNIX command there.

I agree that she may never need to do shell programming (OS-X uses bash), but 
knowing the basics WILL be needed.

-Bill

> (Of course, the python command also takes a bunch of optional, and
> useful. command switches, but you can learn them as you go.)
> 
> By all means continue with the command line book if you are getting
> something useful out of it, but don't think you *have* to learn the
> shell in order to use Python. The two are independent.
> 
> 



> 
> -- 
> Steven
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What are all those letters after terminal commands?

2012-08-23 Thread Steven D'Aprano

On 23/08/12 23:18, Cecilia Chavana-Bryant wrote:
[...]

I found this command:
mkdir -p i/like/icecream. I am guessing that the -p stands for directory
path?


Ha, that's the trouble with command line interfaces -- they tend to end up
being cryptic and painfully terse. In this case, -p actually stands for
"parents", in the sense that mkdir is trying to create the folder "icecream"
inside the parent folder "like", inside the grandparent folder "i". If any
of the parent folders are missing, the -p option says to create the missing
folders.

I don't want to put you off learning about the command line, because
knowledge is good. I've never learned something and then thought "I wish
I was more ignorant". But honestly, you don't need to be a command line
expert to make use of Python's interactive interpreter. To get started,
all you need is one command:

python


and then press the ENTER key. That brings up Python's interactive
interpreter, which uses Python syntax rather than the shell's rather
cryptic commands and options.

(Of course, the python command also takes a bunch of optional, and
useful. command switches, but you can learn them as you go.)

By all means continue with the command line book if you are getting
something useful out of it, but don't think you *have* to learn the
shell in order to use Python. The two are independent.



--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What are all those letters after terminal commands?

2012-08-23 Thread William Ray Wing
On Aug 23, 2012, at 9:18 AM, Cecilia Chavana-Bryant  
wrote:

> Hola,
> 
> I'm going through the 'Command line crash course' by Zed Shaw, thanks to the 
> people that recommended this book, its quite a good course, I can see what 
> the author was going for with the title but if it wasn't for your 
> recommendations, it would have put me off. At the beginning of Chapter 8 - 
> Moving around (pushd, popd) on Source: 13 exercise 8 I found this command: 
> mkdir -p i/like/icecream. I am guessing that the -p stands for directory 
> path? I have seen other such letters sometimes with or without the ' - ' 
> before them (I think) in commands so my question is, what are these letters 
> for? what are they called? and could someone please point me to where I can 
> find a list of these with descriptions of what they do. I have tried googling 
> with no positive results as I don't  know what they are called or I get just 
> the information for the command they are used with.
> 
> Many thanks in advance for the help, Cecilia
> ___
> 
Those letters are options (sometimes called switches) and they modify the 
action of the command. Thus "$ ls" gives you a very terse list of the files in 
a directory.  $ ls -a gives you a list of all the files, including invisible 
ones.  $ ls -l gives you a long list that includes size, date, and protections. 
 And $ ls -al does both. If you open a terminal session and enter $ man 
ls, you will get the "man page" for the ls command that will document 
these and several others. 

Don't worry you're doing great..
Bill
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What are all those letters after terminal commands?

2012-08-23 Thread Peter Otten
Cecilia Chavana-Bryant wrote:

> Hola,
> 
> I'm going through the 'Command line crash course' by Zed Shaw, thanks to
> the people that recommended this book, its quite a good course, I can see
> what the author was going for with the title but if it wasn't for your
> recommendations, it would have put me off. At the beginning of Chapter 8 -
> Moving around (pushd, popd) on Source: 13 exercise 8 I found this command:
> mkdir -p i/like/icecream. I am guessing that the -p stands for directory
> path? 

Arguments like -p or --parents are options that change the behaviour of a 
command or allow you to pass optional arguments to it.

$ mkdir i/like/icecream

will fail unless the directories i and i/like already exist. The leaf 
directory i/like/icecream must not yet exist.

If the -p option is provided

$ mkdir -p i/like/icecream 

will silently create all intermediate (or "parent", hence the abbreviation) 
directories and not complain if a directory i/like/icream already exists. 
You can see

$ mkdir -p i/like/icecream

as a shortcut for

$ mkdir i
$ mkdir i/like
$ mkdir i/like/icecream

> I have seen other such letters sometimes with or without the ' - '
> before them (I think) in commands so my question is, what are these
> letters for? what are they called? and could someone please point me to
> where I can find a list of these with descriptions of what they do. I have
> tried
> googling with no positive results as I don't  know what they are called or
> I get just the information for the command they are used with.

For every shell command there is a "manpage" that describes what the command 
does and what options it will accept. You can display the manpage for mkdir 
with

$ man mkdir

> Many thanks in advance for the help, Cecilia

Well, here is the place for basic help, but it should normally be about 
Python...

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What are all those letters after terminal commands?

2012-08-23 Thread David Rock
* Cecilia Chavana-Bryant  [2012-08-23 14:18]:
> mkdir -p i/like/icecream. I am guessing that the -p stands for directory
> path? I have seen other such letters sometimes with or without the ' - '
> before them (I think) in commands so my question is, what are these letters
> for? what are they called? and could someone please point me to where I can

They are called commandline options.  Most programs allow you to use
options to change the behavior of the program "on the fly."  In this
particular case, mkdir creates a directory, while mkdir -p means "make
the directory and any parent directories that do not already exist.  For
example:

If i/like/icecream does not exist, we try to create it with mkdir:
  mkdir i/like/icecream

The result will be an error if i or i/like does not exist yet:
  mkdir: i/like: No such file or directory

So we use -p, to also create the parent directories:
  mkdir -p i/like/icecream

To learn about options that are available for a given command, try using
the "man" command like so:
  man mkdir

It will give you a list of options, what they do, and how to use them.

In general, there are two things you can use on a commandline, options
and arguments.  Options are the switches that change the program's
behavior and arguments are the inputs to the program (filenames, etc).

-- 
David Rock
da...@graniteweb.com
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What are all those letters after terminal commands?

2012-08-23 Thread Walter Prins
Hi Cecilia,

On 23 August 2012 14:18, Cecilia Chavana-Bryant
 wrote:
> recommendations, it would have put me off. At the beginning of Chapter 8 -
> Moving around (pushd, popd) on Source: 13 exercise 8 I found this command:
> mkdir -p i/like/icecream. I am guessing that the -p stands for directory
> path? I have seen other such letters sometimes with or without the ' - '
> before them (I think) in commands so my question is, what are these letters
> for? what are they called? and could someone please point me to where I can
> find a list of these with descriptions of what they do.

These are variously called command "switches" or "options", thus named
because they switch certain behaviours on and off or specify optional
information to the command.  On *nix like systems, you can usually
find full and comprehensive documentation on any command using the
"man" (for manual) or "info" (in lieu of information) commands.  For
example, try:

man mkdir

In "mkdir"'s case, the default behaviour/convention is for mkdir's
parameter to specify the single folder name to be created in the
current working folder.  The "-p" switch modifies this behaviour so
that the parameter is instead interpreted to be a full path that may
include several folders, and the behaviour is modified such that mkdir
then will, as needed, created all the folders along the entire path
specified.

HTH,

Walter
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor