[need help] Python is crashing and stripping charactors
5 23 Jan 2016 18:44 by u/monoxane
So I'm writing an IRC bot and one of the functions replies with a subverse link if it sees 'v/
if data.find('v/') != -1: x = data.split('#')[1] x = x.split('v/')[1] subverse = x.split(' ') subverse[0] = subverse[0].strip(' ' + subverse[1]) subverse = str(subverse[0]) Send(str('voat.co/v/') + subverse) ~~~
Hoping someone can help, if you can, ill pm you the git repo.
2 comments
2 u/AStoney 24 Jan 2016 22:59
I am not a big fan of Python, (bad experiences with white space dependent languages) but is there a reason you don't use Python's Regular Expression. RegEx is hugely helpful and might help you more easily understand what you were trying to do if you have to come back to it.
Python RegEx
0 u/oddlydrawn 24 Jan 2016 22:42
Something like this?
Edit: It could be improved, though. Instead of get_sub_word() returning a single word, it could return a list of words to find every subname instance. You should probably also check if the sub exists.