×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor
    Join Date
    Aug 2005
    Posts
    200

    Syntax error, I think...

    Hello Fellow Forum users,

    For my first foray into PyS60, I have written a lil' script. As I am learning, I am adding new code.

    But, when I added the following code, the script fails to run successfully:

    Code:
    if not os.path.exists(PATH):
    	os.makedirs(PATH)
    	while True:
    		ap_id = socket.select_access_point()
    		f = file(u"c:\\Data\\SmartCon\\cheap_conf.txt", "a")
    		ap_cheap_dict{}
    		ap_fast_dict{}
    		chk = appuifw.query(u"Mark the connection as 'cheap'?", "query")  
    		ap_cheap_dict["ap_id"] = ap_id
    		ap_cheap_dict["value"] = chk
    		save_dictionary(f,ap_cheap_dict)	
    		if not ap_id:
    			break
    	
    def save_dictionary(filename, dict):
    	f = file(filename, "a")
    	for key, value in dict.items():
    	print >> f, "%s: %s" % (key, value)
    	f.close
    Could you spot the errors, please. I simply want to loop through all ap_ids and mark them as 'cheap' or not.

    Would greatly appreciate assistance.

    Best Regards,
    wirefree101

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Location
    UK
    Posts
    125

    Re: Syntax error, I think...

    Quote Originally Posted by wirefree101 View Post
    Code:
    		ap_cheap_dict{}
    		ap_fast_dict{}
    The only obvious error I can spot is the above two lines which should read...

    Code:
    		ap_cheap_dict = {}
    		ap_fast_dict = {}
    Including the error message you get would make it much easier.

  3. #3
    Regular Contributor
    Join Date
    Aug 2005
    Posts
    200

    Re: Syntax error, I think...

    Quote Originally Posted by aya42 View Post
    The only obvious error I can spot is the above two lines which should read...

    Code:
    		ap_cheap_dict = {}
    		ap_fast_dict = {}
    Including the error message you get would make it much easier.
    As suggsted, I corrected the dict code. But the errors persist. Here they are:

    Code:
    Traceback (most recent call last):
      File "E:\private\2000b1a5\default.py", line 81, in menu_action
        f()
      File "E:\private\2000b1a5\default.py", line 65, in query_and_exec
        execfile(script_list[index][1].encode('utf-8'), script_namespace.namespace)
    IndentationError: expected an indented block (SmartCon.py, line 22)
    Wud appreciate advise.

  4. #4
    Regular Contributor
    Join Date
    Aug 2005
    Posts
    200

    Re: Syntax error, I think...

    Maybe the error is associated with storing "chk" as a value in dict!?

    Pls advise.
    Last edited by wirefree101; 2008-02-17 at 06:06.

  5. #5
    Regular Contributor
    Join Date
    Mar 2003
    Location
    UK
    Posts
    125

    Re: Syntax error, I think...

    Quote Originally Posted by wirefree101 View Post
    Code:
    IndentationError: expected an indented block (SmartCon.py, line 22)
    You have a problem with code indentation. Whitespace is significant in Python. Read: http://docs.python.org/ref/indentation.html

Similar Threads

  1. i cant build helloworld project
    By akhin in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 2
    Last Post: 2008-12-22, 12:38
  2. carbidec++ helloworld project problem
    By akhin in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 0
    Last Post: 2007-03-11, 12:40
  3. carbide build problem help please
    By berkcekisbas in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2006-09-26, 19:41
  4. g++ Compilation Problem - Please Help
    By gilly_kumar in forum Symbian
    Replies: 0
    Last Post: 2005-09-12, 16:22
  5. Cannot compile SDK's examples for 7650 platform...
    By midletsoft in forum Symbian Tools & SDKs
    Replies: 2
    Last Post: 2003-08-12, 19:11

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×