# [Chicago] Cartesian 1111 to 4444.....to nnnn (general case)

Carl Karsten carl at personnelware.com
Fri Jul 17 14:37:59 CEST 2015

```    def __init__(self, int1 = 1, int2 = 1, int3 = 1, int4 = 0):
self.int1 = int1
self.int2 = int2
self.int3 = int3
self.int4 = int4

1,2,3,4 hard coded is generally a red flag that you should be using a list.

I didn't look at what the code is doing, but you should be able to replace
all the int1 with i[1]
(don't use int[1], int is a reserved word)

Step 2: Once you have that working, you should be able to replace all the
1,2,3,4's with for n in range(1,5): i[n]

On Fri, Jul 17, 2015 at 12:30 AM, Lewit, Douglas <d-lewit at neiu.edu> wrote:

> I think this works!  Yay!!!  Although I would like to make it more general
> for any integer n besides 4.  Do I really need int1, int2, int3, int4?  I
> think all I need is the initial vector = [1, 1, 1, 1, ......, 0].
>
> Gotta go!  Oh yeah, code here is in Python 3.  Not sure how well it will
> run in Python 2.  I don't know when Python 4 is coming out, but if it's not
> backward compatible with Python 3 I have a feeling A LOT of folks in the
> Python community are going to be very, very upset!
>
> Best,
>
> Doug.
>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> https://mail.python.org/mailman/listinfo/chicago
>
>

--
Carl K
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20150717/bc51ae73/attachment.html>
```