Python Forum
Problem with importing and using collections module
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with importing and using collections module
#1
Greatings,

I am a new to python and actually whole concept of programming.

Since last one one month i have been working hard but getting stuck many times because training material i have are from instructors who made it on python 2.

I am learning to create a base file for my games references.

I have import collections module

import collections

then while creating vector i used it

class vector(collection.Sequence)

and now the problem start. whenever i tried using vector class for my game but i have error:

Traceback (most recent call last):
File "d:/pYtHON/Pythongames/base.py", line 18, in <module>
class vector(collection.Sequence):
NameError: name 'collection' is not defined

Please share resolution with little explanation to understand it for future reference. Thank You. Smile
Reply
#2
As far as the python interpreter is concerened, collections and collection are two different words.
Reply
#3
Hey, thats's what made me confused too.

here is line of codes which my instructor is able to use but not me.
import collection

class vector(collection.sequence):
    PRECISION = 6
    ....
that's creating an error for collection module. please assist.
Reply
#4
Again, it's Sequence and not sequence. Also usually one capitalizes class names, so it would be a better style to write class Vector although Python does not enforce this.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  problem with memory_graph module akbarza 3 297 Mar-04-2024, 10:15 AM
Last Post: snippsat
  importing variables from module 8376459 1 245 Feb-18-2024, 02:24 PM
Last Post: deanhystad
  problem using coloeama module akbarza 3 513 Jan-08-2024, 07:31 AM
Last Post: akbarza
  no module named 'docx' when importing docx MaartenRo 1 710 Dec-31-2023, 11:21 AM
Last Post: deanhystad
  problem in using subprocess module akbarza 5 944 Sep-24-2023, 02:02 PM
Last Post: snippsat
  problem in import module from other folder akbarza 5 1,259 Sep-01-2023, 07:48 AM
Last Post: Gribouillis
  problem in using pyqrcode module to create QRcode akbarza 9 1,794 Aug-23-2023, 04:17 PM
Last Post: snippsat
  Problem with Pyinstaller. No module named '_tkinter' tonynapoli2309 0 934 May-15-2023, 02:38 PM
Last Post: tonynapoli2309
  Problem with importing python-telegram library into the project gandonio 1 1,515 Nov-01-2022, 02:19 AM
Last Post: deanhystad
  My code displays too much output when importing class from a module lil_e 4 1,103 Oct-22-2022, 12:56 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020