Python source code not getting detected

Issue #1442 new
Amal Murali
created an issue

Thank you for the great work on this library! The issue I've discovered is that guess_lexer() is not finding this (among other snippets) as Python source code:

out=open('', 'w').write

n = 300

for i in range(1, n + 1):
    out(' '.join('%d'%(i * j) for j in range(1, n + 1)) + '\n')

Or any of these: - - -


What can it detect as Python source code? I'm trying to understand why. Could anyone please shed some light on this problem?


Comments (2)

  1. Amal Murali reporter

    Is it because of this condition in lexers/ line 240?

        def analyse_text(text):
            return shebang_matches(text, r'pythonw?(2(\.\d)?)?') or \
                'import ' in text[:1000]
  2. Log in to comment