Menu

I get a NameError executing my python script

Help
2011-02-17
2013-01-25
  • Michael Halsig

    Michael Halsig - 2011-02-17

    I get this error:

    C:\Python27\python.exe "C:\Users\Public\Documents\Notepad++\PythonScripts\ClearReadOnly.py"
    Process started >>>
    Traceback (most recent call last):
      File "C:\Users\Public\Documents\Notepad++\PythonScripts\ClearReadOnly.py", line 1, in <module>
        for f in notepad.getFiles():
    NameError: name 'notepad' is not defined
    <<< Process finished.
    ================ READY ================

    I have installed the latest version of PythonScript but no matter what I do it keeps giving me this error. Do I need to install anything else. Thanks for your help

    Here is my code:

    for files in notepad.getFiles():
       notepad.activateFile(files[0])
       notepad.runMenuCommand('Edit','Clear Read-Only Flag')
    
     
  • Dave Brotherstone

    It looks like you're trying to run the script from Python itself.  You don't need to install (or use) Python to use the PythonScript plugin - it's a plugin like any other, and can be installed from the Plugin Manager.  From there, you can click the menu item Plugins -> PythonScript -> New Script, name your script, and paste your code.  Save it, and run it from Plugins->PythonScript->Scripts->

    Hope that helps.
    Dave.

     
  • Michael Halsig

    Michael Halsig - 2011-02-17

    Thank you. I followed your instructions and it worked.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.