What is wrong with my code?
Dave Angel
d at davea.name
Mon Oct 24 08:18:28 EDT 2011
(Don't top-post. Put your response after the part you're quoting from
earlier messages. And include enough that somebody can help with
minimal effort.)
On 10/24/2011 12:30 AM, apometron wrote:
> The problem is that it is not reporting any error.
>
> The do something and quits silently.
>
> No rename action is done and no error.
>
> Running Python 2.7 on Windows Seven.
>
Your link http://pastebin.com/dExFtTkp shows two copies of the code.
I'm assuming they're identical, and using the second one.
How do you know no rename action is done? Did you do a dir before and
after running it? Were there any files that actually had underscores in
them? Did you try adding a print to the innermost if statement to see
if it ever ran? Did you try adding a print right after the os.rename
that showed both nome and final?
When I run it in CPython 2.7 on Linux, it successfully renamed the file
(dumm_1.txt) I had supplied.
davea at think:~/pytests$ ls
dumm_1.txt itpone.itp~ lina.py~ pdbone.pdb~ prim.py~
itpone.itp lina.py pdbone.pdb prim.py whatswrong.py
davea at think:~/pytests$ python whatswrong.py dumm_1.txt
davea at think:~/pytests$ ls
dumm 1.txt itpone.itp~ lina.py~ pdbone.pdb~ prim.py~
itpone.itp lina.py pdbone.pdb prim.py whatswrong.py
davea at think:~/pytests$
(I had to delete the following part, since you put yours out of order)
--
DaveA
More information about the Python-list
mailing list