0

I am new to python I am trying to assign variable it says systax error

protocol = input.readLine()
connectUrlHttp='http'
connectUrlHttps='https'


if protocol== "t3s":
 connectUrl=connectUrlHttps
elif protocol== "iiops":
  connectUrl=connectUrlHttps
else:
connectUrl=connectUrlHttp


  sca_deployComposite(connectUrl"://"+host+":"+port,emdroot+"/"+compositeLoc,owrite,user, password,default)

I am facing below error

(no code object) at line 0
  File "/scratch/agentHome/sdappaji2/core/12.1.0.3.0/EMStage/PAF/DeployCompositesDP1367835748253/deploycompositesscripts/deployComposites.py", line 36
    connectUrl=connectUrlHttp

Please guide me and give some pointers

3 Answers 3

3

In Python, indentation levels are significant:

Use 4 spaces per indentation level.

--PEP 8 -- Style Guide for Python Code

Your code should probably look like this:

protocol = input.readLine()
connectUrlHttp = 'http'
connectUrlHttps = 'https'

if protocol == "t3s":
    connectUrl = connectUrlHttps
elif protocol == "iiops":
    connectUrl = connectUrlHttps
else:
    connectUrl = connectUrlHttp

# Note the `+` after `connectUrl` on the next line:
sca_deployComposite(connectUrl + "://" + host + ":" + port, emdroot + "/" +
                    compositeLoc, owrite, user, password, default)
Sign up to request clarification or add additional context in comments.

Comments

1

The actual syntax error is here:

sca_deployComposite(connectUrl"://"+host+":"+port,emdroot+"/"+compositeLoc,owrite,user, password,default)
                            ^^^

You probably missed a + there.

The indentation is also wrong after the else, as Ashwini points out.

Comments

1

Your code is not properly indented after else:

if protocol== "t3s":
 connectUrl=connectUrlHttps
elif protocol== "iiops":
  connectUrl=connectUrlHttps
else:
    connectUrl=connectUrlHttp

sca_deployComposite(connectUrl+"://"+host+":"+port,emdroot+"/"+compositeLoc,owrite,user, password,default)

Plus you were missing a + after sca_deployComposite(connectUrl.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.