**The Rub**

You need to make a function that takes an object as an argument, and returns a very similar object but with a special property. The returned object should allow a user to access values by providing only the beginning of the key for the value they want. For example if the given object has a key `idNumber`, you should be able to access its value on the returned object by using a key `idNum` or even simply `id`. `Num` and `Number` shouldn't work because we are only looking for matches at the beginning of a key.

Be aware that you _could_ simply add all these partial keys one by one to the object. However, for the sake of avoiding clutter, we don't want to have a JSON with a bunch of nonsensical keys. Thus, in the random tests there will be a test to check that you did not add or remove any keys from the object passed in or the object returned.

Also, if a key is tested that appears as the beginning of more than one key in the original object (e.g. if the original object had a key `idNumber` and `idString` and we wanted to test the key `id`) then return the value corresponding with whichever key comes first **alphabetically**. (In this case it would be `idNumber`s value because it comes first alphabetically.)

**Example**

```python
o = partial_keys({"abcd": 1})

o['abcd'] == 1 # true
o['abc'] == 1 # true
o['ab'] == 1 # true
o['a'] == 1 # true

o['b'] == 1 # false!
o['b'] == None # true

list(o.keys()) # ['abcd']
```

Source: codewars | Difficulty: EASY

Starter code: def __getitem__(self, key):
	

Solutions:
def partial_keys(d):

	class Dct(dict):

		def __getitem__(self, pk):
			k = min((k for k in self if k.startswith(pk)), default=None)
			return k if k is None else super().__getitem__(k)
	return Dct(d)


class PartialKeysDict(dict):

	def __init__(self, *args, **kwargs):
		super().__init__(*args, **kwargs)
		self._keys_list = sorted(self.keys())

	def __getitem__(self, key):
		for q in self._keys_list:
			if q.startswith(key):
				return super().__getitem__(q)
partial_keys = PartialKeysDict


class partial_keys(dict):
	__getitem__ = lambda self, key: self.get(next((k for k in sorted(self.keys()) if k.startswith(key)), None), None)


class partial_keys(dict):

	def __getitem__(self, key):
		if key in self:
			return super().__getitem__(key)
		for k in sorted(self):
			if k.startswith(key):
				return super().__getitem__(k)


class partial_keys(dict):

	def __getitem__(self, key):
		return next((v for (k, v) in sorted(self.items()) if k.startswith(key)), None)


import re

def partial_keys(d):

	class MyDict(dict):

		def __getitem__(self, item):
			for key in sorted(d):
				if re.match(item, key):
					return d[key]
	return MyDict(**d)


class partial_keys(dict):

	def __getitem__(self, key):
		keys = sorted((k for k in self.keys() if k.startswith(key)))
		if keys:
			return dict.__getitem__(self, keys[0])