A weird syntax error

Included is a file generated by boa. When I run it (rather its wxApp counterpart) it works fine, however, while EXEfying it (py2exe) I get this error:

  File "C:\Python22\Lib\site-packages\Mys\baseconverter.py", line 77
    def dec_base(self, numb10, base):
                                     ^
SyntaxError: invalid syntax
(In my email-ed, the '^' points just after 'numb'. But in IDLE it points to after the':')

So... I opened it with IDLE and 'edit>run script' it to see if it occurs there too, and it does. I have looked and looked, but can't seem to find any syntax errors, not to mention that the program works fine!
Anyone have any idea why?

baseconverter.py (5.89 KB)

Amos Joshua wrote:

Included is a file generated by boa. When I run it (rather its wxApp counterpart) it works fine, however, while EXEfying it (py2exe) I get this error:

File "C:\Python22\Lib\site-packages\Mys\baseconverter.py", line 77
   def dec_base(self, numb10, base):
                                    ^
SyntaxError: invalid syntax
(In my email-ed, the '^' points just after 'numb'. But in IDLE it points to after the':')

So... I opened it with IDLE and 'edit>run script' it to see if it occurs there too, and it does. I have looked and looked, but can't seem to find any syntax errors, not to mention that the program works fine!
Anyone have any idea why?

You might double check for consistent indentation, especially whether you have mixed tabs and spaces anywhere.

David

Included is a file generated by boa. When I run it (rather its wxApp
counterpart) it works fine, however, while EXEfying it (py2exe) I get
this error:

  File "C:\Python22\Lib\site-packages\Mys\baseconverter.py", line 77
    def dec_base(self, numb10, base):

Maybe mixed tabs and spaces? It's difficult to say. Check to see if
one of the "blank" lines between functions has tabs or spaces on it.
                                   

SyntaxError: invalid syntax
(In my email-ed, the '^' points just after 'numb'. But in IDLE it points
to after the':')

So... I opened it with IDLE and 'edit>run script' it to see if it occurs
there too, and it does. I have looked and looked, but can't seem to find
any syntax errors, not to mention that the program works fine!

What do you mean, works fine? What is it supposed to do? When I run it
(by typing 'python baseconverter.py') I get returned to my prompt. Is a
window supposed to open? Where is wxApp?

Having looked at the source code, let me make several suggestions:

Stuff like this, don't do it:

self.base2 = wxComboBox(choices = , id = wxID_WXFRAME1BASE2, name =
'base2', parent = self.panel1, pos = wxPoint(200, 56), size =
wxSize(112, 21), style = 0, validator = wxDefaultValidator, value = '0')

Don't pass in a bunch of unnecessary arguments. It just makes the code
dense and more difficult to read. The above could have just as simply
been written as:

self.base2 = wxComboBox(self.panel1, -1, choices = ,
                        pos = wxPoint(200, 56),
                        size = wxSize(112, 21), value = '0')

Much easier to read, no? Many of the arguments to wxPython class
initializers either aren't needed or have reasonable defaults. Just use
the default unless you know you need something else.

Note that it isn't necessary to create a unique ID for every control.
Just pass -1 and let wxPython do it for you. If you need the ID later,
use self.control.GetId().

Don't use unnecessary white space. The following is twice as long as it
needs to be because you double-spaced the entire method.

   def base_dec(self, numb, base):

        list = str(numb)

        if list == ['']:

            list.append('1')

        numb =

...

Anyway, style is obviously a matter of personal preference, and you are
free to program however you like, but if you post ugly code, don't
expect others to try and read it.

If you clean this up a bit, I expect that
1. You'll find your error on your own
2. Someone else will be more willing to

Finally, if this code was generated by Boa, I apologize in advance and
forward that as a reason not to use code-generators. In any case, you
should learn to code using wxPython by hand, and once you have the
basics firmly in hand, then give Boa a try.

Regards,

···

On Sun, 2002-12-29 at 10:09, Amos Joshua wrote:

--
Cliff Wells <clifford.wells@attbi.com>