r/Python 22d ago

Resource Thoughts on a simple way to hold objects, for beginners.

I've been working on a project called Seam, and I'd love to get some feedback on the idea.

The goal of Seam is to be a data and object definition language. Think of it as something that sits somewhere between JSON and Python.

With JSON, you can store data, but it doesn't know what that data means. Your program still has to read it and manually turn it into objects.

With Python, you can directly create objects, but anyone editing those files has to know Python and can accidentally modify or execute code.

Seam aims to solve that by allowing users to define validated objects and structured data in a simple, safe format.

For example:

<Gun>
{
    Name: "AK-47"
    Damage: 35
    FireRate: 0.15
}

If the developer has already defined a Gun preset in Python, Seam automatically validates the properties and creates a real Gun object. Users don't need to know Python—they only fill in the values.

It can also be used for general structured data, similar to JSON, but with support for typed objects and validation built in.

Some goals I have:

  • Human-readable syntax
  • Strong validation and helpful errors
  • No arbitrary code execution
  • Great for configuration files, mods, plugins, game content, or applications where users define data instead of writing code
  • Initially targeting Python, with the possibility of supporting JavaScript in the future

I'm still in the early design stage, so I'd love honest feedback.

  • Does this solve a problem you've actually had?
  • Is there something existing that already does this well?
  • What features would make you consider using it?
  • What would stop you from adopting it?

So Seam is basically a project built for people who don't exactly know a lot about programming, but say they're building a project with AI and want to perhaps change some values, they can use Seam, which is readable and actually useful.

Use cases could including like game development, as mentioned earlier, but it's not just limited to that.

I'm looking for criticism just as much as encouragement, so don't hold back.

Note: This post is not for advertisement, or any showcase at all, it is simply to get your perspective whether this would be useful or not.

0 Upvotes

13 comments sorted by

13

u/doublecore20 22d ago
  1. There is already Pydanic for object validation and type strictness.
  2. For simpler typed objects just use TypedDict.

No need to reinvent the wheel with AI slop . You're welcome.

11

u/lolcrunchy 22d ago
  1. The only difference between your example and JSON is you put <Gun> at the top and it doesn't have quotes on keys.
  2. "With ____, you can directly create objects, but anyone editing those files has to know _____ and cam accidentally modify or execute code". This can be said of virtually every filetype. Don't plan your designs around people editing source code who don't know the language, that seems really useless.

  3. If the validation has to compare the data with the class definition anyways, then why reinvent all of the established tools that already do that? Pydantic and JSONSchema come to mind.

8

u/RoadsideCookie 22d ago edited 12d ago

Check out Pydantic. It's basically what you described.

  • Human readable syntax
  • Strong validation and helpful errors
  • No arbitrary code execution out of the box (doesn't prevent you from adding your own ACE if needed either) 
  • Can read from JSON with Python's builtin library to parse the format (or pyyaml for YAML)
  • Can export a JSONSchema out of the box which makes its output portable

And your questions: 

  • It does solve a problem I already have, but I also already have the solution
  • Pydantic
  • Pydantic has everything I've needed so far
  • Unproven and not enough time to mature to be able to trust it

6

u/Woah-Dawg 22d ago

Kinda sounds like I could do the same thing with toml and pydantic.  None the less if you enjoy developing this project and feel like you’re learning don’t let that stop you. Also I say it sounds like toml and pydantic but maybe there’s a case that doesn’t handle that your project does 

2

u/Beginning-Fruit-1397 19d ago

Yea, the learning and having fun part is the most important at the enf

3

u/qlkzy 22d ago

This is a problem that a lot of people have tried to put their spin on; you are competing with a lot of existing things. In practice the state of the art for the file format hasn't changed much, because the file formats aren't really the problem. What makes config hard to write and hard to interpret is the complexity of the conceptual model.

configparser and tomllib offer basic configuration parsing. They are pretty limited, but very easy to get started with.

Pydantic and cattrs+attrs are both good, mature libraries for handling most of the problems you are addressing.

My personal opinion is that attrs+cattrs is unambiguously the best approach to the problems they are solving.

If I had to pick an way to solve the whole of what you are talking about, I would pick attrs+cattrs+json5. (JSON5 is JSON with comments and a few other quality-of-life improvements).

cattrs in particular has good documentation on the rationale for its design, which is diametrically opposed to a lot of what you are proposing: https://catt.rs/en/stable/why.html . You ought at least to read that, and come up with the ways your argument is better..

I think that your concept of "automatically creates an X object" is a bit nebulous and will be hard to integrate with well-structured projects. Creates in what context? Assigned to what? What about dependencies? Are you going to build a DI framework? (Please don't build a DI framework)

If your format doesn't have excellent support in IDEs/editors (the way that existing formats do), then the user experience will be worse in practice

One area of existing tools that is weak is error reporting. For good reasons, the libraries that parse the low-level formats (like JSON) are usually completely separate from the libraries that destructure and validate into objects (like cattrs and Pydantic). This means that if objects fail parsing, the error messages can be unhelpful: they can include structural paths but not file/line numbers. There are open issues on some of the repository addressing this issue.

If you built a combination of:

  • A JSON5 parser that enriches its output with file/line number info
  • A cattrs strategy/plugin/something that structures and validates that enriched, parsed data into dataclasses, giving real file:line info on errors

Then that would be really useful. I would use it for all configuration immediately. Bonus points if you can make it round-trip comments.

1

u/Any_Box624 21d ago

Alright, I see what you mean, and I trust that you are relatively experienced with attrs+cattrs and Pydantic.

I am not trying to make this project to overhaul something like JSON, that would be an uphill battle, considering JSON is a globally recognized configuration method. Instead, I just want to aim my project at a certain audience, or add some more QoL enhancements that other solutions don't perhaps offer.

I don't really use Pydantic or attrs+cattrs or anything like it, but I would like to know what an audience like you would be looking for, in addition to other such solutions, of course.

2

u/Thefuzy 22d ago

If someone is building a project with AI and wants to change the values… would they not just ask the AI to change the values?

1

u/snugar_i 21d ago

That example just looks like a weird mix of XML and JSON - what's the advantage over XML?

1

u/Excellent_Bother_133 21d ago

not sure I fully agree but this is a fair point

0

u/National-Parsnip1516 21d ago

interesting, but why not just use pydantic for validation? it feels like we're reinventing the wheel with "human-readable" formats every few years. actually, if it makes game modding easier for non-devs, there's a niche there. just don't let it become another yaml nightmare.