Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Regex higher IR library
Post: RE: Regex higher IR library

(Jun-05-2022, 06:21 PM)Gribouillis Wrote: The closest thing I can think about in Python is the lexer in the PLY module, where tokens are also specified as regular expressions. As David Beazley expla...
DreamingInsanity General Coding Help 6 2,210 Jun-06-2022, 02:37 PM
    Thread: Regex higher IR library
Post: RE: Regex higher IR library

(Jun-05-2022, 03:12 PM)Gribouillis Wrote: The idea of building an order relation for the regular expressions looks creative. What are you going to do with this order relation?Just for a bit of a fun...
DreamingInsanity General Coding Help 6 2,210 Jun-05-2022, 04:07 PM
    Thread: Regex higher IR library
Post: RE: Regex higher IR library

(Jun-05-2022, 05:46 AM)Gribouillis Wrote: (Jun-04-2022, 11:37 PM)DreamingInsanity Wrote: but it's not in a very useful format for doing other stuff with.Why is this not useful enough and what do y...
DreamingInsanity General Coding Help 6 2,210 Jun-05-2022, 10:06 AM
    Thread: Regex higher IR library
Post: Regex higher IR library

Before I delve into making my own module, I was wondering if there already exists a regex higher IR (intermediary representation) of regex tokens for python I can import the actual regex parser from r...
DreamingInsanity General Coding Help 6 2,210 Jun-04-2022, 11:37 PM
    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 2,461 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 2,461 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 2,461 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 2,031 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 2,031 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 2,518 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 10,870 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 2,518 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 10,870 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 2,332 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 4,244 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 4,244 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 4,244 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 4,244 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 4,244 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 4,244 Aug-17-2020, 06:58 PM

User Panel Messages

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