There are several issued with that code, first, there is no need to use a global bar since you can access self. Also, pop will raise an exception if the list is not empty, therefore, you can have the following:
class example:
def __init__(self):
self.queue = []
def funz1(self,q,b):
self.queue.append(q)
self.queue.append(b)
def funz2(self):
if len(self.queue) > 0:
return str(self.queue.pop())
On top of that, if you are using a list as a q you might as well use deque from collections which was designed for that use:
from collections import deque
class example:
def __init__(self):
self.queue = deque()
def funz1(self,q,b):
self.queue.append(q)
self.queue.append(b)
def funz2(self):
if len(self.queue) > 0:
return str(self.queue.popleft())