last day (14 days later) » 

6:15 AM
1
Q: How to get rid of the unicode 'u' from output ? Python

Nishant SinghThe following code looks for 0.0.0.0/0 in sec group and prints on slack. def getTag(connection, instanceId): reservations=connection.get_all_instances(filters={'instance_id':instanceId}) for res in reservations: for instance in res.instances: if instance.state == "running"...

 
As written in the linked question, why not just use Python 3?
 
most of my server run on default python 2.7
@hyst329 and there will be too many syntax changes for that
 
@Nishant Singh And also, except Exception, e is considered bad practice even in 2.7 (and it's completely wrong in 3). Write except Exception as e.
 
@hyst329 well yes correct, but what about print tabulate(data, headers=header, tablefmt='simple') ^ SyntaxError: invalid syntax
 
@Nishant Singh Simply put the expression to parentheses: print(tabulate(...)). It's not that hard, however it's one of the most major incompatibilities between 2 and 3.
 
6:15 AM
well then i get ImportError: No module named 'boto'
, for Python3
 
Maybe you haven't installed it into python 3. Try pip3 install boto
Note that I don't force you to switch to Python 3, it was just a suggestion. But if your ckdebase
O
Sorry
if your codebase is not so large and "old", switching will help you in the future
 
6:36 AM
yeah i get that,, but here i am stuck
 
What exactly are you stuck with? AFAIK the package boto does exist in PyPI for Python 3
 
oh crap.. then i am sure i need 2.7 only
actually its weird prob..
 

last day (14 days later) »