Python: How to solve bracket not closed error

Question:

following a tutorial I’m getting error "(" is not closed while using the exact same code:

compiled_sol = compile_standard(
  {
      "language": "Solidity",
      "sources": {"SimpleStorage.sol": {"content" = simple_storage_file}}
  }
)

don’t know where it’s going wrong getting these errors:

"{" was not closedPylance
Expected parameter namePylance

and

Expected parameter namePylance
Asked By: dariocodes

||

Answers:

try to replace "=" for ":" I hope this solves the problem.

Answered By: adammaly004

As @adammaly004 mentioned, you can’t have an = in a python dict. Replacing "content" = simple_storage_file with "content": simple_storage_file should solve your issue.

Full example:

compiled_sol = compile_standard(
  {
      "language": "Solidity",
      "sources": {"SimpleStorage.sol": {"content": simple_storage_file}}
  }
)

Answered By: JamesRoberts

Thing is you can’t have an "=" in a dict, where you construct it from {} and not this dict()

Here’s examples of both

1.

compiled_sol = compile_standard(
    {
        "language": "Solidity",
        "sources": {
            "SimpleStorage.sol": {
                "content": simple_storage_file
            }
        }
    }
)

You cannot use a "=" sign in above constructor
2.

compiled_sol = compile_standard(
    dict(
        languages="Solidity",
        sources = dict(
            SimpleStorage.sol = dict(
                content = simple_storage_file)
        )
    )
)

In your case the second method will not work, because you have a . in SimpleStorage when you have a . in something Python thinks it is like a module or class
So that’s why this method won’t work for this case

But it’s handy to know

Answered By: Irtiza Babar

i also faced the same problem. my code before i fixed

from django.urls import include, re_path
from EmployeeApp import views

urlpatterns = [
    re_path(r'^department/$',views.departmentApi),
    re_path(r'^department/([0-9]+)$',views.departmentApi)

     re_path(r'^employee/$',views.employeeApi),
    re_path(r'^employee/([0-9]+)$',views.employeeApi)
] 
 i was getting this error, "[" is not closed 
File "F:ProgrammingDjangoAngularTutorialDjangoAPIEmployeeAppurls.py", line 6
    re_path(r'^department/([0-9]+)$',views.departmentApi)

i fixed by adding , on line 6

from django.urls import include, re_path
from EmployeeApp import views

urlpatterns = [
    re_path(r'^department/$',views.departmentApi),
    re_path(r'^department/([0-9]+)$',views.departmentApi),

     re_path(r'^employee/$',views.employeeApi),
    re_path(r'^employee/([0-9]+)$',views.employeeApi)
]  

Answered By: lelaven
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.