[Tutor] One shared object. class attribute or global variable?

Adam adam.jtm30 at gmail.com
Sat Mar 4 01:42:42 CET 2006


On 04/03/06, Adam <adam.jtm30 at gmail.com> wrote:
> I've got a module that needs to share a pack of cards
>
> pack = ["14s", "2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s", "10s", "11s",
>     "12s", "13s", "14d", "2d", "3d", "4d", "5d", "6d", "7d", "8d", "9d", "10d",
>     "11d", "12d", "13d", "14c", "2c", "3c", "4c", "5c", "6c", "7c", "8c", "9c",
>     "10c", "11c", "12c", "13c", "14h", "2h", "3h", "4h", "5h", "6h", "7h", "8h",
>     "9h", "10h", "11h", "12h", "13h"]
> random.shuffle(pack)
>
> do you think it is worth making a class with just this attribute or
> would this be a good place to use a global variable?
>

I just realised this probably isn't as clear as it should be, sorry
it's late. It needs to share the variable with the functions (or
methods) in the module not with anything outside of it.


More information about the Tutor mailing list