Articles tagged with python

  1. New Feautures in Python 3.11

    Posted on in programming

    Here are some of the new features in Python 3.11:

    • Fine-grained error locations in tracebacks. Python 3.11 now provides more information about the location of errors in tracebacks. This can help you to quickly identify the source of an error and fix it.
    • Exception Groups and except*. Python …
  2. Type Checking in Python

    Posted on in programming

    What is type checking?

    Type checking is a process of verifying that the types of variables, expressions, and statements in a program are consistent with the expected types. Type checking can be performed statically, at compile time, or dynamically, at runtime.

    Benefits of type checking in Python

    There are many …

  3. [Python] Patching platform.uname in Tests

    Posted on in programming

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    from unittest import IsolatedAsyncioTestCase
    from unittest.mock import create_autospec, patch
    
    from foo import is_foo, is_bar, platform
    
    class FooTestCase(IsolatedAsyncioTestCase):
        @patch(
            "platform.uname",
            return_value=create_autospec(
                platform.uname_result, system="Linux …
  4. [Python] Popular Search Terms

    Posted on in programming

    I thought it would be neat to keep an eye on the popular google search terms related to Python.

    The list below uses JavaScript from Google Trends. You can use the kebab menu icon to choose between "Top" and "Rising" search phrases.

  5. [Python] Socket Timeouts in urllib2

    Posted on in Programming

    Things have changed quite a lot since this post was originally written in 2016. Currently, I would recommend switching over to making asynchronous calls via aiohttp.

    One of my scripts that makes an API call has been failing silently lately. It appears that the connection is timing out, but I …

  6. Geeky Goals for 2016

    Posted on in uncategorized

    The new year is finally upon us. Traditionally, I have not been one to make New Year's Resolutions. This year, I decided that rather than a list of resolutions, I would create a list of goals. These are things I would like to achieve over the next year. In other …

  7. UnicodeDecodeError: 'ascii' codec can't decode byte

    Posted on in Programming

    Although I was getting this output in relation to one of my Jinja2 templates, it really isn't a Jinja2 problem.

    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 69: ordinal not in range(128)
    

    The bit of code here should be doing nothing more than printing a float …

  8. [Python] Empty String?

    Posted on in Programming

    I've mentioned before that empty strings in Python are false. This leads to a common if not string paradigm. Unfortunately, this can be problematic. Check out this snippet:

    >>> string = ""
    >>> if not string:
    ...  print("empty")
    ... 
    empty
    

    That pretty much worked out just as we imagined. The empty string returned False and …

My Bookshelf

Reading Now

Other Stuff