learnbyexample/py_regular_expressions

Make examples copy pastable

timlt3 opened this issue · 2 comments

Hi Sundeep!

I'm enjoying your book so far.

My feedback is for examples like this on page 25

>>> para = '''\
... (mall) call ball pall
... ball fall wall tall
... mall call ball pall
... wall mall ball fall
... mallet wallet malls
... mall:call:ball:pall'''

since you've included the REPL characters, it makes it difficult to copy and paste this example string to work with.

If you could please include a copy pasteable code block I think that would be great. I think a stretch goal would be to include all these exercises in something like a jupyter notebook so we don't have to all the questions out :)

Hello Timothy.

Thanks for the kind words :)

Exercises with multiple line strings are rare, so I'm not inclined towards making a change just for this. And you could remove the ... part using regex or the replace() string method ;)

That said, I agree with you regarding an interactive tool for exercises. I've already written a TUI app which you can find here: https://github.com/learnbyexample/TUI-apps/tree/main/PyRegexExercises. However, some of the exercises had to be changed and not all of them could be adapted. I hope you'll find this tool useful. You could solve the exercises there and then do a quick glance from the book for the rest.

All good, I've just been typing the examples out. Thanks again for this great resource!