question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow more complex patterns (without context)

See original GitHub issue

At Python Brasil, we talked a lot about how Pattern obj is so limited and how we could improve it. The main point of the discussion was how we could implement other “types” of patterns:

patterns = [
    # 1)
    Pattern('ping', ping),
    RegexPattern(r'^ping \d*$', regex_ping), # "ping 123" would be accepted
    StartswithPattern('/ping', regex_ping), # "/ping bottery" would be accepted

    # 2) or
    Pattern('ping', ping),
    Pattern(r'^ping$', regex_ping, type='regex'),
    Pattern('/ping', regex_ping, type='startswidth'),

    # 3) or
    Pattern('ping', ping),
    Pattern(r'^ping$', regex_ping, validator=regex_validator),
    Pattern('/ping', regex_ping, validator=startswith_validator),
    # where regex_validator and startswith_validator are the checkers
]

I believe the second “kind of” pattern is the easiest for who will use Bottery. But I think we should discuss it better.

@nicoddemus @muriloviana @mawkee @ElSaico @leportella

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mawkeecommented, Oct 11, 2017

I think I prefer the first option. This would give us more flexibility for extra attributes depending on the pattern class; for instance, it’d make sense for RegexPattern to be able to use named groups, but that would make zero sense for Pattern. It’d be easier for IDEs to show some hints based on the pattern class

Even though 2 could potentially be easier to implement, on the long run it could increase complexity.

1reaction
leportellacommented, Oct 11, 2017

Although I think that the second (2) option seems as an easier way to remember things, I personally prefer the first one.

I think the first option would be easier to remember, easier to document and generates lines with less characters, which makes it more readable. Also, you can explore and individualize each of the patterns very well, which seems easier for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reshaping Context Patterns - Quantum Leaders
Learning to reshape Context patterns becomes a critical skill for both ... we are young to handling more complex situations as we mature....
Read more >
A Leader's Framework for Decision Making
Complicated contexts, unlike simple ones, may contain multiple right answers, and though there is a clear relationship between cause and effect, not everyone ......
Read more >
What's in a Context? Cautions, limitations, and potential paths ...
Secondly, context in this paradigm is complex, involving multiple dimensions in the environment (e.g., color, texture, pattern), as well as ...
Read more >
Making sense of complexity in context and implementation ...
Complex interventions usually comprise multiple components, which may act independently or interdependently, with the 'active ingredient(s)' ...
Read more >
Content filtering in Amazon EventBridge event patterns
Amazon EventBridge supports declarative content filtering using event patterns. With content filtering, you can write complex event patterns that only match ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found