Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #50592
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-07-13 04:47 -0700 |
| References | <fba5dac7-963f-4c1b-b40b-c0a54d681530@googlegroups.com> <mailman.4672.1373700539.3114.python-list@python.org> |
| 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 |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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