![]() |
Problem with importing and using collections module - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Problem with importing and using collections module (/thread-22446.html) |
Problem with importing and using collections module - pythomdummy - Nov-13-2019 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. ![]() RE: Problem with importing and using collections module - Gribouillis - Nov-13-2019 As far as the python interpreter is concerened, collections and collection are two different words.
RE: Problem with importing and using collections module - pythomdummy - Nov-14-2019 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. RE: Problem with importing and using collections module - Gribouillis - Nov-14-2019 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.
|