Advertisement
namchef

LPTHW_ex13

Sep 27th, 2011
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. from sys import argv
  2. print "arguments: ", argv
  3. script, first, second, third=argv
  4.  
  5. print "The script is called: ", script
  6. print "The first variable is: ", first
  7. print "The second variable is: ", second
  8. print "Your third variable is: ", third
  9.  
  10.  
  11. ##Windows PYthon SHELL
  12. ##>>> import sys
  13. ##>>> sys.argv=['','alpha','beta','gama']
  14. ##>>> execfile('ex13.py')
  15.  
  16.  
  17.  
  18.  
  19.  
  20. ##Combine raw_input with argv to make a script that gets more input from a user.
  21.  
  22.  
  23. from sys import argv
  24. script, arg1, arg2=argv
  25.  
  26. for i in range(1,int(arg1)):
  27.     print('All work and no play')
  28.  
  29. for j in range(1,int(arg2)):
  30.     print('Makes Jack a dull boy')
  31.  
  32.  
  33.  
  34.  
  35. ##Windows PYthon SHELL
  36. ##>>> import sys
  37. ##>>> sys.argv=['','2','5']
  38. ##>>> execfile('ex13_p3.py')
  39.  
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement