def vendor_import(module_name):
	"""Tries to import a module name ``module_name`` using the standard Python
	`import` statement and return the imported module. If the import fails,
	tries to import a module of the same name from within ``igraph.vendor``
	and return that module instead.
	"""

	parts = module_name.split(".")

	try:
		result = __import__(module_name, level=0)
	except ImportError:
		result = __import__("igraph.vendor.%s" % module_name, level=0)
		parts[0:0] = ["igraph", "vendor"]

	parts.pop(0)
	while parts:
		result = getattr(result, parts.pop(0))

	return result