16 lines
669 B
Python
16 lines
669 B
Python
import collections
|
|
|
|
def glue(*args, **kwargs):
|
|
def flatten(l):
|
|
for el in l:
|
|
if isinstance(el, collections.Iterable) and not isinstance(el, basestring):
|
|
for sub in flatten(el):
|
|
yield sub
|
|
else:
|
|
yield el
|
|
what_to_glue = list(args)
|
|
kwargs = collections.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
|
|
what_to_glue = flatten(what_to_glue)
|
|
return " ".join(what_to_glue)
|