Re: getting the center of mass of each part of a molecule

2017-05-19 Thread Gregory Ewing

qasimp...@gmail.com wrote:

"The atoms of the first part/half according to the main COM of
the ligand are C2, C7, C8 and C9. As for the second part they are C3, C4, C5
and C6 atoms."


Think *very* carefully about how you made that decision. Was it
based *only* on the position of the centre of mass, or did you
take other things into account, such as knowledge of which
atoms are bonded to which other atoms?

In other words, if someone just gave you a list of the positions
of the atoms and nothing else, would you be able to figure out
which atoms belonged to which half, without seeing a picture of
the molecule? If so, how would you do it?

If you need information about the bonds, then there's no way
a program could do it from the sample input file you provided,
because it only contains positions.

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


Re: How to install Python package from source on Windows

2017-05-19 Thread Gregory Ewing

Bart, I think the original experiment you were trying to do
(compiling Python with tcc) would be much more easily performed
on Linux than Windows. Have you considered trying that?

Configure and compile it for Linux using gcc first, then
set CC=tcc and try to compile it again. If you're lucky,
you won't have to fix too many things before it works.

You may find it's still not easy, but at least you won't
be fighting against a programmer-hostile system before
even getting started.

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


Enigma (Tantaliser 482)

2017-05-19 Thread BlindAnagram
Hi Jim,

I woke up this morning realising that my published code for this
tantaliser is not very good.

I would hence be most grateful if you could substitute the attached version.

   best regards,

  Brian

from itertools import combinations, permutations, product

# enumerate the names
A, B, C, D, E, F, G = range(7)
nms = dict(enumerate(('Alice', 'Beatrice', 'Constance', 'Deborah', 
'Emily', 'Flavia', 'Gertrude')))
# enumerate the sins
an, av, en, it, lu, pr, sl = range(7)
sns = dict(enumerate(('anger', 'avarice', 'envy', 'intemperance', 
   'lust', 'pride', 'sloth')))

# all seven sins occur among Beatrice, Deborah, Emily, Gertrude so
# we have the following arrangement of unknown sins (*), which must
# be permutations of anger, avarice, envy, intemperance and pride
#   Beatrice: *, *
#   Deborah: lust, *
#   Emily: lust, *
#   Gertrude: sloth, *
s1 = {an, av, en, it, pr}
sol_g1 = set()
for p in permutations(s1, 3):
  # the set of sins for Beatrice, Deborah, Emily and Gertrude
  tb, td, te, tg = s1.difference(p), {lu, p[0]}, {lu, p[1]}, {sl, p[2]}
  sol_g1.add(tuple(frozenset(x) for x in (tb, td, te, tg)))

# the arrangement of unknown sins among Alice, Constance and Flavia is:
#   Alice: sloth, *
#   Constance: anger, *
#   Flavia: *, *
# since each sin occurs against two names, there are 14 sins among all 
# seven names; the first group above has all seven sins plus lust, so
# this group must have all seven sins minus lust; so the four unknowns
# here must be permutations of avarice, envy, intemperance and pride
s2 = {av, en, it, pr}
sol_g2 = set()
for q in permutations(s2, 2):
  # the set of sins for Alice, Constance and Flavia
  ta, tc, tf = {sl, q[0]}, {an, q[1]}, s2.difference(q)
  sol_g2.add(tuple(frozenset(x) for x in (ta, tc, tf)))
  
for (tb, td, te, tg), (ta, tc, tf) in product(sol_g1, sol_g2):
  # map names to pairs of sins
  p2s = dict(zip(range(7), (ta, tb, tc, td, te, tf, tg)))

  # Constance, Emily and Flavia have no sin shared by any pair
  if any(p2s[x] & p2s[y] for x, y in combinations((C, E, F), 2)):
continue
  
  # Alice and Gertrude admit sloth, Deborah and Emily admit lust
  if not (sl in p2s[A] and sl in p2s[G] and lu in p2s[D] and lu in p2s[E]):
continue
  
  # Alice is not proud and Beatrice is not avaricious
  if pr in p2s[A] or av in p2s[B]:
continue
  
  # Flavia is neither intemperate nor proud
  if p2s[F].intersection([it, pr]):
continue
  
  # Deborah shows no anger; Constance and Deborah share a sin 
  if an in p2s[D] or not p2s[C] & p2s[D]:
continue
  
  u = [nms[x] for x in range(7) if it in p2s[x]]
  v = [nms[x] for x in range(7) if en in p2s[x]] 
  print('Intemperance: {} and {}; Envy: {} and {}.'.format(*u, *v))
  print()
  for n in range(7):
