On Sat, Feb 25, 2012 at 9:16 AM, Rodrick Brown wrote:
> m = { 'a': 'checkDisks()',
> 'b': 'checkMemSize()',
> 'c': 'checkBondInterfaces()'
> }
>
> runlist = [ c for c in m.keys() if c not in r.d ]
> for runable in runlist:
> eval(m[runable])
It's a reasonable tec
On Fri, Feb 24, 2012 at 2:16 PM, Rodrick Brown wrote:
> I have a bunch of sub routines that run independently to perform various
> system checks on my servers. I wanted to get an opinion on the following code
> I have about 25 independent checks and I'm adding the ability to disable
> certain c
I have a bunch of sub routines that run independently to perform various system
checks on my servers. I wanted to get an opinion on the following code I have
about 25 independent checks and I'm adding the ability to disable certain
checks that don't apply to certain hosts.
m = { 'a': 'checkDis
On Jul 14, 11:31 pm, Chris Rebert wrote:
> On Tue, Jul 14, 2009 at 1:40 PM, Mohan Parthasarathy
> wrote:
> > Hi,
> > I am a newbie. I am reading
> >http://www.network-theory.co.uk/docs/pytut/KeywordArguments.html
> > Defining a function with "N" arguments and calling them in "M" different
> > way
On Wed, Jul 15, 2009 at 11:54 AM, Tim Rowe wrote:
>
> Curiously, I never use the all-named style in Python, whereas it's my
> normal style in Ada. I shall now enter a period of self-refelection to
> try to work out why I am so inconsistent :-)
>
>
>
I use it for functions that only (or mostly) ha
2009/7/15 Jeremiah Dodds :
> As a hopefully semi-informative aside, I've been writing python code for a
> few years now, and I regularly use all four forms of argument passing listed
> above.
Curiously, I never use the all-named style in Python, whereas it's my
normal style in Ada. I shall now en
On Wed, Jul 15, 2009 at 1:42 AM, Mohan Parthasarathy wrote:
> So, all four of them above has its use cases in practice i guess.
>
> thanks
> mohan
>
As a hopefully semi-informative aside, I've been writing python code for a
few years now, and I regularly use all four forms of argument passing lis
Chris,
Thanks for your clarifications
> > I am a newbie. I am reading
> > http://www.network-theory.co.uk/docs/pytut/KeywordArguments.html
> > Defining a function with "N" arguments and calling them in "M" different
> > ways. Why does it have to be this complicated ? I like the idea of
> calling
On Tue, Jul 14, 2009 at 1:40 PM, Mohan Parthasarathy wrote:
> Hi,
> I am a newbie. I am reading
> http://www.network-theory.co.uk/docs/pytut/KeywordArguments.html
> Defining a function with "N" arguments and calling them in "M" different
> ways. Why does it have to be this complicated ? I like the
Hi,
I am a newbie. I am reading
http://www.network-theory.co.uk/docs/pytut/KeywordArguments.html
Defining a function with "N" arguments and calling them in "M" different
ways. Why does it have to be this complicated ? I like the idea of calling
the function by explicitly naming the arguments, but
Roberto Bonvallet wrote:
> SeanDavis12 wrote:
> > I have a dictionary like:
> >
> > {"a":1, "b":2}
> >
> > and I want to call a function:
> >
> > def func1(a=3,b=4):
> >print a,b
> >
> > so that I get a=1,b=2, how can I go about that?
>
> func1(**yourdict)
Thanks, Roberto.
Sean
--
http:
SeanDavis12 wrote:
> I have a dictionary like:
>
> {"a":1, "b":2}
>
> and I want to call a function:
>
> def func1(a=3,b=4):
>print a,b
>
> so that I get a=1,b=2, how can I go about that?
func1(**yourdict)
--
Roberto Bonvallet
--
http://mail.python.org/mailman/listinfo/python-list
I have a dictionary like:
{"a":1, "b":2}
and I want to call a function:
def func1(a=3,b=4):
print a,b
so that I get a=1,b=2, how can I go about that?
Thanks,
Sean
--
http://mail.python.org/mailman/listinfo/python-list
That does work yes :) I just noticed that the script had another little error in it, making me believe that the function call was crooking.Cheers TommyOn Oct 19, 2006, at 12:30 PM, Dustin J. Mitchell wrote:Tommy Grav wrote: I have a small program that goes something like thisdef funcA() : passdef
Tommy Grav wrote:
> I have a small program that goes something like this
>
> def funcA() : pass
> def funcB() : pass
> def funcC() : pass
>
> def determine(f):
> t = f()
> return t
>
> What I would like to do is be able to
>
> n = determine(funcA)
> m = determine(funcB)
>
> But I can
Tommy Grav wrote:
> I have a small program that goes something like this
>
> def funcA() : pass
> def funcB() : pass
> def funcC() : pass
>
> def determine(f):
> t = f()
> return t
>
> What I would like to do is be able to
>
> n = determine(funcA)
> m = determine(funcB)
>
> But I can't really
I have a small program that goes something like thisdef funcA() : passdef funcB() : passdef funcC() : passdef determine(f): t = f() return tWhat I would like to do is be able to n = determine(funcA)m = determine(funcB)But I can't really figure out how to do this (I think it is possible :) CheersTom
Brian wrote:
> I just have a basic style question here. Suppose you have the program:
>
> def foo1():
> do something
>
> def foo2()
> do something else
>
> Assume that you want to call these functions at execution. Is it more
> proper to call them directly like:
>
> foo1()
> foo2()
>
> o
The difference becomes clear when you import your program into another
program (or the command line python editor). __name__!='__main__' when
you import, so the functions will not be called if they're inside the
block. This is why you see this block so often at the end of scripts;
so that the scr
I just have a basic style question here. Suppose you have the program:
def foo1():
do something
def foo2()
do something else
Assume that you want to call these functions at execution. Is it more
proper to call them directly like:
foo1()
foo2()
or in an if __name__ == "__main__": ?
B
anthonyberet wrote:
> This is the first time I have tried out functions (is that the main way
> of making subroutines in Python?)
A function is allowed to change it's arguments and to return None, so
yes, you can consider it as a 'subroutine'.
>
> Anyway, my function, mutate, below
>
> #make a
Without a 'global' statement, all variables which are assigned in the body of a
function are local to that function.
Here is an example showing that f() does not create a module-level variable,
but g() does.
>>> def f():
... z = 3
...
>>> def g():
... global z
... z = 3
...
>>> z
Tr
This is the first time I have tried out functions (is that the main way
of making subroutines in Python?)
Anyway, my function, mutate, below
#make a child string by randomly changing one character of the parent
Def mutate():
newnum=random.randrange(27)
if newnum==0:
David Pratt wrote:
> Hi Kent. Thank you for your reply. I gave this a go but get the
> following traceback:
> ...
> result = validator(name, value)
> TypeError: 'str' object is not callable
>
> Have put validators in list and iterate over it as in following:
>
> validator_list =
> [is
George Sakkis wrote:
> That's a typical case for using an OO approach; just make a class for
> each validator and have a single polymorphic validate method (I would
> make validators __call__able instead of naming the method 'validate'):
>
> # Abstract Validator class; not strictly necessary but g
Cool! Many thanks George. Yes this is the way to go - objects. Much
better :-)
On Sunday, June 5, 2005, at 02:49 PM, George Sakkis wrote:
> David Pratt wrote:
>> Hi. I am creating methods for form validation. Each validator has its
>> own method and there quite a number of these. For each fi
Hi Kent. Thank you for your reply. I gave this a go but get the
following traceback:
...
result = validator(name, value)
TypeError: 'str' object is not callable
Have put validators in list and iterate over it as in following:
validator_list =
[isContainedIn,isDate,isDecimal,isEma
David Pratt wrote:
> Hi. I am creating methods for form validation. Each validator has its
> own method and there quite a number of these. For each field, I want
> to evaluate errors using one or more validators so I want to execute
> the appropriate validator methods from those available. I am
David Pratt wrote:
> Hi. I am creating methods for form validation. Each validator has its
> own method and there quite a number of these. For each field, I want to
> evaluate errors using one or more validators so I want to execute the
> appropriate validator methods from those available. I
Hi. I am creating methods for form validation. Each validator has its
own method and there quite a number of these. For each field, I want
to evaluate errors using one or more validators so I want to execute
the appropriate validator methods from those available. I am iterating
over each va
I haven't play with the thread stuff in Python (yet) but in general terms
(from a C mind), one should not expect read/write actions to be sequential
across threads. I would assume the Python threads eventually goes back to
some system calls for thread handling. If that were the case, you should
Steven Bethard wrote:
Fernando Perez wrote:
Steven Bethard wrote:
Fernando Perez wrote:
Steven Bethard wrote:
I get the correct output, but if you run this yourself, you'll see
that
the numbers 1 through 10 aren't printed in sync with the writes (i.e.
every half second); they're all printed at t
Fernando Perez wrote:
Steven Bethard wrote:
Fernando Perez wrote:
Steven Bethard wrote:
I get the correct output, but if you run this yourself, you'll see that
the numbers 1 through 10 aren't printed in sync with the writes (i.e.
every half second); they're all printed at the end. Could someone
Steven Bethard wrote:
> Fernando Perez wrote:
>> Steven Bethard wrote:
>>
>>
>>>I get the correct output, but if you run this yourself, you'll see that
>>>the numbers 1 through 10 aren't printed in sync with the writes (i.e.
>>>every half second); they're all printed at the end. Could someone
>
Fernando Perez wrote:
Steven Bethard wrote:
I get the correct output, but if you run this yourself, you'll see that
the numbers 1 through 10 aren't printed in sync with the writes (i.e.
every half second); they're all printed at the end. Could someone
explain to me why this happens, and how (if p
Steven Bethard wrote:
> I get the correct output, but if you run this yourself, you'll see that
> the numbers 1 through 10 aren't printed in sync with the writes (i.e.
> every half second); they're all printed at the end. Could someone
> explain to me why this happens, and how (if possible) I can
Thomas Rast wrote:
Steven Bethard <[EMAIL PROTECTED]> writes:
I get the correct output, but if you run this yourself, you'll see
that the numbers 1 through 10 aren't printed in sync with the writes
(i.e. every half second); they're all printed at the end. Could
someone explain to me why this happe
Steven Bethard <[EMAIL PROTECTED]> writes:
> I get the correct output, but if you run this yourself, you'll see
> that the numbers 1 through 10 aren't printed in sync with the writes
> (i.e. every half second); they're all printed at the end. Could
> someone explain to me why this happens, and ho
I'm playing around with some threading stuff right now, and I'm having a
little trouble calling a function from one thread that affects another.
Here's my setup:
py> import os, threading, time
py> def write(file_in, input_lines):
... for line in input_lines:
... time.sleep(0.5)
...
39 matches
Mail list logo