From catherine.devlin at gmail.com Thu Jun 5 23:06:40 2008 From: catherine.devlin at gmail.com (Catherine Devlin) Date: Thu, 5 Jun 2008 17:06:40 -0400 Subject: [CentralOH] PyOhio Call for Proposals deadline extended to June 15! Message-ID: <6523e39a0806051406g6075b4e7l188964e1a7c600fc@mail.gmail.com> The PyOhio organizers have extended the Call for Proposals deadline to June 15! Several potential speakers have requested extra time to prepare submissions, and now you can too. http://wiki.python.org/moin/PyOhio/CallForProposals Don't be shy... speaking at an event like PyOhio helps you share your knowledge, deepen your expertise, broaden your horizons, meet people, practice for bigger events like PyCon, and have fun. See you at PyOhio! -- - Catherine http://catherinedevlin.blogspot.com/ *** PyOhio 2008 * Columbus * July 26, 2008 * pyohio.org *** -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at microenh.com Fri Jun 6 15:19:35 2008 From: mark at microenh.com (Mark Erbaugh) Date: Fri, 06 Jun 2008 09:19:35 -0400 Subject: [CentralOH] __slots__ Message-ID: <1212758375.5384.14.camel@P1900> Does anyone know how a class/instance with __slots__ finds an attribute? Without __slots__, there is a dict that is searched for the attribute. With __slots__ what is the lookup mechanism? I'm wondering if it involves a sequential lookup, thus making __slots__ access slower for classes with a large number of attributes. Thanks, Mark From steven_h at acm.org Fri Jun 6 16:52:45 2008 From: steven_h at acm.org (Steven Huwig) Date: Fri, 6 Jun 2008 10:52:45 -0400 Subject: [CentralOH] __slots__ In-Reply-To: <1212758375.5384.14.camel@P1900> References: <1212758375.5384.14.camel@P1900> Message-ID: <7505f2a60806060752x54f5d997vea72a3f6694ea4a@mail.gmail.com> I believe it is a sequential lookup. The motivation to use __slots__ disappears when you have classes with a large number of attributes, since you no longer save anything on the per-instance dictionary overhead. __slots__ is best for classes like Point, where you will have many, many instances with few attributes. On Fri, Jun 6, 2008 at 9:19 AM, Mark Erbaugh wrote: > Does anyone know how a class/instance with __slots__ finds an attribute? > Without __slots__, there is a dict that is searched for the attribute. > With __slots__ what is the lookup mechanism? I'm wondering if it > involves a sequential lookup, thus making __slots__ access slower for > classes with a large number of attributes. > > Thanks, > Mark > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > http://mail.python.org/mailman/listinfo/centraloh > From mark at microenh.com Wed Jun 18 03:24:34 2008 From: mark at microenh.com (Mark Erbaugh) Date: Tue, 17 Jun 2008 21:24:34 -0400 Subject: [CentralOH] Dynamic Access to Class Properties Message-ID: <1213752274.13446.21.camel@P1900> I suspect I've gone about this all wrong, but anyways... I have developed a class that encapsulates access to a moderately complex database object. Once data has been retrieved from the database the various fields are accessed using properties. There are about 70 such properties. Once the fields have been manipulated, the data can be written back to the database using a class method. On the GUI end, I developed a GUI where each user edit field knows the name of the property which contains the field it represents. A method of the form containing the user edit fields can tell all of the edit fields to load the data from or to save the data to the data instance. For example the facility name is accessed as the property facility_name. The edit field for facility name has a string data member with the value 'facility_name'. Is there a way, other than exec'ing some code to convert the string 'facility_name' into the data instance property facility_name? Another thought. Would it be possible for the edit field to store the actual property, rather than the value it contains? For example, say the edit field has a data member called prop. Is there a way that I could make it so when the data member could do value = prop to retrieve and prop = value to set the property value? Is this currying? FWIW, I'm using Python 2.4, I know there were some changes regarding this in Python 2.5. From mark at microenh.com Wed Jun 18 04:08:20 2008 From: mark at microenh.com (Mark Erbaugh) Date: Tue, 17 Jun 2008 22:08:20 -0400 Subject: [CentralOH] Dynamic Access to Class Properties In-Reply-To: <1213752274.13446.21.camel@P1900> References: <1213752274.13446.21.camel@P1900> Message-ID: <1213754900.16697.2.camel@P1900> On Tue, 2008-06-17 at 21:24 -0400, Mark Erbaugh wrote: > I suspect I've gone about this all wrong, but anyways... > > I have developed a class that encapsulates access to a moderately > complex database object. Once data has been retrieved from the database > the various fields are accessed using properties. There are about 70 > such properties. Once the fields have been manipulated, the data can be > written back to the database using a class method. > > On the GUI end, I developed a GUI where each user edit field knows the > name of the property which contains the field it represents. A method of > the form containing the user edit fields can tell all of the edit fields > to load the data from or to save the data to the data instance. > > For example the facility name is accessed as the property facility_name. > The edit field for facility name has a string data member with the value > 'facility_name'. > > Is there a way, other than exec'ing some code to convert the string > 'facility_name' into the data instance property facility_name? > > Another thought. Would it be possible for the edit field to store the > actual property, rather than the value it contains? For example, say > the edit field has a data member called prop. Is there a way that I > could make it so when the data member could do value = prop to retrieve > and prop = value to set the property value? Is this currying? FWIW, I'm > using Python 2.4, I know there were some changes regarding this in > Python 2.5. I did a little more research. I guess it's not really currying. Anyways, here's a way I found to translate a string into the descriptor instance for the property x = main class instance 'prop' = property name d = type(x).__dict__['prop'] returns the descriptor instance you can then call d.__get__(x) to get the value and d.__set__(x, value) to set the value Any other suggestions? Thanks, Mark From mike at mikegray.org Wed Jun 18 07:15:34 2008 From: mike at mikegray.org (Mike Gray) Date: Wed, 18 Jun 2008 01:15:34 -0400 Subject: [CentralOH] Columbus Startup Weekend Message-ID: <65d1711d0806172215w525e29c8i4ea8b2131880bf34@mail.gmail.com> Wanted to be sure any interested Python developers in the Columbus area know about the upcoming Columbus Startup Weekend. It is a chance to build a company, product, network connections, and more in a short time frame. For more information here are some links: http://columbus.startupweekend.com/ http://startupweekendcolumbus.eventbrite.com/ http://startupweekend.com/columbus-startup-weekend/ Hope some pythonistas can make it out. -------------- next part -------------- An HTML attachment was scrubbed... URL: From hickey at oclc.org Wed Jun 18 16:29:28 2008 From: hickey at oclc.org (Hickey,Thom) Date: Wed, 18 Jun 2008 10:29:28 -0400 Subject: [CentralOH] Dynamic Access to Class Properties References: <1213752274.13446.21.camel@P1900> <1213754900.16697.2.camel@P1900> Message-ID: I wouldn't trust anything coming in from a GUI, even if it seemed under my control. I'd make the method names distinctive (e.g. some sort of prefix). That way you can check and make sure something isn't tricking you into calling a method you don't want exposed. --Th -----Original Message----- From: centraloh-bounces at python.org [mailto:centraloh-bounces at python.org] On Behalf Of Mark Erbaugh Sent: Tuesday, June 17, 2008 10:08 PM To: centraloh at python.org Subject: Re: [CentralOH] Dynamic Access to Class Properties On Tue, 2008-06-17 at 21:24 -0400, Mark Erbaugh wrote: > I suspect I've gone about this all wrong, but anyways... > > I have developed a class that encapsulates access to a moderately > complex database object. Once data has been retrieved from the database > the various fields are accessed using properties. There are about 70 > such properties. Once the fields have been manipulated, the data can be > written back to the database using a class method. > > On the GUI end, I developed a GUI where each user edit field knows the > name of the property which contains the field it represents. A method of > the form containing the user edit fields can tell all of the edit fields > to load the data from or to save the data to the data instance. > > For example the facility name is accessed as the property facility_name. > The edit field for facility name has a string data member with the value > 'facility_name'. > > Is there a way, other than exec'ing some code to convert the string > 'facility_name' into the data instance property facility_name? > > Another thought. Would it be possible for the edit field to store the > actual property, rather than the value it contains? For example, say > the edit field has a data member called prop. Is there a way that I > could make it so when the data member could do value = prop to retrieve > and prop = value to set the property value? Is this currying? FWIW, I'm > using Python 2.4, I know there were some changes regarding this in > Python 2.5. I did a little more research. I guess it's not really currying. Anyways, here's a way I found to translate a string into the descriptor instance for the property x = main class instance 'prop' = property name d = type(x).__dict__['prop'] returns the descriptor instance you can then call d.__get__(x) to get the value and d.__set__(x, value) to set the value Any other suggestions? Thanks, Mark _______________________________________________ CentralOH mailing list CentralOH at python.org http://mail.python.org/mailman/listinfo/centraloh From cbc at unc.edu Tue Jun 17 21:49:57 2008 From: cbc at unc.edu (Chris Calloway) Date: Tue, 17 Jun 2008 15:49:57 -0400 Subject: [CentralOH] BootCampArama Early Bird Registration Reminder Message-ID: <48581565.8040308@unc.edu> Just a reminder, we're at the two week warning on early bird registration for PyCamp: http://trizpug.org/boot-camp/2008/ Registration is now open for: PyCamp: Python Boot Camp, August 4 - 8 Plone Boot Camp: Customizing Plone, July 28 - August 1 Advanced Plone Boot Camp: Plone 3 Techniques, August 4 - 7 All of these take place on the campus of the University of North Carolina at Chapel Hill in state of the art high tech classrooms, with free mass transit, low-cost accommodations with free wireless, and convenient dining options. Plone Boot Camp is taught by Joel Burton, twice chair of the Plone Foundation. Joel has logged more the 200 days at the head of Plone classrooms on four continents. See plonebootcamps.com for dozens of testimonials from Joel's students. PyCamp is taught by Chris Calloway, facilitator for TriZPUG and application analyst for the Southeast Coastal Ocean Observing System. Chris has developed PyCamp for over 1500 hours on behalf of Python user groups. Early bird registration runs through June 30. So register today! PyCamp is TriZPUG's Python Boot Camp, which takes a programmer familiar with basic programming concepts to the status of Python developer with one week of training. If you have previous scripting or programming experience and want to step into Python programming as quickly and painlessly as possible, this boot camp is for you. PyCamp is also the perfect follow-on to Plone Boot Camp: Customizing Plone the previous week. At Plone Boot Camp: Customizing Plone you will learn the essentials you need to build your Plone site and deploy it. This course is the most popular in the Plone world--for a good reason: it teaches you practical skills in a friendly, hands-on format. This bootcamp is aimed at: * people with HTML or web design experience * people with some or no Python experience * people with some or no Zope/Plone experience It covers using Plone, customizing, and deploying Plone sites. At Advanced Plone Boot Camp: Plone 3 Techniques you will learn to build a site using the best practices of Plone 3 as well as advance your skills in scripting and developing for Plone. The course covers the new technologies in Plone 3.0 and 3.1 intended for site integrators and developers: our new portlet infrastructure, viewlets, versioning, and a friendly introduction to Zope 3 component architecture. Now, updated for Plone 3.1! The course is intended for people who have experience with the basics of Plone site development and HTML/CSS. It will cover what you need to know to take advantage of these new technologies in Plone 3. For more information contact: info at trizpug.org -- Sincerely, Chris Calloway http://www.secoora.org office: 332 Chapman Hall phone: (919) 599-3530 mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599 From mark at microenh.com Thu Jun 26 18:13:07 2008 From: mark at microenh.com (Mark Erbaugh) Date: Thu, 26 Jun 2008 12:13:07 -0400 Subject: [CentralOH] __metaclass__ Message-ID: <1214496787.18452.6.camel@P1900> I've discovered something strange with some Python 2.4.3 code that I'm working on. I have a class, Query, that sets __metaclass__. The class is designed to be derived from and children of this class have been working. This morning, I created a new child class, but I also named it Query import query_base as Q class Query(Q.Query): The class didn't work and upon investigation, it looks like the metaclass is not being used. IOW, once the instance is created, .__metaclass_ returns None However, if I change the name of the class to something else, everything works and .__metaclass__ has the expected value. It looks like Python or I are violating a namespace somewhere. Obviously, the immediate solution is to not re-use the name, but that happens to be a very good name for the class. I'm really more interested in understanding what's actually going on. From steven_h at acm.org Thu Jun 26 18:31:52 2008 From: steven_h at acm.org (Steven Huwig) Date: Thu, 26 Jun 2008 12:31:52 -0400 Subject: [CentralOH] __metaclass__ In-Reply-To: <1214496787.18452.6.camel@P1900> References: <1214496787.18452.6.camel@P1900> Message-ID: <7505f2a60806260931t207f79fdp36e7a91852843cd7@mail.gmail.com> I tried to replicate this on my 2.5.2 install and was unable to do it. Do you have a minimum failing example? On Thu, Jun 26, 2008 at 12:13 PM, Mark Erbaugh wrote: > I've discovered something strange with some Python 2.4.3 code that I'm > working on. > > I have a class, Query, that sets __metaclass__. The class is designed > to be derived from and children of this class have been working. > > This morning, I created a new child class, but I also named it Query > > import query_base as Q > > class Query(Q.Query): > > The class didn't work and upon investigation, it looks like the > metaclass is not being used. IOW, once the instance is created, > .__metaclass_ returns None > > However, if I change the name of the class to something else, everything > works and .__metaclass__ has the expected value. > > It looks like Python or I are violating a namespace somewhere. > > Obviously, the immediate solution is to not re-use the name, but that > happens to be a very good name for the class. > > I'm really more interested in understanding what's actually going on. > > _______________________________________________ > CentralOH mailing list > CentralOH at python.org > http://mail.python.org/mailman/listinfo/centraloh > From mark at microenh.com Fri Jun 27 02:31:37 2008 From: mark at microenh.com (Mark Erbaugh) Date: Thu, 26 Jun 2008 20:31:37 -0400 Subject: [CentralOH] __metaclass__ In-Reply-To: <7505f2a60806260931t207f79fdp36e7a91852843cd7@mail.gmail.com> References: <1214496787.18452.6.camel@P1900> <7505f2a60806260931t207f79fdp36e7a91852843cd7@mail.gmail.com> Message-ID: <1214526697.14016.5.camel@P1900> On Thu, 2008-06-26 at 12:31 -0400, Steven Huwig wrote: > I tried to replicate this on my 2.5.2 install and was unable to do it. > Do you have a minimum failing example? I figured it out. The problem was with the metaclass. I designed the base class (Query) to be sub-classed. I didn't want the metaclass to do anything to the base class, just to sub-classes, so the metaclass's __init__ starts: def __init__(cls, name, t, d): if name <> 'Query': Thus the stuff that I wanted to happen wasn't happening if the sub-class was also named 'Query'. So I changed the code: def __init__(cls, name, t, d): # if name <> 'Query': if cls.__base__ <> object: I originally tried if cls <> Query: But Python complained about unknown Query. Query was declared later in the same file. I tried swapping Query and the metaclass, but then I got complaints about the metaclass being unkown in the definition of Query: Mark