Rakesh George
Rakesh George

Reputation: 33

Azure Table Storage Python SDK, Invalid syntax

I was playing around with Azure Table service with their python SDK, the below given is a part of my code, but I believe the error comes from inside the SDK

from azure.storage import TableService, Entity
from datetime import datetime

ac_name = 'my_account_name'
primary_key = 'my_primary_key'
table_name = 'my_table_name'

def get_connection_string_and_create_table():
    global table_service
    table_service = TableService(account_name = ac_name,account_key=primary_key)
    table_service.create_table(table=table_name)

the code works fine when running in Windows but throws the following error when trying to run in Raspberry (running Raspbian OS)

from azure.storage import TableService, Entity
File "/usr/local/lib/python3.2/dist-packages/azure/storage/__init__.py" line 55
self.prefix = u''

SyntaxError: invalid syntax

Could someone please help me out with this issue? :) I'd be very much happy :)

Upvotes: 0

Views: 296

Answers (1)

Ashwini Chaudhary
Ashwini Chaudhary

Reputation: 251041

The u"" syntax for string literals was re-introduced only in Python 3.3, so as you're using Python 3.2 you will get a syntax error.

From What's new in Python 3.3:

To ease the transition from Python 2 for Unicode aware Python applications that make heavy use of Unicode literals, Python 3.3 once again supports the “u” prefix for string literals. This prefix has no semantic significance in Python 3, it is provided solely to reduce the number of purely mechanical changes in migrating to Python 3, making it easier for developers to focus on the more significant semantic changes (such as the stricter default separation of binary and text data).

So, either get rid of the the u''(by default all strings are already unicode strings in Python 3) or upgrade Python 3 to a newer version to make it work.

Upvotes: 2

Related Questions