Skip to content

Instantly share code, notes, and snippets.

@bmaggard
bmaggard / myurlparse.py
Created June 24, 2024 20:10 — forked from alexwlchan/myurlparse.py
Helper functions for dealing with query strings in URLs
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
Utility functions for dealing with URL query strings in Python,
i.e., URLs of the form
http://example.net?field1=value1&field2=value2
This module includes a pair of helper functions: one for getting the values
associated with a particular field; another for setting the query string
@bmaggard
bmaggard / literal_string.py
Created February 12, 2023 00:40 — forked from paulkernstock/literal_string.py
Literal block scalars with PyYAML's dump
import yaml
from yaml.representer import SafeRepresenter
class LiteralString(str):
pass
def change_style(style, representer):
def new_representer(dumper, data):
scalar = representer(dumper, data)