On Mon, Oct 3, 2011 at 4:24 PM, Chris Withers <ch...@simplistix.co.uk>wrote:
> On 03/10/2011 15:15, Michael Bayer wrote: > >> ive no idea what __main__.py is either ? where's the SQLAlchemy >> exceptions here ? (keeping in mind i havent yet gone through all the steps >> to download a file...untar it...figure out what you're trying to do...) >> > > The attached .tgz simplifies the real process, since this is a Python issue > not a SA one... > > The SA bit is that Declarative barfs 'cos the class is processed twice... > > Chris > > I haven't run the code, but this sounds like the import gotcha described at http://effbot.org/zone/import-confusion.htm#using-modules-as-scripts. As far as python is concerned these are 2 separate modules, and I don't think it's Declarative's job to detect and ignore the second occurrence. If I were you, I would try to move the "if __name__ == '__main__'" part into a separate module that imports the first. This can then be run with "python -m mypackage.main". This isn't so helpful if you were intending to have a number of modules that could be run independently. Perhaps you could live with something like "python -m mypackage.main mod1 mod2 mod3"? Hope that helps, Simon PS. __main__.py and other behaviour are mentioned on http://docs.python.org/using/cmdline.html. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.