Indentation issues with python
I downloaded this code and am attempting to run it. I keep getting indentation error. there is a way to handle it with a editor which can recognize the tab or space issue. I have tried different options such as 2 or 3 spaces or tab to no avail. I have encased the error mesage with line 23 between "" import sys import azure import socket from azure.servicebus import ( _service_bus_error_handler ) from azure.servicebus.servicebusservice import ( ServiceBusService, ServiceBusSASAuthentication ) from azure.http import ( HTTPRequest, HTTPError ) from azure.http.httpclient import _HTTPClient class EventHubClient(object): def sendMessage(self,body,partition):eventHubHost = "pac-ns.servicebus.windows.net" httpclient = _HTTPClient(service_instance=self) File "test1.py", line 23 def sendMessage(self,body,partition): ^ IndentationError: expected an indented block *** sasKeyName = "SendPolicy" sasKeyValue = "erENqf/5wdWCNEbCA9NsDIRqd5MRKdkii07+wezl/NU=" authentication = ServiceBusSASAuthentication(sasKeyName,sasKeyValue) request = HTTPRequest() request.method = "POST" request.host = eventHubHost request.protocol_override = "https" request.path = "/myhub/publishers/" + partition + "/messages?api-version=2014-05 " request.body = body request.headers.append(('Content-Type', 'application/atom+xml;type=entry;charset =utf-8')) authentication.sign_request(request, httpclient) request.headers.append(('Content-Length', str(len(request.body))) -- *Syed Khalid* -- https://mail.python.org/mailman/listinfo/python-list
Re: Indentation issues with python
syed khalid writes: > I downloaded this code and am attempting to run it. I keep getting > indentation error. Indentation is crucial information in Python code. If it is lost, don't waste time trying to guess it; instead, get the correct code. How did you download it? You should download the code as a “plain text” file. -- \ “I got some new underwear the other day. Well, new to me.” —Emo | `\ Philips | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: Indentation issues with python
class EventHubClient(object): ... def sendMessage(self,body,partition): ... > ^ IndentationError: expected an indented block *** and 'def' is not indented as it must be. This must be covered in the tutorial. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Indentation issues with python
On Wed, 04 Feb 2015 19:07:53 -0800, syed khalid wrote: > I downloaded this code and am attempting to run it. I keep getting > indentation error. > class EventHubClient(object): > def sendMessage(self,body,partition):eventHubHost = > "pac-ns.servicebus.windows.net" >httpclient = _HTTPClient(service_instance=self) > def sendMessage(self,body,partition): > ^ > IndentationError: expected an indented block > *** > sasKeyName = "SendPolicy" > sasKeyValue = "erENqf/5wdWCNEbCA9NsDIRqd5MRKdkii07+wezl/NU=" class starts a class definition. def starts a function (or method) definition. The parser expects these definitions to be followed by one or more indented lines being the code of the class or function (method). The following lines down to either a return or the next function definition line should probably all be indented. eg: class EventHubClient(object): def sendMessage(self,body,partition): eventHubHost = "pac-ns.servicebus.windows.net" httpclient = _HTTPClient(service_instance=self) sasKeyName = "SendPolicy" sasKeyValue = "erENqf/5wdWCNEbCA9NsDIRqd5MRKdkii07+wezl/NU=" .. more indented code should probably follow Getting the indentation correct is absolutely critical in Python. -- Denis McMahon, denismfmcma...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list