what is I just set
"colors": self.opt['arg_opts_options']['imp_colors']
then they are both pointing to the same place, correct?
-Alex Goretoy
http://www.goretoy.com
On Sun, Mar 15, 2009 at 11:16 PM, alex goretoy
wrote:
> i did this because this will read colors into a nested variable
>
> How
i did this because this will read colors into a nested variable
How would i make this work the way you suggest? I already have it working
now :)
Not able to set to dict value with setattr, how to do this too(sorry if off
subject)?
I can set it like this:
for i in self.opt['p
alex goretoy wrote:
ok now for the final result, i decided to split options out to a
separate dict of lists, does this look right to every one, I currently
have error somewhere else in my code so can't test this right now, Is
this a good method to do this? or is there another option?
[snip]
ok now for the final result, i decided to split options out to a separate
dict of lists, does this look right to every one, I currently have error
somewhere else in my code so can't test this right now, Is this a good
method to do this? or is there another option?
self.opt={}
self.
this is the final result of the args i will be parsing for now
d={
"site_name":["s","sn","site",'sites','site_name','site_names'],
"jar_name":["j","jn","jar",'jars','jar_name','jar_names'],
"file_name":["f","fn",'file','files','filename','filenames','file_name','fi
Michele I tried your way but I dont seem to have a good grasp on the concept
yet, will read up more
for now I think I will try to make it work same way as colors only with
decorator as def inside def instead of @, that doesn't make sense quite yet
-Alex Goretoy
http://www.goretoy.com
On Sun, M
this is what I did to define all my color functions by color name, but I am
still going to need a good solution for args
#import functions by color name into current namespace
> for color in self.colors.keys():
> setattr(self, color,lambda x,y=color,z="INFO":
> self._he
this means i have to check if d[i] is list or dict and iterate over
properties
-Alex Goretoy
http://www.goretoy.com
On Sun, Mar 15, 2009 at 1:03 PM, alex goretoy
wrote:
> I will also actually need to nest it like so
>
> d={
>"site_name":["s","site",'
>>
>> sites','site_name','site_names'],
I will also actually need to nest it like so
d={
"site_name":["s","site",'
>
> sites','site_name','site_names'],
>"jar_name":["j","jar",'jars','jar_name','jar_names'],
"options":{
"src_name":["ss","src","source"],
"mod_name":['m',"mod",'mods',"module","modules"],
}
-Al
alex goretoy wrote:
I would imagine that I could do this with a generator and setattr, but I
am still learning how to do that kinda of codingmaybe if I had a
dictionary like this and then loaded it
d={
"site_name":["s","site",'sites','site_name','site_names'],
"jar_name":["j","jar"
On Sun, Mar 15, 2009 at 7:33 AM, alex goretoy
wrote:
> sweet, I've been wondering how those work. I've read some stuff about them
> and still doesn't make sense to me. Why would I want to use itPlease
> explain, thank you
Well, the typical usage for class decorators is to dynamically add
meth
sweet, I've been wondering how those work. I've read some stuff about them
and still doesn't make sense to me. Why would I want to use itPlease
explain, thank you
-Alex Goretoy
http://www.goretoy.com
On Sun, Mar 15, 2009 at 1:05 AM, Michele Simionato <
michele.simion...@gmail.com> wrote:
>
On Mar 15, 12:09 am, s...@pobox.com wrote:
> I'm doing this in my code, how to make it define all this functions for me
> with lambda, I've been up for a while and cant seem to figure it out,
> whats
> the most efficient way to do it? with lambda? how? thx
>
> def red(self,value,co
I would imagine that I could do this with a generator and setattr, but I am
still learning how to do that kinda of codingmaybe if I had a dictionary
like this and then loaded it
d={
"site_name":["s","site",'sites','site_name','site_names'],
"jar_name":["j","jar",'jars','jar_name','jar_
Nice, this is good code. Thank you. Seeing as we are still on the same
subject, how would I do it on sysarg values from getopt?
I have a main method defined like so
def main(self):
#XXX
"""
1
#get site_name: prepend to curl get/post requests
alex goretoy wrote:
I'm doing this in my code, how to make it define all this functions for
me with lambda, I've been up for a while and cant seem to figure it out,
whats the most efficient way to do it? with lambda? how? thx
def red(self,value,color='red',level='INFO'):
self.write
is this what you want (python 3.0)?
>>> class Colours:
... def __init__(self):
... for colour in ['red', 'blue']:
... setattr(self, colour, lambda value, c=colour: self.write(value, c))
... def write(self, value, colour):
... print(value, colour)
...
>>> c = Colours()
>>> c.red(
I would suggest using functools.partial like this
from functools import partial
class Foo(object):
#...
red = partial(color='red')
--
http://mail.python.org/mailman/listinfo/python-list
I'm doing this in my code, how to make it define all this functions for me
with lambda, I've been up for a while and cant seem to figure it out, whats
the most efficient way to do it? with lambda? how? thx
def red(self,value,color='red',level='INFO'):
self.write(value,color
19 matches
Mail list logo