Lemon
Lemon

Reputation: 13

error on Tkinter askopenfilename method

self.file_opt=options={}
options['defaultextension']='.txt'
options['filetypes']=[('text files','.txt')]
options=['initialdir']=['home/var/www/']
options=['initialfile']='sampl1.py'
options['parent']=root
options['title']='This is a title'

In the above code i get error on following..

options=['initialdir']=['home/var/www/']
options=['initialfile']='sampl1.py'

syntax error- Can't assign to literal

Don't know why it is happening.. Any help?

Upvotes: 0

Views: 283

Answers (1)

falsetru
falsetru

Reputation: 369394

You can't assigned to a literal (['x'] is a list literal):

>>> ['x'] = [1]
  File "<stdin>", line 1
SyntaxError: can't assign to literal

Remove = in the following lines:

options=['initialdir']=['home/var/www/']
options=['initialfile']='sampl1.py'
#      ^

Upvotes: 1

Related Questions