why o/p is different ???

James Mills prologic at shortcircuit.net.au
Thu Jan 15 07:47:25 CET 2009


On Thu, Jan 15, 2009 at 4:34 PM, asit <lipun4u at gmail.com> wrote:
> I recently faced a peculiar o/p.
>
> My objective is to remove the command name(my script name) from
> sys.argv[0].
> I coded like this

If you _really_ want to remove your script_name from
sys.argv, then do this:

del sys.argv[0]

If you're just after what the name of your script is
that's being run (for human readability) try the
following function (taken from pymills):

def getProgName():
   """getProgName() -> str

   Return the name of the current program being run
   by working it out from the script's basename.
   """

   return os.path.basename(sys.argv[0])

--------------------------------------------------

cheers
James



More information about the Python-list mailing list