Creating a list with holes

Larry Martell larry.martell at gmail.com
Fri Jan 3 10:41:21 EST 2014


On Fri, Jan 3, 2014 at 10:30 AM,  <eneskristo at gmail.com> wrote:
> On Friday, January 3, 2014 4:19:09 PM UTC+1, Larry.... at gmail.com wrote:
>> I think I know the answer is no, but is there any package that allows
>>
>> creating a list with holes in it? E.g. I'd want to do something like:
>>
>> x[10] = 12
>> x[20] = 30
>>
>> I'm thinking of something like defaultdict but for lists (I know
>>
>> that's very different, but ... )
>
> Hello Larry!
>
> The thing is, where to put the holes? A costum function can be made if you want the hole to be placed for example:
> 1. In random
> 2. Every nth hole(Or with another sequence)
> 3. In the beginning or end.
>
> Please tell me how do you want them, and I will try my best to help!

The holes would be between the items I put in. In my example above, if
I assigned to [10] and [20], then the other items ([0..9] and
[11..19]) would have None.



More information about the Python-list mailing list