Is there a way to use tqdm on a function call because i am not understanding how to display a progress bar because i don't have any loops: this is where the function call happens:
if length == 2:
post().request(email,password)
everytime it makes a request, i want my progress bar to move, is there a way?
So post is a class. As much I understood your question, you may try these:
For a progressbar for each request:
class post():
def __init__(self):
pass
def req(self):
for _ in trange(1):
print("req")
p = post()
p.req()
For single progressbar for n_req requests:
class post(tqdm.tqdm):
def __init__(self, n_req = 1):
tqdm.tqdm.__init__(self)
self.total = n_req
def req(self, i):
print("req", i)
self.update()
n_req = 5
with post(n_req) as p:
for i in range(n_req):
p.req(i)
#------------OR-----------------
n_req = 5
with post(n_req) as p:
p.req(1); p.req(2); p.req(3); p.req(4); p.req(5)
(I'm not sure why it's not working without with
format. Probably because python objects or callbacks don't work same as c++ objects.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.