Sublime Text Editor Anaconda package Autoformat PEP8 Errors doesn't automatically reformat comments that are too long - comments

I'm trying the STE Anaconda's autoformatting feature and it works well with every other PEP8 feature but seems to not change any lines that are like:
def foo(): # asasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasas
pass
even though the line is clearly longer than the PEP8 limit. Is there a setting that I'm missing or does Anaconda not cover this with it's autoformatter? Are there any other PEP8 formatting packages / comment wrapping packages that anyone recommends?
Alternatively, are comments exempt from this 79 character limit by any chance?

Related

Jedi-vim: No auto-complete on dot (.), testing shows erroneous "no python" error

I just installed jedi-vim and supertab (because I already had something bound to <C-Space>). <Tab> now shows the autocomplete menu and it's working pretty well, however I don't see any menus when I hit ..
If I use <Tab> in insert mode after pressing ., I get the normal menu that doesn't have the context of the name preceding the dot (and it's not at all useful because of it).
:verbose imap . says No mapping found, but I'm guessing that's not how jedi-vim works.
In my effort to troubleshoot the issue I've disabled my other plugins and replaced my .vimrc with just execute pathogen#infect().
Now, when I :e foo.py I see: "Error: jedi-vim failed to initialize Python: jedi-vim requires Vim with support for Python 2 or 3." I didn't get this error before, and :version shows that I have both Python 2 and 3 support.
Scriptnames: https://gist.github.com/hovissimo/a2413d6a5d0e1be356c0
:version: https://gist.github.com/hovissimo/f5a0e630edac8756397e
Edit:
:JediDebugInfo says Using Python Version: null
I don't know why I didn't see the error before, but it looks like my python3 integration in Vim was in fact broken.
I had Python 3.5 32-bit installed, but I was using a 64-bit version of Vim. Installing a 32-bit version of Vim (making sure it was compiled for python35) seems to have fixed all problems.

How do I import Zbar into my Python 3.4 script?

I am pretty new to programming, and have never used Zbar before. I am trying to write a simple script that will allow me to import Zbar and use it to decode a barcode image. I already have a script set up to decode text from images that uses Pytesseract and Tesseract OCR, but I need to be able to decode barcodes as well. I have Windows 7 32 bit, and and am using Python 3.4. I have already installed Zbar and have used it from the command line successfully to decode their barcode sample. I have tried using >pip install zbar, but I keep getting the error:
"fatal error C1083: Cannot open include file: 'zbar.h': No such file or directory
error: command 'C:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\cl.exe' failed with exit status 2"
Getting the pytesseract OCR was painless but I have wasted a lot of time on this barcode portion of it, any help or alternatives would be much appreciated.
Seven months later you accepted the best answer, a simple solution for
python3.4+ on Windows OS appeared. A ctypes-based wrapper around the zbar barcode reader, a package named pyzbar. If you are on Linux, you need to install libzbar0 but you said you are using Windows and the zbar library is included as dll with the Windows Python wheels. Today, all you need to do is launch:
pip install pyzbar
References for the package:
https://pypi.python.org/pypi/pyzbar
https://github.com/NaturalHistoryMuseum/pyzbar/
I thought I'd share my explorations and discoveries in relation to this problem, even though #ltadams21 has found a workaround.
The short answer: You can't. The zbar module is only compatible with Python 2. The incompatibilities are at the level of the Python C API, which is deep magic beyond my ken.
There's a bug report for this. In the meantime, use the os.system workaround that #ltadams21 posted, or maybe try zbarlight instead? (I haven't tried it myself, because it says it only reads QR codes, and I need something that reads EAN barcodes.)
The long answer: You can follow along with these steps, which represent my best efforts to get it working, but (spoiler alert) it still won't work at the end.
(Re)install zbar for Windows (zbar-0.10-setup.exe), making sure to tick the "Development Headers and Libraries" option.
Download and extract the zbar Python package (zbar-0.10.tar.bz2).
Open setup.py in your preferred text editor.
Scroll to the bottom, find the line that starts libraries, and insert a new line below it, like so (checking that the path is the same on your system as it is on mine):
libraries = [ 'zbar' ],
include_dirs = ['C:/Program Files (x86)/ZBar/include'],
Open a command prompt inside the extracted package and run python setup.py install.
Observe that the new errors now relate to PyIntObject and PyInt_Type. Discover that these are Python 2-only objects.
If desperate, try to re-#define them to use PyLongObject and PyLong_Type instead. Fail, because of course it's not that easy. Bang head against keyboard (gently).
Give up, and use the os.system workaround that #ltadams21 posted.
Forget wrestling with all of the wrappers. The easiest solution for me was to simply use
import os
os.system(r'D:\Winapps\Zbar\bin\zbarimg.exe -d d:\Winapps\Zbar\Examples
\barcode.png')
Worked instantly. Hope this helps anyone else struggling with that issue.
As of November 2016, there is the package pyzbar. To import Zbar for python3.4+ on Windows OS, all you need to do is launch
pip install pyzbar
This is possible because pyzbar is a ctypes-based wrapper around the zbar library that is included as dll with the Windows Python wheels.
The ZBar for python says you need to have the ZBar library installed for it to work. http://zbar.sourceforge.net/download.html
I found an easy solution for 3.4+. First install pyzbar
pip install pyzbar.
Then the below should work
import pyqrcode
from pyzbar.pyzbar import decode
from PIL import Image
qr = pyqrcode.create("HORN O.K. PLEASE.")
qr.png("horn.png", scale=6)
decode(Image.open('horn.png'))
print(qr.data)

SublimeCodeIntel Canopy modules autocompletion

I am using Sublime Text 3 with CodeIntel plugin on OSX Mavericks. I have installed Canopy and set the env so that I can simply use it from Terminal.app. In Sublime, I want the Canopy's modules to be recognized and auto-completed as I type. So far it only works for python packages OSX comes with. For example when I do
import
CodeIntel makes an autocompletion list and Sublime shows this popup, but this list does not include any Canopy modules such as pandas, even though they are installed. To proove I have a working pandas I did:
import pandas; help(pandas)
and hit Build in Sublime. It showed me help documentation of pandas. In addition, when I do:
import sys; print(sys.path)
it shows me canopy paths.
I have read about .codeintel/config file and tried various paths such as adding the /Library/path to Canopy lib/site-packages. in pythonExtraPaths in .codeintel/config , but it did not resolve the issue.
If you have any recommendations or previous relevant experience about this issue, it would be great. Thanks in advance.
Canopy is a virtual env, so you could search for "sublime virtualenv", or click this:
http://matthewphiong.com/sublime-codeintel-configuration-for-virtualenv

iPython won't autoindent

I've never had this problem before and I don't understand why it's happening now so I'm hoping someone has encountered this. If I'm using iPython in interactive mode and try to do a loop I don't get an auto indent (and can't add one in on my own). So if I do
for i in range(5):
The next line is not indented, and if I try to indent it won't move the cursor over. I'm using iPython 0.13.2 on Mac OS X Mountain Lion
EDIT I can space over to add indentation but I can't use tab and it's never added automatically. I have also ensured that %autoindent has auto indent on
This is another symptom of the problems with libedit, the Mac equivalent of readline.
IPython will show a warning about libedit, which will instruct you to easy_install readline. Be sure to use easy_install, not pip - the latter won't install it correctly in this case.

How do I get fmt-like functionality for Vim in Windows?

I've found fmt to be extremely useful with Vim for formatting code comments. Unfortunately, I'm now working on Windows and fmt is not available. Is there a way to get similar functionality in Windows?
I use GnuWin32. You can install just the CoreUtils package to get fmt. Make sure you edit your environment's PATH variable to point to GnuWin32's bin directory.

Resources