print('{}: {}, {}'.format(nms[n], *(sns[s] for s in sorted(p2s[n]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Enigma (Tantaliser 482)

2017-05-19 Thread BlindAnagram
On 19/05/2017 10:06, BlindAnagram wrote:
> Hi Jim,
> 
> I woke up this morning realising that my published code for this
> tantaliser is not very good.
> 
> I would hence be most grateful if you could substitute the attached version.
> 
>best regards,
> 
>   Brian

Apologies - posted in error

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


Re: How to install Python package from source on Windows

2017-05-19 Thread Terry Reedy

On 5/19/2017 2:33 AM, Christian Gollwitzer wrote:

Caveat Emptor: I haven't run this build bat on Windows myself. I am a 
bit astonished it depends on svn. Which software packages does it 
download via svn?


At least some of the dependencies.  You can check the external.bat 
invoked by the -e option.


> Isn't everything hosted on git these days, or at least

mirrored somewhere where it can be accessed via git?


Until CPython switched to git 3 months ago, that was irrelevant.  Not 
everything was accessible via hg.  Since svn was needed at all, no 
reason to fiddle with what worked.


When everything else more important is done, someone will look into 
whether svn could be made *completely* unneeded.


--
Terry Jan Reedy

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


Re: How to install Python package from source on Windows

2017-05-19 Thread bartc

On 19/05/2017 04:31, Steve D'Aprano wrote:

On Fri, 19 May 2017 04:17 am, bartc wrote:



There is one uninitialised variable reported. And that is used only in
an error situation. But yes, that was a mistake.


"Only one"?




Its a bit naughty to claim "one" uninitialized variable when there are
somewhere between 10 and 28.


I thought you were compiling qcc32.c not pcc32.c.


> [steve@ando langs]$ gcc -Wall -m32 -O3 qlang/pcc32.c -opcc -lm 2>&1 | 
grep

> uninitialized | head

Which gcc version? I can't get mine (5.1.0) to report any of these, even 
with -Wall -Wextra -Wpedantic.


> qlang/pcc32.c:8952: warning: ‘c’ may be used uninitialized in this 
function


Take this example. The code fragment is this:

n = p->objptr->length;
if (!n) {
return 0;
}
hsum = csum = 0;
s = p->objptr->strptr;
av_9 = n;
while (av_9--) {
c = (uchar)*s++;
csum += c;
hsum = (hsum<<2)+c;
}
return (c+(hsum<<3)^csum^c)&2147483647;

I assume it's concerned about the use of 'c' on the last line, because 
it is only initialised in the conditional while loop. It thinks that 
that the loop may be executed zero times. But it is executed n times; 
the case of n being zero is taken care of earlier on.


I checked a few others, and they are not serious (one is in a debugging 
function that is never called from example).


I'll take care of both programs I think by putting the word 
'experimental' back in the comments. Originally such files were just 
demonstrations of how reasonably substantial programs (around 10% the 
size of CPython sources as it might have been then) could be distributed 
in a form that was as easy to build as a Hello, World program.


I don't think I claimed that they were perfect, finished products.

(But it seems I may have overestimated people's ability to compile a 
'naked' hello.c file, without a configuration script and makefile to do 
the work...)


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


Re: How to install Python package from source on Windows

2017-05-19 Thread bartc

On 19/05/2017 08:56, Gregory Ewing wrote:

Bart, I think the original experiment you were trying to do
(compiling Python with tcc) would be much more easily performed
on Linux than Windows. Have you considered trying that?


Yes, the last time I tried to compile CPython, I had to do it on Linux. 
Using configure etc, and it worked. (Turnaround time to make incremental 
changes was 5 seconds; slower than I was used to, but workable. But 
finding my way around a sprawling application on an alien OS, and with 
slow, unresponsive, unfamiliar editors was too much effort.)


I wouldn't know how to change things to use tcc, but after there's been 
a first pass with gcc, there might be a good chance that any synthesised 
headers etc are in place and will be usable for manual compiling from tcc.


 > Configure and compile it for Linux using gcc first, then

set CC=tcc and try to compile it again. If you're lucky,
you won't have to fix too many things before it works.


Actually, I remember struggling to get even tcc installed! I think I had 
to compile from source, using configure and make (and that worked, this 
being Linux). But didn't know how to set it up to work from anywhere. So 
CC=tcc might not work.



You may find it's still not easy, but at least you won't
be fighting against a programmer-hostile system before
even getting started.


By programmer-hostile do you mean Windows? Or the build system?! I'm 
quite capable of compiling the files one by one provided I knew what 
they were! And it would then be trivial to script it - but my way.


(I might well have finished the lot, even by hand, in the 2.5 hours I 
spent yesterday trying to do it via VS2015!)


These are the binary files on my Python 3.4 system:

python.exe
pythonw.exe
DLLs/pyexpat.pyd
DLLs/python3.dll
DLLs/select.pyd
DLLs/sqlite3.dll
DLLs/tcl86t.dll
DLLs/tk86t.dll
DLLs/unicodedata.pyd
DLLs/winsound.pyd
DLLs/_bz2.pyd
DLLs/_ctypes.pyd
DLLs/_ctypes_test.pyd
DLLs/_decimal.pyd
DLLs/_elementtree.pyd
DLLs/_hashlib.pyd
DLLs/_lzma.pyd
DLLs/_msi.pyd
DLLs/_multiprocessing.pyd
DLLs/_overlapped.pyd
DLLs/_socket.pyd
DLLs/_sqlite3.pyd
DLLs/_ssl.pyd
DLLs/_testbuffer.pyd
DLLs/_testcapi.pyd
DLLs/_testimportmultiple.pyd
DLLs/_tkinter.pyd

(The .pyd files are apparently .dll shared libraries if you look inside. 
Not Python code or byte-code, so the extension is confusing.)


So, which sources are needed to compile and link python.exe for example? 
Which headers or other files need to be synthesised for them can be 
compiled, and what would typical versions look like for Windows?


Just to get the ball rolling, they don't need to be perfect. Building 
python.exe would be a useful first step, even if it fails to run for 
many other reasons.


Once this exercise can be done for a compiler which is expected to (ie. 
gcc) /then/ it would be possible to try with another.


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


Re: How to install Python package from source on Windows

2017-05-19 Thread Chris Angelico
On Fri, May 19, 2017 at 9:00 PM, bartc  wrote:
> Just to get the ball rolling, they don't need to be perfect. Building
> python.exe would be a useful first step, even if it fails to run for many
> other reasons.

Actually, it's more useful if it completely fails to build. As I was
porting one particular app to OS/2, I spent about a day just getting
the configure script to succeed, upon which getting it to compile took
maybe five minutes, and getting it to run correctly with all
subcomponents was maybe another hour. The earlier it fails, the
better.

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


Re: How to install Python package from source on Windows

2017-05-19 Thread Steve D'Aprano
On Fri, 19 May 2017 08:36 pm, bartc wrote:

> Which gcc version? I can't get mine (5.1.0) to report any of these, even
> with -Wall -Wextra -Wpedantic.


[steve@ando langs]$ gcc --version
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.



Now perhaps you will feel a tiny glimmer of what it is like to support a
project like Python. You can't assume that your users are running the same
hardware and software platform you are. So you have a choice:

- refuse to support users on unusual, old, or merely different platforms;

- add complexity to your project in order to support more people.


**Which is the whole point of this argument.** You see the complexity in
Python's build process, and claim that it's unnecessary crap. After all,
your code doesn't need anything nearly so complex!

And then, almost the first time you have another person attempt to build
your software, you learn that other users are seeing behaviour that you
don't see on your platform.

Maybe the Python core devs aren't are stupid as you have been assuming.
Maybe there's a good reason for the complexity of Python.


[...]
> I assume it's concerned about the use of 'c' on the last line, because
> it is only initialised in the conditional while loop. It thinks that
> that the loop may be executed zero times. But it is executed n times;
> the case of n being zero is taken care of earlier on.

Maybe so. And maybe a smarter compiler can recognise that the variable is
actually initialised. (That's why this is a warning only, not a syntax
error: because it is conditional on compiler heuristics.)


> (But it seems I may have overestimated people's ability to compile a
> 'naked' hello.c file, without a configuration script and makefile to do
> the work...)

You shouldn't assume that all your users are C programmers.

Or rather, of course you are entitled to if you so choose. But then you
don't get to take the moral high-horse that your build-process is easy.
Easy for expert C programmers is not easy for the average person who might
want to check out your programming language.

Yes, we acknowledge that there's much improvement needed to building Python,
especially on Windows. The build process on Windows is relatively neglected
compared to Linux (but not as much as on OS X) due to the relatively few
number of Python Windows developers who have become core devs. But we
*acknowledge* that weakness, there are reasons (both practical and
historical) for that, and are (slowly) working to fix them.



-- 
Steve
Emoji: a small, fuzzy, indistinct picture used to replace a clear and
perfectly comprehensible word.

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


No module named vtkCommonCorePython

2017-05-19 Thread Nurzat Aysa
Hello everyone,
 
I have a problem to finding file in Python path,Anybody knows how to solve it?


Unexpected error: 
Traceback (most recent call last):
  File 
"/home/nurzat/Documents/vmtk-build/Install/bin/vmtklevelsetsegmentation", line 
20, in 
from vmtk import pypeserver
  File 
"/usr/local/lib/python2.7/dist-packages/vmtk-1.3.linux-x86_64.egg/vmtk/pypeserver.py",
 line 15, in 
import vtk
  File 
"/usr/local/lib/python2.7/dist-packages/vmtk-1.3.linux-x86_64.egg/vmtk/vtk/__init__.py",
 line 41, in 
from .vtkCommonCore import *
  File 
"/usr/local/lib/python2.7/dist-packages/vmtk-1.3.linux-x86_64.egg/vmtk/vtk/vtkCommonCore.py",
 line 9, in 
from vtkCommonCorePython import *
ImportError: No module named vtkCommonCorePython

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


python-enum34

2017-05-19 Thread Gene Heskett
Greetings all;

I have a need for the subjects function but installed on wheezy.  But it 
is not in the repo's.

Is there a solution that doesn't break wheezy?

Thanks.

Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page 
-- 
https://mail.python.org/mailman/listinfo/python-list


Finding sentinel text when using a thread pool...

2017-05-19 Thread Christopher Reimer

Greetings,

I'm developing a web scraper script. It takes 25 minutes to process 590 
pages and ~9,000 comments. I've been told that the script is taking too 
long.


The way the script currently works is that the page requester is a 
generator function that requests a page, checks if the page contains the 
sentinel text (i.e., "Sorry, no more comments."), and either yields the 
page and request the next page or exits the function. Every yielded page 
is parsed by Beautiful Soup and saved to disk.


Timing the page requester separately from the rest of the script and the 
end value set to 590, each page request takes 1.5 seconds.


If I use a thread pool of 16 threads, each request takes 0.1 seconds. 
(Higher thread numbers will result in the server forcibly closing the 
connection.)


I'm trying to figure out how I would find the sentinel text by using a 
thread pool. Seems like I need to request an arbitrary number of pages 
(perhaps one page per thread), evaluate the contents of each page for 
the sentinel text, and either request another set of pages or exit the 
function.


Is that the most efficient approach for using a thread pool?

I'm using this article for the thread pool coding example.

http://chriskiehl.com/article/parallelism-in-one-line/

Thank you,

Chris Reimer


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


Re: python-enum34

2017-05-19 Thread Ethan Furman

On 05/19/2017 04:49 AM, Gene Heskett wrote:


I have a need for the subjects function but installed on wheezy.  But it
is not in the repo's.

Is there a solution that doesn't break wheezy?


It's a pure Python module, so should work fine.  But I would recommend 
aenum instead as I only update enum34 with bug fixes, but I still 
actively develop aenum.


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


type hinting backward compatibility with python 3.0 to 3.4

2017-05-19 Thread Edward Ned Harvey (python)
I think it's great that for built-in types such as int and str, backward 
compatibility of type hinting annotations is baked into python 3.0 to 3.4. In 
fact, I *thought* python 3.0 to 3.4 would *ignore* annotations, but it 
doesn't...

I'm struggling to create something backward compatible that requires the 
'typing' module. For example, the following program is good in python 3.5, but 
line 11 is a syntax error in python 3.4:

 1 import sys 
 2 
 3 if sys.version_info[0] < 3:
 4 raise RuntimeError("Must use at least python version 3") 
 5 
 6 # The 'typing' module, useful for type hints, was introduced in python 
3.5 
 7 if sys.version_info[1] >= 5: 
 8 from typing import Optional
 9 
10 
11 def divider(x: int, y: int) -> Optional[float]:
12 if y == 0: 
13 return None
14 return x / y
15 
16 print("22 / 7 = " + str(divider(22, 7)))
17 print("8 / 0 = " + str(divider(8, 0)))
18

When I run this program in python 3.4, I get this:
Traceback (most recent call last):
  File "./ned.py", line 11, in 
def divider(x: int, y: int) -> Optional[float]:
NameError: name 'Optional' is not defined
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to install Python package from source on Windows

2017-05-19 Thread bartc

On 19/05/2017 12:41, Steve D'Aprano wrote:

On Fri, 19 May 2017 08:36 pm, bartc wrote:


Which gcc version? I can't get mine (5.1.0) to report any of these, even
with -Wall -Wextra -Wpedantic.



[steve@ando langs]$ gcc --version
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55)


Interesting; an older version.



Now perhaps you will feel a tiny glimmer of what it is like to support a
project like Python. You can't assume that your users are running the same
hardware and software platform you are. So you have a choice:

- refuse to support users on unusual, old, or merely different platforms;

- add complexity to your project in order to support more people.


I have up to 6 C compilers to hand (maybe 7 if clang now runs because of 
my VS2015, assuming it doesn't need MSBUILD too...). One more if I 
include mine, but that one will always work (I will guarantee it).


Every so often and I try and test with all of them, but usually it is 
gcc and tcc. (Currently, qcc/pcc32.c will fail on some because I'm 
letting through untruncated string constants.)


Some of the lesser compilers will have bugs; sometimes I can work around 
that, by changing the code. Sometimes I can't and that will be a limitation.


But the main aim is to have ONE single source (leaving aside the 
32/64-bit business) that works on anything as much as it can, and 
without ANY compiler-specific code. (Currently, there is one gcc-related 
macro, to do with its funny handling of callback functions in optimised 
mode for Win64.)


For qcc32.c [Q compiler] and mcc32.c [C compiler], those uploads are 
OS-neutral, since they are only doing file i/o (although mcc32 will then 
be a cross-compiler if not run on Windows).


For pcc32.c [Q interpreter], that is also OS-neutral but is a 
demonstration version, as it can't access arbitrary shared library 
functions.


For that, it would need LoadLibrary/GetProcAddr, or dlopen/dlsym. To 
make the demo version useful, a selection of essential functions (eg 
file handling) are provided by the host interpreter.




**Which is the whole point of this argument.** You see the complexity in
Python's build process, and claim that it's unnecessary crap.


The configure stuff certainly is. If someone could do an analysis where 
they detect the changes made by configure, then they can see how much 
work it actually did. (Or maybe it generates even more unnecessary 
stuff; I think nobody actually knows, because nobody actually wrote it.)


 After all,

your code doesn't need anything nearly so complex!

And then, almost the first time you have another person attempt to build
your software, you learn that other users are seeing behaviour that you
don't see on your platform.


Compiling a C file should be nothing at all. Especially of a known, 
working program.




Maybe the Python core devs aren't are stupid as you have been assuming.
Maybe there's a good reason for the complexity of Python.


Actually the majority of the C source is quite reasonable. It's when you 
get a preponderance of #includes, #defined, #ifs, #ifdefs and #errors, 
especially in headers, that it becomes taxing to try and follow.


That can happen if there are problems in compiling or linking and you 
need to delve into it, or just trying to understand it.


But I can't even get to that point. If I try and compile Modules/main.c 
I get:


 ./_decimal/libmpdec/mpdecimal.h:227:4: error: #error "define CONFIG_64 
or CONFIG_32"

#error "define CONFIG_64 or CONFIG_32"
 ^
 ./_decimal/libmpdec/mpdecimal.h:260:5: error: unknown type name 
'mpd_ssize_t'

  mpd_ssize_t prec;   /* precision */
 ..


You shouldn't assume that all your users are C programmers.


C is the lingua franca for open source. They don't need to understand 
the details, just what to do with the files. That means using a program 
X to turn file A into file B.



Yes, we acknowledge that there's much improvement needed to building Python,
especially on Windows.


The 'improvement' seems to involve making things more complicated rather 
than less.


(So I need VS2015, .NET, GIT, SVN and MSBUILD. Or maybe even more stuff, 
as I wasn't able to proceed to see what the next obstacle would be. Plus 
the minor detail of a C compiler! Presumably that's part of VS, but the 
most likely issue is that won't work from a command line.


Typing 'cl', if it's still called that, doesn't work. But there do 
appear be 3-4 versions of 'cl.exe' within the VS directories, so it 
doesn't bode well.)


--
bartc

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


Re: python-enum34

2017-05-19 Thread Gene Heskett
On Friday 19 May 2017 09:32:00 Ethan Furman wrote:

> On 05/19/2017 04:49 AM, Gene Heskett wrote:
> > I have a need for the subjects function but installed on wheezy. 
> > But it is not in the repo's.
> >
> > Is there a solution that doesn't break wheezy?
>
> It's a pure Python module, so should work fine.  But I would recommend
> aenum instead as I only update enum34 with bug fixes, but I still
> actively develop aenum.
>
> --
> ~Ethan~

Thank you Ethan. But pip cannot find a python-aenum either.  Do I need to 
update pip?

Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page 
-- 
https://mail.python.org/mailman/listinfo/python-list


FW: Python win 10 problem

2017-05-19 Thread Andrew Havalda


Sent from Mail for Windows 10

From: Havalda Andrew
Sent: 2017. május 18., csütörtök 19:56
To: python-list@python.org
Subject: Python win 10 problem

Dear Python team,

I have encountered a problem with Python 3.6 version, when I open IDLE it sais: 
"Subprocess startup error". I attached a photo of it. And after I click "Ok" it 
closes. I can not even use IDEs either. (I can not run a single print 
statement...)

I am using Windows 10  on a Dell laptop.( It is quite embarrassing that I have 
recently bought this laptop for my python engineering work.)

I tried to reinstall Python and to use the 64-bit and the 32-bit version too. 
Neither of them worked. I also googled my problem but none of those solutions 
helped me.

I would be grateful if you would help me solve this embarrassing problem.

I look forward to hearing from you as soon as possible.

Yours faithfully,
Andrew Havalda

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


Re: python-enum34

2017-05-19 Thread Peter Otten
Gene Heskett wrote:

> On Friday 19 May 2017 09:32:00 Ethan Furman wrote:
> 
>> On 05/19/2017 04:49 AM, Gene Heskett wrote:
>> > I have a need for the subjects function but installed on wheezy.
>> > But it is not in the repo's.
>> >
>> > Is there a solution that doesn't break wheezy?
>>
>> It's a pure Python module, so should work fine.  But I would recommend
>> aenum instead as I only update enum34 with bug fixes, but I still
>> actively develop aenum.
>>
>> --
>> ~Ethan~
> 
> Thank you Ethan. But pip cannot find a python-aenum either.  Do I need to
> update pip?

Try

$ pip install aenum

The "python-" prefix is not part of the package name on pypi, it's Debian's 
addition to distinguish it from the python3 or the hypothetical ruby, 
haskell, or you-name-it version.


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


Python subprocess error win 10

2017-05-19 Thread Havalda Andrew
Dear Python team,

I have encountered a problem with Python 3.6 version, when I open IDLE it
sais: "Subprocess startup error". I attached a photo of it. And after I
click "Ok" it closes. I can not even use IDEs either. (I can not run a
single print statement...)

I am using Windows 10  on a Dell laptop.( It is quite embarrassing that I
have recently bought this laptop for my python engineering work.)

I tried to reinstall Python and to use the 64-bit and the 32-bit version
too. Neither of them worked. I also googled my problem but none of those
solutions helped me.

I would be grateful if you would help me solve this embarrassing problem.

I look forward to hearing from you as soon as possible.

Yours faithfully,
Andrew Havalda
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: type hinting backward compatibility with python 3.0 to 3.4

2017-05-19 Thread Peter Otten
Edward Ned Harvey (python) wrote:

> I think it's great that for built-in types such as int and str, backward
> compatibility of type hinting annotations is baked into python 3.0 to 3.4.
> In fact, I *thought* python 3.0 to 3.4 would *ignore* annotations, but it
> doesn't...
> 
> I'm struggling to create something backward compatible that requires the
> 'typing' module. For example, the following program is good in python 3.5,
> but line 11 is a syntax error in python 3.4:
> 
>  1 import sys
>  2
>  3 if sys.version_info[0] < 3:
>  4 raise RuntimeError("Must use at least python version 3")
>  5
>  6 # The 'typing' module, useful for type hints, was introduced in
>  python 3.5 7 if sys.version_info[1] >= 5:
>  8 from typing import Optional
>  9
> 10
> 11 def divider(x: int, y: int) -> Optional[float]:
> 12 if y == 0:
> 13 return None
> 14 return x / y
> 15
> 16 print("22 / 7 = " + str(divider(22, 7)))
> 17 print("8 / 0 = " + str(divider(8, 0)))
> 18
> 
> When I run this program in python 3.4, I get this:
> Traceback (most recent call last):
>   File "./ned.py", line 11, in 
> def divider(x: int, y: int) -> Optional[float]:
> NameError: name 'Optional' is not defined

Luckily it's a NameError. To backport you only have to define a symbol. The 
easiest way to do that is to get hold of a copy of 3.5's typing.py, so let's 
try that first:

$ cp /usr/local/lib/python3.5/typing.py .
$ python3.4
Python 3.4.3 (default, Nov 17 2016, 01:08:31) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from typing import Optional
>>> def divider(x: int, y: int) -> Optional[float]: pass
... 
>>> 

Works...

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


RE: type hinting backward compatibility with python 3.0 to 3.4

2017-05-19 Thread Edward Ned Harvey (python)
This pattern seems to work:

import sys

if sys.version_info[0] < 3:
raise RuntimeError("Must use at least python version 3")

# The 'typing' module, useful for type hints, was introduced in python 3.5
if sys.version_info[1] >= 5:
from typing import Optional
optional_float = Optional[float]
else:
optional_float = object

def divider(x: int, y: int) -> optional_float:
if y == 0:
return None
return x / y

print("3 / 0 = " + str(divider(3,0)))
print("22 / 7 = " + str(divider(22,7)))

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


Re: Python subprocess error win 10

2017-05-19 Thread Peter Otten
Havalda Andrew wrote:

> Dear Python team,
> 
> I have encountered a problem with Python 3.6 version, when I open IDLE it
> sais: "Subprocess startup error". I attached a photo of it. 

This is a text-only list, so we will not be able to see any pictures.

> And after I
> click "Ok" it closes. I can not even use IDEs either. (I can not run a
> single print statement...)
> 
> I am using Windows 10  on a Dell laptop.( It is quite embarrassing that I
> have recently bought this laptop for my python engineering work.)
> 
> I tried to reinstall Python and to use the 64-bit and the 32-bit version
> too. Neither of them worked. I also googled my problem but none of those
> solutions helped me.
> 
> I would be grateful if you would help me solve this embarrassing problem.
> 
> I look forward to hearing from you as soon as possible.

Does the error message look like this?

"Subprocess Startup Error",
"IDLE's subprocess didn't make connection.  Either IDLE can't "
"start a subprocess or personal firewall software is blocking "
"the connection.",

Then try starting idle from the command line with the -n option. If it 
starts there may indeed be a firewall that you have to reconfigure. 

(If it still doesn't start there may be a module written by yourself hiding 
a necessary part of the standard library -- but first check for the 
firewall.)


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


Re: python-enum34

2017-05-19 Thread Gene Heskett
On Friday 19 May 2017 10:21:26 Peter Otten wrote:

> Gene Heskett wrote:
> > On Friday 19 May 2017 09:32:00 Ethan Furman wrote:
> >> On 05/19/2017 04:49 AM, Gene Heskett wrote:
> >> > I have a need for the subjects function but installed on wheezy.
> >> > But it is not in the repo's.
> >> >
> >> > Is there a solution that doesn't break wheezy?
> >>
> >> It's a pure Python module, so should work fine.  But I would
> >> recommend aenum instead as I only update enum34 with bug fixes, but
> >> I still actively develop aenum.
> >>
> >> --
> >> ~Ethan~
> >
> > Thank you Ethan. But pip cannot find a python-aenum either.  Do I
> > need to update pip?
>
> Try
>
> $ pip install aenum
>
> The "python-" prefix is not part of the package name on pypi, it's
> Debian's addition to distinguish it from the python3 or the
> hypothetical ruby, haskell, or you-name-it version.

I finally grokked that Peter, thanks.  That and pstoedit were needed yet.

Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
Genes Web page 
-- 
https://mail.python.org/mailman/listinfo/python-list


EuroPython 2017 Keynote: Katharine Jarmul

2017-05-19 Thread Alexander Hendorf
We are pleased to announce our next keynote speaker for 
EuroPython 2017: 

 * Katharine Jarmul * 


About Katharine Jarmul


Katharine Jarmul is a pythonista and founder of Kjamistan, 
a data consulting company in Berlin, Germany. 
She’s been using Python since 2008 to solve and create problems. 
She helped form the first PyLadies chapter in Los Angeles in 2010, 
and co-authored an O'Reilly book along with several video courses 
on Python and data. 

She enjoys following the latest developments 
in machine learning, natural language processing and workflow automation 
infrastructure and is generally chatty and crabby on Twitter, 
where you can keep up with her latest shenanigans (@kjam).

The Keynote: If Ethics is not None
-
The history of computing, as it’s often covered in textbooks or talks, 
remains primarily focused on a series of hardware advancements, 
architectures, operating systems and software. 

In this talk, we will instead explore the history of ethics in computing, 
touching on the early days of computers in warfare and science, 
leading up to ethical issues today such as Artificial Intelligence and privacy 
regulation.


Enjoy,
--
EuroPython 2017 Team
http://ep2017.europython.eu/
http://www.europython-society.org/

PS: Please forward or retweet to help us reach all interested parties:
https://twitter.com/europython/status/865181154214916097
Thanks.



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


Re: How to install Python package from source on Windows

2017-05-19 Thread eryk sun
On Fri, May 19, 2017 at 1:57 PM, bartc  wrote:
>> Yes, we acknowledge that there's much improvement needed to building
>> Python, especially on Windows.
>
> The 'improvement' seems to involve making things more complicated rather
> than less.
>
> (So I need VS2015, .NET, GIT, SVN and MSBUILD. Or maybe even more stuff, as
> I wasn't able to proceed to see what the next obstacle would be. Plus the
> minor detail of a C compiler! Presumably that's part of VS, but the most
> likely issue is that won't work from a command line.
>
> Typing 'cl', if it's still called that, doesn't work. But there do appear be
> 3-4 versions of 'cl.exe' within the VS directories, so it doesn't bode
> well.)

You don't need a full Visual Studio 2015 installation. You can install
Visual C++ 2015 Build Tools [1], which includes MSBuild, and use the
x86 or x64 native tools command prompt. Install the WDK to get the
Windows debuggers windbg, cdb, kd, and ntsd.

To build the external dependencies, you'll need svn and nasm in PATH.
You don't need git if you've downloaded the source manually. Ignore
the warning if it can't find git.

[1]: http://landinghub.visualstudio.com/visual-cpp-build-tools
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to install Python package from source on Windows

2017-05-19 Thread eryk sun
On Wed, May 17, 2017 at 10:49 PM, Michael Torrie  wrote:
>
> In fact Python 3.6 ships with the latest version of the MSVCRT universal 
> runtime.

Windows Python 3.6 is distributed with vcruntime140.dll, which is a
relatively small component of the CRT that's closely coupled to the
compiler. The Universal CRT (ucrtbase.dll) is an operating system
component that applications link with via API Sets such as
"api-ms-win-crt-heap-l1-1-0.dll".
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python subprocess error win 10

2017-05-19 Thread Peter Otten
Havalda Andrew wrote:

[Please answer to the list rather than in private mail. Thank you.]

> Yes, the message is exactly like that. I can't really use the command
> line, so could you please tell me how should I start it from there with
> the -n option?

I'm sorry I cannot give you any details as I'm not a Windows expert nor do I 
have a Windows system to try it. Someone else will have to help out.

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


Re: How to install Python package from source on Windows

2017-05-19 Thread bartc

On 19/05/2017 19:53, eryk sun wrote:

On Fri, May 19, 2017 at 1:57 PM, bartc  wrote:



The 'improvement' seems to involve making things more complicated rather
than less.



You don't need a full Visual Studio 2015 installation. You can install
Visual C++ 2015 Build Tools [1], which includes MSBuild, and use the
x86 or x64 native tools command prompt. Install the WDK to get the
Windows debuggers windbg, cdb, kd, and ntsd.

To build the external dependencies, you'll need svn and nasm in PATH.
You don't need git if you've downloaded the source manually. Ignore
the warning if it can't find git.

[1]: http://landinghub.visualstudio.com/visual-cpp-build-tools


TBH I've no idea what most of these things do. So if something goes 
wrong, I can't hack my way around them.


(And things will go wrong; I've just tried to uninstall VS2017, as I 
think it was, and eventually it said 'Uninstall Failed'! I download 
msbuild tools you suggested. MSBUILD, I simply don't know how to use. 
CL, either it can't find it, or it crashes. So forget it.


I'm not impressed. People are trying to be far too clever by halves and 
are forgetting the basics. Especially MS.)


But for building Python, I think trying to get these myriad applications 
working and talking to each other, and then relying on scripts that may 
unexpectedly fail, is the wrong approach. For people like me anyway.


I will look some more at the Python code, and maybe tinker with it 
trying to find out what's what, if no one can just tell me.


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


Re: How to install Python package from source on Windows

2017-05-19 Thread bartc

On 19/05/2017 12:00, bartc wrote:



These are the binary files on my Python 3.4 system:

python.exe
pythonw.exe
DLLs/pyexpat.pyd
DLLs/python3.dll

...


So, which sources are needed to compile and link python.exe for example?
Which headers or other files need to be synthesised for them [to] be
compiled, and what would typical versions look like for Windows?


I've had to compile Python on Linux so as to get some clues to what's 
happening. That configure/make process worked without a problem 
(although it imposed the output directory structure of the new Python on 
the same directory used for the sources, which was a little odd.)


If I delete the executable 'python' and run make, then it will tell me 
how python[.exe] is built: Programs/python.o plus libpython3.6m.a.


If I delete the .a file and do make again, then it will give me a list 
of object files comprising libpython3.6m.a (not sure why it needs to be 
a library, rather than bundle the list of .o files with python.o).


Anyway it's a start.

For the compilation, I think it's done with the -D compiler option (to 
pass on a special macro, which perhaps triggers certain things to be 
included or defined).



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


Re: How to install Python package from source on Windows

2017-05-19 Thread eryk sun
On Fri, May 19, 2017 at 9:18 PM, bartc  wrote:
> On 19/05/2017 19:53, eryk sun wrote:
>>
>> On Fri, May 19, 2017 at 1:57 PM, bartc  wrote:
>
>
>>> The 'improvement' seems to involve making things more complicated rather
>>> than less.
>
>
>> You don't need a full Visual Studio 2015 installation. You can install
>> Visual C++ 2015 Build Tools [1], which includes MSBuild, and use the
>> x86 or x64 native tools command prompt. Install the WDK to get the
>> Windows debuggers windbg, cdb, kd, and ntsd.
>>
>> To build the external dependencies, you'll need svn and nasm in PATH.
>> You don't need git if you've downloaded the source manually. Ignore
>> the warning if it can't find git.
>>
>> [1]: http://landinghub.visualstudio.com/visual-cpp-build-tools
>
> TBH I've no idea what most of these things do. So if something goes wrong, I
> can't hack my way around them.
>
> (And things will go wrong; I've just tried to uninstall VS2017, as I think
> it was, and eventually it said 'Uninstall Failed'! I download msbuild tools
> you suggested. MSBUILD, I simply don't know how to use. CL, either it can't
> find it, or it crashes. So forget it.

MSBuild is a build tool for C/C++ and .NET projects that are defined
by XML project files. You need it to build CPython via pcbuild.proj.

Run the x64 or x86 native tools command prompt to set up the
command-line build environment (PATH, INCLUDE, LIB). Assuming
everything is set up right, you should have no problem running cl.exe
and link.exe.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python subprocess error win 10

2017-05-19 Thread Terry Reedy

On 5/19/2017 10:27 AM, Havalda Andrew wrote:


I have encountered a problem with Python 3.6 version, when I open IDLE


How did you start IDLE?


it says: "Subprocess startup error".


There are over 5 possible reasons for this.

> I am using Windows 10

That is helpful to know.  How did you install python?  What installer, 
what options?



I tried to reinstall Python and to use the 64-bit and the 32-bit version
too. Neither of them worked.


If python starts and runs, which it did to display that message, then 
there is no reason to reinstall completely.  A repair might be needed if 
a particular file is bad.



I also googled my problem but none of those
solutions helped me.


Since you did not say what did not work, I don't know what not to 
suggest ;-).  Anyway...


Have you added any files to the Python36 directory?  If so, what.

Open a Command Prompt window.  (Type 'com' in the Win 10 search bar 
"Type here to search" and look under apps.)  After the 'path>' prompt, enter


path> python -m idlelib
or
path> py -3 -m idlelib

If you get the same message and click OK, do you see any error messages?

A workaround, hopefully temporary, is to add the -n (no subprocess) 
option for IDLE.


> python -m idlelib -n

IDLE will execute you code in the same process with IDLE's.  This 
usually works but occasionally there can be a conflict.


--
Terry Jan Reedy

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


Re: getting the center of mass of each part of a molecule

2017-05-19 Thread qasimpars
The center of mass of the whole ligand that I calculated is the center of 
geometry (the average/mean atomic positions) from the sample input file 
provided. I don't take other things into account, such as knowledge of the mass 
of each atom and so on. The difference between the center of mass and the 
center of geometry/atom positions is probably small, and my aim is only to 
select the atom closest to the center of geometry.

Dear Gregory Ewing, lets consider I get the center of geometry (the average 
positions of atoms - X, Y, Z) of the whole molecule. Then I can compare those 
average positions X, Y and Z and find the greatest one, and list separately the 
ligand atoms according to the greatest average position out of X, Y and Z (The 
greatest one is the "longest" axis of the molecule in some sense). This way, 
the ligand atoms will have been divided in two parts, right? After that, I can 
calculate the center of geometry of each part. Does this procedure make sense? 
If no, what do you suggest me to divide the ligand/molecule in two parts?




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


Re: How to install Python package from source on Windows

2017-05-19 Thread bartc

On 19/05/2017 23:22, breamore...@gmail.com wrote:

On Friday, May 19, 2017 at 1:41:02 AM UTC+1, Michael Torrie wrote:

On 05/18/2017 05:15 PM, Steve D'Aprano wrote:

Oh but this is Bart we're talking about. Of course his code generator is
perfect, it is unthinkable that it emits incorrect code.


I think we've picked on Bart enough for one day.  Fortunately he seems
rather good natured, but this is bordering on the ad hominem in my
opinion.  Sure Bart's posts often reflect a bit of confrontation in
regards to his own programming languages vs Python.  But I don't think
an attack ("of course his code generator is perfect") is called for.



I disagree entirely.  For a person who claims to have 40 years programming 
experience I say he's completely clueless.  Until such time as he can show that 
he understands source code control, the difficulties in building cross platform 
code and the other 1,000,001 problems that people who have to work in teams 
have to put up with on a daily basis, I will not be changing my opinion.  Run 
time speed, which he is completely obsessed with, is for 99.99% of programmers 
in the 21st century irrelevant.


> I disagree entirely.  For a person who claims to have 40 years
>programming experience I say he's completely clueless.  Until such time
> as he can show that he understands source code control, the
> difficulties in building cross platform code and the other 1,000,001
> problems that people who have to work in teams have to put up with on
> a daily basis, I will not be changing my opinion.

That's not really coding, IMO. Just the same sort of cooperation you 
have to do in any sort of endeavour or in a large company.


What I call coding is a lot more hands-on with less reliance on massive 
great toolsets or libraries that already contain everything you could 
possibly need.


> Run time speed, which he is completely obsessed with, is for 99.99%
> of programmers in the 21st century irrelevant.

Fortunately /some/ people are obsessed with these things, otherwise we 
wouldn't have fast processors, fast memory, fast storage, fast 
connections, nor super-optimising compilers.


And we wouldn't have people spending considerable efforts on tracing 
JITs as used for Javascript or the PyPy project for Python.


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


Re: type hinting backward compatibility with python 3.0 to 3.4

2017-05-19 Thread Steve D'Aprano
On Fri, 19 May 2017 11:35 pm, Edward Ned Harvey (python) wrote:

> I think it's great that for built-in types such as int and str, backward
> compatibility of type hinting annotations is baked into python 3.0 to 3.4.
> In fact, I *thought* python 3.0 to 3.4 would *ignore* annotations, but it
> doesn't...

Why would you think that? Was there something in the documentation or PEP
for annotations that lead you to believe that they were ignored by the
interpreter? If so, that documentation needs improvement.

 
> I'm struggling to create something backward compatible that requires the
> 'typing' module. For example, the following program is good in python 3.5,
> but line 11 is a syntax error in python 3.4:

You say "syntax error". But it isn't a syntax error, the actual error is:


> When I run this program in python 3.4, I get this:
> Traceback (most recent call last):
>   File "./ned.py", line 11, in 
> def divider(x: int, y: int) -> Optional[float]:
> NameError: name 'Optional' is not defined

NameError.

You solve this NameError the same way you solve any other NameError: by
making sure that the name "Optional" is defined.

You should actually read the error message you get, and pay attention to it.


(By the way, nobody should be using Python 3.0, it is so heavily bug-ridden
that it is not supported. Most Python 3 devs consider Python 3.3 the first
one worth supporting.)



-- 
Steve
Emoji: a small, fuzzy, indistinct picture used to replace a clear and
perfectly comprehensible word.

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


Re: How to install Python package from source on Windows

2017-05-19 Thread Chris Angelico
On Sat, May 20, 2017 at 9:29 AM, bartc  wrote:
>> I disagree entirely.  For a person who claims to have 40 years
>>programming experience I say he's completely clueless.  Until such time
>> as he can show that he understands source code control, the
>> difficulties in building cross platform code and the other 1,000,001
>> problems that people who have to work in teams have to put up with on
>> a daily basis, I will not be changing my opinion.
>
> That's not really coding, IMO. Just the same sort of cooperation you have to
> do in any sort of endeavour or in a large company.
>
> What I call coding is a lot more hands-on with less reliance on massive
> great toolsets or libraries that already contain everything you could
> possibly need.

Distinguishing the two is like trying to say that debugging isn't
coding. Sure, you can draw lines in the sand and say "this is
programming, this is something else", but the reality is that a
programmer needs to do all of the above. And while I wouldn't call you
"completely clueless", I do say that you are naive and foolish to try
to (a) write code as if you're the only person who'll ever need to run
it, and then (b) berate other people for their complicated build
systems etc. If you're going to live in a bubble, you have no right to
point fingers at people outside it. Face it: you don't even HAVE a
test suite (or at least, I couldn't find one), so you can't even
*know* whether your code works on any other system.

>> Run time speed, which he is completely obsessed with, is for 99.99%
>> of programmers in the 21st century irrelevant.
>
> Fortunately /some/ people are obsessed with these things, otherwise we
> wouldn't have fast processors, fast memory, fast storage, fast connections,
> nor super-optimising compilers.
>
> And we wouldn't have people spending considerable efforts on tracing JITs as
> used for Javascript or the PyPy project for Python.

Even the people who care about performance do not make it their sole
focus. If someone contributes a patch to CPython that makes it run ten
times faster, but totally fail on Windows 8, it will most likely be
rejected, because Windows 8 is a supported platform. Or if the patch
makes everything faster at the expense of preventing anything from
running if there's no internet connection, nobody's interested.
Performance isn't everything.

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


Re: How to install Python package from source on Windows

2017-05-19 Thread Michael Torrie
On 05/19/2017 03:38 PM, bartc wrote:
> If I delete the .a file and do make again, then it will give me a list 
> of object files comprising libpython3.6m.a (not sure why it needs to be 
> a library, rather than bundle the list of .o files with python.o).

The reason is that the core of CPython is a shared library. This is so
that Python can be embedded in other programs, and also to allow
building of C-based extensions for Python. Without the shared library to
link against, C-based extensions would be orphans without any way to
work with CPython.

> Anyway it's a start.
> 
> For the compilation, I think it's done with the -D compiler option (to 
> pass on a special macro, which perhaps triggers certain things to be 
> included or defined).

Some things are defined that way yes. Other things are defined in the
generated header file mentioned by someone else the other day.


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


Re: How to install Python package from source on Windows

2017-05-19 Thread Gregory Ewing

bartc wrote:
Actually, I remember struggling to get even tcc installed! I think I had 
to compile from source, using configure and make (and that worked, this 
being Linux). But didn't know how to set it up to work from anywhere. So 
CC=tcc might not work.


If it comes with a standard gnu config arrangement, and you let it
use all its defaults, "make install" should install it in /usr/local
or some such well-known place.


By programmer-hostile do you mean Windows?


Yes. At least it seems that way to people who are used to developing
on unix systems. For example, your problems with not being able to
run programs from the command line even though they're installed
hardly ever happens on unix, because everything goes in /usr/bin
or /usr/local/bin.

However, I'm not sure why you had so much trouble compiling it even
after installing the recommended version of VS, seems to me it should
have been smoother if you were just trying to do a standard build.
You would have to ask someone with more Windows knowledge than me.

What I can say is that I think you have a better chance of using tcc
as a drop-in replacement for gcc on linux than you do of plugging it
into the VS build system.

I'm 
quite capable of compiling the files one by one provided I knew what 
they were!


As has been said, figuring out which files to compile is the least hard
part -- it's coming up with the right config settings for your platform
that makes the build system so complicated.

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


Re: How to install Python package from source on Windows

2017-05-19 Thread Gregory Ewing

Steve D'Aprano wrote:

The build process on Windows is relatively neglected
compared to Linux (but not as much as on OS X)


If it's neglected on OSX, it's doing pretty well despite that!
I built Python 3.5.1 on my 10.6 system not long ago, and it
worked flawlessly.

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


Re: How to install Python package from source on Windows

2017-05-19 Thread Gregory Ewing

bartc wrote:
Compiling a C file should be nothing at all. Especially of a known, 
working program.


Writing reasonably portable C is feasible, as long as you don't
use any platform-specific system calls or libraries, don't do any
low-level bit twiddling that depends on data sizes and endianness,
don't take advantage of compiler-specific features for speed, etc.

Python does all of those things in spades. That's why it needs
so many #ifdefs.

It's when you 
get a preponderance of #includes, #defined, #ifs, #ifdefs and #errors, 
especially in headers, that it becomes taxing to try and follow.


I fully agree that such code is hard to follow. But it's hard to
see how to do any better, given that Python needs to work in such
a diverse set of environments.

I also happen to agree that the way the configuration system is
implemented, based on a mishmash of shell scripting and m4 macros,
is very difficult to follow for someone not deeply involved in its
development. Anyone else more or less needs to treat it as a black
box.

Possibly the implementation could be improved. Something written
in Python could probably be made clearer, although that would lead
to a bootstrapping problem. But however it's done, the underlying
complexity will remain, and dealing with that is never going to
be a piece of cake.

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


Re: How to install Python package from source on Windows

2017-05-19 Thread Gregory Ewing

bartc wrote:
If I delete the .a file and do make again, then it will give me a list 
of object files comprising libpython3.6m.a (not sure why it needs to be 
a library, rather than bundle the list of .o files with python.o).


Most of the interpreter is built as a library so that other
programs can embed it easily. (Usually they link to the shared
version rather than the static version, though. Not sure why
the static library is there, maybe just for completeness
in case someone wants it.)

The python executable that you normally run is just a small
stub that links to the library.

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


I need help with making my calculator

2017-05-19 Thread garsink
m using Python 3.4.2 
This is my code: 


from tkinter import* 

def iCalc(source, side): 
storeObj= Frame(source, borderwidth= 1, bd= 4, bg="powder blue") 
storeObj.pack(side=side, expand=YES, fill=BOTH) 
return storeObj 

def button (source, side, text, command=None): 
storeObj= Button(source, text=text, command=command) 
storeObj.pack(side=side, expand=YES, fill=BOTH) 
return storeObj 

class app(Frame): 
def __init__(self): 
Frame.__init__(self) 
self.option_add('*Front', 'arial 20 bold') 
self.pack(expand=YES, fill=BOTH) 
self.master.title('Calculator') 

display= StringVar() 
Entry(self, relief=RIDGE, 
  textvariable=display, justify='right', bd=30, bg="powder 
blue").pack(side=TOP, expand=YES, 

   fill=BOTH) 
for clearBut in(["CE"], ["C"]): 
erase = iCalc(self, TOP) 
for ichar in clearBut: 
button(erase, LEFT, ichar, 
   lambda storeObj=display, q=ichar: storeObj.set('')) 

for NumBut in ("789/", "456*", "123-", "0.+"): 
FunctionNum = iCalc(self, TOP) 
for iEquals in NumBut: 
button(FunctionNum, LEFT, iEquals, 
   lambda storeObj=display, q=iEquals: 
storeObj.set(storeObj.get() + q)) 

EqualsButton=iCalc(self, TOP) 
for iEquals in "=": 
if iEquals == '=': 
btniEquals= button(EqualsButton, LEFT, iEquals) 
btniEquals.bind('', 
lambda e, s=self, storeObj=display: 
s.calc(storeObj), '+') 
else: 
btniEquals= buton(EqualsButton, LEFT, iEquals, 
  lambda storeObj=display, s=' %s '%Equals: 
storeObj.set(storeObj.get()+s)) 

  

def calc(self, display): 
try: 
display.set(eval(display.get())) 
except: 
display.set("Type an actual equation please!") 



if __name__ == '__main__': 
app().mainloop() 
-- 
https://mail.python.org/mailman/listinfo/python-list


I need help with making my claculator

2017-05-19 Thread gareths2017
Im using Python 3.4.2
This is my code:


from tkinter import*

def iCalc(source, side):
storeObj= Frame(source, borderwidth= 1, bd= 4, bg="powder blue")
storeObj.pack(side=side, expand=YES, fill=BOTH)
return storeObj

def button (source, side, text, command=None):
storeObj= Button(source, text=text, command=command)
storeObj.pack(side=side, expand=YES, fill=BOTH)
return storeObj

class app(Frame):
def __init__(self):
Frame.__init__(self)
self.option_add('*Front', 'arial 20 bold')
self.pack(expand=YES, fill=BOTH)
self.master.title('Calculator')

display= StringVar()
Entry(self, relief=RIDGE,
  textvariable=display, justify='right', bd=30, bg="powder 
blue").pack(side=TOP, expand=YES,

   fill=BOTH)
for clearBut in(["CE"], ["C"]):
erase = iCalc(self, TOP)
for ichar in clearBut:
button(erase, LEFT, ichar,
   lambda storeObj=display, q=ichar: storeObj.set(''))

for NumBut in ("789/", "456*", "123-", "0.+"):
FunctionNum = iCalc(self, TOP)
for iEquals in NumBut:
button(FunctionNum, LEFT, iEquals,
   lambda storeObj=display, q=iEquals: 
storeObj.set(storeObj.get() + q))

EqualsButton=iCalc(self, TOP)
for iEquals in "=":
if iEquals == '=':
btniEquals= button(EqualsButton, LEFT, iEquals)
btniEquals.bind('',
lambda e, s=self, storeObj=display: 
s.calc(storeObj), '+')
else:
btniEquals= buton(EqualsButton, LEFT, iEquals,
  lambda storeObj=display, s=' %s '%Equals: 
storeObj.set(storeObj.get()+s))

 

def calc(self, display):
try:
display.set(eval(display.get()))
except:
display.set("Type an actual equation please!") 



if __name__ == '__main__':
app().mainloop()
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: type hinting backward compatibility with python 3.0 to 3.4

2017-05-19 Thread Gregory Ewing

Steve D'Aprano wrote:

On Fri, 19 May 2017 11:35 pm, Edward Ned Harvey (python) wrote:


I *thought* python 3.0 to 3.4 would *ignore* annotations, but it
doesn't...


Why would you think that?


Ever since Guido retconned the purpose of annotations to be
for static type hinting *only*, it would make more sense for
the interpreter to ignore them, or at least not evaluate them
immediately at run time (since it would avoid all the problems
of forward references, etc).

So I can see how someone relying on the principle of least
surprise might assume that.

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


Re: type hinting backward compatibility with python 3.0 to 3.4

2017-05-19 Thread Chris Angelico
On Sat, May 20, 2017 at 11:42 AM, Gregory Ewing
 wrote:
> Steve D'Aprano wrote:
>>
>> On Fri, 19 May 2017 11:35 pm, Edward Ned Harvey (python) wrote:
>>
>>> I *thought* python 3.0 to 3.4 would *ignore* annotations, but it
>>> doesn't...
>>
>>
>> Why would you think that?
>
>
> Ever since Guido retconned the purpose of annotations to be
> for static type hinting *only*, it would make more sense for
> the interpreter to ignore them, or at least not evaluate them
> immediately at run time (since it would avoid all the problems
> of forward references, etc).
>
> So I can see how someone relying on the principle of least
> surprise might assume that.

They're function metadata. What would the principle of least surprise
say about this?

print("Spam")
def func(arg: print("Foo") = print("Quux")):
print("Blargh")
print("Fred")
func()
print("Eggs")

What should be printed, and in what order?

Actually, Python does violate least-surprise in one area here. There's
one message that gets printed "out of order" compared to my
expectation. I wonder if it's the same one that other people will be
surprised at.

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


Re: I need help with making my calculator

2017-05-19 Thread MRAB

On 2017-05-20 02:42, gars...@gmail.com wrote:

m using Python 3.4.2
This is my code:


from tkinter import*

def iCalc(source, side):
 storeObj= Frame(source, borderwidth= 1, bd= 4, bg="powder blue")
 storeObj.pack(side=side, expand=YES, fill=BOTH)
 return storeObj

def button (source, side, text, command=None):
 storeObj= Button(source, text=text, command=command)
 storeObj.pack(side=side, expand=YES, fill=BOTH)
 return storeObj

class app(Frame):
 def __init__(self):
 Frame.__init__(self)
 self.option_add('*Front', 'arial 20 bold')
 self.pack(expand=YES, fill=BOTH)
 self.master.title('Calculator')

 display= StringVar()
 Entry(self, relief=RIDGE,
   textvariable=display, justify='right', bd=30, bg="powder 
blue").pack(side=TOP, expand=YES,

fill=BOTH)
 for clearBut in(["CE"], ["C"]):
 erase = iCalc(self, TOP)
 for ichar in clearBut:
 button(erase, LEFT, ichar,
lambda storeObj=display, q=ichar: storeObj.set(''))

 for NumBut in ("789/", "456*", "123-", "0.+"):
 FunctionNum = iCalc(self, TOP)
 for iEquals in NumBut:
 button(FunctionNum, LEFT, iEquals,
lambda storeObj=display, q=iEquals: 
storeObj.set(storeObj.get() + q))

 EqualsButton=iCalc(self, TOP)
 for iEquals in "=":
 if iEquals == '=':
 btniEquals= button(EqualsButton, LEFT, iEquals)
 btniEquals.bind('',
 lambda e, s=self, storeObj=display: 
s.calc(storeObj), '+')
 else:
 btniEquals= buton(EqualsButton, LEFT, iEquals,
   lambda storeObj=display, s=' %s '%Equals: 
storeObj.set(storeObj.get()+s))
 
   


def calc(self, display):
 try:
 display.set(eval(display.get()))
 except:
 display.set("Type an actual equation please!")



if __name__ == '__main__':
 app().mainloop()

You haven't said what the problem is, but it's because the 'calc' method 
isn't indented enough. You've indented the '__init__' method correctly, 
but not the 'calc' method.

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


Re: I need help with making my claculator

2017-05-19 Thread Chris Angelico
On Sat, May 20, 2017 at 11:40 AM,   wrote:
> def calc(self, display):
> try:
> display.set(eval(display.get()))
> except:
> display.set("Type an actual equation please!")

Without any specific questions, you're not going to get anything more
than a basic eyeballing of the code. So I'm going to say this: Don't
do this! Just plain don't! A bare "except" clause is almost never the
right thing to do, and on the rare occasions when you really want to
catch everything, at very least, report on the actual error. You're
using eval(), which means that any code can be executed, which means
that literally any exception could occur. Additionally, your
try/except is around the set and get, too. Here's how I would write
this:

def calc(self, display):
equation = display.get()
try:
result = eval(equation)
except (ValueError, TypeError):
result = ""
except Exception as e:
result = "<%s: %s>" % (type(e).__name__, str(e))
display.set(result)

That lets you give much friendlier messages on known exceptions, and
still be informative and helpful on unknown ones.

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


Re: type hinting backward compatibility with python 3.0 to 3.4

2017-05-19 Thread oliver
makes sense that the RHS of the equality (deafult value) should be
evaluated before the LHS (arg name + type) but if you hadn't pointed out
that something was not as you expected, i would not have paid attention and
anticipated as you did. Then again RHS vs LHS might have nothing to do with
the reason that the interpreter evaluates in this order :)

On Fri, 19 May 2017 at 21:59 Chris Angelico  wrote:

> On Sat, May 20, 2017 at 11:42 AM, Gregory Ewing
>  wrote:
> > Steve D'Aprano wrote:
> >>
> >> On Fri, 19 May 2017 11:35 pm, Edward Ned Harvey (python) wrote:
> >>
> >>> I *thought* python 3.0 to 3.4 would *ignore* annotations, but it
> >>> doesn't...
> >>
> >>
> >> Why would you think that?
> >
> >
> > Ever since Guido retconned the purpose of annotations to be
> > for static type hinting *only*, it would make more sense for
> > the interpreter to ignore them, or at least not evaluate them
> > immediately at run time (since it would avoid all the problems
> > of forward references, etc).
> >
> > So I can see how someone relying on the principle of least
> > surprise might assume that.
>
> They're function metadata. What would the principle of least surprise
> say about this?
>
> print("Spam")
> def func(arg: print("Foo") = print("Quux")):
> print("Blargh")
> print("Fred")
> func()
> print("Eggs")
>
> What should be printed, and in what order?
>
> Actually, Python does violate least-surprise in one area here. There's
> one message that gets printed "out of order" compared to my
> expectation. I wonder if it's the same one that other people will be
> surprised at.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Oliver
My StackOverflow contributions
My CodeProject articles
My Github projects
My SourceForget.net projects
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: type hinting backward compatibility with python 3.0 to 3.4

2017-05-19 Thread Dan Stromberg
On Fri, May 19, 2017 at 6:35 AM, Edward Ned Harvey (python)
 wrote:
> I think it's great that for built-in types such as int and str, backward 
> compatibility of type hinting annotations is baked into python 3.0 to 3.4. In 
> fact, I *thought* python 3.0 to 3.4 would *ignore* annotations, but it 
> doesn't...

Perhaps you'd be interested in the typing backport?
https://pypi.python.org/pypi/typing
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to install Python package from source on Windows

2017-05-19 Thread Steve D'Aprano
On Sat, 20 May 2017 10:43 am, Gregory Ewing wrote:

> bartc wrote:
[...]
>> By programmer-hostile do you mean Windows?
> 
> Yes. At least it seems that way to people who are used to developing
> on unix systems. For example, your problems with not being able to 
> run programs from the command line even though they're installed
> hardly ever happens on unix, because everything goes in /usr/bin
> or /usr/local/bin.

Or /sbin or /usr/sbin or /opt :-)

/sbin is often left out of the path of ordinary users.


-- 
Steve
Emoji: a small, fuzzy, indistinct picture used to replace a clear and
perfectly comprehensible word.

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


Re: getting the center of mass of each part of a molecule

2017-05-19 Thread jladasky
On Friday, May 19, 2017 at 4:17:23 PM UTC-7, qasi...@gmail.com wrote:
> The center of mass of the whole ligand that I calculated is the center of 
> geometry (the average/mean atomic positions) from the sample input file 
> provided. I don't take other things into account, such as knowledge of the 
> mass of each atom and so on. The difference between the center of mass and 
> the center of geometry/atom positions is probably small, and my aim is only 
> to select the atom closest to the center of geometry.

Just a quick note, the image that you showed at the beginning of this 
discussion would not have picked C1 as the closest atom to the center of the 
molecule.  If your molecule consisted of only the benzene ring C1...C6, the 
center of mass would be exactly at the center.  Adding C7 would shift the 
center directly toward C2.  C8 and C9, as you have drawn them, shift the center 
further, in a direction pointing somewhere between C2 and C4.

> Dear Gregory Ewing, lets consider I get the center of geometry (the average 
> positions of atoms - X, Y, Z) of the whole molecule. Then I can compare those 
> average positions X, Y and Z and find the greatest one, and list separately 
> the ligand atoms according to the greatest average position out of X, Y and Z 
> (The greatest one is the "longest" axis of the molecule in some sense). This 
> way, the ligand atoms will have been divided in two parts, right? After that, 
> I can calculate the center of geometry of each part. Does this procedure make 
> sense? If no, what do you suggest me to divide the ligand/molecule in two 
> parts?

Any procedure that serves your intended purpose is the one that makes sense.  
Personally, I don't understand the goal of dividing a molecule into two parts 
and then computing separate centers of mass for each, but maybe you can explain 
why this is a useful thing to do.

As you have described it, here is one possible way to proceed?

1) Identify "the" atom which is closest to the center of mass.  As I mentioned, 
there could be more than one atom which is the same distance from the center.  
You need to define what to do in that case.
2) Rank the atoms in order of Euclidean distance from the center; choose "the 
one" that is farthest from the center.  Again, there could be ties.  What do 
you do?
4) Define a vector from the center to the most distant atom.
5) The plane that divides the molecule in half is defined as passing through 
"the" central atom, and is normal to the vector.

I'm not sure that's what you want.  Using this algorithm, the picture that you 
show would not divide the molecule in the way you describe.  I predict that C2 
would be closest to the center of mass, so C2 would be the excluded atom.  C9 
would be the most distant from the center of mass.  C1, C3, C5 and C6 would be 
on one side of the dividing plane.  C7, C8, and C9 would be on the other.  I'm 
not quite sure which side C4 would be on.

In your data table, you did not give coordinates for all 9 atoms.  With that 
information we could check whether your coordinates agree with your picture.
-- 
https://mail.python.org/mailman/listinfo/python-list