Reportlab - Command
Question: I am new to python and reportlab, but trying to generate a PDF file where I
write my hostname into it.

This is my code, and the title. How can I print my hostname and generate a PDF
with it?

    
    
    #!/usr/bin/python
    
    from reportlab.pdfgen import canvas
    def hello():
            c = canvas.Canvas("helloworld.pdf")
            c.drawString(250,800,'Hello world')
            c.showPage()
            c.save()
    hello()
    


Answer: Since you don't mention your platform (win, macos, linux) then I will give you
a generic way to find your hostname in python.

To get the hostname you use the socket library and the gethostname function
from that, so the final function would look like this:

    
    
    from reportlab.pdfgen import canvas
    from socket import gethostname
    def hello():
            c = canvas.Canvas("hostname.pdf")
            c.drawString(250,800,gethostname())
            c.save()
    hello()
    

