Skip to content

Updated print function's arguments in borg.py. #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 2, 2014

Conversation

honishi
Copy link
Contributor

@honishi honishi commented Jan 1, 2014

@faif, Thanks for your devotion about this great python stuff.

BTW, regarding borg.py, I found the print function works as expected in python 3 environment. But it seems that it does not in python 2 environment.

Python 3:

pyvers@www1021uh:~/sandbox_3.0.1$ python --version
Python 3.0.1
pyvers@www1021uh:~/sandbox_3.0.1$ python ../borg.py 
rm1: Running
rm2: Running
rm1: Zombie
rm2: Zombie
rm1 id: 139692613715664
rm2 id: 139692613715728
rm1: Zombie
rm2: Zombie
rm3: Zombie
pyvers@www1021uh:~/sandbox_3.0.1$ 

Python 2:

pyvers@www1021uh:~/sandbox_2.7.5$ python --version
Python 2.7.5
pyvers@www1021uh:~/sandbox_2.7.5$ python ../borg.py
('rm1:', <__main__.Borg instance at 0x1a620e0>)
('rm2:', <__main__.Borg instance at 0x1a62128>)
('rm1:', <__main__.Borg instance at 0x1a620e0>)
('rm2:', <__main__.Borg instance at 0x1a62128>)
('rm1 id:', 27664608)
('rm2 id:', 27664680)
('rm1:', <__main__.Borg instance at 0x1a620e0>)
('rm2:', <__main__.Borg instance at 0x1a62128>)
('rm3:', <__main__.YourBorg instance at 0x1a62170>)
pyvers@www1021uh:~/sandbox_2.7.5$

This is because the argument of print function is parsed as tuple in python 2 environment.

So I changed the argument of print function using str.format(). This works as expected in both environments, python 2 and 3. (And I think this is proper way to handle string formatting in python 3 environment, as described like here; http://docs.python.org/3.2/tutorial/inputoutput.html#old-string-formatting )

Python 3:

pyvers@www1021uh:~/sandbox_3.0.1$ python --version
Python 3.0.1
pyvers@www1021uh:~/sandbox_3.0.1$ python ../borg.py 
rm1: Running
rm2: Running
rm1: Zombie
rm2: Zombie
rm1 id: 139889706944208
rm2 id: 139889706944272
rm1: Zombie
rm2: Zombie
rm3: Zombie
pyvers@www1021uh:~/sandbox_3.0.1$ 

Python 2:

pyvers@www1021uh:~/sandbox_2.7.5$ python --version
Python 2.7.5
pyvers@www1021uh:~/sandbox_2.7.5$ python ../borg.py
rm1: Running
rm2: Running
rm1: Zombie
rm2: Zombie
rm1 id: 17121504
rm2 id: 17121576
rm1: Zombie
rm2: Zombie
rm3: Zombie
pyvers@www1021uh:~/sandbox_2.7.5$ 

It is much appreciated if you would take a look at this pull request.

Thanks.

faif pushed a commit that referenced this pull request Jan 2, 2014
Updated print function's arguments in borg.py.
@faif faif merged commit f0aacac into faif:master Jan 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants