Reputation: 408
I have files with code that is formatted for windows. when I try to run them on linux machine i have problem with file encodings. Can anybody suggest a solution for this
on Windows when I run I get -
This was return from redis
Exception in thread Thread-3:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/home/bsingh/python_files/lib/Site.py", line 85, in monitor
self.update1()
File "/home/bsingh/python_files/lib/Site.py", line 78, in update1
for entry in new_pastes[::-1]:
TypeError: 'NoneType' object has no attribute '__getitem__'
Upvotes: 1
Views: 3825
Reputation: 11
if you think this is a problem about file encodings. maybe you should add
# -*- coding: utf-8 -*-
or
# coding: utf-8
in the head(line 1 or line 2) of any python script file.
Upvotes: 1
Reputation: 91009
You should try -
dos2unix <filename>
To convert files created in windows to unix format. Reference
Please note dos2unix, is not python code conversion, it would convert dos characters to unix equivalent.
Upvotes: 1