Nerd Paradise
Username:   Password:   (Register)

Accepting command line arguments in python scripts

Post by Blake
Since it's not quite as obvious as it is in other languages like Java and C# where the main function always accepts a string array, I figured it was worth mentioning. And also a really cheap blog post:

import sys
args = sys.argv


That's all there is to it. The string array is stashed in .argv under the sys module.
Share on Facebook Tweet Submit to Stumble Upon Reddit
No Comments yet. You can be the first!
You must be logged in to post comments.
List all posts by Blake
Most recent posts by Blake
 
Users online: Cosman246
Your IP: 38.107.191.115
Current Time: 10 Cresco 6:3 - 16.19.97 ?
Blake O'Hare | asdfjkl; | Two Cans & String | Game Requests | GameLight