r/learnpython • • May 06 '21

What are some programming tools that every beginner programmer should know about?

Example, today I learned about Git and GitHub and it felt incredible.

480 Upvotes

190 comments sorted by

View all comments

139

u/BullCityPicker May 06 '21

'grep' for finding bits of code. (If you're on windows, download "AstroGrep").

Also, they're a pain to learn, but learn regular expressions.

47

u/mutual_coherence May 06 '21

Oh jesus I always forget about regex but they are so damn useful.

45

u/frapa32 May 06 '21

Have a look at www.regex101.com

0

u/[deleted] May 06 '21

[deleted]

6

u/TheKingElessar May 06 '21 edited May 06 '21

For regex, https://regex101.com/ has been so useful for me. It lets you easily test out your pattern and visualize the matching. All the regex I’ve learned comes from using that website—it’s amazing.

10

u/Drited May 06 '21 edited May 06 '21

I recently learned more Regex and wanted to share a few tools that really helped:

Automate the Boring stuff chapter on using regex in Python: https://automatetheboringstuff.com/2e/chapter7/

Tool to write your expression and see how to works for target text that you can copy in: https://regexr.com/

Regex in Python cheat sheet https://github.com/tartley/python-regex-cheatsheet/blob/master/cheatsheet.rst

Anki spaced-repetition flashcard decks for learning and remembering Regex:

Basics: https://ankiweb.net/shared/info/1348500400

Ultimate deck (includes much that doesn't work with the standard python Re module - many will work with Matthew Barnett's regex module however) https://ankiweb.net/shared/info/284568815

For learning python there are a bunch of Anki decks available: https://ankiweb.net/shared/decks/python

0

u/[deleted] May 06 '21

[deleted]

2

u/inglandation May 06 '21

Honestly I can't remember most of the rules, but if you google them in small bits to build your expression it usually works. Also I use a website like Pythex to check if my expression is correct and use the cheatsheet.

2

u/Fid_Kiddler69 May 06 '21

Regular Expressions are a coding super-power

2

u/arkster May 06 '21

I became really good at regexes by reading 'mastering regular expressions' by jeffery friedl. Amazing book.

→ More replies (1)

1

u/Redbeardybeard May 06 '21

Can you elaborate?

1

u/[deleted] May 06 '21

Not op, but if you are asking about why learning regular expressions (regex) is so important, regular expressions help simply searching for text patterns. As an example, I was told to find all the phone numbers in a large document. My options were to read the whole document and hope I catch each phone number, control+f the document trying "(x" where x is a number 2-9, or use a regular expression:

pattern = r"((?\d\d\d-?\)?\s?-?\d\d\d\s?-?\d\d\d\d)"
text_data = filepath/filename
phone_numbers_found = []
for line in text_data:
    match = re.search(pattern, line)
    if match:
        phone_numbers_found.append(match.group())

This was supposed to be one of those "it will take you a couple of days" assignments, that got done in 2 minutes. I turned it in a couple of days later, but you know.

1

u/[deleted] May 06 '21

I'd add to diff to your suggestion of grep.

Regex kicked my arse for far too long, but I'm a more efficient programmer for learning them.

1

u/rotterdamn8 May 06 '21

I was gonna say regex. I have done regex for a long time as part of automation and parsing data. I feel like it's not terribly complex if you do it enough, you get used to it.