Re: [Tutor] What is wrong with my code?

2011-10-25 Thread apometron

On 10/25/2011 7:34 AM, Dave Angel wrote:
(Once again, please don't top-post.  It makes your responses out of 
order)


On 10/25/2011 04:24 AM, apometron wrote:

I did it very much times, Anssi.

Beyond of run it on Python 2.7 latest build, what do you suggest?

Do install Python 3.2 along the Python 2.7 installation could give me 
any problems?




Why don't you say publicly that you aren't using cmd ?

If your file manager is not running the equivalent of


python  yourprogram.py filename.txt


then everyone here is chasing a wild goose.

Switch to the command line, issue a sequence of commands that cause 
the failure, and paste them in a message here.  Then if it works, but 
doesn't from your file manager, you/we/they can address the 
differences from the working command line.




I found out what it is.

It is the File Commander giving wrong informations to the script.

In Take Command command line it works sweet.

I will show all this to the File Commander author and ask him some way 
to solve this.


It turns out do the thing in command line every time is not best way. I 
need do it by the file manager.


But the file manager was puting stones in the way.

Take Command has a script language also, but I would like do the things 
in Python, if possible.


And this difficulty with File Commander makes use Python a thing less 
easy to do.


Question solved. It was not Take Command the problem and I was sure it 
was not.


Enter in command line to do things is a pain. =( I mean, e-ve-ry ti-me.

But then, good news, all the three scripts works smoothly in the command 
line.


Do you believe drag and drop in the Windows Explorer can be my salvation?

Cool thing to try.

[]s
Apometron
http://about.me/apometron


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What is wrong with my code?

2011-10-25 Thread apometron

I did it very much times, Anssi.

Beyond of run it on Python 2.7 latest build, what do you suggest?

Do install Python 3.2 along the Python 2.7 installation could give me 
any problems?


cheers,
Apometron
http://about.me/apometron

On 10/25/2011 6:11 AM, Anssi Saari wrote:

apometron  writes:


Now it is another
thing, entirely. Rename1.py and Rename2.py works, but why Rename3.py
dont works?

Well, Rename3.py works for me, even in Windows 7. Maybe you should test
it again?


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] What is wrong with my code?

2011-10-23 Thread apometron
Sorry to continue discussing my thread on this list, I already subbed on 
the Tutor list
but I need to reply and if possible, some ideas of why it dont works. 
Now it is another
thing, entirely. Rename1.py and Rename2.py works, but why Rename3.py 
dont works?


http://pastebin.com/dExFtTkp

Thanks by the gentle support.

[]s
Apometron

On 10/23/2011 8:56 PM, Dave Angel wrote:

On 10/23/2011 06:03 AM, apometron wrote:

import os
nome = sys.argv[1]
final = nome
for i in nome:
print i
if nome[i] = "_":
final[i] = " "
os.rename(nome, final)

What do you want to be wrong with it?  There are so many things, it'd 
be fun to try to see who could come up with the most.


1) it's not a valid Fortran program.
2) it's missing a shebang line
if we assume it's for Windows, or that you run it with an explicit 
bash line

3) if we pretend it's a python program, a few more
3a)  It has a syntax error calling the print() function.  (Python 3.2)
  If we assume it's a python 2.x program
4) it uses sys, without importing it
5) it uses second argument without checking if the user typed such an 
argument
6) it tries to change a character within a string, which is a 
non-mutable type
7) It creates two more references to the same string sys.argv[1], then 
tries to modify one of them, not realizing the others would change to.

8) it tries to subscript a string using a character.
9) it calls rename with two references to the same object.  So nothing 
will ever actually happen, even if the other problems were fixed.


Generally, you'll get the best answers here if you specify more of 
your environment (python version, OS), show what you tried (pasted 
from the command line), and the results you got (such as stack traces).


HTH

DaveA




___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor