Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #85244 > unrolled thread
| Started by | syed khalid <syedk@pacificloud.com> |
|---|---|
| First post | 2015-02-04 19:07 -0800 |
| Last post | 2015-02-05 11:46 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
Indentation issues with python syed khalid <syedk@pacificloud.com> - 2015-02-04 19:07 -0800
Re: Indentation issues with python Denis McMahon <denismfmcmahon@gmail.com> - 2015-02-05 11:46 +0000
| From | syed khalid <syedk@pacificloud.com> |
|---|---|
| Date | 2015-02-04 19:07 -0800 |
| Subject | Indentation issues with python |
| Message-ID | <mailman.18482.1423105677.18130.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
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*
[toc] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2015-02-05 11:46 +0000 |
| Message-ID | <mavl5t$cm1$2@dont-email.me> |
| In reply to | #85244 |
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, denismfmcmahon@gmail.com
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web