when i use python-docx , my IDE ,like pycharm wing , can't Auto-Complete it.
this code
````
from docx import Document
asd = Document()
asd.add_heading("test")
asd.save("cao.docx")
````
when i typing asd. add_heading can't Auto-Complete.
from docx.document import Document
asd = Document()
asd.save()
this code can Auto-Complete
but atention
TypeError: __init__() missing 2 required positional arguments: 'element' and 'part'
I am sorry for my poor english
This question would be better posted on StackOverflow. This issues list is for suspected bugs and feature requests.
As a matter of fact, docx.Document(...) is actually a method, which returns an object of the docx.document.Document class.
You hve been trying to treat this (docx.Document()) method as a class.
Hence, you shall use both the following imports, in order to get the visibility of the contents of docx.document.Document class:
from docx import Document
from docx.document import Document
I've commented over this closed issue, to highlight that perhaps they should have named this method by following the naming convention.
Say something like docx.create_document(...) -> docx.document.Document.
Most helpful comment
As a matter of fact,
docx.Document(...)is actually a method, which returns an object of thedocx.document.Documentclass.You hve been trying to treat this (
docx.Document()) method as a class.Hence, you shall use both the following imports, in order to get the visibility of the contents of
docx.document.Documentclass:I've commented over this closed issue, to highlight that perhaps they should have named this method by following the naming convention.
Say something like
docx.create_document(...) -> docx.document.Document.