|
|
Subject: python optparse multiple arguments - msg#00005
List: org.user-groups.linux.linux-nepal
Hi,
I'm having some minor problems with optparse. I'm just worried that
someone shouldn't say that multiple argument feature isn't implemented
in optpartse.
How to tackle multiple arguments to an option ?
As far as I dug, I've found that >1 arguments are being ignored.
parser.add_option("", "--my-option", dest="my_option", action="store",
type="string")
Now if someone uses it as:
./foo --my-option a b c
I want somehow to store all the three arguments but my_option stores
only "a" while ignoring b and c.
Any help?
Ritesh
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Linux-Nepal" group.
To post to this group, send email to
Linux-Nepal-/JYPxA39Uh5TLH3MbocFFw@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
Linux-Nepal-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@xxxxxxxxxxxxxxxx
For more options, visit this group at http://groups.google.com/group/Linux-Nepal
Linux-Nepal - http://www.researchut.com/linux-nepal/
-~----------~----~----~----~------~----~------~--~---
Was this page helpful?
Thread at a glance:
Previous Message by Date:
click to view message preview
python ZipFile mode append misbehaving
Hi,
I've got a problem here.
def compress_the_file(zip_file_name, files_to_compress, sSourceDir):
"""
Condenses all the files into one single file for easy transfer
"""
try:
import zipfile
except ImportError:
sys.stderr.write("Aieeee! module not found.\n")
try:
os.chdir(sSourceDir)
except:
#TODO: Handle this exception
pass
filename = zipfile.ZipFile(zip_file_name, "a")
# try:
# filename = zipfile.ZipFile(zip_file_name, "a")
# except:
# #TODO Handle the exception
# sys.stderr.write("\nAieee! Some error exception in creating
zip file %s\n" % (zip_file_name))
# sys.exit(1)
filename.write(files_to_compress, files_to_compress,
zipfile.ZIP_DEFLATED)
filename.close()
The line
filename = zipfile.ZipFile(zip_file_name, "a")
throws an exception if the given filename is not present already.
Shouldn't it create a file (in case one is not there) since it is
"append" mode ??
Ritesh
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Linux-Nepal" group.
To post to this group, send email to
Linux-Nepal-/JYPxA39Uh5TLH3MbocFFw@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
Linux-Nepal-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@xxxxxxxxxxxxxxxx
For more options, visit this group at http://groups.google.com/group/Linux-Nepal
Linux-Nepal - http://www.researchut.com/linux-nepal/
-~----------~----~----~----~------~----~------~--~---
Next Message by Date:
click to view message preview
FIXED: python optparse multiple arguments
Ritesh Raj Sarraf wrote:
> Hi,
>
> I'm having some minor problems with optparse. I'm just worried that
> someone shouldn't say that multiple argument feature isn't implemented
> in optpartse.
>
>
> How to tackle multiple arguments to an option ?
> As far as I dug, I've found that >1 arguments are being ignored.
>
>
> parser.add_option("", "--my-option", dest="my_option", action="store",
> type="string")
>
>
> Now if someone uses it as:
> ./foo --my-option a b c
>
>
> I want somehow to store all the three arguments but my_option stores
> only "a" while ignoring b and c.
>
>
> Any help?
>
>
> Ritesh
I fixed it, I guess.
parser.add_option("", "--my-option", dest="my_option",
action="store_true")
sets my_option to True and the arguments are all stored in the list
"args". :-)
Ritesh
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Linux-Nepal" group.
To post to this group, send email to
Linux-Nepal-/JYPxA39Uh5TLH3MbocFFw@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
Linux-Nepal-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@xxxxxxxxxxxxxxxx
For more options, visit this group at http://groups.google.com/group/Linux-Nepal
Linux-Nepal - http://www.researchut.com/linux-nepal/
-~----------~----~----~----~------~----~------~--~---
Previous Message by Thread:
click to view message preview
python ZipFile mode append misbehaving
Hi,
I've got a problem here.
def compress_the_file(zip_file_name, files_to_compress, sSourceDir):
"""
Condenses all the files into one single file for easy transfer
"""
try:
import zipfile
except ImportError:
sys.stderr.write("Aieeee! module not found.\n")
try:
os.chdir(sSourceDir)
except:
#TODO: Handle this exception
pass
filename = zipfile.ZipFile(zip_file_name, "a")
# try:
# filename = zipfile.ZipFile(zip_file_name, "a")
# except:
# #TODO Handle the exception
# sys.stderr.write("\nAieee! Some error exception in creating
zip file %s\n" % (zip_file_name))
# sys.exit(1)
filename.write(files_to_compress, files_to_compress,
zipfile.ZIP_DEFLATED)
filename.close()
The line
filename = zipfile.ZipFile(zip_file_name, "a")
throws an exception if the given filename is not present already.
Shouldn't it create a file (in case one is not there) since it is
"append" mode ??
Ritesh
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Linux-Nepal" group.
To post to this group, send email to
Linux-Nepal-/JYPxA39Uh5TLH3MbocFFw@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
Linux-Nepal-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@xxxxxxxxxxxxxxxx
For more options, visit this group at http://groups.google.com/group/Linux-Nepal
Linux-Nepal - http://www.researchut.com/linux-nepal/
-~----------~----~----~----~------~----~------~--~---
Next Message by Thread:
click to view message preview
FIXED: python optparse multiple arguments
Ritesh Raj Sarraf wrote:
> Hi,
>
> I'm having some minor problems with optparse. I'm just worried that
> someone shouldn't say that multiple argument feature isn't implemented
> in optpartse.
>
>
> How to tackle multiple arguments to an option ?
> As far as I dug, I've found that >1 arguments are being ignored.
>
>
> parser.add_option("", "--my-option", dest="my_option", action="store",
> type="string")
>
>
> Now if someone uses it as:
> ./foo --my-option a b c
>
>
> I want somehow to store all the three arguments but my_option stores
> only "a" while ignoring b and c.
>
>
> Any help?
>
>
> Ritesh
I fixed it, I guess.
parser.add_option("", "--my-option", dest="my_option",
action="store_true")
sets my_option to True and the arguments are all stored in the list
"args". :-)
Ritesh
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Linux-Nepal" group.
To post to this group, send email to
Linux-Nepal-/JYPxA39Uh5TLH3MbocFFw@xxxxxxxxxxxxxxxx
To unsubscribe from this group, send email to
Linux-Nepal-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@xxxxxxxxxxxxxxxx
For more options, visit this group at http://groups.google.com/group/Linux-Nepal
Linux-Nepal - http://www.researchut.com/linux-nepal/
-~----------~----~----~----~------~----~------~--~---
|
|