Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
  Smile Thread: Import error with local file
Post: Import error with local file

Hello. When I try to run a python file python optimizer.pyit says ImportError: No module named optimizers.PSOThere is a file called "PSO.py" on the folder "optimizers", that happens to be on the same ...
colt General Coding Help 1 1,949 Nov-08-2020, 01:17 AM
    Thread: AttributeError: 'Register' object has no attribute 'bit_7'
Post: AttributeError: 'Register' object has no attribute...

Hello. I have this simple class class Register (object): def init (self): self.bit_0 = False self.bit_1 = False self.bit_2 = True self.bit_3 = False self.bit_4 = False self.bit_5 = True ...
colt General Coding Help 1 2,002 Dec-12-2019, 09:31 PM
    Thread: Polymorphism not working with a call to a abstract method
Post: RE: Polymorphism not working with a call to a abst...

(Nov-04-2019, 01:24 AM)MckJohan Wrote: can you explain a little bit more on the problem?do you want python to search the implementation to all subclass and used it?[/quote] Yes. Quote:where are yo...
colt General Coding Help 3 2,344 Nov-04-2019, 11:04 PM
    Thread: Polymorphism not working with a call to a abstract method
Post: Polymorphism not working with a call to a abstract...

Hello. I was creating two classes that both implemented an abstract method of their parent class. However, as I went to implement them, I realized that both did about the same thing, at least in the ...
colt General Coding Help 3 2,344 Nov-03-2019, 11:54 PM
    Thread: NameError: NameError: global name 'BPLInstruction' is not defined
Post: RE: NameError: NameError: global name 'BPLInstruct...

I somewhat was able to fix it through the correction of a logical bug. The code that fix it is: if byte==0x78: instruction = SEIInstruction (byte) elif byte==0xD8: instruction = CLD...
colt General Coding Help 7 4,410 Oct-27-2019, 12:22 AM
    Thread: NameError: NameError: global name 'BPLInstruction' is not defined
Post: RE: NameError: NameError: global name 'BPLInstruct...

(Oct-23-2019, 11:29 PM)Larz60+ Wrote: it's line 18! print ("Identifier Byte: BPLinstruction:",hex (self.identity_byte), self.identity_byte) Between the quotes? Well, I changed it but the error remai...
colt General Coding Help 7 4,410 Oct-25-2019, 10:39 PM
    Thread: NameError: NameError: global name 'BPLInstruction' is not defined
Post: RE: NameError: NameError: global name 'BPLInstruct...

(Oct-21-2019, 12:51 AM)Larz60+ Wrote: in class definition, name is BPLinstruction (small i) when instantiated you use capital I Thanks. I did changed it to class BPLInstruction (Instruction): instea...
colt General Coding Help 7 4,410 Oct-23-2019, 10:09 PM
    Thread: NameError: NameError: global name 'BPLInstruction' is not defined
Post: NameError: NameError: global name 'BPLInstruction'...

Hello I am receiving these messages when running my code: Error:File "/home/leopoldo/cpu.py", line 28, in process_instructions instruction = self.identify_instruction (byte) File "/home/leopold...
colt General Coding Help 7 4,410 Oct-20-2019, 11:15 PM
    Thread: How to convert "str" to "int"
Post: RE: How to convert "str" to "int"

(Oct-15-2019, 03:45 PM)Gribouillis Wrote: In python 3 you don't need to call ord() if self.header[4] is already an integer. Use this value directly. Sure, but then it doesn't work with older python....
colt General Coding Help 12 4,956 Oct-15-2019, 11:40 PM
    Thread: How to convert "str" to "int"
Post: RE: How to convert "str" to "int"

(Oct-12-2019, 10:39 PM)Gribouillis Wrote: colt Wrote:I don't know why, but now the code is working on python 3.2, since it converts the values to int.That's because in python 3 a bytes string is a s...
colt General Coding Help 12 4,956 Oct-15-2019, 03:17 PM
    Thread: How to convert "str" to "int"
Post: RE: How to convert "str" to "int"

(Oct-09-2019, 05:59 PM)Gribouillis Wrote: Could it be an error similar to this one ? >>> rom_bytes = b'hello world' >>> import struct >>> struct.unpack("I", rom_bytes[4]) ...
colt General Coding Help 12 4,956 Oct-12-2019, 09:55 PM
    Thread: How to convert "str" to "int"
Post: RE: How to convert "str" to "int"

(Oct-09-2019, 05:51 AM)Gribouillis Wrote: colt Wrote:It says line 11, which is the one that uses struct.unpackThere is no struct.unpack in the original post. It will be much easier if you post the w...
colt General Coding Help 12 4,956 Oct-09-2019, 05:40 PM
    Thread: How to convert "str" to "int"
Post: RE: How to convert "str" to "int"

(Oct-06-2019, 05:25 AM)scidam Wrote: Take a look at the struct module. import struct four_bytes = b'abcd' # sample bytesting struct.unpack("I", four_bytes) # interpret bytesting as unsigned int F...
colt General Coding Help 12 4,956 Oct-08-2019, 11:13 PM
    Thread: Object cannot find its attribute
Post: RE: Object cannot find its attribute

(Oct-06-2019, 01:59 AM)ichabod801 Wrote: I cannot replicate your problem. I can't run all of your code, since I don't have ROM data or anything. But, if I load your classes and do this: instruc...
colt General Coding Help 6 3,470 Oct-08-2019, 11:04 PM
    Thread: How to convert "str" to "int"
Post: How to convert "str" to "int"

Hello I am currently reading a file in binary mode. I do the reading with with open (args.rom_path, 'rb') as file: rom_bytes = file.read () Then part of these rom_bytes are transferred to another...
colt General Coding Help 12 4,956 Oct-06-2019, 01:57 AM
    Thread: Object cannot find its attribute
Post: RE: Object cannot find its attribute

(Sep-30-2019, 12:30 AM)ichabod801 Wrote: (Sep-29-2019, 11:48 PM)colt Wrote: I do not know why its complaining about the lack of the 'identity_byte' attribute, which is clearly present. Looks prett...
colt General Coding Help 6 3,470 Oct-06-2019, 01:39 AM
    Thread: Object cannot find its attribute
Post: Object cannot find its attribute

Hello, I have this line of code print ("Identifier Byte: {}".format(self.identity_byte))that generates this output: Quote:120 216 169 Traceback (most recent call last): File "emulator.py", line 19,...
colt General Coding Help 6 3,470 Sep-29-2019, 11:48 PM
    Thread: For loop prints strane values?
Post: For loop prints strane values?

Hello. I have this code for printing all the values of "header" (a list of bytes) and the first value of "data_bytes" (another list of bytes): def test (self): print ("Header: ") for x in self.he...
colt General Coding Help 2 2,199 Sep-22-2019, 01:38 AM
    Thread: Python complains that class instance is not defined
Post: RE: Python complains that class instance is not de...

(Sep-14-2019, 12:54 AM)ichabod801 Wrote: Where is the class statement relative to the line causing the error? It looks like the error line is in a function called main. If the class definition is no...
colt General Coding Help 3 5,666 Sep-16-2019, 11:36 PM
    Thread: Python complains that class instance is not defined
Post: Python complains that class instance is not define...

Hello. I have this code line: instruction = Instruction (byte)that generates the following error message: Quote:Traceback (most recent call last): File "emulator.py", line 29, in <module> ...
colt General Coding Help 3 5,666 Sep-14-2019, 12:07 AM

User Panel Messages

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