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


Groups > comp.lang.python > #50592

Re: help with explaining how to split a list of tuples into parts

X-Received by 10.224.54.73 with SMTP id p9mr30364580qag.1.1373716031382; Sat, 13 Jul 2013 04:47:11 -0700 (PDT)
X-Received by 10.50.101.110 with SMTP id ff14mr428739igb.9.1373716031335; Sat, 13 Jul 2013 04:47:11 -0700 (PDT)
Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.glorb.com!t19no1456565qam.0!news-out.google.com!f7ni2314qai.0!nntp.google.com!t19no1456563qam.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Sat, 13 Jul 2013 04:47:10 -0700 (PDT)
In-Reply-To <mailman.4672.1373700539.3114.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=59.167.142.22; posting-account=LtLxqAoAAADQjg1vtFVfX3d75UlsEb8Y
NNTP-Posting-Host 59.167.142.22
References <fba5dac7-963f-4c1b-b40b-c0a54d681530@googlegroups.com> <mailman.4672.1373700539.3114.python-list@python.org>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <2a457e73-cbb2-4f2f-9b84-5feaaab809dd@googlegroups.com> (permalink)
Subject Re: help with explaining how to split a list of tuples into parts
From peter@ifoley.id.au
Injection-Date Sat, 13 Jul 2013 11:47:11 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.lang.python:50592

Show key headers only | View raw


On Saturday, 13 July 2013 17:28:50 UTC+10, Peter Otten  wrote:
> 
> Every time when you have to look up something you should think 'dict', and I
> 
> expect that pretty that will happen automatically.
> 
> Also, to split a tuple into its items you can "unpack" it:
> 
> 
> 
> triple = (1, 2, 3)
> 
> one, two, three = triple
> 
> assert one == 1 and two == 2 and three == 3
> 
> 
> 
> So:
> 
> 
> 
> supported_hashes = {
> 
>     "crypt": (2, "", 13),
> 
>     "md5": (8, "$1$", 22),
> 
>     ...
> 
> }
> 
> ...
> 
> parser.add_argument(
> 
>     '--hash', default='sha512', 
> 
>     choices=supported_hashes, # accept the keys
> 
>     help='Which Hash function to use')
> 
> ...
> 
> salt_length, hash_type, expected_password_length = supported_hashes[args.hash]
> 
> ...

Hi Peter,

Thanks for the pointers I will try your suggestion out and read some more.

Peter.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

help with explaining how to split a list of tuples into parts peter@ifoley.id.au - 2013-07-12 23:43 -0700
  Re: help with explaining how to split a list of tuples into parts Peter Otten <__peter__@web.de> - 2013-07-13 09:28 +0200
    Re: help with explaining how to split a list of tuples into parts peter@ifoley.id.au - 2013-07-13 04:47 -0700
  Re: help with explaining how to split a list of tuples into parts Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-13 08:11 +0000
    Re: help with explaining how to split a list of tuples into parts peter@ifoley.id.au - 2013-07-13 05:05 -0700
      Re: help with explaining how to split a list of tuples into parts Roy Smith <roy@panix.com> - 2013-07-13 10:50 -0400
  Re: help with explaining how to split a list of tuples into parts Roy Smith <roy@panix.com> - 2013-07-13 10:33 -0400

csiph-web