Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Sunday, October 28, 2018

Pass environment variables to pythons using sudo while invoking it


  • sudo -E PYTHONPATH=${PYTHONPATH} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} python
  • Create simple webserver in python


    To create simple web server in python run below command in shell
    python -m SimpleHTTPServer 5000
    this will start serving pages at the address http://localhost:5000 and will show files from the location from where command is ran.

    Tuesday, September 25, 2012

    Print Hex numbers with leading zeros in python

    To print Hex numbers with leading zeros in python, I have used following code,

    
    
    
    for i in range(0,32):
        print '0x%0.8X' %(1<<);