Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9228099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:14:31+00:00 2026-06-18T05:14:31+00:00

I have seen other examples of this happening on StackOverflow, but I didn’t understand

  • 0

I have seen other examples of this happening on StackOverflow, but I didn’t understand any of the answers (I’m still a new programmer,) nor did the other examples I saw look quite like mine, else I wouldn’t post this question.

I’m running Python 3.2 on Windows 7.

I have never had this happen to me before and I’ve done classes this way many times, so I don’t really know what is different this time. The only difference is that I didn’t make all of the Class file; I was given a template to fill in and a test file to try it on. It worked on the test file, but is not working on my file. I have been calling on the methods in the class in the exact same way as the test file (e.g. Lineup.size())

This is my Class:

class Queue:
    
    # Constructor, which creates a new empty queue:
    def __init__(self):
        self.__items = []
        
    # Adds a new item to the back of the queue, and returns nothing:
    def queue(self, item):
        self.__items.insert(0,item)
        return
        
    # Removes and returns the front-most item in the queue.  
    # Returns nothing if the queue is empty.
    def dequeue(self):
        if len(self.__items) == 0:
            return None
        else:
            return self.__items.pop()
        
    # Returns the front-most item in the queue, and DOES NOT change the queue.  
    def peek(self):
        if len(self.__items) == 0:
            return None
        else:
            return self.__items[(len(self.__items)-1)]
        
    # Returns True if the queue is empty, and False otherwise:
    def is_empty(self):
        return len(self.__items) == 0
    
    # Returns the number of items in the queue:
    def size(self):
        return len(self.__items)
    
    # Removes all items from the queue, and sets the size to 0:
    def clear(self):
        del self.__items[0:len(self.__items)]
        return
        
    # Returns a string representation of the queue:
    def __str__(self):
        return "".join(str(i) for i in self.__items)

This is my program:

from queue import Queue

Lineup = Queue()

while True:
    decision = str(input("Add, Serve, or Exit: ")).lower()
    if decision == "add":
        if Lineup.size() == 3:
            print("There cannot be more than three people in line.")
            continue
        else:
            person = str(input("Enter the name of the person to add: "))
            Lineup.queue(person)
            continue
    elif decision == "serve":
        if Lineup.is_empty() == True:
            print("The lineup is already empty.")
            continue
        else:
            print("%s has been served."%Lineup.peek())
            Lineup.dequeue()
            continue
    elif (decision == "exit") or (decision == "quit"):
        break
    else:
        print("%s is not a valid command.")
        continue

And this is my error message when I enter "add" as my decision variable:

line 8, in
builtins.AttributeError: ‘Queue’ object has no attribute ‘size’

So, what is going on here? What is different about this one?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:14:32+00:00Added an answer on June 18, 2026 at 5:14 am

    Python 3 already has a queue module (which you might want to take a look at). When you import queue, Python finds that queue.py file before it finds your queue.py.

    Rename your queue.py file to my_queue.py, change your import statements to from my_queue import Queue, and your code will work as you intend.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen some of the other answers on this topic but dont really
I have seen other questions on here related to this, but I have their
i have seen other blogs and SO questions relating to this issue but none
I have seen the other posts but I am still having trouble. Below is
I've seen a few other examples of this for SQL, but I am looking
I googled,I binged,I already have seen the other duplicates here,but none of them work
I have seen in some source code (by other developers) something like this: #import
It is very strange what is happening, I have never seen this before and
I have seen other posts , but they are mostly in C#. For someone
I have seen similar examples but have not seen exactly what I am looking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.