Error: Not all argument converted during string format in zmq
I am trying to give host and port info separately but i get the error as mentioned in the question. The reason is because the zmq takes only the link like address for example 'tcp://192.X.X.X:5643'. So i am unable to give the host address by myself or either just type it. I want to provide host address seperately because i get my host address from other function so its easier to pass to a variable.
Here is the code:
def req_con:
Context=zmq.Context()
socket=context.socket(zmq.REQ)
aad="192.x.x.x"
port =8574
host=["%s".format(aad,port)]
for adres in host:
socket.connect("tcp://" %adres) ---> error is here
socket.send_string("get")
Updated:
def req_con:
..
..
host:['{p.aad}:{p.port}'.forma(p=req_con())]
I tried to make it better but now i get maximum recursion depth exceeded while calling a python object error
python string format zeromq
add a comment |
I am trying to give host and port info separately but i get the error as mentioned in the question. The reason is because the zmq takes only the link like address for example 'tcp://192.X.X.X:5643'. So i am unable to give the host address by myself or either just type it. I want to provide host address seperately because i get my host address from other function so its easier to pass to a variable.
Here is the code:
def req_con:
Context=zmq.Context()
socket=context.socket(zmq.REQ)
aad="192.x.x.x"
port =8574
host=["%s".format(aad,port)]
for adres in host:
socket.connect("tcp://" %adres) ---> error is here
socket.send_string("get")
Updated:
def req_con:
..
..
host:['{p.aad}:{p.port}'.forma(p=req_con())]
I tried to make it better but now i get maximum recursion depth exceeded while calling a python object error
python string format zeromq
1
You are mixing up two styles of string formatting. I recommend reading up on string formatting. This site seems to give a nice overview : pyformat.info The host you're trying to connect is '%s'. I think you want something like this : host = "%s:%s" % (aad, port)
– Q-life
Nov 24 '18 at 13:18
The same error persists @Q-life
– keerthana
Nov 24 '18 at 13:35
Possible duplicate of TypeError: not all arguments converted during string formatting python
– Q-life
Nov 24 '18 at 20:57
add a comment |
I am trying to give host and port info separately but i get the error as mentioned in the question. The reason is because the zmq takes only the link like address for example 'tcp://192.X.X.X:5643'. So i am unable to give the host address by myself or either just type it. I want to provide host address seperately because i get my host address from other function so its easier to pass to a variable.
Here is the code:
def req_con:
Context=zmq.Context()
socket=context.socket(zmq.REQ)
aad="192.x.x.x"
port =8574
host=["%s".format(aad,port)]
for adres in host:
socket.connect("tcp://" %adres) ---> error is here
socket.send_string("get")
Updated:
def req_con:
..
..
host:['{p.aad}:{p.port}'.forma(p=req_con())]
I tried to make it better but now i get maximum recursion depth exceeded while calling a python object error
python string format zeromq
I am trying to give host and port info separately but i get the error as mentioned in the question. The reason is because the zmq takes only the link like address for example 'tcp://192.X.X.X:5643'. So i am unable to give the host address by myself or either just type it. I want to provide host address seperately because i get my host address from other function so its easier to pass to a variable.
Here is the code:
def req_con:
Context=zmq.Context()
socket=context.socket(zmq.REQ)
aad="192.x.x.x"
port =8574
host=["%s".format(aad,port)]
for adres in host:
socket.connect("tcp://" %adres) ---> error is here
socket.send_string("get")
Updated:
def req_con:
..
..
host:['{p.aad}:{p.port}'.forma(p=req_con())]
I tried to make it better but now i get maximum recursion depth exceeded while calling a python object error
python string format zeromq
python string format zeromq
edited Nov 24 '18 at 13:32
keerthana
asked Nov 24 '18 at 13:13
keerthanakeerthana
378
378
1
You are mixing up two styles of string formatting. I recommend reading up on string formatting. This site seems to give a nice overview : pyformat.info The host you're trying to connect is '%s'. I think you want something like this : host = "%s:%s" % (aad, port)
– Q-life
Nov 24 '18 at 13:18
The same error persists @Q-life
– keerthana
Nov 24 '18 at 13:35
Possible duplicate of TypeError: not all arguments converted during string formatting python
– Q-life
Nov 24 '18 at 20:57
add a comment |
1
You are mixing up two styles of string formatting. I recommend reading up on string formatting. This site seems to give a nice overview : pyformat.info The host you're trying to connect is '%s'. I think you want something like this : host = "%s:%s" % (aad, port)
– Q-life
Nov 24 '18 at 13:18
The same error persists @Q-life
– keerthana
Nov 24 '18 at 13:35
Possible duplicate of TypeError: not all arguments converted during string formatting python
– Q-life
Nov 24 '18 at 20:57
1
1
You are mixing up two styles of string formatting. I recommend reading up on string formatting. This site seems to give a nice overview : pyformat.info The host you're trying to connect is '%s'. I think you want something like this : host = "%s:%s" % (aad, port)
– Q-life
Nov 24 '18 at 13:18
You are mixing up two styles of string formatting. I recommend reading up on string formatting. This site seems to give a nice overview : pyformat.info The host you're trying to connect is '%s'. I think you want something like this : host = "%s:%s" % (aad, port)
– Q-life
Nov 24 '18 at 13:18
The same error persists @Q-life
– keerthana
Nov 24 '18 at 13:35
The same error persists @Q-life
– keerthana
Nov 24 '18 at 13:35
Possible duplicate of TypeError: not all arguments converted during string formatting python
– Q-life
Nov 24 '18 at 20:57
Possible duplicate of TypeError: not all arguments converted during string formatting python
– Q-life
Nov 24 '18 at 20:57
add a comment |
2 Answers
2
active
oldest
votes
Solved it by
host="192.x.x.X"
port=...
socket.connect("tcp://" "%s:%d" %(format(host),port))
I'm glad it works but your syntax is weird and, honestly, I think there's no reason for the format function. Why do you think you need it ? If you replace the socket.connect() call by print() you can easily see that syntax I suggested first really should work.>>> print("tcp://" "%s:%d" % (format(host), port))output :tcp://192.x.x.X:8574>>> print("tcp://" "%s:%d" % (host, port))output :tcp://192.x.x.X:8574>>> print("tcp://%s:%d" % (host, port))output :tcp://192.x.x.X:8574
– Q-life
Nov 24 '18 at 18:47
If i do not use format then i get an error saying all strings are not converted so i had to use it.
– keerthana
Nov 24 '18 at 19:56
add a comment |
.format() is an easy way in strings:
host = "192.x.x.x"
port = 1234
socket.connect("tcp://{}:{}".format(host, port))
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53458507%2ferror-not-all-argument-converted-during-string-format-in-zmq%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Solved it by
host="192.x.x.X"
port=...
socket.connect("tcp://" "%s:%d" %(format(host),port))
I'm glad it works but your syntax is weird and, honestly, I think there's no reason for the format function. Why do you think you need it ? If you replace the socket.connect() call by print() you can easily see that syntax I suggested first really should work.>>> print("tcp://" "%s:%d" % (format(host), port))output :tcp://192.x.x.X:8574>>> print("tcp://" "%s:%d" % (host, port))output :tcp://192.x.x.X:8574>>> print("tcp://%s:%d" % (host, port))output :tcp://192.x.x.X:8574
– Q-life
Nov 24 '18 at 18:47
If i do not use format then i get an error saying all strings are not converted so i had to use it.
– keerthana
Nov 24 '18 at 19:56
add a comment |
Solved it by
host="192.x.x.X"
port=...
socket.connect("tcp://" "%s:%d" %(format(host),port))
I'm glad it works but your syntax is weird and, honestly, I think there's no reason for the format function. Why do you think you need it ? If you replace the socket.connect() call by print() you can easily see that syntax I suggested first really should work.>>> print("tcp://" "%s:%d" % (format(host), port))output :tcp://192.x.x.X:8574>>> print("tcp://" "%s:%d" % (host, port))output :tcp://192.x.x.X:8574>>> print("tcp://%s:%d" % (host, port))output :tcp://192.x.x.X:8574
– Q-life
Nov 24 '18 at 18:47
If i do not use format then i get an error saying all strings are not converted so i had to use it.
– keerthana
Nov 24 '18 at 19:56
add a comment |
Solved it by
host="192.x.x.X"
port=...
socket.connect("tcp://" "%s:%d" %(format(host),port))
Solved it by
host="192.x.x.X"
port=...
socket.connect("tcp://" "%s:%d" %(format(host),port))
answered Nov 24 '18 at 14:09
keerthanakeerthana
378
378
I'm glad it works but your syntax is weird and, honestly, I think there's no reason for the format function. Why do you think you need it ? If you replace the socket.connect() call by print() you can easily see that syntax I suggested first really should work.>>> print("tcp://" "%s:%d" % (format(host), port))output :tcp://192.x.x.X:8574>>> print("tcp://" "%s:%d" % (host, port))output :tcp://192.x.x.X:8574>>> print("tcp://%s:%d" % (host, port))output :tcp://192.x.x.X:8574
– Q-life
Nov 24 '18 at 18:47
If i do not use format then i get an error saying all strings are not converted so i had to use it.
– keerthana
Nov 24 '18 at 19:56
add a comment |
I'm glad it works but your syntax is weird and, honestly, I think there's no reason for the format function. Why do you think you need it ? If you replace the socket.connect() call by print() you can easily see that syntax I suggested first really should work.>>> print("tcp://" "%s:%d" % (format(host), port))output :tcp://192.x.x.X:8574>>> print("tcp://" "%s:%d" % (host, port))output :tcp://192.x.x.X:8574>>> print("tcp://%s:%d" % (host, port))output :tcp://192.x.x.X:8574
– Q-life
Nov 24 '18 at 18:47
If i do not use format then i get an error saying all strings are not converted so i had to use it.
– keerthana
Nov 24 '18 at 19:56
I'm glad it works but your syntax is weird and, honestly, I think there's no reason for the format function. Why do you think you need it ? If you replace the socket.connect() call by print() you can easily see that syntax I suggested first really should work.
>>> print("tcp://" "%s:%d" % (format(host), port)) output : tcp://192.x.x.X:8574 >>> print("tcp://" "%s:%d" % (host, port)) output : tcp://192.x.x.X:8574 >>> print("tcp://%s:%d" % (host, port)) output : tcp://192.x.x.X:8574– Q-life
Nov 24 '18 at 18:47
I'm glad it works but your syntax is weird and, honestly, I think there's no reason for the format function. Why do you think you need it ? If you replace the socket.connect() call by print() you can easily see that syntax I suggested first really should work.
>>> print("tcp://" "%s:%d" % (format(host), port)) output : tcp://192.x.x.X:8574 >>> print("tcp://" "%s:%d" % (host, port)) output : tcp://192.x.x.X:8574 >>> print("tcp://%s:%d" % (host, port)) output : tcp://192.x.x.X:8574– Q-life
Nov 24 '18 at 18:47
If i do not use format then i get an error saying all strings are not converted so i had to use it.
– keerthana
Nov 24 '18 at 19:56
If i do not use format then i get an error saying all strings are not converted so i had to use it.
– keerthana
Nov 24 '18 at 19:56
add a comment |
.format() is an easy way in strings:
host = "192.x.x.x"
port = 1234
socket.connect("tcp://{}:{}".format(host, port))
add a comment |
.format() is an easy way in strings:
host = "192.x.x.x"
port = 1234
socket.connect("tcp://{}:{}".format(host, port))
add a comment |
.format() is an easy way in strings:
host = "192.x.x.x"
port = 1234
socket.connect("tcp://{}:{}".format(host, port))
.format() is an easy way in strings:
host = "192.x.x.x"
port = 1234
socket.connect("tcp://{}:{}".format(host, port))
answered Nov 25 '18 at 20:34
Benyamin JafariBenyamin Jafari
3,31032245
3,31032245
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53458507%2ferror-not-all-argument-converted-during-string-format-in-zmq%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You are mixing up two styles of string formatting. I recommend reading up on string formatting. This site seems to give a nice overview : pyformat.info The host you're trying to connect is '%s'. I think you want something like this : host = "%s:%s" % (aad, port)
– Q-life
Nov 24 '18 at 13:18
The same error persists @Q-life
– keerthana
Nov 24 '18 at 13:35
Possible duplicate of TypeError: not all arguments converted during string formatting python
– Q-life
Nov 24 '18 at 20:57