#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    1
    Rep Power
    0

    Wink Array definition problem


    DEar all,

    I have a problem in the function below, the problem is that the compilation gives a syntaxis error.
    any help.....

    Code:
    def onClick_500(self,evt):
    filename=time.asctime(time.gmtime()).replace(' ','_').replace(':','-')
    dat=[]
    while time.clock()<start_time+10:
      dat.append(cam.snap())
      dat = array(dat)    ########## the syntax error cames in this line.
    fn='c:/images/'filename+'.fits
    FITS.Write(dat,fn)
    Last edited by netytan; July 29th, 2004 at 03:02 AM. Reason: Added Code tags
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    1) please put the code in [ CODE]... [/ CODE] tags (without the spaces), so that it does not lose its indentation.

    2) What is the error message? Does it just say 'syntax error' or does it give any other information?

    3) have you checked the indentation is correct, and does not mix tabs and spaces? This is one of the commonest causes of syntax errors for newbies.

    4) Where does 'array' come from? If you are using the array module then you need to do from array import array somewhere at the start of the program. You also need to specify the array type.

    5) Are you sure it is a syntax error and not a runtime error? Your code does not make sense, since dat starts off as a list and the first time round the loop you change it to an array. The second time round the loop it will fail since you cannot initialise an array object with another array.

    Dave - The Developers' Coach
  4. #3
  5. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    An array in Python is called a list(), so if you want to create an array from another data type i.e. a string you would do this.

    Code:
    >>> list('string')
    ["s", "t", "r", "i", "n", "g"]
    >>>
    You have a major indent error after your function definition. So i would think that is where the SyntaxError is coming from rather than the line you marked.

    Which, if you havn't defined or imported the array() class/function elsewhere in your program, should raise a NameError.

    Hope this helps,

    Mark.
    programming language development: www.netytan.com Hula


IMN logo majestic logo threadwatch logo seochat tools logo