Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Solved] python code gives different results on my machine

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
adido
Posts: 21
Joined: 2014-02-10 11:57

[Solved] python code gives different results on my machine

#1 Post by adido »

hi,

I'm learning Python and when I compile one of the exercises from the course, the results come strikingly different than the original version. This is not me solving an exercise! It is an example that I ran from file & interpreter, and the results I receive are different (similar on my machine, but different than other machines).

I posted on the Python forum, but there's no solution yet https://python-forum.io/Thread-py4e-boo ... n-compiled

I was thinking maybe there is a package issue...

Any ideas?
Thanks!
Last edited by adido on 2018-06-13 11:46, edited 1 time in total.

Dai_trying
Posts: 1100
Joined: 2016-01-07 12:25
Has thanked: 5 times
Been thanked: 16 times

Re: python code gives different results on my machine

#2 Post by Dai_trying »

I just tested in my Jessie machine and got this output

Code: Select all

Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> data = 'From stephen.marquard@uct.ac.za Sat Jan  5 09:14:16 2008'
>>> atpos = data.find('@')
>>> print (atpos)
21
>>> spos = data.find(' ',atpos)
>>> print (spos)
31
>>> host = data[atpos+1 : spos]
>>> print (host)
uct.ac.za
I also tested in my Buster installation and get the same (correct) results just with newer Python and GCC versions, which leads me to think there could be a problem with your python installation (just a guess really).

reinob
Posts: 1189
Joined: 2014-06-30 11:42
Has thanked: 97 times
Been thanked: 47 times

Re: python code gives different results on my machine

#3 Post by reinob »

My bet is that the space (' ') is not a real space but something you've copied over from HTML (&nbsp or who knows what).
Type the program yourself, with a normal (ASCII) editor.

User avatar
sunrat
Administrator
Administrator
Posts: 6412
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 116 times
Been thanked: 462 times

Re: python code gives different results on my machine

#4 Post by sunrat »

+1 for what reinob said. I had the same problem recently.
See http://forums.debian.net/viewtopic.php? ... 02#p675102
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

adido
Posts: 21
Joined: 2014-02-10 11:57

[Solved] python code gives different results on my machine

#5 Post by adido »

reinob wrote:My bet is that the space (' ') is not a real space but something you've copied over from HTML (&nbsp or who knows what).
Type the program yourself, with a normal (ASCII) editor.
son of a...
Thank you, there was a problem with space in the string I believe... I first edited the (' ') and had the same results. Then I re-did all the spaces in the string and it all worked!
Many thanks!

arzgi
Posts: 1185
Joined: 2008-02-21 17:03
Location: Finland
Been thanked: 31 times

Re: [Solved] python code gives different results on my machi

#6 Post by arzgi »

adido wrote:
reinob wrote:My bet is that the space (' ') is not a real space but something you've copied over from HTML (&nbsp or who knows what).
Type the program yourself, with a normal (ASCII) editor.
son of a...
Thank you, there was a problem with space in the string I believe... I first edited the (' ') and had the same results. Then I re-did all the spaces in the string and it all worked!
Many thanks!
Good you got this solved. One thing that could be used, is to paste to some word processing program (tested with Abiword), which can show nonprintable characters.

Post Reply