-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from sys import argv | ||
from os.path import exists | ||
|
||
script, from_file, to_file = argv | ||
|
||
print "Copying from %s to %s" % (from_file, to_file) | ||
|
||
# we could do these two on one line too, how? | ||
input = open(from_file) | ||
indata = input.read() | ||
|
||
print "The input file is %d bytes long" % len(indata) | ||
|
||
print "Does the output file exist? %r" % exists(to_file) | ||
print "Ready, hit RETURN to continue, CTRL-C to abort." | ||
raw_input() | ||
|
||
output = open(to_file, 'w') | ||
output.write(indata) | ||
|
||
print "Alright, all done." | ||
|
||
output.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# this one is like your scriptss with argv | ||
|
||
def print_two(*args): | ||
arg1, arg2 = args | ||
print "arg1: %r, arg2: %r" % (arg1, arg2) | ||
|
||
# of, that *args is actually pointless, we can just do this | ||
def print_two_again(arg1, arg2): | ||
print "arg1: %r, arg2: %r" % (arg1, arg2) | ||
|
||
# this just takes one argument | ||
def print_one(arg1): | ||
print "arg1: %r" % arg1 | ||
|
||
# this one takes no arguments | ||
def print_none(): | ||
print "I got nothin'." | ||
|
||
|
||
print_two("Zed","Shaw") | ||
print_two_again("Zed","Shaw") | ||
print_one("First!") | ||
print_none() |