Note that there are some explanatory texts on larger screens.

plurals
  1. POPython, removing required quotes from input()
    primarykey
    data
    text
    <p>Ok, I've been putting together a script (with much help from here) and it's working (essentially the script updates html files that are on a static server, ie. no php, so I can change menus, sidebars, etc.), but there's an annoying thing that happens with the input part. Depending on which computer or which version (or versions) of python I have, I either need to include quotes for my input or I don't. On my linux laptop, I need quotes; on a windows laptop (that only has python3.3 on it), I don't need quotes; on a windows desktop that has had 2.5, 2.7 and now 3.3 on it I need quotes when I run it in commandline (even though it's running through C:\Python33\py.exe), but not in IDLE?? This is strange...</p> <pre><code>import os import glob import fileinput if __name__ == '__main__': # Menu should not have any marker, just pure contents with open(input('Enter Update File: ')) as f: menu_contents = f.read() # Initialize a few items start_marker = '&lt;!--begin-menu--&gt;' end_marker = '&lt;!--end-menu--&gt;' file_list = [] for root, dirs, files in os.walk(input('Enter Directory: ')): file_list += glob.glob(os.path.join(root, '*.html')) found_old_contents = False # Loop to replace text in place for line in fileinput.input(file_list, inplace=True): line = line.rstrip() if line == start_marker: found_old_contents = True print(line) print(menu_contents) elif line == end_marker: found_old_contents = False if not found_old_contents: print(line) </code></pre> <p>Is there a way to avoid this?</p> <p>Otherwise, I suppose I'll start researching how to just call an explorer dialog up so I can just pick a file and a folder... Any thoughts on this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload