Re: Partitioning a list

2018-08-22 Thread Paul Moore
On Wed, 22 Aug 2018 at 00:44, Poul Riis  wrote:
>
> I would like to list all possible ways to put N students in groups of k 
> students (suppose that k divides N) with the restriction that no two students 
> should ever meet each other in more than one group.
> I think this is a classical problem and I think there must be a python 
> solution out there but I cannot find it. For instance, numpy's array_split 
> only lists one (trivial) split.
> I would be happy if someone could refer me to a general python algorithm 
> solving the problem.

The basic problem seems to be a simple case of looking for
combinations of k items from N, which is something itertools can help
you with. I don't understand the restriction (or at least, if I
understand the basic requirement then the restriction makes no sense
to me, as a set of combinations only puts any one student in one
group, so "meeting someone in more than one group" isn't possible).
But what I'd be inclined to do, at least as a first approach (refine
it if it's too slow for your real case) is to take each basic
solution, and check if it satisfies the extra constraint - keep the
ones that do.

Combinatorial problems typically grow very fast as N (and/or k)
increase, so that approach may not work as a practical solution, but
it will at least mean that you code your requirement in an executable
form (which you can test for small numbers) and then you'll have a
more precise problem to describe when looking for help tuning it.

Paul
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Saving application configuration to the ini file respecting order of sections/options and providing mechanism for (nested) complex objects

2018-08-22 Thread zljubisic
Thanks. As I can see python 3.7 is the best option.
Thank you very very muchs for the code as well.

Best regards.
-- 
https://mail.python.org/mailman/listinfo/python-list


zpifile.py error - no crc 32 attribute

2018-08-22 Thread jacob m
 Hi guys,
I have a problem with zipfile and zlib module, and hope to get some help.

That's my error:
"import zipfile
  File "/home/lib/python3.7/lib/python3.7/zipfile.py", line 19, in 
crc32 = zlib.crc32
AttributeError: module 'zlib' has no attribute 'crc32' "

I have no idea what to do with that :/ I use this version of zipfile:
https://github.com/python/cpython/blob/3.7/Lib/zipfile.py

Somebody knows how to solve it?
Regards
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Partitioning a list

2018-08-22 Thread Richard Damon

> On Aug 22, 2018, at 8:51 AM, Paul Moore  wrote:
> 
>> On Wed, 22 Aug 2018 at 00:44, Poul Riis  wrote:
>> 
>> I would like to list all possible ways to put N students in groups of k 
>> students (suppose that k divides N) with the restriction that no two 
>> students should ever meet each other in more than one group.
>> I think this is a classical problem and I think there must be a python 
>> solution out there but I cannot find it. For instance, numpy's array_split 
>> only lists one (trivial) split.
>> I would be happy if someone could refer me to a general python algorithm 
>> solving the problem.
> 
> The basic problem seems to be a simple case of looking for
> combinations of k items from N, which is something itertools can help
> you with. I don't understand the restriction (or at least, if I
> understand the basic requirement then the restriction makes no sense
> to me, as a set of combinations only puts any one student in one
> group, so "meeting someone in more than one group" isn't possible).
> But what I'd be inclined to do, at least as a first approach (refine
> it if it's too slow for your real case) is to take each basic
> solution, and check if it satisfies the extra constraint - keep the
> ones that do.
> 
> Combinatorial problems typically grow very fast as N (and/or k)
> increase, so that approach may not work as a practical solution, but
> it will at least mean that you code your requirement in an executable
> form (which you can test for small numbers) and then you'll have a
> more precise problem to describe when looking for help tuning it.
> 
> Paul
> 
Paul, my understanding of the problem is that you want to create multiple 
divisions of the larger group into smaller groups, such that if two people are 
in the same group in 1 division, they never appear together in other divisions.

One sample problem which I have had to solve with a similar restriction (but in 
my case was to minimize not eliminate repeats) was scheduling races. Say you 
have 9 cars you want to race in triples, and no pair of cars should ever meet 
twice. One option would be the following matches:
1,2,3; 4,5,6; 7,8,9
1,4,7; 2,5,8; 3,6,9
1,5,9; 2,6,7; 3,4,8
1,6,8; 2,4,9; 3,5,7
You can show this is the most number of triples you can get out of 9, as every 
number has been paired with every other number once, so to create another 
triple, you must get a duplicate pairing.
I don’t know of any general algorithm to generate these.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: zpifile.py error - no crc 32 attribute

2018-08-22 Thread Peter Pearson
On Wed, 22 Aug 2018 13:12:59 +0200, jacob m  wrote:
[snip]
> That's my error:
> "import zipfile
>   File "/home/lib/python3.7/lib/python3.7/zipfile.py", line 19, in 
> crc32 = zlib.crc32
> AttributeError: module 'zlib' has no attribute 'crc32' "
>
> I have no idea what to do with that :/ I use this version of zipfile:
> https://github.com/python/cpython/blob/3.7/Lib/zipfile.py
>
> Somebody knows how to solve it?

zipfile imports zlib and expects zlib to define something called crc32.
On your system, for some reason, the zlib that's being imported doesn't
define anything called crc32.  Is there perhaps a different zlib on
your path, hiding the real zlib?

-- 
To email me, substitute nowhere->runbox, invalid->com.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: zpifile.py error - no crc 32 attribute

2018-08-22 Thread jacob m
 Hi,
" Is there perhaps a different zlib on
your path, hiding the real zlib?" - I'm unsure of that.

"sudo apt-get install zlib1g-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
zlib1g-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded."
Regards


On 22 August 2018 at 13:12, jacob m  wrote:

> Hi guys,
> I have a problem with zipfile and zlib module, and hope to get some help.
>
> That's my error:
> "import zipfile
>   File "/home/lib/python3.7/lib/python3.7/zipfile.py", line 19, in
> 
> crc32 = zlib.crc32
> AttributeError: module 'zlib' has no attribute 'crc32' "
>
> I have no idea what to do with that :/ I use this version of zipfile:
> https://github.com/python/cpython/blob/3.7/Lib/zipfile.py
>
> Somebody knows how to solve it?
> Regards
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Partitioning a list

2018-08-22 Thread Paul Moore
On Wed, 22 Aug 2018 at 17:33, Richard Damon  wrote:
> Paul, my understanding of the problem is that you want to create multiple 
> divisions of the larger group into smaller groups, such that if two people 
> are in the same group in 1 division, they never appear together in other 
> divisions.
>
> One sample problem which I have had to solve with a similar restriction (but 
> in my case was to minimize not eliminate repeats) was scheduling races. Say 
> you have 9 cars you want to race in triples, and no pair of cars should ever 
> meet twice. One option would be the following matches:
> 1,2,3; 4,5,6; 7,8,9
> 1,4,7; 2,5,8; 3,6,9
> 1,5,9; 2,6,7; 3,4,8
> 1,6,8; 2,4,9; 3,5,7
> You can show this is the most number of triples you can get out of 9, as 
> every number has been paired with every other number once, so to create 
> another triple, you must get a duplicate pairing.
> I don’t know of any general algorithm to generate these.

I don't know of a general algorithm for that either. What I'd do is:

1. Generate all the combinations
2. Run through them, keeping track of all pairings we've seen in
already-accepted combinations
3. If the new combination has no "already seen" pairings, yield it and
add its pairings to the set of already seen ones, otherwise skip it.

I think that gives the expected result.

Paul
-- 
https://mail.python.org/mailman/listinfo/python-list


What is the pattern?

2018-08-22 Thread no
I asked this before but my Usenet reader only saves messages for 30
days.  I still can't get the pattern for this chart.
I started working on the code that should print it, but I never
remembered how to do it.

empire={6:"Infantry",12:"Armor/Fighter",30:"Transport"}
for x in range (6,120,6):
print(x,x - x / 6)

Anyone want to fill in the blanks to give this chart?
https://imgur.com/a/OR0WKsv
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: zpifile.py error - no crc 32 attribute

2018-08-22 Thread jacob m
" import zlib
print(zlib.__file__)"

When I don't have the zlib uploaded to my Python3.7 library, I have the
following error:
"Traceback (most recent call last):
  File "./testx.py", line 2, in 
import zlib
ModuleNotFoundError: No module named 'zlib'"

When I download the zlib 1.2.11 from http://www.zlib.net/, rename the
"zlib-1.2.11" folder into "zlib" (after unpacking) and upload it into
Python library, the result is:
"# ./testx.py
None
"
In the second case I still have the AttributeError with crc32.



On 22 August 2018 at 23:09, Ashok Arora  wrote:

> Test this in the interpreter:-
>
> import zlib
> zlib.__file__
>
> It will return the location of zlib module.
>
> On 8/22/18, jacob m  wrote:
> >  Hi,
> > " Is there perhaps a different zlib on
> > your path, hiding the real zlib?" - I'm unsure of that.
> >
> > "sudo apt-get install zlib1g-dev
> > Reading package lists... Done
> > Building dependency tree
> > Reading state information... Done
> > zlib1g-dev is already the newest version.
> > 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded."
> > Regards
> >
> >
> > On 22 August 2018 at 13:12, jacob m  wrote:
> >
> >> Hi guys,
> >> I have a problem with zipfile and zlib module, and hope to get some
> help.
> >>
> >> That's my error:
> >> "import zipfile
> >>   File "/home/lib/python3.7/lib/python3.7/zipfile.py", line 19, in
> >> 
> >> crc32 = zlib.crc32
> >> AttributeError: module 'zlib' has no attribute 'crc32' "
> >>
> >> I have no idea what to do with that :/ I use this version of zipfile:
> >> https://github.com/python/cpython/blob/3.7/Lib/zipfile.py
> >>
> >> Somebody knows how to solve it?
> >> Regards
> >>
> >>
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: zpifile.py error - no crc 32 attribute

2018-08-22 Thread Ashok Arora
Test this in the interpreter:-

import zlib
zlib.__file__

It will return the location of zlib module.

On 8/22/18, jacob m  wrote:
>  Hi,
> " Is there perhaps a different zlib on
> your path, hiding the real zlib?" - I'm unsure of that.
>
> "sudo apt-get install zlib1g-dev
> Reading package lists... Done
> Building dependency tree
> Reading state information... Done
> zlib1g-dev is already the newest version.
> 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded."
> Regards
>
>
> On 22 August 2018 at 13:12, jacob m  wrote:
>
>> Hi guys,
>> I have a problem with zipfile and zlib module, and hope to get some help.
>>
>> That's my error:
>> "import zipfile
>>   File "/home/lib/python3.7/lib/python3.7/zipfile.py", line 19, in
>> 
>> crc32 = zlib.crc32
>> AttributeError: module 'zlib' has no attribute 'crc32' "
>>
>> I have no idea what to do with that :/ I use this version of zipfile:
>> https://github.com/python/cpython/blob/3.7/Lib/zipfile.py
>>
>> Somebody knows how to solve it?
>> Regards
>>
>>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: zpifile.py error - no crc 32 attribute

2018-08-22 Thread Thomas Jollans



On 08/23/2018 12:43 AM, jacob m wrote:

" import zlib
print(zlib.__file__)"

When I don't have the zlib uploaded to my Python3.7 library, I have the
following error:
"Traceback (most recent call last):
   File "./testx.py", line 2, in 
 import zlib
ModuleNotFoundError: No module named 'zlib'"


zlib is part of the standard library. It should have been there when you 
installed Python.



When I download the zlib 1.2.11 from http://www.zlib.net/, rename the
"zlib-1.2.11" folder into "zlib" (after unpacking) and upload it into
Python library, the result is:


Don't do that.

 * that's not a Python package. It has no business being in the Python 
path.
 * don't put things into the Python path willy-nilly. Let the canonical 
tools (i.e.: pip, setup.py files, etc.) take care of it.
 * DEFINITELY don't put your own stuff into the *standard* library 
location. Use site-packages/ for custom packages.


Install Python again from scratch. If you can't import zlib and zipfile 
in a *clean* Python install, come back and tell us how you installed 
Python and what OS/distribution you're using. Then I'm sure we can help 
you figure out what went wrong.


If you installed from source and you didn't have zlib headers installed 
at the time, I could imagine this happening... but I have no idea if 
Python would even build without zlib.


-- Thomas



"# ./testx.py
None
"
In the second case I still have the AttributeError with crc32.



On 22 August 2018 at 23:09, Ashok Arora  wrote:


Test this in the interpreter:-

 import zlib
 zlib.__file__

It will return the location of zlib module.

On 8/22/18, jacob m  wrote:

  Hi,
" Is there perhaps a different zlib on
your path, hiding the real zlib?" - I'm unsure of that.

"sudo apt-get install zlib1g-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
zlib1g-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded."
Regards


On 22 August 2018 at 13:12, jacob m  wrote:


Hi guys,
I have a problem with zipfile and zlib module, and hope to get some

help.

That's my error:
"import zipfile
   File "/home/lib/python3.7/lib/python3.7/zipfile.py", line 19, in

 crc32 = zlib.crc32
AttributeError: module 'zlib' has no attribute 'crc32' "

I have no idea what to do with that :/ I use this version of zipfile:
https://github.com/python/cpython/blob/3.7/Lib/zipfile.py

Somebody knows how to solve it?
Regards



--
https://mail.python.org/mailman/listinfo/python-list



--
https://mail.python.org/mailman/listinfo/python-list


Re: zpifile.py error - no crc 32 attribute

2018-08-22 Thread MRAB

On 2018-08-22 23:43, jacob m wrote:

" import zlib
print(zlib.__file__)"

When I don't have the zlib uploaded to my Python3.7 library, I have the
following error:
"Traceback (most recent call last):
   File "./testx.py", line 2, in 
 import zlib
ModuleNotFoundError: No module named 'zlib'"

When I download the zlib 1.2.11 from http://www.zlib.net/, rename the
"zlib-1.2.11" folder into "zlib" (after unpacking) and upload it into
Python library, the result is:
"# ./testx.py
None
"
In the second case I still have the AttributeError with crc32.


In the first case, without the downloaded zlip, can you import zipfile?

If yes, try:

zipfile.zlib

From what I've seen, zlib is a built-in.



On 22 August 2018 at 23:09, Ashok Arora  wrote:


Test this in the interpreter:-

import zlib
zlib.__file__

It will return the location of zlib module.

On 8/22/18, jacob m  wrote:
>  Hi,
> " Is there perhaps a different zlib on
> your path, hiding the real zlib?" - I'm unsure of that.
>
> "sudo apt-get install zlib1g-dev
> Reading package lists... Done
> Building dependency tree
> Reading state information... Done
> zlib1g-dev is already the newest version.
> 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded."
> Regards
>
>
> On 22 August 2018 at 13:12, jacob m  wrote:
>
>> Hi guys,
>> I have a problem with zipfile and zlib module, and hope to get some
help.
>>
>> That's my error:
>> "import zipfile
>>   File "/home/lib/python3.7/lib/python3.7/zipfile.py", line 19, in
>> 
>> crc32 = zlib.crc32
>> AttributeError: module 'zlib' has no attribute 'crc32' "
>>
>> I have no idea what to do with that :/ I use this version of zipfile:
>> https://github.com/python/cpython/blob/3.7/Lib/zipfile.py
>>
>> Somebody knows how to solve it?
>> Regards
>>

--
https://mail.python.org/mailman/listinfo/python-list