Re: [code] Textadept in the migration from Python2 to Python3

From: Arnel <rcl.att.openmailbox.org>
Date: Fri, 22 Apr 2016 00:19:30 +0800

On 21 April 2016 03:59PM, Pedro Andres Aranda Gutierrez wrote:
> Hi folks,
>
> I'm starting to migrate from Python2 to Python3. No problems in Python2,
> but since the default program bindings are for Python2, I get tons of false
> warnings and errors.
> I'm currently marking migrated Python3 scripts with the following shebang:
>
> #!/usr/bin/env python3
>
> Is there any way to take this into account. At least to avoid false
> positives when saving files...
>
> Best, /PA

To identify Python3 scripts, you could add these to your 'init.lua':

   textadept.file_types.patterns['^#!.+[/ ]python3'] = 'python3'

   textadept.run.syntax_commands.python3 = function()
      return ([[python3 -c
      "compile(open('%f').read(),'%f','exec',0,1)"]]):gsub('%%f',
      (buffer.filename:gsub('\\', '\\\\\\\\'))) end

   textadept.run.run_commands.python3 = 'python3 -u "%f"'

(You may need to adjust the indentation.)

That covers the syntax-checking and "run" commands for Python 3, at least.

However, if we change the default file extensions like so:

   textadept.file_types.extensions.py = 'python3'

TA would read that as "all files ending in '.py' are Python3." Your Python2
scripts won't get identified as Python2 scripts.

----
Thank you,
Arnel
-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Thu 21 Apr 2016 - 12:19:30 EDT

This archive was generated by hypermail 2.2.0 : Fri 22 Apr 2016 - 06:52:13 EDT