Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: JS Buffer.from VS struct.pack
Post: RE: JS Buffer.from VS struct.pack

Ok, I think I fixed it. I missed a break in a for loop so it was calling the write function more times that it needed to. The map now actually loads in the map editor. which is good. It doesn't look h...
DreamingInsanity General Coding Help 3 410 Apr-05-2021, 06:27 PM
    Thread: JS Buffer.from VS struct.pack
Post: RE: JS Buffer.from VS struct.pack

(Apr-05-2021, 03:14 PM)deanhystad Wrote: Why are you testing with a map? Test by writing an unsigned int or a string. I would write a test for each data type and compare the resulting files. Just t...
DreamingInsanity General Coding Help 3 410 Apr-05-2021, 04:30 PM
    Thread: JS Buffer.from VS struct.pack
Post: JS Buffer.from VS struct.pack

I'm trying to port over a little of bit of a JS library so I can work with it in Python. It allows for you to create Celeste (the game) maps through code. Celeste maps are saved as binary files theref...
DreamingInsanity General Coding Help 3 410 Apr-05-2021, 02:58 PM
    Thread: Split string between two different delimiters, with exceptions
Post: RE: Split string between two different delimiters,...

(Aug-24-2020, 08:05 AM)millpond Wrote: I have never seen split used like this. And surprised it works at all. Are you parsing the class or the raw data? I would start with something simple like: ...
DreamingInsanity General Coding Help 2 659 Aug-24-2020, 08:23 AM
    Thread: Split string between two different delimiters, with exceptions
Post: Split string between two different delimiters, wit...

I couldn't really think of a good title for this, so, sorry! Say I have some data like so: :1:123456:2:name:42:3:30:4::5:somerandomdata:9:8 The important data is held between groups like :1:. Each of...
DreamingInsanity General Coding Help 2 659 Aug-23-2020, 04:03 PM
    Thread: How can you make it simpler?
Post: RE: How can you make it simpler?

(Aug-22-2020, 08:00 PM)bitcoin10mil Wrote: x is the first digit num2= 2nd digit num3= 3rd digit num4= 4th digitWith a little change, it works with this: def fourdigit(first): n = random.randint(1...
DreamingInsanity General Coding Help 5 743 Aug-22-2020, 08:15 PM
    Thread: "can't set attribute" on class
Post: RE: "can't set attribute" on class

(Aug-22-2020, 07:53 PM)Gribouillis Wrote: The problem is that you have a read-only @property named data. The best solution is to rename the attribute. You could use _data or datadict for example.Ah ...
DreamingInsanity General Coding Help 2 1,125 Aug-22-2020, 07:57 PM
    Thread: How can you make it simpler?
Post: RE: How can you make it simpler?

I'm not sure what the parameter "x" does - could you expand on that? If you just want a 4 digit number with not repeating digits, you could try this: def fourdigit(): n = random.randint(1000, 9999)...
DreamingInsanity General Coding Help 5 743 Aug-22-2020, 07:39 PM
    Thread: "can't set attribute" on class
Post: "can't set attribute" on class

I have a class like so: class CustomLevel(BaseLevel): def __init__(self, **data: dict) -> None: self.data = data @classmethod def fromData(cls, data: Union[dict, str]) -> CustomLevel: i...
DreamingInsanity General Coding Help 2 1,125 Aug-22-2020, 07:16 PM
    Thread: "Class already defined" while using typings.
Post: "Class already defined" while using typings.

I'm building a little program but I'm trying to make it more easily expandable for the future (without the need of much refactoring). I'm experimenting with thing I have never used before like typings...
DreamingInsanity General Coding Help 0 701 Aug-19-2020, 10:43 AM
    Thread: str.find() not returning correct index.
Post: RE: str.find() not returning correct index.

(Aug-18-2020, 05:01 PM)bowlofred Wrote: I can't confirm this will work, since I don't have your original (non-ascii) file, but this code does the reads/compares in binary and works on the ascii snip...
DreamingInsanity General Coding Help 10 1,169 Aug-18-2020, 05:41 PM
    Thread: str.find() not returning correct index.
Post: RE: str.find() not returning correct index.

(Aug-18-2020, 03:16 PM)bowlofred Wrote: Rather than open the file in ascii and ignore errors, I would prefer opening the file in binary and searching for the binary/byte string instead.I like that i...
DreamingInsanity General Coding Help 10 1,169 Aug-18-2020, 04:57 PM
    Thread: str.find() not returning correct index.
Post: RE: str.find() not returning correct index.

I keep coming here to post an interring discovery and then keep realising I've been an idiot. I said that it was a few tens of characters off, which it was. I first tried using a substring rather tha...
DreamingInsanity General Coding Help 10 1,169 Aug-18-2020, 10:25 AM
    Thread: str.find() not returning correct index.
Post: RE: str.find() not returning correct index.

(Aug-18-2020, 04:44 AM)bowlofred Wrote: Hmm. I'm not sure what's going on then. I wonder if the file is in some odd encoding that your editor is handling automatically?When I opened up the file in...
DreamingInsanity General Coding Help 10 1,169 Aug-18-2020, 08:39 AM
    Thread: str.find() not returning correct index.
Post: RE: str.find() not returning correct index.

(Aug-17-2020, 07:04 PM)bowlofred Wrote: base64 encoding and "visible in a hex editor" seem like completely different things. If you're just looking for a string that has a particular hex representa...
DreamingInsanity General Coding Help 10 1,169 Aug-17-2020, 07:28 PM
    Thread: str.find() not returning correct index.
Post: RE: str.find() not returning correct index.

From the testing I have done, and the fact that that testing did this to my console: [Image: https://i.imgur.com/DkKQdzK.png] The only thing I can put it down to is like unsupported characters or some...
DreamingInsanity General Coding Help 10 1,169 Aug-17-2020, 06:58 PM
    Thread: str.find() not returning correct index.
Post: str.find() not returning correct index.

Hopefully I'm not being stupid here. I am searching through a MacOS executable for a certain string (base64 encoded) like so: with open(self.dir, 'r', encoding="ascii", errors="ignore") as f: t = ...
DreamingInsanity General Coding Help 10 1,169 Aug-17-2020, 05:45 PM
    Thread: Install libraries in Google Coral TPU
Post: RE: Install libraries in Google Coral TPU

It seems like that's more likely an issue with the Google Coral TPU and support for libraries. I can't say for certain since I've never used it but I don't think it would be a bug with numpy. How abo...
DreamingInsanity General Coding Help 1 644 Jul-13-2020, 09:57 PM
    Thread: name 'temperatures' not defined?
Post: RE: name 'temperatures' not defined?

You could do something like this: import ast def get_input(): input_list = ast.literal_eval(input("\nEnter the temperatures: ")) return input_list def get_temperature(temps): output_list =...
DreamingInsanity General Coding Help 3 951 Jul-13-2020, 01:46 PM
    Thread: Input Error
Post: RE: Input Error

It maybe be a bug with the library but I've never used it so I can't say for certain. Have you thought about using other libraries? There's a very popular one called youtube-dl. It supports hundreds ...
DreamingInsanity General Coding Help 2 823 Jul-12-2020, 02:08 PM

User Panel Messages

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