Skip to content

Conversation

@github4bhavin
Copy link

had to change it since it was throwing error on 2.7

had to change it since it was throwing error on 2.7
@shirou
Copy link
Contributor

shirou commented Jun 11, 2015

Thank you.
But my Python 2.7.8 on Mac OS X,

Python 2.7.8 (default, Oct 19 2014, 16:03:53) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.51)] on darwin
>>> "http://{}:{}/".format("a", "b")
'http://a:b/'

works. What patch level version are you using?

@github4bhavin
Copy link
Author

its actually 2.6

Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2

@shirou
Copy link
Contributor

shirou commented Jun 16, 2015

I hadn't know {} is only in 2.7+. Thank you.
But, your field name based approach is a little bit complex. How about using just {0} like

addr = "http://{0}:{1}/".format(host, port)

https://docs.python.org/2.7/library/string.html#format-string-syntax
And could you remove your comment about compatiblity?

If you change your PR, I will merge. Thank you for your contribution!

* changing to simple Parameter usage
* compatibility comment removed
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