[Tutor] Debugging skills

ThreeBlindQuarks threesomequarks at proton.me
Fri Jan 5 17:01:28 EST 2024


Mats,

In theory, regular expressions were intended to be largely language independent and initially fairly simple. So any stand-alone program could take a regular expression and try to tell you in other more detailed words what it might be doing.

In practice, languages like PERL made their own extensions or interpretations and there are often flags external to the RE string that also guide what it does and those are far from standardized. Python has multiple variations including asking for some PERL compatibility.

Still, it may be possible to have a tool that takes in a string containing the RE, perhaps sanitizes it by removing for example the comments allowed in some versions, asks some questions on what setting you are using, and gives a half decent answer.

In practice, I have often found it best NOT to make a humongously complex RE. Instead, some purposes are better done in stages, including some not directly using regular expressions and the stages together perform the required result with each step being able to be somewhat understood and results checked. I suspect a really complex RE, with any tool, might be as hard to understand as some legalese that keep mumbling about the party of the second part until you forget what the topic is and start over.





Sent with Proton Mail secure email.

On Friday, January 5th, 2024 at 8:56 AM, Mats Wichmann <mats at wichmann.us> wrote:


> On 1/4/24 14:58, dn via Tutor wrote:
> 
> > > > Interestingly the paper book version of my tutorial has a chapter on
> > > > debugging. However, I've never got round to adding that chapter
> > > > to the online version. I probably should...
> > > 
> > > That would be cool.
> 
> 
> while we're nattering on a whole range of sort-of-debugging topics,
> here's something I've occasionally wondered about, when a beginner has
> written something that makes sense only to them, not to the Python
> interpreter. Regexes are confusing, so there are several websites (see
> for example regex101.com) where you can enter your "code" (regex) and as
> it's interpreted, will show you an explanation in words in a separate
> pane. Does anyone know if there's a similar thing for Python code?
> "This is what you wrote actually means to the interpreter". Ones I know
> about (like at Programiz, w3schools, online-python) don't attempt the
> explanation part. It's not something that's likely to be useful for
> very many cases, but I could see where in the beginning there might be
> some benefit...
> 
> 
> 
> 
> 
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list