Skip to main content

Posts

Showing posts with the label aware

Be aware of the count 0 when using Pythons re sub to find and replace text

I have an xml file and I want to remove a whole section of element without actually parsing the XML file. I wrote an Python script to do just that. I first tested it out like this: import re input_text = open(my.xml).read() result = re.findall(r<library-ref>.*</library-ref>, input_text, re.S) print(result) The result IS what I wanted, so I thought I can quickly replace it with something like this: result = re.sub(r<library-ref>.*</library-ref>, , input_text, re.S) And to my surprise this does not work. It took me a while to notice that I mis used the method according to the documentation, which has this signature: re.sub(pattern, repl, string, count=0, flags=0) At first glace, I thought that count is already default to zero and I do not need to set it, but because that is a positional parameter, you must include it! So you suppose to call it explicit like this: result = re.sub(r<library-ref>.*</library-ref>, , input_text, 0, re.S) Or, if you like, yo...

Battlefield Hardline Open Beta EA Aware Of Issues Some Servers Working Already Notice

Just a quick post for those playing the Battlefield: Hardline Open Beta this weekend, finding that things were going fine until just a bit ago, and now seeming like they cant join any servers and seeing errors like the one below, noticing that the website (Battlelog) isnt working right, their Stats are gone (Rank Zero), etc... This is just a little notice that EA is aware of the issue and is working on it. You should find that servers are already coming back up now and things are straightening out already (way to go, EA!). Open Beta has been Extended until sometime Monday night (Feb.9th). Woot! See You In The Game!