[BioPython] Cookbook:RenameFasta
Michiel De Hoon
mdehoon at c2b2.columbia.edu
Fri Nov 2 00:22:18 UTC 2007
> If I revert back to the old code for this line, ie. replace
> ' filename, basename = sys.argv'
> with
> 'filename = sys.argv[1] '
> 'basename = sys.argv[2]'
>
> it works fine.
There is also a sys.argv[0]. So sys.argv is a list with (at least) three
elements.
If you do 'filename, basename = sys.argv', you have two variables on the
left-hand-side and three on the right-hand-side. Instead, you could do
temp, filename, basename = sys.argv # And ignore temp subsequently
or
filename, basename = sys.argv[1:]
--Michiel.
Michiel de Hoon
Center for Computational Biology and Bioinformatics
Columbia University
1150 St Nicholas Avenue
New York, NY 10032
-----Original Message-----
From: biopython-bounces at lists.open-bio.org on behalf of Mike Dyall-Smith
Sent: Thu 11/1/2007 5:52 PM
To: biopython at lists.open-bio.org
Subject: [BioPython] Cookbook:RenameFasta
Njm revised the code of Humberto at:
http://bio.scipy.org/wiki/index.php/RenameFastaSequences
to make it more idiomatic Python. I altered my discussion according
to the new code. However, when I tested it on a fasta file I get an
error:
File "REnameFasta2.py", line 6, in <module>
filename, basename = sys.argv
ValueError: too many values to unpack
If I revert back to the old code for this line, ie. replace
' filename, basename = sys.argv'
with
'filename = sys.argv[1] '
'basename = sys.argv[2]'
it works fine. I assume there is some subtle error in assigning two
names to sys.argv
Regards, Mike D-S
_______________________________________________
BioPython mailing list - BioPython at lists.open-bio.org
http://lists.open-bio.org/mailman/listinfo/biopython
More information about the Biopython
mailing list