The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Make a 2d array with object in python

TODO: Pull subtitle into page object

This is how to prepopulate a two dimensional list of lists (aka array of arrays) with objects in python.

code_start_default_section code_end_default_section
Results
[[{'k': 'v'}, {'k': 'v'}, {'k': 'v'}],
   [{'k': 'v'}, {'k': 'v'}, {'k': 'v'}],
   [{'k': 'v'}, {'k': 'v'}, {'k': 'v'}],
   [{'k': 'v'}, {'k': 'v'}, {'k': 'v'}]]

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Make a 2d array with object in python


-- p

This is how to prepopulate a two dimensional
list of lists (aka array of arrays) with
objects in python.

-- code/
-- python

from pprint import pprint

  grid = []

  rows = 4
  cols = 3

  for i in range(0, rows):
    grid.append([{"k": "v"}] * cols)

  pprint(grid)

-- /code

-- results/

[[{'k': 'v'}, {'k': 'v'}, {'k': 'v'}],
   [{'k': 'v'}, {'k': 'v'}, {'k': 'v'}],
   [{'k': 'v'}, {'k': 'v'}, {'k': 'v'}],
   [{'k': 'v'}, {'k': 'v'}, {'k': 'v'}]]

-- /results


-- categories
-- Miscellaneous

-- metadata
-- date: 2022-06-02 12:06:17
-- id: 2a1nutmn
-- status: scratch
-- type: post
-- SCRUBBED_NEO: false
-- site: aws