This commit is contained in:
Tyrel Souza 2014-10-30 14:07:41 -04:00
parent fa4b3396b6
commit a3479b618d
2 changed files with 27 additions and 0 deletions

View File

@ -1,4 +1,7 @@
from collections import OrderedDict
def glue(*args, **kwargs):
what_to_glue = list(args)
kwargs = OrderedDict(sorted(kwargs.items(), key=lambda t: t[0])) # I dont care what order you submit them in, they will be alphabetical
what_to_glue.extend([v for k,v in kwargs.iteritems()]) # Ignore all your keys, because you're doing this wrong anyway
return " ".join(what_to_glue)

24
tests.py Normal file
View File

@ -0,0 +1,24 @@
import unittest
from glue import glue
class GlueTests(unittest.TestCase):
def setUp(self):
pass
def test_tuple(self):
output = glue("why", "would", "you", "run", "these", "tests")
assert output == "why would you run these tests"
def test_tuple_and_named(self):
output = glue("why", "would", "you", "run", "these", "tests", who="bozo")
assert output == "why would you run these tests bozo"
def test_named(self):
output = glue(what="bozo", who="clown")
print output
assert output == "bozo clown"
if __name__ == '__main__':
unittest.main()