#!/usr/bin/python3
# -*- coding: utf-8 -*-

# %% Container conversions
"""
list(s)
Converts s to a list.
"""
# This is often heplful:
char_list = list("string")
print(char_list)

# and back to the string
print("".join(char_list))

"""
tuple(s)
Converts s to a tuple.
"""
print(tuple([1, 2, 3]))

"""
set(s)
Converts s to a set.
"""
# Great way to grab unique values:
print(set([1, 1, 1, 3, 4]))

"""
frozenset(s)
Converts s to a frozen set.
"""
aset = set([1, 2, 3])
print(frozenset(aset))

"""
dict(d)
Creates a dictionary.
d must be a sequence of (key,value) tuples.
"""
print(dict([("key1", 1), ("key1", 2), ("key3", 3)]))


"""
str(d)
Creates a string.
Converts s to a string.
"""
adict = dict([("key1", 1), ("key1", 2), ("key3", 3)])
print(str(adict))
# Much can be converted to str,
# which is sometimes what happens when a thing gets printed.