__import__ with dict values

alex goretoy aleksandr.goretoy at gmail.com
Sat Mar 14 04:13:43 EDT 2009


I can show you people more code if you want :) I like to learn
-Alex Goretoy
http://www.goretoy.com



On Sat, Mar 14, 2009 at 3:09 AM, alex goretoy
<aleksandr.goretoy at gmail.com>wrote:

> I'm actually still getting to this section of my code, I've been working a
> logging,stdout colors lately, Although I am going to need __import__ in
> several places in this program
>
> -Alex Goretoy
> http://www.goretoy.com
>
>
>
> On Sat, Mar 14, 2009 at 3:05 AM, alex goretoy <aleksandr.goretoy at gmail.com
> > wrote:
>
>> I don't get *why* someone would like to write that. Does it look "cool"?
>>> Is it some kind of "Look, ma, I know those hidden names!" syndrome? Is it
>>> contagious?
>>>
>>
>> I think thats what it is. It does look cool, thats for telling me about
>> the fact that
>>
>> prevents the interpreter from doing many optimizations...
>>>
>> that makes sense to me, where would I read more about python
>> optimizations?
>> I want to see code more, I like code, comments are good too :)
>>
>> I have this piece of code I would like to turn into a generator, can some
>> one please help me do it?
>> I want to make it very optimized. The data comes from a options file that
>> is parsed and used for this header/field function mapping function . I need
>> to generate this, unless you advise against it then what are my options? How
>> to wrap my head around this?
>>
>>
>>     def loop_lines(self):
>>         self.soc.me_him(['ENTER:',__name__],self.func_me_color)
>>         print self.lines
>>         for k in range(len(self.lines)): #for every line in csv file
>>             self.line=self.lines[k]
>>             for optv in self.order:
>>                 for optvv in self._optv[optv]["headers"]:
>>                     if self._optv[optv]["headers"][optvv]!="":
>>
>> _optvk=string.split(self._optv[optv]["headers"][optvv],",")
>>                         for optvk in _optvk:
>>                             for optvvv in self._optv[optv]["mappings"]:
>>                                 if optvk == optvvv:
>>                                     if
>> self._optv[optv]["mappings"][optvvv].find("self.fun.func") >= 0:
>>                                         self.field=optvvv
>>
>> self.value=self.parsed[k][optvv].replace('"', '\\"').replace("'", "\\'")
>>
>>                                         try:
>>                                             exec
>> (self._optv[optv]["mappings"][optvvv]) #execute custom function
>>                                             self.last_value=self.value
>>                                         except NameError, e:
>>                                             self.soc.w(["\n\nERROR: %s
>> \n\nFUNCTION or VARIABLE IS DEFINED IN JAR_CONTROLLER" % e],'white_on_red')
>>                                             sys.exit(1)
>>                                         #print self.opt['data']
>>
>> #self.opt['data'][self.field]=self.fun.data[self.field]
>>                                         #print self.opt['data']
>>                                     else:
>>                                         #self.soc.write(["FUNC NOT
>> FOUND:",pfhpv[pfhpvi],self._pfmp[pfhpv[pfhpvi]]],'red')
>>                                         #if self._pfmp[pfhpv[pfhpvi]]==
>> pfhp:
>>
>> self.opt['data']['defaults'][optv][optvvv]=self.value
>>                                         self.last_item=self.value
>>             for ff in self.final_funcs.keys():
>>                 if self.final_funcs[ff]:
>>                     exec ( ff )
>>
>>         self.soc.me_him(['EXIT:',__name__],self.func_me_color)
>>
>> Thank you,
>> -Alex Goretoy
>> http://www.goretoy.com
>>
>>
>>
>> On Fri, Mar 13, 2009 at 11:56 PM, Gabriel Genellina <
>> gagsl-py2 at yahoo.com.ar> wrote:
>>
>>> prevents the interpreter from doing many optimizations...
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090314/2593d5fd/attachment.html>


More information about the Python-list mailing list