[Tutor] Re: OT: Re: Re: accepting wild chars from pythons command line

Derrick 'dman' Hudson dman@dman.ddts.net
Wed Oct 23 13:17:01 2002


--ikeVEW9yuYc//A+q
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Oct 22, 2002 at 12:54:46PM +0200, Magnus Lycka wrote:
| At 23:34 2002-10-21 -0400, Derrick 'dman' Hudson wrote:
| >Actually, python will never see the '*' character.  The /shell/
| >expands it first.  Depending on your system and environment, that
| >shell is often one of  bash, ash, csh, tcsh, ksh, zsh, command.com or
| >cmd.exe.  The beauty of shell metacharacters is that the shell handles
| >their expansion and your program can't tell the difference.
|=20
| It seems you don't use Windows...you lucky bastard! ;)

I avoid it when at all possible.  When it isn't possible, I either
don't do real work, grab putty and use my own machine (remotely), or
install cygwin and use bash exclusively.

| Neither cmd.exe not command.com will do anything with
| * or other wildcard characters.

Oh.  I guess every DOS program I've run from cmd.exe or command.com
did the expansion itself and I never knew the difference.  Then I
learned UNIX and have used a *nix shell ever since (I started
programing, on UNIX, around the time I learned it).

| That's why you could write
|=20
| copy *.txt *.bak
|=20
| in DOS to create backup versions for all your text
| files. In the days when most people knew DOS, this
| was often a confusing problem for Unix newbies...

Oh, I see.  mcp(1)

(Actually I don't do that very often and am not familiar with the
command.  I use CVS or a tarball for backups.)



To the OP :

Either you can code the expansion yourself (the glob module should
help) or you can use a decent shell.  Go to cygwin.com and install at
least 'bash', then use it instead of cmd.exe or command.com to run
your scripts from.  An advantage of letting the shell perform wildcard
expansion is it simplifies your programs, and it also allows you to do
something like this :
    ./my_script.py `find . -t d -print`
(the arguments to the script will be a list of the absolute path to
all directories under the current directory)

-D

--=20
How great is the love the Father has lavished on us,
that we should be called children of God!
        1 John 3:1
=20
http://dman.ddts.net/~dman/

--ikeVEW9yuYc//A+q
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAj223ckACgkQO8l8XBKTpRSYGACfdJQWRC+F8C8mACrRVE5E45Xx
0QoAn0kmeWRx4cj4mbvxOtLLQaUkd01Y
=/zfW
-----END PGP SIGNATURE-----

--ikeVEW9yuYc//A+q--