View previous topic :: View next topic |
Author |
Message |
J3N7iL Apprentice
Joined: 24 Sep 2005 Posts: 169 Location: Chicago
|
Posted: Sun Jan 30, 2011 5:28 pm Post subject: Python giving double output |
|
|
I was getting some odd output from my python script and narrowed it down. I took the code and isolated it into it's own script for testing . .
Code: |
#!/usr/bin/python
import string
str = 'Gentoo rocks'
maxpos = len(str)
print maxpos
|
Output:
Quote: |
jimmy@localhost ~/Projects/Python/MediaGrabber $ ./string.py
12
12
|
If I use PyAlamode or just the normal command line python dialogue, it works as expected.
Any ideas?[/quote] _________________ For Sale: Parachute. Only used once, never opened, small stain. |
|
Back to top |
|
|
tomk Bodhisattva
Joined: 23 Sep 2003 Posts: 7221 Location: Sat in front of my computer
|
Posted: Sun Jan 30, 2011 5:49 pm Post subject: |
|
|
What version of python are you using? _________________ Search | Read | Answer | Report | Strip |
|
Back to top |
|
|
J3N7iL Apprentice
Joined: 24 Sep 2005 Posts: 169 Location: Chicago
|
Posted: Sun Jan 30, 2011 5:53 pm Post subject: |
|
|
I have 2.6 installed, and apparently 3.1,
./usr/bin/python2.6 gives a pydialoge
as well as
./usr/bin/python3.1
another odd thing that started happening, I can't emerge anything, I get this error:
Code: |
'${EPREFIX}/usr/bin/python' is not valid symlink
|
This started occurring after I emerged bluefish, and updated world _________________ For Sale: Parachute. Only used once, never opened, small stain. |
|
Back to top |
|
|
tomk Bodhisattva
Joined: 23 Sep 2003 Posts: 7221 Location: Sat in front of my computer
|
Posted: Sun Jan 30, 2011 6:04 pm Post subject: |
|
|
Sounds like python hasn't been selected correctly, run:
Code: | eselect python list |
Then set it to the 2.6 version (probably 1 but check the output from above), you'll have to do this as root:
Code: | eselect python set 1 |
_________________ Search | Read | Answer | Report | Strip |
|
Back to top |
|
|
J3N7iL Apprentice
Joined: 24 Sep 2005 Posts: 169 Location: Chicago
|
Posted: Sun Jan 30, 2011 6:11 pm Post subject: |
|
|
Ah great! so the emerging works now, but I am still getting double output on the script.
At first I thought that having two versions of python installed was causing it, but clearly that should not have an effect on it. _________________ For Sale: Parachute. Only used once, never opened, small stain. |
|
Back to top |
|
|
M Guru
Joined: 12 Dec 2006 Posts: 432
|
Posted: Sun Jan 30, 2011 6:12 pm Post subject: |
|
|
Also, str is builtin function, you should not redeclare it. |
|
Back to top |
|
|
tomk Bodhisattva
Joined: 23 Sep 2003 Posts: 7221 Location: Sat in front of my computer
|
Posted: Sun Jan 30, 2011 6:27 pm Post subject: Re: Python giving double output |
|
|
The problem is that you've called your script string.py, then you are importing string (which is the script itself) so it gets run twice. _________________ Search | Read | Answer | Report | Strip |
|
Back to top |
|
|
J3N7iL Apprentice
Joined: 24 Sep 2005 Posts: 169 Location: Chicago
|
Posted: Sun Jan 30, 2011 11:21 pm Post subject: |
|
|
Holy bajebus . . .
Thanks, I feel foolish _________________ For Sale: Parachute. Only used once, never opened, small stain. |
|
Back to top |
|
|
|