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!).
Currently, there is no module that will run within your python program and do this conversion. But I see the problem of creating a XSD schema from XML as a tooling problem. It's the kind of functionality that I'll use once, to get a schema started but after that I'll be maintaining the schema myself. From reading a single XML file the XSD generator will create a starting point for a real schema, it cannot infer all the functionality and options offered by XSD. 
Basically, I don't see the need to have this conversion run as a module inside of my code, generating new XSDs every time the XML changes. After all, it's the schema that defines the XML not the other way around.

As end-user pointed out you could use xsd.exe but you might also want to look at other tools such as [trang](http://www.thaiopensource.com/relaxng/trang.html) (a bit old) for Java and [stylusstudio](http://www.stylusstudio.com/) (XML tool).