Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7433 > unrolled thread

(*args **kwargs) how do I use' em?

Started byTheSaint <nobody@nowhere.net.no>
First post2011-06-11 13:01 +0800
Last post2011-06-11 19:32 +0800
Articles 3 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  (*args **kwargs) how do I use' em? TheSaint <nobody@nowhere.net.no> - 2011-06-11 13:01 +0800
    Re: (*args **kwargs) how do I use' em? OliDa <olivier.darge@gmail.com> - 2011-06-11 01:20 -0700
      Re: (*args **kwargs) how do I use' em? TheSaint <nobody@nowhere.net.no> - 2011-06-11 19:32 +0800

#7433 — (*args **kwargs) how do I use' em?

FromTheSaint <nobody@nowhere.net.no>
Date2011-06-11 13:01 +0800
Subject(*args **kwargs) how do I use' em?
Message-ID<isusrj$kbs$1@speranza.aioe.org>
Hello,
I'm seldomly writng python code, nothing but a beginner code.

I wrote these lines >>

=============================================================
_log_in= mhandler.ConnectHandler(lmbox, _logger, accs)
multhr= sttng['multithread']
if multhr:
    _log_in= mhandler.mThreadSession(lmbox, _logger, accs)

for svr in servrs:
    nmsvr, user, pwd, ptcl = servrs[svr]
    al, dn= sttng['Cfilter']; er= sttng['filter']
    try:
         rx.append( _log_in.connect((nmsvr, user, pwd, ptcl, (al, dn, er))))
    except ProtocolError:
         print(svr+ errors['SerProb'])
    except KeyboardInterrupt:
        raise SystemExit(errors['YouStop'])
if multhr:
    for s in rx:
        try: s.start()
        except (ProtocolError, AttributeError):
            print(svr+ errors['SerProb'])
        except KeyboardInterrupt:
            raise SystemExit(errors['YouStop'])
    for s in rx:
        try: s.join() # waiting all threads to finish
        except (ProtocolError, AttributeError):
            print(svr+ errors['SerProb'])
        except KeyboardInterrupt:
            raise SystemExit(errors['YouStop'])

=============================================================

Surely ugly and I believe that would be a better way to pass the arguments 
as I mention on the subject.
Then it should give a dictionary of keywords and some function or a 
callable. I don't know how to put down these code lines.
I think I should restructure many points of my data.

Any suggestion will make me happier :)


-- 
goto /dev/null

[toc] | [next] | [standalone]


#7438

FromOliDa <olivier.darge@gmail.com>
Date2011-06-11 01:20 -0700
Message-ID<21977783-bec2-4652-b6e4-ea2a3cd3e358@z33g2000yqb.googlegroups.com>
In reply to#7433
On 11 juin, 07:01, TheSaint <nob...@nowhere.net.no> wrote:
> Hello,
> I'm seldomly writng python code, nothing but a beginner code.
>
> I wrote these lines >>
>
> =============================================================
> _log_in= mhandler.ConnectHandler(lmbox, _logger, accs)
> multhr= sttng['multithread']
> if multhr:
>     _log_in= mhandler.mThreadSession(lmbox, _logger, accs)
>
> for svr in servrs:
>     nmsvr, user, pwd, ptcl = servrs[svr]
>     al, dn= sttng['Cfilter']; er= sttng['filter']
>     try:
>          rx.append( _log_in.connect((nmsvr, user, pwd, ptcl, (al, dn, er))))
>     except ProtocolError:
>          print(svr+ errors['SerProb'])
>     except KeyboardInterrupt:
>         raise SystemExit(errors['YouStop'])
> if multhr:
>     for s in rx:
>         try: s.start()
>         except (ProtocolError, AttributeError):
>             print(svr+ errors['SerProb'])
>         except KeyboardInterrupt:
>             raise SystemExit(errors['YouStop'])
>     for s in rx:
>         try: s.join() # waiting all threads to finish
>         except (ProtocolError, AttributeError):
>             print(svr+ errors['SerProb'])
>         except KeyboardInterrupt:
>             raise SystemExit(errors['YouStop'])
>
> =============================================================
>
> Surely ugly and I believe that would be a better way to pass the arguments
> as I mention on the subject.
> Then it should give a dictionary of keywords and some function or a
> callable. I don't know how to put down these code lines.
> I think I should restructure many points of my data.
>
> Any suggestion will make me happier :)
>
> --
> goto /dev/null

could you check the Alex Martelli comments here ?
maybe some clarification about kwargs...

http://stackoverflow.com/questions/1098549/proper-way-to-use-kwargs-in-python

OliDa

[toc] | [prev] | [next] | [standalone]


#7445

FromTheSaint <nobody@nowhere.net.no>
Date2011-06-11 19:32 +0800
Message-ID<isvjor$4l7$1@speranza.aioe.org>
In reply to#7438
OliDa wrote:

> maybe some clarification about kwargs...
> 
> http://stackoverflow.com/questions/1098549/proper-way-to-use-kwargs-in-
python

Great point. Now it's clearer :)

I think I'll share the dictionary which contains the configuration loaded 
form a file.
-- 
goto /dev/null

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web