On 19/07/16 12:31, Marc Sànchez Quibus wrote: > and now I need some help to finish my project. > I have two scripts, one of them in python (the main script) and the other > one written in html. Well, is just a brief javascript (an app) that I took > by Github. I need to change a variable inside this html script. I was > wondering wether I could change this variable from my python script or not. > Is there some way to do it?
The easiest way is to put the entire html code into a string inside a module: # file: myhtml.py ######## html = """ <html><body><h1>Hello %s</h1><body></html> """ Then import that and use string formatting to insert the variable #file: myscript.py import myhtml myvar = "World" print myhtml.html % myvar Instead of printing you could overwrite the original html file. Or you could write a web based app using a framework like Flask or Pylons and call your myscript.py from a web url and get it to just serve the html string directly. We don't know enough about your system and how the two scripts are related to say more than that. But it might give you some ideas. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor