score:1

Accepted answer

i found the answer. i needed to test this remote debugger approach.

let me explain how i found out:

i have a local system with python 2.6.5. i created a new remote system (virtual machine in this case) with python 2.7.3. then i shared the following script:

import pydevd
print 'hello world'

# call debugger server to handle this breakpoint
pydevd.settrace('10.31.94.156', stdouttoserver=true, stderrtoserver=true)

# fron now on the host (debugger server) has control over breakpoints,
# variables, stepping through code etc.
print 'hi again'
import sys
print sys.version  # 2.7.3 (default, sep 26 2013, 20:08:41)
                   # [gcc 4.6.3]

# now use a 2.7 feature: 
x = {i : chr(65+i) for i in range(4)}  # dict comprehension
print x  # {0: 'a', 1: 'b', 2: 'c', 3: 'd'}

import socket
print socket.gethostname()  # my virtual machine name

print 'done'

of course i added some breakpoints in eclipse on my hostmachine. it's funny to see that the local interpreter gives errors about the list comprehension, while it does actually run. and it also has variable x nicely displayed in the debuggers variables pane.

conclusion: the remote interpreter is used to run / evaluate code. the debugger server helps you ad

score:0

here are two ways to determine the current python version.

via code:

python -c 'import sys; print sys.version'

2.7.5+ (default, feb 27 2014, 19:37:08) 
[gcc 4.8.1]

and via

direct command:

python -v

python 2.7.5+

also

hostname:

print socket.gethostname()

score:0

if you are using code and not sure if it is v2 or v3 you can use

import sys
try:
    print sys.version
except:
    print(sys.version)

Related Query

More Query from same tag