addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwchatcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgoogleimageimagesinstagramlinklocation-pinmagnifying-glassmailminusmoremuplabelShape 3 + Rectangle 1outlookpersonplusprice-ribbonImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruseryahoo

Re: [PhillyPUG] Python hackery, any better ideas?

From: Mat S.
Sent on: Thursday, January 12, 2012 12:31 PM
On Thu, Jan 12, 2012 at 12:21 PM, Thomas E Jenkins <[address removed]> wrote:
Along those same lines you can put all the vars in a class like above and just pass the class or an instance of it to your hairy function if you want to keep the actual code in a function instead of making it a class.

Thanks Erik and Thomas, but I think both of those solutions would require prepending `vars.` to all the local variable references in the code which is a frightening prospect. It's about 250 lines with lots of cross referencing of values and oddly placed list comprensions :(

I updated https://gist.github.com/1601533#file_uglycode.py to point out where that line is (currently 12) that I don't want to touch anything below. It's possible that what I have is as good as it gets, but the warning on first run (I suspect the compilation process) is concerning.

-Mat

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy