Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Expected an indented block
#1
Hello I keep getting an error saying
Quote:Expected an indented block
but then i add an indentation and i get
Quote:inconsistent use of tabs and spaces

below is my code

class myHTTPTransport(HTTPTransport):
	username = None
	passwd = None

	@classmethod
	def setAuthentication(cls,u,p):
		cls.username = u
		cls.passwd = p

	def call(self, addr, data, namespace, soapaction=None, encoding=None,
		http_proxy=None, config=Config, timeout=None):

	if not isinstance(addr, SOAPAddress):
		addr=SOAPAddress(addr, config)

	if self.username != None:
		addr.user = self.username+":"+self.passwd

	return HTTPTransport.call(self, addr, data, namespace, soapaction,
								encoding, http_proxy, config)
thanks in advance
Reply
#2
The code under def call should be indented one level. That will make it part of the call method of your class. When you add that indentation, it needs to be the same as the other indentation. If the indents are done with space, indent with spaces. If the indents are done with tabs, indent with tabs.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
What line is the error starting from the log output?

class myHTTPTransport(HTTPTransport):
    username = None
    passwd = None
    
    @classmethod
    def setAuthentication(cls,u,p):
        cls.username = u
        cls.passwd = p
        
    def call(self, addr, data, namespace, soapaction=None, encoding=None,
             http_proxy=None, config=Config, timeout=None):
        if not isinstance(addr, SOAPAddress):
            addr=SOAPAddress(addr, config)
            
        if self.username != None:
            addr.user = self.username+":"+self.passwd
            
        return HTTPTransport.call(self, addr, data, namespace, soapaction,
                                  encoding, http_proxy, config)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to write in text file - indented block Joni_Engr 4 6,439 Jul-18-2022, 09:09 AM
Last Post: Hathemand
  how far is this line indented? Skaperen 3 1,322 May-30-2022, 05:49 PM
Last Post: Skaperen
  error "IndentationError: expected an indented block" axa 4 2,910 Sep-08-2020, 02:09 PM
Last Post: ibreeden
  IndentationError: expected an indented block ryder5227 2 2,599 Sep-27-2019, 06:59 PM
Last Post: jefsummers
  [SOLVED] Expected An Indented Block Panda 4 6,002 Jun-06-2018, 09:57 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020