Question: I'm looking for a tool that will play nicely with Python. 
Except for my Python requirement, my question is the same as this [one](https://stackoverflow.com/questions/74879/any-tools-to-generate-an-xsd-schema-from-an-xml-instance-document): 

> 
> "I am looking for a tool which will take an XML instance document and output a corresponding XSD schema."
> 
> 
>

Answer: 
According to the [PyCharm docs](https://www.jetbrains.com/help/pycharm/2016.1/generating-xml-schema-from-instance-document.html "PyCharm docs"), PyCharm has a facility for this. This is not exactly accessible by a program as an API. You are probably better off using [XML Schema Learner](https://github.com/kore/XML-Schema-learner) as a separate program since it is a command line program (subprocess friendly!).
Are you looking for something like [pyxsd](http://pypi.python.org/pypi/pyxsd)? (primarily used for validation against a schema) Or maybe [PyXB](http://pyxb.sourceforge.net/)? (can generate classes based on xml) Otherwise, I don't think there's a tool [yet] that will generate the schema from within Python. Can you do it on demand using something like xsd.exe? Does it have to be programmatic/repeatable?