Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Python giving double output
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
J3N7iL
Apprentice
Apprentice


Joined: 24 Sep 2005
Posts: 169
Location: Chicago

PostPosted: Sun Jan 30, 2011 5:28 pm    Post subject: Python giving double output Reply with quote

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
View user's profile Send private message
tomk
Bodhisattva
Bodhisattva


Joined: 23 Sep 2003
Posts: 7221
Location: Sat in front of my computer

PostPosted: Sun Jan 30, 2011 5:49 pm    Post subject: Reply with quote

What version of python are you using?
_________________
Search | Read | Answer | Report | Strip
Back to top
View user's profile Send private message
J3N7iL
Apprentice
Apprentice


Joined: 24 Sep 2005
Posts: 169
Location: Chicago

PostPosted: Sun Jan 30, 2011 5:53 pm    Post subject: Reply with quote

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
View user's profile Send private message
tomk
Bodhisattva
Bodhisattva


Joined: 23 Sep 2003
Posts: 7221
Location: Sat in front of my computer

PostPosted: Sun Jan 30, 2011 6:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
J3N7iL
Apprentice
Apprentice


Joined: 24 Sep 2005
Posts: 169
Location: Chicago

PostPosted: Sun Jan 30, 2011 6:11 pm    Post subject: Reply with quote

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
View user's profile Send private message
M
Guru
Guru


Joined: 12 Dec 2006
Posts: 432

PostPosted: Sun Jan 30, 2011 6:12 pm    Post subject: Reply with quote

Also, str is builtin function, you should not redeclare it.
Back to top
View user's profile Send private message
tomk
Bodhisattva
Bodhisattva


Joined: 23 Sep 2003
Posts: 7221
Location: Sat in front of my computer

PostPosted: Sun Jan 30, 2011 6:27 pm    Post subject: Re: Python giving double output Reply with quote

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
View user's profile Send private message
J3N7iL
Apprentice
Apprentice


Joined: 24 Sep 2005
Posts: 169
Location: Chicago

PostPosted: Sun Jan 30, 2011 11:21 pm    Post subject: Reply with quote

Holy bajebus . . .

Thanks, I feel foolish
_________________
For Sale: Parachute. Only used once, never opened, small stain.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum