#1
  1. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154

    Can't Assign to Function Call


    I keep receiving this error for the following code:
    Code:
                    if textCtrl8.GetValue() == 'starcraft.exe':
                        star_exe = textCtrl8.GetValue(), star_dll = textCtrl9.GetValue(), star_snp = textCtrl10.GetValue()
                        w2bn_exe = '', w2bn_dll = '', w2bn_snp = ''
                        d2dv_exe = '', d2dv_dll = '', d2dv_snp = ''
                    elif textCtrl8.GetValue() == 'warcraft ii bne.exe':
                        star_exe = '', star_dll = '', star_snp = ''
                        w2bn_exe = textCtrl8.GetValue(), w2bn_dll = textCtrl9.GetValue(), w2bn_snp = textCtrl10.GetValue()
                        d2dv_exe = '', d2dv_dll = '', d2dv_snp = ''
                    elif textCtrl8.GetValue() == 'game.exe':
                        star_exe = '', star_dll = '', star_snp = ''
                        w2bn_exe = '', w2bn_dll = '', w2bn_snp = ''
                        d2dv_exe = textCtrl8.GetValue(), d2dv_dll = textCtrl9.GetValue(), d2dv_snp = textCtrl10.GetValue()
    From my point of view, there is nothing wrong with this code. But apparently there must be, or 3 different editors wouldn't be giving me the same error. Any help is appreciated.

    Note: The bold line is the one I am currently receiving an error on.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    461
    Rep Power
    25
    At a quick glance I don't see any syntax errors, Could you possibly post the error msg itself to us, that will help us out a lot more.
  4. #3
  5. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    Code:
    Syntax Error : can't assign to function call
        566: Frame1.py: star_exe = textCtrl8.GetValue(), star_dll = textCtrl9.GetValue(), star_snp = textCtrl10.GetValue()
    This is exactly what it gives me. I still can't figure out why this is an error though.
  6. #4
  7. Commie Mutant Traitor
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2004
    Location
    Alpharetta, GA
    Posts
    1,806
    Rep Power
    1570
    In this context, the comma operator is interpreted as a multiple assignment, not as a statement separator. If you wanted multiple separate statements, you should replace the commas with semi-colons:
    Code:
    star_exe = textCtrl8.GetValue(); star_dll = textCtrl9.GetValue(); star_snp = textCtrl10.GetValue()
    If you did want to use multiple assignment, you'll need to write it (and the subsequent lines) like this:
    Code:
    star_exe, star_dll, star_snp = textCtrl8.GetValue() , textCtrl9.GetValue(), textCtrl10.GetValue()
    I should add that multiple assignment is primarily meant as a way of avoiding sequencing issues, such as when swapping two variables:
    Code:
    a, b = b, a
    Unless the sub-expressions have some dependency on each other's pre-assignment values - which none of these do - you should use separate statements.
    Last edited by Schol-R-LEA; June 15th, 2005 at 10:39 PM.
    Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
    #define KINSEY (rand() % 7) λ Scheme is the Red Pill
    Scheme in Short Understanding the C/C++ Preprocessor
    Taming Python A Highly Opinionated Review of Programming Languages for the Novice, v1.1

    FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov
  8. #5
  9. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    Thanks a lot for the help Schol-E-LEA, it works correctly now. This will probably help me with future problems as well like this. Thanks again.

IMN logo majestic logo threadwatch logo seochat tools logo