PyCharm… and my regex learning…

So I installed PyCharm today… I know I’m a VIM user, and I could use vim to write my python code very easily, but I’ve learned, both from past experience (i.e. an older job where I wrote PHP via VIM) and my current experience (i.e. my current job where I write Javascript/HTML 5 via VisualStudio) that there are some features that an IDE provides that are incredibly useful.

For me, 2 of the most useful features are the debugger (being able to see my python results immediately, and having clues about bad pythonic form) and being able to jump around based on a function (meaning if i’m making a function call, in the code, I can highlight the function call itself, click a key, and jump to the definition of the function… very useful!

I’m sure there are lots of different ways VIM can do things as well, but so far, I’m happy with PyCharm and will continue to use it!

On a different note, I’m working on learning regex. Regex is one of those things that have popped up since I took programming in college, and has really only been something seen as very minor in the peripheral view of coding… But i’m realizing its usefulness more and more, so I started working on it…

My first big breakthrough was on my gaming program i’m working on… Of course, when making a RPG Game manager, you are going to need dice rolled, and I know that python has the randint function to simply give me a single random die roll, but I wanted to be able to handle all kinds of die situations… one of them was for rolling stats for an NPC… so I would pass in ‘6@4d6!1’ into the die roll parser… (which basically means roll 4d6, drop the lowest result, and do that 6 times – giving me all 6 individual results)

In my javascript version, I was using this complex set of ifs to loop through each character in the string, to determine if there was an @ symbol, etc… Then I learned about grouping in regex, and was able to use ‘(\d*)@*(\d+)[Dd](\d+)([\+\-\*/!\^]*)(\d*)’ to group everything I needed in 1 statement… now I had groups that had the values I needed instead of trying to parse individual characters from the string…

I’ve seen the light!

Whole Lotta Love – Led Zepplin
Never B Flat, Sometimes B Sharp, Always B Natural