Skip to content

Conversation

@maximlt
Copy link
Member

@maximlt maximlt commented Nov 12, 2025

Resolves #934

I've wanted for a long time to extend the README with more examples, and update the landing page a little bit too.

@maximlt
Copy link
Member Author

maximlt commented Nov 12, 2025

Test failure is unrelated.

Copy link
Member

@jbednar jbednar left a comment

Choose a reason for hiding this comment

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

Nicely done! Thanks for doing this.

# => {'mode': 'accurate', 'name': 'Processor00042', 'retries': 3, 'verbose': False}
```

Runtime attribute validation is a great feature that helps build defendable code bases! Alternative libraries, like [Pydantic](https://docs.pydantic.dev) and others, excel at input validation, and if this is only what you need, you should probably look into them. Where Param shines is when you also need:
Copy link
Member

Choose a reason for hiding this comment

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

I'd personally say that Pydantic focuses on sanitization or coercion rather than validation, coercing values rather than rejecting them (see pydantic/pydantic#578 (comment)), but maybe that's too much detail to get into here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I think they've gone back and forth on how they want to describe themselves between validation and parsing/coercion. In v2, they added a strict mode (configurable per class or per field) that prevents coercion, and decided to stick to "validation" (more info in the middle of this long blog post https://pydantic.dev/articles/pydantic-v2#im-dropping-the-word-parse-and-just-using-validate).

image

I'd prefer to stick to "validation" here as a general term.

def __init__(self, **params):
super().__init__(**params)
self.param.watch(lambda event: print(event), 'a') # 1.

Copy link
Member

Choose a reason for hiding this comment

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

Is it truly necessary to have an __init__ here? I worry that it conveys a level of complexity that param users can generally avoid, even when doing reactive programming.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, I could remove it, instantiate the class, and then attach the watcher with sfe.param.watch(...) but it's not the same, as what I generally want is for all the instances to have the watcher set up. I believe that having to override __init__ is very common when writing Parameterized classes (and is a reason why I want to add post_init).

README.md Outdated
sfe.b = 'bar'
# print_b: self.b='bar'

@param.depends(sfe.param.c, watch=True) # 3.
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest not documenting using depends() outside of a class because of how the decorator syntax encourages early binding to a reactive object, which I think limits how the function can be used. I don't know of any advantage that usage has over bind and would always steer users to bind instead when using functions.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm curious about what others think (and believe it's time to reach a clear consensus) so I asked on Discord, quoting your comment. Not sure how long it'll take for people to answer, and if there will actually be a consensus (I guess yes but who knows). In case it takes too long, I think this could still be merged as is, and the README updated based on feedback later.

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed these examples.

@maximlt
Copy link
Member Author

maximlt commented Nov 13, 2025

Added a section with allow_refs=True to help users understand how they can directly use bound functions/reactive expressions in Param without having to rely on another framework to introspect them. Also made a few minor edits. I'm going to merge as the README can easily be edited later (its changes being directly reflected on Github).

@maximlt maximlt merged commit 0b66fe6 into main Nov 13, 2025
15 checks passed
@maximlt maximlt deleted the readme_landing_page branch November 13, 2025 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discussion about the intro video

3 participants