Skip to content

Passing dictionary values to a function, with missing keys

I have a class with a constructor that receives several arguments. These arguments I get from an external file, which is a list of dictionaries. My problem is that some dictionaries have missing fields. If a field is missing, I want the constructor to simply receive None instead. But as the code is written no…

Wrong result with regular expressions

Any idea why the regular expression below cuts the ‘fl’ part of the sentence ? This is the result I get : Answer You’re replacing all non-alphabetical characters with whitespace. In your code, the ‘fl’ is actually fl – a single unicode (non-AZ) character, so it is being remo…

Strange gzip – almost extracted, but not totally correct

Some program sends some info that starts with x1fxe2x80xb9x08x00x00x00x00x00x04x00M… to the server and receives the text response. I need to guess what info is it. In fact, I need the method to convert the real string to that identical gzipped original string to receive responses without that program. A…