Skip to content

Conversation

@TomNicholas
Copy link
Contributor

@TomNicholas TomNicholas commented Sep 10, 2025

Would close #1208, supercedes #1209.

To-do:

  • A non-executable repr
  • An executable repr
  • A nested repr
  • (Bonus) a nested HTML repr

@TomNicholas TomNicholas added enhancement ✨ New feature or request rust 🦀 Pull requests that update Rust code python Pull requests that update Python code labels Sep 10, 2025
@@ -0,0 +1,26 @@
pub fn dataclass_repr(class_name: &str, attributes: &[(&str, &str)]) -> String {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used a slice here because it seemed to be a simple way to pass an ordered list of str-str pairs. I first tried a HashMap but that doesn't preserve order which led to my reprs looking different every time!

Apparently there is an IndexMap thing that preserves insertion order, which sounds neat, but I didn't use that because it would have added a dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement ✨ New feature or request python Pull requests that update Python code rust 🦀 Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nicer python reprs (string and HTML)

1 participant