Karlsruhe (Germany) Python User Group, December 19th 2014, 7pm

2014-12-12 Thread Jürgen A . Erhard
The Karlsruhe Python User Group (KaPy) meets again.

Friday, 2014-12-19 (December 19th) at 19:00 (7pm) in the rooms of Entropia eV
(the local affiliate of the CCC).  See http://entropia.de/wiki/Anfahrt
on how to get there.

For your calendars: meetings are held monthly, on the 3rd Friday.

There's also a mailing list at
https://lists.bl0rg.net/cgi-bin/mailman/listinfo/kapy.
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


ANN: pandas v0.15.2

2014-12-12 Thread Jeff Reback
Hello,

We are proud to announce v0.15.2 of pandas, a minor release from 0.15.1.

This release includes a small number of API changes, several new features,
enhancements, and performance improvements along with a large number of bug
fixes.

This was a short release of 4 weeks with 137 commits by 49 authors
encompassing 75 issues.

We recommend that all users upgrade to this version.

For a more full description of Whatsnew for v0.15.2, see here:
http://pandas.pydata.org/pandas-docs/stable/whatsnew.html

*What is it:*

*pandas* is a Python package providing fast, flexible, and expressive data
structures designed to make working with “relational” or “labeled” data both
easy and intuitive. It aims to be the fundamental high-level building block
for
doing practical, real world data analysis in Python. Additionally, it has
the
broader goal of becoming the most powerful and flexible open source data
analysis / manipulation tool available in any language.


Documentation:
http://pandas.pydata.org/pandas-docs/stable/

Source tarballs, windows binaries are available on PyPI:
https://pypi.python.org/pypi/pandas

windows binaries are courtesy of  Christoph Gohlke and are built on Numpy
1.8
macosx wheels are courtesy of Matthew Brett

Please report any issues here:
https://github.com/pydata/pandas/issues


Thanks

The Pandas Development Team


Contributors to the 0.15.2 release


   - Aaron Staple
   - Angelos Evripiotis
   - Artemy Kolchinsky
   - Benoit Pointet
   - Brian Jacobowski
   - Charalampos Papaloizou
   - Chris Warth
   - David Stephens
   - Fabio Zanini
   - Francesc Via
   - Henry Kleynhans
   - Jake VanderPlas
   - Jan Schulz
   - Jeff Reback
   - Jeff Tratner
   - Joris Van den Bossche
   - Kevin Sheppard
   - Matt Suggit
   - Matthew Brett
   - Phillip Cloud
   - Rupert Thompson
   - Scott E Lasley
   - Stephan Hoyer
   - Stephen Simmons
   - Sylvain Corlay
   - Thomas Grainger
   - Tiago Antao
   - Trent Hauck
   - Victor Chaves
   - Victor Salgado
   - Vikram Bhandoh
   - WANG Aiyong
   - Will Holmgren
   - behzad nouri
   - broessli
   - charalampos papaloizou
   - immerrr
   - jnmclarty
   - jreback
   - mgilbert
   - onesandzeroes
   - peadarcoyle
   - rockg
   - seth-p
   - sinhrks
   - unutbu
   - wavedatalab
   - Åsmund Hjulstad
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Call for speakers for the first PyCon Belarus. Python-announce

2014-12-12 Thread Alina Dolgikh
Hello, dear community!

I represent Belarusian Python community. We have regular monthly meet-ups
for 70-100 persons and we are going to develop further.

We are planning to make the first Belarusian PyCon on the 31st of January
and looking for speakers.

We will be glad to meet at our event speakers, which are experienced in
public talks (links for videos of public talks or for the other conferences
web-pages are preferable) and can speak at
- highload in Python
- functional style Python
- best practices on popular tools and libraries using
- data analysis
- CI, pypy, C-extensions, python performance
- Python in mobile OS (Tizen for example)
- all the other topics are welcome as well!

Organising team is ready to cover the costs for the road and accommodation
for interested speakers.

Thanks in advance and, please, send your responses or recommendations to
*alina at *dev.by. Also do not hesitate to require more information about
our community and our events.

Regards,
Alina Dolgikh,
PyCon
Minsk
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Re: Extension of while syntax

2014-12-12 Thread Mark Lawrence

On 12/12/2014 02:21, Nelson Crosby wrote:

I was thinking a bit about the following pattern:

value = get_some_value()
while value in undesired_values:
 value = get_some_value()

I've always hated code that looks like this. Partly due to the repetition, but 
partly also due to the fact that without being able to immediately recognise 
this pattern, it isn't very readable.

Python already has one-line syntaxes (e.g. list comprehensions), I was 
wondering what people thought about a similar thing with while. It might look 
something like:

value = get_some_value() while value in undesired_values()

Perhaps not this exact syntax though, as the parser might try to do `value = 
(get_some_value() while...)` instead of `(value = get_some_value) while...`.

Other languages have features which allow something to look slightly less like 
this pattern, e.g. Java:

SomeType value;
while ((/* The assignment */ value = getSomeValue()) /* Compare */ == 
undesired_value) {}

Granted, this isn't exactly tidy, but it's a little more DRY and, IMO, 
preferable.

What are other's thoughts on this?



It won't happen as different format loops have been discussed and 
rejected umpteen times over the last 20 odd years, mainly because the 
code can be restructured using break as others have already pointed out. 
 Unless of course you fork Python, joining others working on variants 
such as Python 2.8 or RickedPython :)


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Extension of while syntax

2014-12-12 Thread Chris Angelico
On Fri, Dec 12, 2014 at 7:00 PM, Mark Lawrence breamore...@yahoo.co.uk wrote:
 It won't happen as different format loops have been discussed and rejected
 umpteen times over the last 20 odd years, mainly because the code can be
 restructured using break as others have already pointed out.  Unless of
 course you fork Python, joining others working on variants such as Python
 2.8 or RickedPython :)

RickRolledPython, the variant in which errors become warnings because
it's never gonna give you up.

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


Re: Extension of while syntax

2014-12-12 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com:

 On Fri, Dec 12, 2014 at 6:10 PM, Marko Rauhamaa ma...@pacujo.net wrote:
 Chris Angelico ros...@gmail.com:

 You could deduplicate it by shifting the condition:

 while True:
 value = get_some_value()
 if value not in undesired_values: break

 But I'm not sure how common this idiom actually is.

 Extremely common, and not only in Python.

 Something like it is certainly common, but to justify dedicated
 syntax, the pure form has to be so amazingly common as to merit it.

You already showed the perfect dedicated syntax.

The variations of the while-True-...-break idiom are limitless. There's
little need to optimize it further.


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


Re: list comprehension return a list and sum over in loop

2014-12-12 Thread KK Sasa
Mark Lawrence於 2014年12月12日星期五UTC+8下午3時17分43秒寫道:
 On 12/12/2014 06:22, KK Sasa wrote:
  Hi there,
 
  The list comprehension is results = [d2(t[k]) for k in xrange(1000)], where 
  d2 is a function returning a list, say [x1,x2,x3,x4] for one example. So 
  results is a list consisting of 1000 lists, each of length four. Here, 
  what I want to get is the sum of 1000 lists, and then the result is a list 
  of length four. Is there any efficient way to do this? Because I found it 
  is slow in my case. I tried sum(d2(t[k]) for k in xrange(1000)), but it 
  returned error: TypeError: unsupported operand type(s) for +: 'int' and 
  'list'. Thanks.
 
 
 I think you need something like this 
 http://stackoverflow.com/questions/19339/a-transpose-unzip-function-in-python-inverse-of-zip
 
 I'll let you add the finishing touches if I'm correct :)
 
 -- 
 My fellow Pythonistas, ask not what our language can do for you, ask
 what you can do for our language.
 
 Mark Lawrence

Hi Mark and Yotam,
  Thanks for kind reply. I think I didn't make my problem clear enough. The 
slow part is [d2(t[k]) for k in xrange(1000)]. In addition, I don't need to 
construct a list of 1000 lists inside, but my aim is to get the sum of all 
d2(t[k]). I wonder if there is any method to sum up efficiently.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyQt: user interface freezed when using concurrent.futures.ThreadPoolExecutor

2014-12-12 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com:

 And I don't remember how Java did things, except that I struggled to
 find basic fundamental primitives like semaphores, and had to use
 synchronized functions/objects instead.

Java now has a diverse set of synchornization facilities, but the
builtin object synchronization produces excellent idioms and is usually
preferred (by me). Java also has rigorously defined its multithreaded
data model (the Happens-Before Relation).

Java's threads have two major problems:

 * The classic I/O forced you to dedicate a thread for each
   communication context (connection) because there was no multiplexing
   facility and because the sockets were blocking (and buffered IIRC).
   The thread proliferation caused serious scalability issues.
   Latter-day Java's NIO framework addresses this shortcoming to a great
   degree, but even that is a surprisingly tricky beast to program
   for -- it suffers from builtin race conditions.

 * There is no way to interrupt a thread -- except in Solaris! You can
   mark a thread for interruption and there is an associated exception
   but they are not guaranteed to be provided by JVM.

And then there's the inherent problems of thread programming:

 * Deadlocks.

 * Missing synchronization.

which in practice are just too hard for mortals. I've seen it. I've been
complicit.

Now, when it comes to Python, asyncio is its answer to Java's NIO. It
seeks to provide a cross-platform Way to Life, Universe and Everything.
A commendable objective. Unfortunately, I find the coroutine approach
artificial and unintuitive in practice. Select.epoll(EPOLLET) plus a
timer implementation easily beats it (as long as you can limit yourself
to linux).


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


How to make subprocess run for 60 sec?

2014-12-12 Thread Robert Clove
Hi All,

I have the following python script that runs.
I want is to run the subprocess to run for 60 sec and then send the SIGINT
signal to subprocess and write the output in file.

#!/usr/bin/python
import os
import subprocess
PIPE = subprocess.PIPE
import signal
import time

def handler(signum, frame):
pass

signal.signal(signal.SIGALRM, handler)
signal.alarm(60)
command = strace -c ./server
os.chdir(/root/Desktop/)
p = subprocess.Popen(command, stdout=PIPE, stderr=PIPE)
time.sleep(60)
p.send_signal(signal.SIGINT)
signal.alarm(0)
print p.communicate()[1]


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


Re: list comprehension return a list and sum over in loop

2014-12-12 Thread Christian Gollwitzer

Am 12.12.14 09:30, schrieb KK Sasa:

Mark Lawrence於 2014年12月12日星期五UTC+8下午3時17分43秒寫道:
Hi Mark and Yotam, Thanks for kind reply. I think I didn't make my
problem clear enough. The slow part is [d2(t[k]) for k in
xrange(1000)]. In addition, I don't need to construct a list of 1000
lists inside, but my aim is to get the sum of all d2(t[k]). I
wonder if there is any method to sum up efficiently.


Not sure I understand what you need, but it seems that NumPy would be a 
more efficient method. numpy.sum can sum elements along every dimensions 
of a higher-dimensional matrix, and in general NumPy stores the elements 
in native doubles instead of Python lists, which improves both 
performance and memory usage


Christian

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


Re: list comprehension return a list and sum over in loop

2014-12-12 Thread Peter Otten
KK Sasa wrote:

 Mark Lawrence於 2014年12月12日星期五UTC+8下午3時17分43秒寫道:
 On 12/12/2014 06:22, KK Sasa wrote:
  Hi there,
 
  The list comprehension is results = [d2(t[k]) for k in xrange(1000)],
  where d2 is a function returning a list, say [x1,x2,x3,x4] for one
  example. So results is a list consisting of 1000 lists, each of
  length four. Here, what I want to get is the sum of 1000 lists, and
  then the result is a list of length four. Is there any efficient way to
  do this? Because I found it is slow in my case. I tried sum(d2(t[k])
  for k in xrange(1000)), but it returned error: TypeError: unsupported
  operand type(s) for +: 'int' and 'list'. Thanks.
 
 
 I think you need something like this
 http://stackoverflow.com/questions/19339/a-transpose-unzip-function-in-python-inverse-of-zip
 
 I'll let you add the finishing touches if I'm correct :)
 
 --
 My fellow Pythonistas, ask not what our language can do for you, ask
 what you can do for our language.
 
 Mark Lawrence
 
 Hi Mark and Yotam,
   Thanks for kind reply. I think I didn't make my problem clear enough.
   The slow part is [d2(t[k]) for k in xrange(1000)]. In addition, I
   don't need to construct a list of 1000 lists inside, but my aim is to
   get the sum of all d2(t[k]). I wonder if there is any method to sum up
   efficiently.

If that is slow the culprit is probably the d2() function. If so 

results = [0] * 4
for k in xrange(1000):
for i, v in enumerate(d2(t[k])):
results[i] += v

won't help. Can you tell us what's inside d2()?

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


Re: Extension of while syntax

2014-12-12 Thread cl
Marko Rauhamaa ma...@pacujo.net wrote:
 Chris Angelico ros...@gmail.com:
 
  You could deduplicate it by shifting the condition:
 
  while True:
  value = get_some_value()
  if value not in undesired_values: break
 
  But I'm not sure how common this idiom actually is.
 
 Extremely common, and not only in Python.
 
It's the classic C 'for' loop.

'for' in C is essentially a while with an initialiser for the loop
variable.

-- 
Chris Green
·
-- 
https://mail.python.org/mailman/listinfo/python-list


encoding name mappings in codecs.py with email/charset.py

2014-12-12 Thread Stefanos Karasavvidis
I've hit a wall with mailman which seems to be caused by pyhon's character
encoding names.

I've narrowed the problem down to the email/charset.py file. Basically the
following happens:

given an encoding name as 'iso-8859-X' it is transformed to 'iso8859-X'
(without the first dash). This happens with python 2.7, but not with python
3.4. Now Microsoft Exchange doesn't like the form without the dash, and
bounces the emails from Mailman. And Mailman doesn't work with python 3.x.

This transformation is done in charset.py with the following line
input_charset = codecs.lookup(input_charset).name

The following code example demonstrates the issue
   from email.charset import Charset
   charset = Charset('iso-8859-7')
   print(str(charset))

In python 2.7, iso8859-7 is printed. In python 3.4 iso-8859-7 is printed.

I tried to find the location of these mappings in the codecs.py file, but
it seems that it uses some internal mapping I couldn't find. And I'm not
100% sure that this is not OS related.

So the question basically is if there is a way to change the name mappings
this codecs file does.

My environment is Ubuntu 14.04
python2.7 --version
Python 2.7.6

python3.4 --version
Python 3.4.0

-- 
==
Stefanos Karasavvidis,  Electronic  Computer Engineer, M.Sc.
s...@isc.tuc.gre-mail: s...@isc.tuc.gr, Tel.: (+30) 2821037508, Fax: (+30)
2821037520
Technical University of Crete, Campus, Building A1
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: list comprehension return a list and sum over in loop

2014-12-12 Thread KK Sasa
Peter Otten於 2014年12月12日星期五UTC+8下午5時13分58秒寫道:
 KK Sasa wrote:
 
  Mark Lawrence於 2014年12月12日星期五UTC+8下午3時17分43秒寫道:
  On 12/12/2014 06:22, KK Sasa wrote:
   Hi there,
  
   The list comprehension is results = [d2(t[k]) for k in xrange(1000)],
   where d2 is a function returning a list, say [x1,x2,x3,x4] for one
   example. So results is a list consisting of 1000 lists, each of
   length four. Here, what I want to get is the sum of 1000 lists, and
   then the result is a list of length four. Is there any efficient way to
   do this? Because I found it is slow in my case. I tried sum(d2(t[k])
   for k in xrange(1000)), but it returned error: TypeError: unsupported
   operand type(s) for +: 'int' and 'list'. Thanks.
  
  
  I think you need something like this
  http://stackoverflow.com/questions/19339/a-transpose-unzip-function-in-python-inverse-of-zip
  
  I'll let you add the finishing touches if I'm correct :)
  
  --
  My fellow Pythonistas, ask not what our language can do for you, ask
  what you can do for our language.
  
  Mark Lawrence
  
  Hi Mark and Yotam,
Thanks for kind reply. I think I didn't make my problem clear enough.
The slow part is [d2(t[k]) for k in xrange(1000)]. In addition, I
don't need to construct a list of 1000 lists inside, but my aim is to
get the sum of all d2(t[k]). I wonder if there is any method to sum up
efficiently.
 
 If that is slow the culprit is probably the d2() function. If so 
 
 results = [0] * 4
 for k in xrange(1000):
 for i, v in enumerate(d2(t[k])):
 results[i] += v
 
 won't help. Can you tell us what's inside d2()?

Thanks for reply, Christian and Peter. Actually, the d2() is the Hessian 
function of a simple function (derived by using ad package, 
http://pythonhosted.org//ad/). The package hasn't supported Numpy array so far. 
And I am still not how to take a look inside d2(). Because I have to use d2() 
in a heavy way for iterative algorithm, the efficiency is a issue in my case. 
Following is an example.

import scipy
from scipy import stats
import numpy
from ad import adnumber
from ad.admath import *
from ad import jacobian
from ad import gh  # the gradient and hessian functions generator
from ad import *
import time
people = 1000
range_people = xrange(people)
dim0 = 2; mean0 = [0,0]; cov0 = [[1,0],[0,1]]
seed([1])
t = stats.multivariate_normal.rvs(mean0,cov0,people)
t = t.reshape(people,dim0)
t = t.tolist() # back to list
x = [0, 0, 1, 2]
point = 2
def p(x,t,point,z,obs):
d = x[0]
tau = [0]+[x[1:point]] 
a = x[point:len(x)]
at = sum(i*j for i, j in zip(a, t))
nu = [exp(z[k]*(at-d)-sum(tau[k])) for k in xrange(point)]
de = sum(nu, axis=0)
probability = [nu[k]/de for k in xrange(point)]
return probability[obs]

d1, d2 = gh(p)
tStart = time.time()
z = range(point)
re = [d2(x,t[k],2,z,1) for k in range_people]
tEnd = time.time()
print It cost %f sec % (tEnd - tStart)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: list comprehension return a list and sum over in loop

2014-12-12 Thread Steven D'Aprano
KK Sasa wrote:

 Hi there,
 
 The list comprehension is results = [d2(t[k]) for k in xrange(1000)],
 where d2 is a function returning a list, say [x1,x2,x3,x4] for one
 example. So results is a list consisting of 1000 lists, each of length
 four. Here, what I want to get is the sum of 1000 lists, and then the
 result is a list of length four. Is there any efficient way to do this?
 Because I found it is slow in my case. I tried sum(d2(t[k]) for k in
 xrange(1000)), but it returned error: TypeError: unsupported operand
 type(s) for +: 'int' and 'list'. Thanks.

That's because sum() defaults to adding with a default value of 0:

py sum([[1, 2], [3, 4]], 0)
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: unsupported operand type(s) for +: 'int' and 'list'
py sum([[1, 2], [3, 4]], [])
[1, 2, 3, 4]


But don't do that! It will be slow.


I don't completely understand your requirements. You should show some
typical data, and the expected result. The business with the xrange and
t[k] and even d2() is probably irrelevant. The important part is summing
the lists. That could mean either of these two things:

results = [ [1, 2, 3, 4], 
[5, 6, 7, 8],
[9, 10, 11, 12]]

sum(results)
-- gives [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

The way to do this efficiently is:

results = []
for sublist in [d2(t[k]) for k in xrange(1000)]:
results.extend(sublist)


Or perhaps you mean this:


results = [ [1, 2, 3, 4], 
[5, 6, 7, 8],
[9, 10, 11, 12]]

sum(results)
-- gives [15, 18, 21, 24]


I expect that the fastest, most efficient way to do this will be with the
third-party library numpy. But in pure Python, you can do this:

def add(alist, blist):
if len(blist) != len(alist): raise ValueError
for i, x in blist:
alist[i] += x


results = [0]*4  # Like [0,0,0,0]
for sublist in [d2(t[k]) for k in xrange(1000)]:
add(results, sublist)





-- 
Steven

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


Re: Extension of while syntax

2014-12-12 Thread Marko Rauhamaa
c...@isbd.net:

 Marko Rauhamaa ma...@pacujo.net wrote:
 Chris Angelico ros...@gmail.com:
 
  You could deduplicate it by shifting the condition:
 
  while True:
  value = get_some_value()
  if value not in undesired_values: break
 
  But I'm not sure how common this idiom actually is.
 
 Extremely common, and not only in Python.
 
 It's the classic C 'for' loop.

It's the classic:

for (;;) {
...
if (...)
break;
...
}


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


Re: [newbie] how to make program suggest to install missing modules

2014-12-12 Thread hugocoolens
On Monday, December 8, 2014 9:00:13 PM UTC+1, sohca...@gmail.com wrote:
 On Monday, December 8, 2014 10:46:47 AM UTC-8, Jean-Michel Pichavant wrote:
  - Original Message -
   From: sohcahto...@gmail.com
   try:
   import someModule
   except ImportError:
   print Module is missing
   # handle it!
   
   Just make sure to attempt to import it again after making the call to
   pip to install it.
  
  Note that ImportError may be raised for other reasons than a missing module.
  
  Check https://docs.python.org/2/library/imp.html and the imp.find_module, 
  it could be a safer way to check for a missing module.
  
  JM
  
  
  -- IMPORTANT NOTICE: 
  
  The contents of this email and any attachments are confidential and may 
  also be privileged. If you are not the intended recipient, please notify 
  the sender immediately and do not disclose the contents to any other 
  person, use it for any purpose, or store or copy the information in any 
  medium. Thank you.
 Good point.
 Of course, imp.find_module ALSO throws ImportError if the module can't be 
 found, but at least in that case, you'd know the exact cause.

Thanks for the suggestions, you can see here below what I came up with.
All suggestions/corrections welcome:

#!/usr/bin/env python
import imp
import os
import sys
try:
imp.find_module('rtlsdr')
except ImportError:
print('Module rtlsdr is missing')
print(I'll try to install it)
os.system('sudo pip install pyrtlsdr')
try:
imp.find_module('rtlsdr')
except ImportError:
sys.exit('Sorry could not install module rtlsdr, contact your
local Python-guru')
import rtlsdr
print('Module rtlsdr succesfully imported')



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


Re: list comprehension return a list and sum over in loop

2014-12-12 Thread Jussi Piitulainen
KK Sasa writes:

 def p(x,t,point,z,obs):
 d = x[0]
 tau = [0]+[x[1:point]] 
 a = x[point:len(x)]
 at = sum(i*j for i, j in zip(a, t))
 nu = [exp(z[k]*(at-d)-sum(tau[k])) for k in xrange(point)]
 de = sum(nu, axis=0)
 probability = [nu[k]/de for k in xrange(point)]
 return probability[obs]

I must be blind, but this looks like computing a whole probability
distribution and then throwing almost all of it away.

Can't this just return nu[obs]/de?

The expression for tau also seems weird to me. Isn't it equivalent to
[0, x[1:point]], a two-element list with the second element a list?
How can sum(tau[k]) work at all then, for any k  1?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: is_whatever_you_are_testing_for as method or property?

2014-12-12 Thread Mateusz Loskot
On 11 December 2014 at 19:20, Chris Angelico ros...@gmail.com wrote:
 On Fri, Dec 12, 2014 at 4:34 AM, Mateusz Loskot mate...@loskot.net wrote:
 If a class member function simply tests something and
 returns a b::oolean call it

 def is_whatever_you_are_testing_for():
  pass

 like 'is_even'.

 Should I define it as a classic method

 def is_even(self):
 pass

 or as a property

 @property
 def is_even(self):
 pass

 A property should be used if what you're creating is virtually an
 attribute. If it would make sense to have an attribute is_even, then
 a property is_even makes sense. If in doubt, go with a method.

Thanks for the advise.

I've got several cases which are not obvious to me.
For instance, class Foo has a boolean attribute, read-write,
which I see a couple of realisations for possible:

1) properties only
class Foo:
  @property
  def is_default(self):
pass

  @is_default.setter
  def is_default(self, current):
pass

2) property + method mix
class Foo:
  @property
  def is_default(self):
pass

  def make_default(self, current):
pass

3) methods only
class Foo:
  def is_default(self):
pass

  def make_default(self, current):
pass

From one angle, that is is_default is known and does not need to be
calculated upon every query, the option 1) fits well.
It is aligned with Ethan's suggestion in the other post.

From other point, let's assume updating it takes a little bit of changes of
state of Foo instance, then perhaps methods-only option 3) fits best.

Looks like if in doubt, go with a method is the safest bet.
'Statistics' from Python codebase also seem to suggest that.

Best regards,
-- 
Mateusz  Loskot, http://mateusz.loskot.net
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: is_whatever_you_are_testing_for as method or property?

2014-12-12 Thread Chris Angelico
On Fri, Dec 12, 2014 at 10:21 PM, Mateusz Loskot mate...@loskot.net wrote:
 I've got several cases which are not obvious to me.
 For instance, class Foo has a boolean attribute, read-write,
 which I see a couple of realisations for possible:


0) Attribute only.

class Foo:
pass

Foo().default = True

Unless you need something more than this, go with this style. Much simpler.

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


Re: list comprehension return a list and sum over in loop

2014-12-12 Thread Peter Otten
Jussi Piitulainen wrote:

 KK Sasa writes:
 
 def p(x,t,point,z,obs):
 d = x[0]
 tau = [0]+[x[1:point]]
 a = x[point:len(x)]
 at = sum(i*j for i, j in zip(a, t))
 nu = [exp(z[k]*(at-d)-sum(tau[k])) for k in xrange(point)]
 de = sum(nu, axis=0)
 probability = [nu[k]/de for k in xrange(point)]
 return probability[obs]
 
 I must be blind, but this looks like computing a whole probability
 distribution and then throwing almost all of it away.
 
 Can't this just return nu[obs]/de?
 
 The expression for tau also seems weird to me. Isn't it equivalent to
 [0, x[1:point]], a two-element list with the second element a list?
 How can sum(tau[k]) work at all then, for any k  1?

Also, after adding 

from numpy.random import seed

to the code I run into the next problem:

Traceback (most recent call last):
  File hessian.py, line 34, in module
re = [d2(x,t[k],2,z,1) for k in range_people]
  File /home/petto/.local/lib/python2.7/site-packages/ad/__init__.py, line 
1114, in hess
return func(xa, *args).hessian([xa])
  File hessian.py, line 26, in p
nu = [exp(z[k]*(at-d)-sum(tau[k])) for k in xrange(point)]
TypeError: 'int' object is not iterable

OP: Optimizations only make sense when you can start from a known-good base. 
You should sort out the logic of your problem (we probably can't help you 
with that), then fix the bugs in your code and only then revisit the speed 
issue. 

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


Run Programming ?????

2014-12-12 Thread Delgado Motto
I travel alot, if not just interested in things of pocketable portability,
and was curious if you can tell me if Python can be LEARNED from beginner
on an IOS device ( with interest of being able to test my code, possibly
even if a free website is capable of reviewing scripts ) but if not then I
prefer if you can suggest a language that can be used from such a machine.
My ultimate goal is to be able to create web pages and internet bots
capable of searching specific things for me, simply to save me time in my
day as little as crawling Youtube for a song that fails to be uploaded or
other related examples. Please advise me. Thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [newbie] how to make program suggest to install missing modules

2014-12-12 Thread Chris Warrick
On Dec 12, 2014 11:56 AM, hugocoolens hugocool...@gmail.com wrote:

 On Monday, December 8, 2014 9:00:13 PM UTC+1, sohca...@gmail.com wrote:
  On Monday, December 8, 2014 10:46:47 AM UTC-8, Jean-Michel Pichavant
wrote:
   - Original Message -
From: sohcahto...@gmail.com
try:
import someModule
except ImportError:
print Module is missing
# handle it!
   
Just make sure to attempt to import it again after making the call
to
pip to install it.
  
   Note that ImportError may be raised for other reasons than a missing
module.
  
   Check https://docs.python.org/2/library/imp.html and the
imp.find_module, it could be a safer way to check for a missing module.
  
   JM
  
  
   -- IMPORTANT NOTICE:
  
   The contents of this email and any attachments are confidential and
may also be privileged. If you are not the intended recipient, please
notify the sender immediately and do not disclose the contents to any other
person, use it for any purpose, or store or copy the information in any
medium. Thank you.
  Good point.
  Of course, imp.find_module ALSO throws ImportError if the module can't
be found, but at least in that case, you'd know the exact cause.

 Thanks for the suggestions, you can see here below what I came up with.
 All suggestions/corrections welcome:

 #!/usr/bin/env python
 import imp
 import os
 import sys
 try:
 imp.find_module('rtlsdr')
 except ImportError:
 print('Module rtlsdr is missing')
 print(I'll try to install it)
 os.system('sudo pip install pyrtlsdr')
 try:
 imp.find_module('rtlsdr')
 except ImportError:
 sys.exit('Sorry could not install module rtlsdr, contact your
 local Python-guru')
 import rtlsdr
 print('Module rtlsdr succesfully imported')



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

This is bad practice. The user should install it themselves: sudo pip may
interfere with virtualenv and OS package managers. Just tell the user what
to install and call it a day.

-- 
Chris Warrick https://chriswarrick.com/
Sent from my Galaxy S3.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Run Programming ?????

2014-12-12 Thread Chris Warrick
On Dec 12, 2014 1:40 PM, Delgado Motto riskyay...@gmail.com wrote:

 I travel alot, if not just interested in things of pocketable
portability, and was curious if you can tell me if Python can be LEARNED
from beginner on an IOS device ( with interest of being able to test my
code, possibly even if a free website is capable of reviewing scripts ) but
if not then I prefer if you can suggest a language that can be used from
such a machine. My ultimate goal is to be able to create web pages and
internet bots capable of searching specific things for me, simply to save
me time in my day as little as crawling Youtube for a song that fails to be
uploaded or other related examples. Please advise me. Thanks.
 --
 https://mail.python.org/mailman/listinfo/python-list


Get a real computer. An iOS device won't work, unless you care to buy a
vps, use ssh and can stand the onscreen keyboard. It's easier to buy a
notebook.

-- 
Chris Warrick https://chriswarrick.com/
Sent from my Galaxy S3.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: list comprehension return a list and sum over in loop

2014-12-12 Thread KK Sasa
Jussi Piitulainen於 2014年12月12日星期五UTC+8下午7時12分39秒寫道:
 KK Sasa writes:
 
  def p(x,t,point,z,obs):
  d = x[0]
  tau = [0]+[x[1:point]] 
  a = x[point:len(x)]
  at = sum(i*j for i, j in zip(a, t))
  nu = [exp(z[k]*(at-d)-sum(tau[k])) for k in xrange(point)]
  de = sum(nu, axis=0)
  probability = [nu[k]/de for k in xrange(point)]
  return probability[obs]
 
 I must be blind, but this looks like computing a whole probability
 distribution and then throwing almost all of it away.
 
 Can't this just return nu[obs]/de?
 
 The expression for tau also seems weird to me. Isn't it equivalent to
 [0, x[1:point]], a two-element list with the second element a list?
 How can sum(tau[k]) work at all then, for any k  1?

This is just a probability of binary response. Not continuous one. Tau is a 
parameter and just have two in this case.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: list comprehension return a list and sum over in loop

2014-12-12 Thread KK Sasa
Peter Otten於 2014年12月12日星期五UTC+8下午8時32分55秒寫道:
 Jussi Piitulainen wrote:
 
  KK Sasa writes:
  
  def p(x,t,point,z,obs):
  d = x[0]
  tau = [0]+[x[1:point]]
  a = x[point:len(x)]
  at = sum(i*j for i, j in zip(a, t))
  nu = [exp(z[k]*(at-d)-sum(tau[k])) for k in xrange(point)]
  de = sum(nu, axis=0)
  probability = [nu[k]/de for k in xrange(point)]
  return probability[obs]
  
  I must be blind, but this looks like computing a whole probability
  distribution and then throwing almost all of it away.
  
  Can't this just return nu[obs]/de?
  
  The expression for tau also seems weird to me. Isn't it equivalent to
  [0, x[1:point]], a two-element list with the second element a list?
  How can sum(tau[k]) work at all then, for any k  1?
 
 Also, after adding 
 
 from numpy.random import seed
 
 to the code I run into the next problem:
 
 Traceback (most recent call last):
   File hessian.py, line 34, in module
 re = [d2(x,t[k],2,z,1) for k in range_people]
   File /home/petto/.local/lib/python2.7/site-packages/ad/__init__.py, line 
 1114, in hess
 return func(xa, *args).hessian([xa])
   File hessian.py, line 26, in p
 nu = [exp(z[k]*(at-d)-sum(tau[k])) for k in xrange(point)]
 TypeError: 'int' object is not iterable
 
 OP: Optimizations only make sense when you can start from a known-good base. 
 You should sort out the logic of your problem (we probably can't help you 
 with that), then fix the bugs in your code and only then revisit the speed 
 issue.

I have no idea why you added from numpy.random import seed to this syntax. 
Even I added that, my python didn't complain any bugs inside. Maybe your ad 
package was not be installed correctly?
-- 
https://mail.python.org/mailman/listinfo/python-list


Python REST API Wrapper framework?

2014-12-12 Thread Alec Taylor
It's not overly difficult to build a wrapper of someones RESTfull HTTP
API using something like: urllib2 or requests.

However, there is still a decent amount of generic boilerplate required.

Are there any decent frameworks around which reduce the amount of
boilerplate required to consume 3rd-party APIs?



# Research results (thus far)
So far my research has come up with:

###[Finsh](https://github.com/jaimegildesagredo/finch)
Asynchronous RESTful API consumer for Python. Finch is focused on remove all 
of the boilerplate related to consuming http based APIs and provide a high 
level abstraction to develop API clients.

###[Hammock](https://github.com/kadirpekel/hammock)
Hammock is a fun module lets you deal with rest APIs by converting them into 
dead simple programmatic APIs.

###[Tortilla](https://github.com/redodo/tortilla)
Wrapping web APIs made easy. Tortilla uses a bit of magic to wrap APIs. 
Whenever you get or call an attribute of a wrapper, the URL is appended by 
that attribute's name or method parameter.



Would be great to get more suggestions + scientific anecdotes =)

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


Re: beautifulsoup VS lxml

2014-12-12 Thread iMath
在 2014年12月12日星期五UTC+8上午10时19分56秒,Michael Torrie写道:
 On 12/11/2014 07:02 PM, iMath wrote:
  
  which is more easy and elegant for pulling data  out of HTML?
 
 Beautiful Soup is specialized for HTML parsing, and it can deal with
 badly formed HTML, but if I recall correctly BeautifulSoup can use the
 lxml engine under the hood, so maybe it's the way to go for you, is it
 gives you the most flexibility.  It certainly has a good API that's easy
 to use for data scraping.  Try it and see if it's acceptable.

tried it, very elegant and Pythonic.
thank you very much !!!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Run Programming ?????

2014-12-12 Thread William Ray Wing

 On Dec 12, 2014, at 8:03 AM, Chris Warrick kwpol...@gmail.com wrote:
 
 
 On Dec 12, 2014 1:40 PM, Delgado Motto riskyay...@gmail.com 
 mailto:riskyay...@gmail.com wrote:
 
  I travel alot, if not just interested in things of pocketable portability, 
  and was curious if you can tell me if Python can be LEARNED from beginner 
  on an IOS device ( with interest of being able to test my code, possibly 
  even if a free website is capable of reviewing scripts ) but if not then I 
  prefer if you can suggest a language that can be used from such a machine. 
  My ultimate goal is to be able to create web pages and internet bots 
  capable of searching specific things for me, simply to save me time in my 
  day as little as crawling Youtube for a song that fails to be uploaded or 
  other related examples. Please advise me. Thanks.  
  --
  https://mail.python.org/mailman/listinfo/python-list 
  https://mail.python.org/mailman/listinfo/python-list
 
 
 Get a real computer. An iOS device won't work, unless you care to buy a vps, 
 use ssh and can stand the onscreen keyboard. It's easier to buy a notebook.
 
 -- 
 Chris Warrick https://chriswarrick.com/ https://chriswarrick.com/
 Sent from my Galaxy S3.
 
 -- 
 https://mail.python.org/mailman/listinfo/python-list

Second the motion.  Apple’s sandbox policies on iOS devices mean that while you 
can run Python on them (there are several versions available), the sandbox  
pretty much guarantees that at some point you will need a library you can’t 
import, and you won’t be able to test your web pages as you go.

A MacBook Air is within a fraction of being as portable as an iPad, and can 
easily do everything you want.  If you are currently traveling with an iPad, 
you _might_ even discover you prefer traveling with the MacBook.

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


Re: Run Programming ?????

2014-12-12 Thread Chris Angelico
On Sat, Dec 13, 2014 at 2:03 AM, William Ray Wing w...@mac.com wrote:
 A MacBook Air is within a fraction of being as portable as an iPad, and can
 easily do everything you want.  If you are currently traveling with an iPad,
 you _might_ even discover you prefer traveling with the MacBook.

Or get some hardware that you can actually put a free operating system
on. I like the IBM/Lenovo laptops for their reliability.

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


Re: Run Programming ?????

2014-12-12 Thread Delgado Motto
I was specifically talking POCKETABLE devices so Phablet or Telephone
preferably, simply hopeful as smaller machines continue to become more
capable, but I expected as much of this being a problem. Thanks.



On Friday, December 12, 2014, William Ray Wing w...@mac.com wrote:


 On Dec 12, 2014, at 8:03 AM, Chris Warrick kwpol...@gmail.com
 javascript:_e(%7B%7D,'cvml','kwpol...@gmail.com'); wrote:


 On Dec 12, 2014 1:40 PM, Delgado Motto riskyay...@gmail.com
 javascript:_e(%7B%7D,'cvml','riskyay...@gmail.com'); wrote:
 
  I travel alot, if not just interested in things of pocketable
 portability, and was curious if you can tell me if Python can be LEARNED
 from beginner on an IOS device ( with interest of being able to test my
 code, possibly even if a free website is capable of reviewing scripts ) but
 if not then I prefer if you can suggest a language that can be used from
 such a machine. My ultimate goal is to be able to create web pages and
 internet bots capable of searching specific things for me, simply to save
 me time in my day as little as crawling Youtube for a song that fails to be
 uploaded or other related examples. Please advise me. Thanks.
  --
  https://mail.python.org/mailman/listinfo/python-list
 

 Get a real computer. An iOS device won't work, unless you care to buy a
 vps, use ssh and can stand the onscreen keyboard. It's easier to buy a
 notebook.

 --
 Chris Warrick https://chriswarrick.com/
 Sent from my Galaxy S3.
 --
 https://mail.python.org/mailman/listinfo/python-list


 Second the motion.  Apple’s sandbox policies on iOS devices mean that
 while you can run Python on them (there are several versions available),
 the sandbox  pretty much guarantees that at some point you will need a
 library you can’t import, and you won’t be able to test your web pages as
 you go.

 A MacBook Air is within a fraction of being as portable as an iPad, and
 can easily do everything you want.  If you are currently traveling with an
 iPad, you _might_ even discover you prefer traveling with the MacBook.

 -Bill

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


Re: Run Programming ?????

2014-12-12 Thread Chris Angelico
On Sat, Dec 13, 2014 at 2:43 AM, Delgado Motto riskyay...@gmail.com wrote:
 I was specifically talking POCKETABLE devices so Phablet or Telephone
 preferably, simply hopeful as smaller machines continue to become more
 capable, but I expected as much of this being a problem. Thanks.

Those usually are terrible for any sort of programming. Typing on a
touch-screen - especially a tiny one - is tedious and error-prone, and
as mentioned, you often can't get a decent environment set up. Get
some real hardware, preferably with a free OS on it (Linux being the
most popular, but not the only, option), and carry around something
that sits on your lap instead of in your pocket, but can actually do
what you need it to. I've been carrying around a 14 or 15 laptop for
years, now, and I happily sit all the way up back of a bus, coding
away on an actual keyboard. (I recommend about that size,
incidentally. Smaller ones tend to feel cramped, larger ones have
trouble fitting in between other passengers. 14-15 inch is about
right.)

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


Re: Call for speakers for the first PyCon Belarus. Python-announce

2014-12-12 Thread serge Guelton
On Fri, Dec 12, 2014 at 04:32:26PM +0300, Alina Dolgikh wrote:
 Hello, dear community!
 
 I represent Belarusian Python community. We have regular monthly meet-ups
 for 70-100 persons and we are going to develop further.
 
 We are planning to make the first Belarusian PyCon on the 31st of January
 and looking for speakers.
 
 We will be glad to meet at our event speakers, which are experienced in
 public talks (links for videos of public talks or for the other conferences
 web-pages are preferable) and can speak at

 - CI, pypy, C-extensions, python performance

I there,

I am the core developer of the Pythran[0] compiler, a Python to C++
compiler that focuses on the numpy package optimization, and tries hard
to turn high-level Numpy code into low-level, vectorized, parallel C++
code. I presented an early version at Scipy 2013[1], this should give
you a decent idea of my yet to improve speaker skills :-/

Any way, I would be happy to speak about it at PyCon Belarusian!

If you're intereseted/curious, I can provide a more detailed description
;-)

See ya,

Serge

[0] http://pythonhosted.org/pythran/
[1] https://www.youtube.com/watch?v=KT5-uGEpnGw
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: encrypt the http request url on the local machine

2014-12-12 Thread iMath
在 2014年12月9日星期二UTC+8下午2时58分36秒,iMath写道:
 my software on the local machine needs to send http request to a specific web 
 server , is there any way to protect the http request url from being found by 
 Packet analyzer software like Wireshark and fiddler. The sever is not mine, 
 so I can do nothing in the server .
 
 It would be better to show some code, I am an absolutely newbie in encryption 
 .

After some retinking on my question ,I found what I am really want is not let  
any other guys using packet analyzer software know the server name (host name) 
my software is sending data to .

so I translate the host name to IP address format, it somewhat hides the host 
name.
Another question is : for common sites, is the IP address under the host name 
hardly  changing ?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: encrypt the http request url on the local machine

2014-12-12 Thread Chris Angelico
On Sat, Dec 13, 2014 at 2:53 AM, iMath redstone-c...@163.com wrote:
 After some retinking on my question ,I found what I am really want is not let 
  any other guys using packet analyzer software know the server name (host 
 name) my software is sending data to .

 so I translate the host name to IP address format, it somewhat hides the host 
 name.
 Another question is : for common sites, is the IP address under the host name 
 hardly  changing ?

It depends entirely on the site's admins. Usually, you don't want to
do this, in case the IP changes. Plus, you run into a catch-22: if you
use the IP without ever using the host name, you depend on the server
responding with what you want in the absence of a host header
(basically, you depend on the server running just one web site), but
if that's the case, then concealing the host name is almost completely
useless, because anyone else can talk to the same server without a
host name. In fact, for big web sites, chances are the reverse DNS for
that IP will at least point to a related domain, even if not to the
exact web site you're accessing (for instance, www.wikipedia.org -
198.35.26.96 - text-lb.ulsfo.wikimedia.org). Basically, this either
will stop you from accessing what you want, or won't conceal anything.

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


Re: list comprehension return a list and sum over in loop

2014-12-12 Thread Peter Otten
KK Sasa wrote:

 Peter Otten於 2014年12月12日星期五UTC+8下午8時32分55秒寫道:
 Jussi Piitulainen wrote:
 
  KK Sasa writes:
  
  def p(x,t,point,z,obs):
  d = x[0]
  tau = [0]+[x[1:point]]
  a = x[point:len(x)]
  at = sum(i*j for i, j in zip(a, t))
  nu = [exp(z[k]*(at-d)-sum(tau[k])) for k in xrange(point)]
  de = sum(nu, axis=0)
  probability = [nu[k]/de for k in xrange(point)]
  return probability[obs]
  
  I must be blind, but this looks like computing a whole probability
  distribution and then throwing almost all of it away.
  
  Can't this just return nu[obs]/de?
  
  The expression for tau also seems weird to me. Isn't it equivalent to
  [0, x[1:point]], a two-element list with the second element a list?
  How can sum(tau[k]) work at all then, for any k  1?
 
 Also, after adding
 
 from numpy.random import seed
 
 to the code I run into the next problem:
 
 Traceback (most recent call last):
   File hessian.py, line 34, in module
 re = [d2(x,t[k],2,z,1) for k in range_people]
   File /home/petto/.local/lib/python2.7/site-packages/ad/__init__.py,
   line
 1114, in hess
 return func(xa, *args).hessian([xa])
   File hessian.py, line 26, in p
 nu = [exp(z[k]*(at-d)-sum(tau[k])) for k in xrange(point)]
 TypeError: 'int' object is not iterable
 
 OP: Optimizations only make sense when you can start from a known-good
 base. You should sort out the logic of your problem (we probably can't
 help you with that), then fix the bugs in your code and only then revisit
 the speed issue.
 
 I have no idea why you added from numpy.random import seed to this
 syntax. Even I added that, my python didn't complain any bugs inside.
 Maybe your ad package was not be installed correctly?

It may be a version issue. I'm using

 import ad, numpy
 ad.__version__
'1.2.2'
 numpy.__version__
'1.9.1'

Or are you using an environment that does some imports automatically?


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


Re: list comprehension return a list and sum over in loop

2014-12-12 Thread Oscar Benjamin
On 12 December 2014 at 06:22, KK Sasa genwei...@gmail.com wrote:
 Hi there,

 The list comprehension is results = [d2(t[k]) for k in xrange(1000)], where 
 d2 is a function returning a list, say [x1,x2,x3,x4] for one example. So 
 results is a list consisting of 1000 lists, each of length four. Here, what 
 I want to get is the sum of 1000 lists, and then the result is a list of 
 length four. Is there any efficient way to do this? Because I found it is 
 slow in my case. I tried sum(d2(t[k]) for k in xrange(1000)), but it returned 
 error: TypeError: unsupported operand type(s) for +: 'int' and 'list'. Thanks.

Use numpy.sum:

 import numpy as np
 a = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]]
 np.sum(a, 0)
array([6, 6, 6, 6])
 np.sum(a, 1)
array([ 4,  8, 12])

The second argument to numpy.sum is the dimension along which you want
to sum e.g. rows or columns.


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


Re: How to make subprocess run for 60 sec?

2014-12-12 Thread Dan Stromberg
On Fri, Dec 12, 2014 at 12:48 AM, Robert Clove cloverob...@gmail.com wrote:
 Hi All,

 I have the following python script that runs.
 I want is to run the subprocess to run for 60 sec and then send the SIGINT
 signal to subprocess and write the output in file.

 #!/usr/bin/python
 import os
 import subprocess
 PIPE = subprocess.PIPE
 import signal
 import time

 def handler(signum, frame):
 pass

 signal.signal(signal.SIGALRM, handler)
 signal.alarm(60)
 command = strace -c ./server
 os.chdir(/root/Desktop/)
 p = subprocess.Popen(command, stdout=PIPE, stderr=PIPE)
 time.sleep(60)
 p.send_signal(signal.SIGINT)
 signal.alarm(0)
 print p.communicate()[1]

Perhaps try something like:

#!/usr/bin/python

#import os
import subprocess
PIPE = subprocess.PIPE
import signal
import time

#def handler(signum, frame):
#pass

with open('output.txt', 'w') as out_file:
#signal.signal(signal.SIGALRM, handler)
#signal.alarm(60)
#command = strace -c ./server
command = ./test-script
#os.chdir(/root/Desktop/)
p = subprocess.Popen(command, stdout=out_file, stderr=out_file, shell=True)
time.sleep(5)
p.send_signal(signal.SIGINT)
#signal.alarm(0)
#print p.communicate()[1]

with open('output.txt', 'r') as in_file:
output = in_file.read()

print(output)


BTW, killing an active strace may leave strace's subprocess stuck in
an unkillable state.

Also note that this will sleep for n seconds whether the subprocess
takes that long or not.

If you just want a program that does this, and it doesn't have to be
in Python, you might try
http://stromberg.dnsalias.org/~strombrg/maxtime.html
It's in C, and is the product of considerable real-world use.  It
exits almost immediately after its subprocess exits, FWIW.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Python-Dev] Python 2.x and 3.x use survey, 2014 edition

2014-12-12 Thread Mark Roberts
So, I'm more than aware of how to write Python 2/3 compatible code. I've
ported 10-20 libraries to Python 3 and write Python 2/3 compatible code at
work. I'm also aware of how much writing 2/3 compatible code makes me hate
Python as a language. It'll be a happy day when one of the two languages
dies so that I never have to write code like that again. However, my point
was that just because the core libraries by usage are *starting* to roll
out Python 3 support doesn't mean that things are easy or convenient
yet. There are too many libraries in the long tail which fulfill
semi-common purposes and haven't been moved over yet. Yeah, sure, they
haven't been updated in years... but neither has the language they're built
on.

I suppose what I'm saying is that the long tail of libraries is far more
valuable than it seems the Python3 zealots are giving it credit for. Please
don't claim it's easy to move over just because merely most of the top 20
libraries have been moved over. :-/

-Mark

On Thu, Dec 11, 2014 at 12:14 PM, Dan Stromberg drsali...@gmail.com wrote:

 On Thu, Dec 11, 2014 at 11:35 AM, Mark Roberts wiz...@gmail.com wrote:
  I disagree. I know there's a huge focus on The Big Libraries (and
 wholesale
  migration is all but impossible without them), but the long tail of
  libraries is still incredibly important. It's like saying that migrating
 the
  top 10 Perl libraries to Perl 6 would allow people to completely ignore
 all
  of CPAN. It just doesn't make sense.

 Things in the Python 2.x vs 3.x world aren't that bad.

 See:
 https://python3wos.appspot.com/ and
 https://wiki.python.org/moin/PortingPythonToPy3k
 http://stromberg.dnsalias.org/~strombrg/Intro-to-Python/ (writing code
 to run on 2.x and 3.x)

 I believe just about everything I've written over the last few years
 either ran on 2.x and 3.x unmodified, or ran on 3.x alone.  If you go
 the former route, you don't need to wait for your libraries to be
 updated.

 I usually run pylint twice for my projects (after each change, prior
 to checkin), once with a 2.x interpreter, and once with a 3.x
 interpreter (using
 http://stromberg.dnsalias.org/svn/this-pylint/trunk/this-pylint) , but
 I gather pylint has the option of running on a 2.x interpreter and
 warning about anything that wouldn't work on 3.x.

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


Re: [Python-Dev] Python 2.x and 3.x use survey, 2014 edition

2014-12-12 Thread Petr Viktorin
Also keep in mind that not all Python libraries are on PyPI.
For non-Python projects with Python bindings (think video players,
OpenCV, systemd, Samba), distribution via PyPI doesn't make much
sense. And since the Python bindings are usually second-class
citizens, the porting doesn't have a high priority.

If anyone is wondering why their favorite Linux distribution is stuck
with Python 2 – well, I can only speak for Fedora, but nowadays most
of what's left are CPython bindings.
No pylint --py3k or 2to3 will help there...


On Fri, Dec 12, 2014 at 7:24 PM, Mark Roberts wiz...@gmail.com wrote:
 So, I'm more than aware of how to write Python 2/3 compatible code. I've
 ported 10-20 libraries to Python 3 and write Python 2/3 compatible code at
 work. I'm also aware of how much writing 2/3 compatible code makes me hate
 Python as a language. It'll be a happy day when one of the two languages
 dies so that I never have to write code like that again. However, my point
 was that just because the core libraries by usage are *starting* to roll out
 Python 3 support doesn't mean that things are easy or convenient yet.
 There are too many libraries in the long tail which fulfill semi-common
 purposes and haven't been moved over yet. Yeah, sure, they haven't been
 updated in years... but neither has the language they're built on.

 I suppose what I'm saying is that the long tail of libraries is far more
 valuable than it seems the Python3 zealots are giving it credit for. Please
 don't claim it's easy to move over just because merely most of the top 20
 libraries have been moved over. :-/

 -Mark

 On Thu, Dec 11, 2014 at 12:14 PM, Dan Stromberg drsali...@gmail.com wrote:

 On Thu, Dec 11, 2014 at 11:35 AM, Mark Roberts wiz...@gmail.com wrote:
  I disagree. I know there's a huge focus on The Big Libraries (and
  wholesale
  migration is all but impossible without them), but the long tail of
  libraries is still incredibly important. It's like saying that migrating
  the
  top 10 Perl libraries to Perl 6 would allow people to completely ignore
  all
  of CPAN. It just doesn't make sense.

 Things in the Python 2.x vs 3.x world aren't that bad.

 See:
 https://python3wos.appspot.com/ and
 https://wiki.python.org/moin/PortingPythonToPy3k
 http://stromberg.dnsalias.org/~strombrg/Intro-to-Python/ (writing code
 to run on 2.x and 3.x)

 I believe just about everything I've written over the last few years
 either ran on 2.x and 3.x unmodified, or ran on 3.x alone.  If you go
 the former route, you don't need to wait for your libraries to be
 updated.

 I usually run pylint twice for my projects (after each change, prior
 to checkin), once with a 2.x interpreter, and once with a 3.x
 interpreter (using
 http://stromberg.dnsalias.org/svn/this-pylint/trunk/this-pylint) , but
 I gather pylint has the option of running on a 2.x interpreter and
 warning about anything that wouldn't work on 3.x.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Run Programming ?????

2014-12-12 Thread sohcahtoa82

 On Friday, December 12, 2014, William Ray Wing w...@mac.com wrote:
 
 
 
 
 On Dec 12, 2014, at 8:03 AM, Chris Warrick kwpol...@gmail.com wrote:
 
 
 
 
 On Dec 12, 2014 1:40 PM, Delgado Motto riskyay...@gmail.com wrote:
 
 
 
  I travel alot, if not just interested in things of pocketable portability, 
  and was curious if you can tell me if Python can be LEARNED from beginner 
  on an IOS device ( with interest of being able to test my code, possibly 
  even if a free website is capable of reviewing scripts ) but if not then I 
  prefer if you can suggest a language that can be used from such a machine. 
  My ultimate goal is to be able to create web pages and internet bots 
  capable of searching specific things for me, simply to save me time in my 
  day as little as crawling Youtube for a song that fails to be uploaded or 
  other related examples. Please advise me. Thanks.  
 
  --
 
  https://mail.python.org/mailman/listinfo/python-list
 
 
 Get a real computer. An iOS device won't work, unless you care to buy a vps, 
 use ssh and can stand the onscreen keyboard. It's easier to buy a notebook.
 -- 
 
 Chris Warrick https://chriswarrick.com/
 
 Sent from my Galaxy S3.
 -- 
 https://mail.python.org/mailman/listinfo/python-list
 
 
 Second the motion.  Apple's sandbox policies on iOS devices mean that while 
 you can run Python on them (there are several versions available), the 
 sandbox  pretty much guarantees that at some point you will need a library 
 you can't import, and you won't be able to test your web pages as you go.
 
 
 A MacBook Air is within a fraction of being as portable as an iPad, and can 
 easily do everything you want.  If you are currently traveling with an iPad, 
 you _might_ even discover you prefer traveling with the MacBook.
 
 
 -Bill

On Friday, December 12, 2014 7:44:12 AM UTC-8, Delgado Motto wrote:
 I was specifically talking POCKETABLE devices so Phablet or Telephone 
 preferably, simply hopeful as smaller machines continue to become more 
 capable, but I expected as much of this being a problem. Thanks. 
 

Its not a matter of processing power.  The Motorola Droid I got five years ago 
could certainly run a Python app if someone wrote an interpreter for it, and I 
imagine someone already has.

The problem is actually writing code.  Typing on a touch-screen keyboard is 
already difficult enough.  Dealing with frequently having to type special 
characters (parentheses, brackets, colons, etc.) and numbers would make it 
extremely tedious to the point of being painful.  Top that off with having a 
tiny screen so you can only see around 5 lines of code at a time and being 
unable to have a decent debugging UI, and you're really looking at a truly 
miserable time.

The real challenge won't be the software engineering, it'll be fighting with an 
absolutely piss-poor interface for doing it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Python-Dev] Python 2.x and 3.x use survey, 2014 edition

2014-12-12 Thread Matthew Ruffalo
On 12/11/2014 09:48 PM, Terry Reedy wrote:
 A possible reason: one is developing an app expected to be released
 fall 2015 after the 3.5 release and the app depends on something new
 in 3.5.  I must admit though that I cannot think of any such thing now
 for 3.5.  For 3.3 there was the new unicode, which was first committed
 about a year before release.  For 3.4, there was asyncio, but it was
 not committed until beta1, and was hardly usable then.

 So it was a defensible position.  Anyone who would check 3.5 could
 just as well check 3.4 and have most of the same impact on the summary.
The NumPy and SciPy developers who are implementing support for PEP 465
('@' as a dedicated matrix multiplication operator) will likely want to
test against a development version of 3.5 at some point. Using 3.5 isn't
strictly required, though, since supporting the @ operator is mostly a
matter of implementing the new __matmul__ methods and one can test those
by calling them directly instead of using the new operator.

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


Re: [Python-Dev] Python 2.x and 3.x use survey, 2014 edition

2014-12-12 Thread Barry Warsaw
On Dec 12, 2014, at 08:07 PM, Petr Viktorin wrote:

If anyone is wondering why their favorite Linux distribution is stuck with
Python 2 – well, I can only speak for Fedora, but nowadays most of what's
left are CPython bindings.  No pylint --py3k or 2to3 will help there...

It's true that some of these are tough.  I tried and failed a few times to
port Xapian to Python 3.  The issue was opened upstream 6 years ago and it's
still unresolved: http://trac.xapian.org/ticket/346

OTOH, I ported dbus-python to Python 3 and that worked out much better; we've
had solid Python 3 bindings for several years now, which allowed us to port
many important Debian/Ubuntu tools to Python 3 and more importantly, do all
our new work in Python 3.  With other big toolkits like GObject introspection
working on Python 3, there's a lot you can do.

IME, if the underlying model is string/bytes clean, then the C extension port
can sometimes be easier than pure-Python, thanks to cpp games.  D-Bus's model
is pretty clean, Xapian I found to be not so much (it doesn't help that Xapian
is C++ ;).

We're actually not terribly far from switching Debian and Ubuntu's default
to Python 3.  On Debian, the big blocker is the BTS code (which uses SOAP) and
on Ubuntu it's the launchpadlib stack.  I hope to find time after Jessie to
work on the former, and before 16.04 LTS to work on the latter.

Not that I disagree that there's a long tail of code that would still benefit
a significant population if it got ported to Python 3.  By far Python 3 is a
better language, with a better stdlib, so the work is worth it.

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


Re: How to make subprocess run for 60 sec?

2014-12-12 Thread Akira Li
Dan Stromberg drsali...@gmail.com writes:

 On Fri, Dec 12, 2014 at 12:48 AM, Robert Clove cloverob...@gmail.com wrote:
 Hi All,

 I have the following python script that runs.
 I want is to run the subprocess to run for 60 sec and then send the SIGINT
 signal to subprocess and write the output in file.

 #!/usr/bin/python
 import os
 import subprocess
 PIPE = subprocess.PIPE
 import signal
 import time

 def handler(signum, frame):
 pass

 signal.signal(signal.SIGALRM, handler)
 signal.alarm(60)
 command = strace -c ./server
 os.chdir(/root/Desktop/)
 p = subprocess.Popen(command, stdout=PIPE, stderr=PIPE)
 time.sleep(60)
 p.send_signal(signal.SIGINT)
 signal.alarm(0)
 print p.communicate()[1]

 Perhaps try something like:

 #!/usr/bin/python

 #import os
 import subprocess
 PIPE = subprocess.PIPE
 import signal
 import time

 #def handler(signum, frame):
 #pass

 with open('output.txt', 'w') as out_file:
 #signal.signal(signal.SIGALRM, handler)
 #signal.alarm(60)
 #command = strace -c ./server
 command = ./test-script
 #os.chdir(/root/Desktop/)
 p = subprocess.Popen(command, stdout=out_file, stderr=out_file, 
 shell=True)
 time.sleep(5)
 p.send_signal(signal.SIGINT)
 #signal.alarm(0)
 #print p.communicate()[1]

 with open('output.txt', 'r') as in_file:
 output = in_file.read()

 print(output)

You should probably call p.wait() after p.send_signal(), to wait until
the child process exits (possibly properly flushing its stdout buffer). 
It might make the output.txt content less garbled.


 BTW, killing an active strace may leave strace's subprocess stuck in
 an unkillable state.

 Also note that this will sleep for n seconds whether the subprocess
 takes that long or not.

The answer on StackOverflow [1] shows how to avoid waiting n seconds if the
subprocess finishes sooner.

[1] 
http://stackoverflow.com/questions/27443480/how-to-make-subprocess-run-for-60-sec

 If you just want a program that does this, and it doesn't have to be
 in Python, you might try
 http://stromberg.dnsalias.org/~strombrg/maxtime.html
 It's in C, and is the product of considerable real-world use.  It
 exits almost immediately after its subprocess exits, FWIW.


--
Akira

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


Re: is_whatever_you_are_testing_for as method or property?

2014-12-12 Thread Mateusz Loskot
On 12 December 2014 at 12:26, Chris Angelico ros...@gmail.com wrote:
 On Fri, Dec 12, 2014 at 10:21 PM, Mateusz Loskot mate...@loskot.net wrote:
 I've got several cases which are not obvious to me.
 For instance, class Foo has a boolean attribute, read-write,
 which I see a couple of realisations for possible:


 0) Attribute only.

 class Foo:
 pass

 Foo().default = True

 Unless you need something more than this, go with this style. Much simpler.


Agreed, in general, but if the question was related to such simple case,
I wouldn't bother asking it.

I mentioned, setting the new value involves more changes to Foo()
instance, so i's not possible to capture it with just an assignment.
Hence, the discussion between property vs method.

Best regards,
-- 
Mateusz  Loskot, http://mateusz.loskot.net
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: is_whatever_you_are_testing_for as method or property?

2014-12-12 Thread Chris Angelico
On Sat, Dec 13, 2014 at 8:03 AM, Mateusz Loskot mate...@loskot.net wrote:
 On 12 December 2014 at 12:26, Chris Angelico ros...@gmail.com wrote:
 On Fri, Dec 12, 2014 at 10:21 PM, Mateusz Loskot mate...@loskot.net wrote:
 I've got several cases which are not obvious to me.
 For instance, class Foo has a boolean attribute, read-write,
 which I see a couple of realisations for possible:


 0) Attribute only.

 class Foo:
 pass

 Foo().default = True

 Unless you need something more than this, go with this style. Much simpler.


 Agreed, in general, but if the question was related to such simple case,
 I wouldn't bother asking it.

 I mentioned, setting the new value involves more changes to Foo()
 instance, so i's not possible to capture it with just an assignment.
 Hence, the discussion between property vs method.

It's still worth mentioning, for completeness. Plenty of people come
from C++ or Java and simply don't realize that direct attribute access
makes fine sense. Your statement here talks about a read-write boolean
attribute, so starting off with the simplest way of doing that - an
actual attribute - emphasizes the commonness of this.

So, your subsequent design decisions are based around the fact that
you cannot simply assign to .default and have it do the right thing.
Are you even able to set default to False? For instance, you might
have a system where there must always be one default, and so you
can't make this one not-default, but you could make a different one
the default, which will un-default-ify this one as a side effect. In
that case, a make_default() method makes the most sense. But if you
can independently and cheaply set any instance's default flag, you
could have the actual attribute, and then a set_default() method,
which updates it. Plenty of Python classes recommend not arbitrarily
altering certain attributes.

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


Re: is_whatever_you_are_testing_for as method or property?

2014-12-12 Thread Mateusz Loskot
On 12 December 2014 at 22:14, Chris Angelico ros...@gmail.com wrote:
 On Sat, Dec 13, 2014 at 8:03 AM, Mateusz Loskot mate...@loskot.net wrote:
 On 12 December 2014 at 12:26, Chris Angelico ros...@gmail.com wrote:
 On Fri, Dec 12, 2014 at 10:21 PM, Mateusz Loskot mate...@loskot.net wrote:
 I've got several cases which are not obvious to me.
 For instance, class Foo has a boolean attribute, read-write,
 which I see a couple of realisations for possible:


 0) Attribute only.

 class Foo:
 pass

 Foo().default = True

 Unless you need something more than this, go with this style. Much simpler.


 Agreed, in general, but if the question was related to such simple case,
 I wouldn't bother asking it.

 I mentioned, setting the new value involves more changes to Foo()
 instance, so i's not possible to capture it with just an assignment.
 Hence, the discussion between property vs method.

 It's still worth mentioning, for completeness.

Of course, very good point.

 Plenty of people come from C++

That's me.

 or Java and simply don't realize that direct attribute access
 makes fine sense. Your statement here talks about a read-write boolean
 attribute, so starting off with the simplest way of doing that - an
 actual attribute - emphasizes the commonness of this.

Yes, I see your point now.

 So, your subsequent design decisions are based around the fact that
 you cannot simply assign to .default and have it do the right thing.
 Are you even able to set default to False?

Right. The particular case (with is_default and make_default members)
I'm discussing is similar to this:

class Window:
   def close(self):
  # operate window so it gets closed

   @property
   def is_closed(self)
  # query state of window

 For instance, you might
 have a system where there must always be one default, and so you
 can't make this one not-default, but you could make a different one
 the default, which will un-default-ify this one as a side effect. In
 that case, a make_default() method makes the most sense. But if you
 can independently and cheaply set any instance's default flag, you
 could have the actual attribute, and then a set_default() method,
 which updates it. Plenty of Python classes recommend not arbitrarily
 altering certain attributes.

Yes, makes sense. Thanks for brainstorming those ideas deeper.

Best regards,
-- 
Mateusz  Loskot, http://mateusz.loskot.net
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: encrypt the http request url on the local machine

2014-12-12 Thread Michael Torrie
On 12/12/2014 08:53 AM, iMath wrote:
 After some retinking on my question ,I found what I am really want is
 not let  any other guys using packet analyzer software know the
 server name (host name) my software is sending data to .
 
 so I translate the host name to IP address format, it somewhat hides
 the host name. Another question is : for common sites, is the IP
 address under the host name hardly  changing ?

I don't see what that will accomplish.  Of what value is the hostname vs
the IP address?  Many servers have proper reverse entries in DNS to map
IP addresses back to host names.

Furthermore a packet trace can show exactly what the HTTP request was,
and that doesn't matter whether you do IP address or hostname.

As for whether the IP address changes often, depends on the server.
Sometimes some web sites use a cluster of servers and each name lookup
will give you a different IP address (round robin lookup).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Script to convert firewall rules

2014-12-12 Thread Jason Friedman


 Thanks for the reply. Yes I can make the all possible keywords/values for
 both formate. But after that what gonna be the logic to convert one format
 to other format. Like to convert one line below are the keywords:

 set interface ethernet2/5 ip 10.17.10.1/24 (format 1)
 set interfaces ge-0/0/0 unit 0 family inet address 10.17.10.1/24 (format
 2)

 (set, interface, ip) = (set, interfaces, family inet address)

 But some values are variable and should ask the user to convert manually
 like ethernet2/5 equal to ge-0/0/0 or ge-0/0/1 or ge-0/0/2

 And some values keep as it is like 10.17.10.1/24

 Also then format 2 can be converted int o format 3 (as below) for more
 readability of format 2. This is just optional.

 interfaces {
 ge-2/0/5 {
 unit 0 {
 family inet {
 address 10.17.10.1/24;
 }
 }
 }
 }


Note that the practice on this list is to put your response after the
(edited) portion of the previous posts.

Are you willing to learn some Python, if someone gets you started?
Would it be helpful if someone provided Python code to convert this:

set interfaces ge-0/0/0 unit 0 family inet address 10.17.10.1/24

to this:

interfaces {
ge-2/0/5 {
unit 0 {
family inet {
address 10.17.10.1/24;
}
}
}
}

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


Re: list comprehension return a list and sum over in loop

2014-12-12 Thread KK Sasa
Sorry, i should say I'm using pythonxy, maybe it imports other things. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Fatal Python error: PyCOND_WAIT(gil_cond) failed

2014-12-12 Thread dieter
keepplearningpython krishna2pra...@gmail.com writes:

 I am running ipython3 on Unix and constantly see this crash -
 It happens when i try to issue commands on the ipython interactive shell.

 I have tried to set the PYTHONDIR to /var/tmp/ in case there was an issue 
 accessing the default location of the history file. However, this makes no 
 difference.

 I can run a command a few times successfully after which I hit this error.
 ...
 Any suggestions on what might be going on?




 Fatal Python error: PyCOND_WAIT(gil_cond) failed

Apparently, some thread should wait for the GIL
(Python's Global Interpreter Lock) but instead of waiting,
the operation results in an error.

This looks like an important bug in GIL handling -- likely
caused by some C extension, likely executing Python code
without first acquiring the GIL.

It might be difficult to locate the error: likely C level
debugging will be necessary. Should my hypothesis be true,
a change in C code would be necessary to fix the problem.


I recommend to check for known problems related to GIL handling
for all C implemented components of your application.
If you are lucky, your problem is known and has been fixed
in a different version. Then upgrading would be all you need to do.

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


[issue21793] httplib client/server status refactor

2014-12-12 Thread Raymond Hettinger

Changes by Raymond Hettinger raymond.hettin...@gmail.com:


--
assignee: rhettinger - 

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21793
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22477] GCD in Fractions

2014-12-12 Thread gladman

gladman added the comment:

I notice on the documentation for Python 3.5 that this proposed addition is not 
mentioned. Is it still the intention to add this proposed change to Python 3.5?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22477
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9536] defaultdict doc makes incorrect reference to __missing__ method

2014-12-12 Thread Raymond Hettinger

Changes by Raymond Hettinger raymond.hettin...@gmail.com:


--
resolution:  - rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9536
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15178] Doctest should handle situations when test files are not readable

2014-12-12 Thread Bohuslav Slavek Kabrda

Bohuslav Slavek Kabrda added the comment:

Attaching a new version of patch:
- Rebased to latest default branch
- Simplified prints
- Using OSError instead of IOError

Hopefully this is the final version :)

--
Added file: 
http://bugs.python.org/file37421/doctest-dont-end-with-exception-on-unreadable-files-v6.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15178
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21793] httplib client/server status refactor

2014-12-12 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
assignee:  - serhiy.storchaka
nosy: +serhiy.storchaka

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21793
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22477] GCD in Fractions

2014-12-12 Thread STINNER Victor

STINNER Victor added the comment:

I see that the issue #22486 is still open.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22477
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22486] Add math.gcd()

2014-12-12 Thread STINNER Victor

STINNER Victor added the comment:

What's the status of this issue? See also the issue #22477.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22486
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22935] Disabling SSLv3 support

2014-12-12 Thread Ned Deily

Ned Deily added the comment:

The changes for 3.4 are incomplete:  

 import ssl
Traceback (most recent call last):
  File stdin, line 1, in module
  File /py/dev/34/source/Lib/ssl.py, line 122, in module
from _ssl import PROTOCOL_SSLv3, PROTOCOL_SSLv23, PROTOCOL_TLSv1
ImportError: cannot import name 'PROTOCOL_SSLv3'

For the default (3.5) branch, f776771ab0ee for Issue21068 changed ssl.py to 
handle missing SSLv3 support; 3.4 needs something similar.

--
resolution: fixed - 
stage: resolved - needs patch
status: closed - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22935
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22486] Add math.gcd()

2014-12-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch which addresses both Mark's suggestions.

* math.gcd() now work with arbitrary Python objects implementing __index__.
* fractions.gcd() and Fraction's constructor now use math.gcd() if both 
arguments are int, but also support non-ints (e.g. Fractions or floats).
* fractions.gcd() now is deprecated.

But before committing I want to experiment with simpler implementation and 
compare it with current complex implementation. If the difference will be not 
too large, we could use simpler implementation.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22486
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22486] Add math.gcd()

2014-12-12 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


Added file: http://bugs.python.org/file37422/lehmer_gcd_8.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22486
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17914] add os.cpu_count()

2014-12-12 Thread Mark Summerfield

Mark Summerfield added the comment:

In message
http://bugs.python.org/issue17914#msg188626
Victor Stenner says

On Windows, GetSystemInfo() is called instead of reading an environment 
variable. I suppose that this function is more reliable.

From my reading, and based on feedback from one of my customers, I believe he 
is correct and that GetSystemInfo() ought to be used on Windows. (It is 
available in pywin32 win32api.)

--
nosy: +mark

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17914
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22935] Disabling SSLv3 support

2014-12-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 773e55c95703 by Victor Stinner in branch '3.4':
Issue #22935: Fix ssl module when SSLv3 protocol is not supported
https://hg.python.org/cpython/rev/773e55c95703

New changeset fb1ffd40d33e by Victor Stinner in branch 'default':
Issue #22935: Fix test_ssl when the SSLv3 protocol is not supported
https://hg.python.org/cpython/rev/fb1ffd40d33e

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22935
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22935] Disabling SSLv3 support

2014-12-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f0297263a1e8 by Victor Stinner in branch '3.4':
Issue #22935: Fix test_ssl when the SSLv3 protocol is not supported
https://hg.python.org/cpython/rev/f0297263a1e8

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22935
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22935] Disabling SSLv3 support

2014-12-12 Thread STINNER Victor

STINNER Victor added the comment:

 The changes for 3.4 are incomplete

Ok, I fixed most obvious issues. There is a major severe issue in Lib/ssl.py:

def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv3, ca_certs=None):
...


This line fails if PROTOCOL_SSLv3 name does not exist. I propose to use 
PROTOCOL_SSLv23 by default if PROTOCOL_SSLv3 does not exist, as done in Python 
3.5. See attached patch.

A better option (more secure?) is to use PROTOCOL_SSLv23 by default.

What do you think? I prefer to switch to PROTOCOL_SSLv23 by default in Python 
3.4.

--
Added file: http://bugs.python.org/file37423/get_server_certificate_sslv3.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22935
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22935] Disabling SSLv3 support

2014-12-12 Thread STINNER Victor

STINNER Victor added the comment:

Oh, in Python 3.4, create_default_context() uses PROTOCOL_SSLv23, SSLSocket, 
wrap_socket() and _create_unverified_context() use PROTOCOL_SSLv23 by default.

In Python 3.5, get_server_certificate() now uses PROTOCOL_SSLv23 by default 
because test_ssl failed on the host svn.python.org: see issue #20896.

changeset:   90360:55f62fa5bebc
user:Antoine Pitrou solip...@pitrou.net
date:Wed Apr 16 18:56:28 2014 +0200
files:   Doc/library/ssl.rst Lib/ssl.py Lib/test/test_ssl.py Misc/NEWS
description:
Issue #20896: ssl.get_server_certificate() now uses PROTOCOL_SSLv23, not 
PROTOCOL_SSLv3, for maximum compatibility.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22935
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17914] add os.cpu_count()

2014-12-12 Thread STINNER Victor

STINNER Victor added the comment:

 From my reading, and based on feedback from one of my customers, I believe he 
 is correct and that GetSystemInfo() ought to be used on Windows. (It is 
 available in pywin32 win32api.)

Please open a new issue to suggest this enhancement, this issue is closed.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17914
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22935] Disabling SSLv3 support

2014-12-12 Thread STINNER Victor

STINNER Victor added the comment:

get_server_certificate_sslv23.patch: Patch to use PROTOCOL_SSLv23 by default in 
get_server_certificate(), as done in Python 2.7 and 3.5.

--
Added file: http://bugs.python.org/file37424/get_server_certificate_sslv23.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22935
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23036] Crash Error?

2014-12-12 Thread E Roberts

New submission from E Roberts:

New to the world of Python. The picture attached is an error that a teacher at 
my school is receiving when he tries to run anything in IDLE.

I know nothing about coding/python/idle or anything of that nature. 

Sorry I am of little help.

Please can someone help me out with this error and provide any help or an 
answer. 

Thank you for dealing with a complete novice.

--
components: IDLE
files: python error.png
messages: 232531
nosy: E.Roberts
priority: normal
severity: normal
status: open
title: Crash Error?
type: crash
versions: Python 3.3
Added file: http://bugs.python.org/file37425/python error.png

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23036
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23036] Crash Error?

2014-12-12 Thread STINNER Victor

STINNER Victor added the comment:

The problem is that your student created a file called random.py which 
conflicts with the module random of the Python standard library. Please 
rename the random.py file to random.py and remove .pyc files (ex: random.pyc or 
__pycache__/random*pyc).

--
nosy: +haypo
resolution:  - not a bug
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23036
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15267] tempfile.TemporaryFile and httplib incompatibility

2014-12-12 Thread STINNER Victor

STINNER Victor added the comment:

Catching TypeError on len() looks as an ugly test to check if body is a string. 
Why not doing the opposite: first to call fileno() and call AttributeError? Or 
even use hasattr(body, fileno)?

--
nosy: +haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15267
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15267] tempfile.TemporaryFile and httplib incompatibility

2014-12-12 Thread STINNER Victor

STINNER Victor added the comment:

issue15267.patch: I would feel more confortable if test_send_tempfile() ensures 
that the socket contains the file content.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15267
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18028] Warnings with -fstrict-aliasing

2014-12-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 9565b56a4615 by Victor Stinner in branch '2.7':
Issue #18028: Fix aliasing issue in READ_TIMESTAMP() of ceval.c  on x86_64,
https://hg.python.org/cpython/rev/9565b56a4615

New changeset adb445578995 by Victor Stinner in branch '3.4':
Issue #18028: Fix aliasing issue in READ_TIMESTAMP() of ceval.c  on x86_64,
https://hg.python.org/cpython/rev/adb445578995

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18028
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18028] Warnings with -fstrict-aliasing

2014-12-12 Thread STINNER Victor

STINNER Victor added the comment:

3 core developers reviewed Christian's patch, so it also looks good to me :-) 
Since Christian looks to be busy, I commited his patch. Thanks Christian for 
your fix.

We might enable -fstrict-aliasing later, at least to compile Python core (not 
to build extensions).

--
nosy: +haypo
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18028
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23035] python -c: Line causing exception not shown for exceptions other than SyntaxErrors

2014-12-12 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@gmail.com:


--
title: -c: Line causing exception not shown for exceptions other than 
SyntaxErrors - python -c: Line causing exception not shown for exceptions 
other than SyntaxErrors

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23035
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23035] python -c: Line causing exception not shown for exceptions other than SyntaxErrors

2014-12-12 Thread STINNER Victor

STINNER Victor added the comment:

SyntaxError exceptions have a text attribute which contains the line where the 
error occurred. It's really a special case. For other exceptions, Python only 
knows that the error occurred in the file called string.

Being able to display the line for any exception requires a complex 
development. I'm not interested to implement it, I don't think that it's very 
useful (compared to the time needed to develop it).

--
nosy: +haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23035
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23034] Dynamically control debugging output

2014-12-12 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Also this debug output should be printed on stderr, not stdout.

--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23034
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23034] Dynamically control debugging output

2014-12-12 Thread STINNER Victor

STINNER Victor added the comment:

 Debugging output switched by Py_REF_DEBUG is now enabled only when -X 
 showrefcount is specified (issue17323).

Yes, I like the idea of doing that for other debug options.

--
nosy: +haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23034
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23037] cpu_count() unreliable on Windows

2014-12-12 Thread Mark Summerfield

New submission from Mark Summerfield:

In message
http://bugs.python.org/issue17914#msg188626
Victor Stenner says

On Windows, GetSystemInfo() is called instead of reading an environment 
variable. I suppose that this function is more reliable.

From my reading, and based on feedback from one of my customers, I believe he 
is correct and that GetSystemInfo() ought to be used on Windows. (It is 
available in pywin32 win32api.)

--
components: Library (Lib), Windows
messages: 232540
nosy: mark, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23037
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17914] add os.cpu_count()

2014-12-12 Thread Mark Summerfield

Mark Summerfield added the comment:

Since this is closed I've created a new issue as requested:
http://bugs.python.org/issue23037

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17914
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22935] Disabling SSLv3 support

2014-12-12 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

Please always use PROTOCOL_SSLv23 since this is the only forward compatible way 
of telling OpenSSL to use the best protocol available.

Any of the other options such as PROTOCOL_TLSv1 will fix the protocol version 
to that one protocol version, whereas PROTOCOL_SSLv23 means to use any protocol 
starting with SSLv2. In the context options you can then disable SSLv2 and 
SSLv3 to e.g. have the connection use TLS 1.0 or later.

--
nosy: +lemburg

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22935
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22935] Disabling SSLv3 support

2014-12-12 Thread Kurt Roeckx

Kurt Roeckx added the comment:

So this seems to be a function that just gets the certificate?  You need to be 
careful with this since a server could perfectly decide to send a different 
certificate depending on the client hello it receives.  Like if you support 
ECDSA it might decide to send you the ECDSA certificate instead of the RSA 
certificate.  Or maybe you're even connecting to a different IP address?

In any case, you should always use SSLv23, stop supporting anything else.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22935
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23037] cpu_count() unreliable on Windows

2014-12-12 Thread STINNER Victor

STINNER Victor added the comment:

The code getting the number of processors on Windows is different between the 
multiprocessing (Python 3.3) and os (Python 3.5) modules.

multiprocessing (old code):

try:
num = int(os.environ['NUMBER_OF_PROCESSORS'])
except (ValueError, KeyError):
num = 0

os (new code):

SYSTEM_INFO sysinfo;
GetSystemInfo(sysinfo);
ncpu = sysinfo.dwNumberOfProcessors;

os.cpu_count() is already implemented with GetSystemInfo() in Python 3.5, so 
this issue can be closed. Thanks for the reminder Mark, it was useful to double 
check.

If you want to take a look at the source code:
https://hg.python.org/cpython/file/35b7dde7fd53/Modules/posixmodule.c#l16064

--
nosy: +haypo
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23037
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22935] Disabling SSLv3 support

2014-12-12 Thread STINNER Victor

STINNER Victor added the comment:

 So this seems to be a function that just gets the certificate?  You need to 
 be careful with this since a server could perfectly decide to send a 
 different certificate depending on the client hello it receives. (...) In any 
 case, you should always use SSLv23, stop supporting anything else.

I don't understand. You say that depending on the protocol, you may get a 
different certificate, and then that we should stop supporting multiple 
protocol. Does it mean that you ask to remove a Python feature?

Even if it is technically possible to return a different certificate, I don't 
think that much servers will return a different certificate if the client uses 
SSLv23 instead of SSLv3.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22935
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22935] Disabling SSLv3 support

2014-12-12 Thread STINNER Victor

STINNER Victor added the comment:

 Any of the other options such as PROTOCOL_TLSv1 will fix the protocol version 
 to that one protocol version, whereas PROTOCOL_SSLv23 means to use any 
 protocol starting with SSLv2. In the context options you can then disable 
 SSLv2 and SSLv3 to e.g. have the connection use TLS 1.0 or later.

get_server_certificate() uses _create_unverified_context() (In Python
2.7, 3.4  3.5) which explicitly disable SSLv2 and SSLv3. I still have
trouble to understand which protocol will be negociated. We use SSLv3
and disable SSLv3, so the server can only use SSLv23. Am I right?
https://docs.python.org/dev/library/ssl.html#ssl.wrap_socket

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22935
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22935] Disabling SSLv3 support

2014-12-12 Thread Kurt Roeckx

Kurt Roeckx added the comment:

SSLv3 does not support the TLS extensions so it's going to send a totally 
different Client Hello.  It will for instance not indicate with elliptic curves 
it supports.  So yes the behavior for SSLv3 and SSLv23 can be totally 
different.  But even with both SSLv23 and a different cipher list you can get a 
different certificate.

So what I'm really saying is that if you have an API to get a certificate that 
creates a new connection and you can set the options for that connection too 
that you need to document that properly that you might get a different 
certificate.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22935
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22935] Disabling SSLv3 support

2014-12-12 Thread STINNER Victor

STINNER Victor added the comment:

Do you have an example of server returning a different certificate depending on 
the protocol?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22935
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23014] Don't have importlib.abc.Loader.create_module() be optional

2014-12-12 Thread Brett Cannon

Brett Cannon added the comment:

I don't think we really need to say anything. If people want default results, 
simply return None (which is handled for them by importlib.abc.Loader). The 
only thing changing here is that the method will now be required instead of 
optional.

I'll post the patch here before I commit to make sure it's all clear.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23014
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23038] #python.web irc channel is dead

2014-12-12 Thread Collin Anderson

New submission from Collin Anderson:

Can we remove references to #python.web? I assume it was a flourishing channel 
at some point.

https://docs.python.org/3/howto/webservers.html#other-notable-frameworks

--
assignee: docs@python
components: Documentation
messages: 232550
nosy: collinanderson, docs@python
priority: normal
severity: normal
status: open
title: #python.web irc channel is dead
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23038
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22935] Disabling SSLv3 support

2014-12-12 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

 STINNER Victor added the comment:
 
 Any of the other options such as PROTOCOL_TLSv1 will fix the protocol 
 version to that one protocol version, whereas PROTOCOL_SSLv23 means to use 
 any protocol starting with SSLv2. In the context options you can then 
 disable SSLv2 and SSLv3 to e.g. have the connection use TLS 1.0 or later.
 
 get_server_certificate() uses _create_unverified_context() (In Python
 2.7, 3.4  3.5) which explicitly disable SSLv2 and SSLv3. I still have
 trouble to understand which protocol will be negociated. We use SSLv3
 and disable SSLv3, so the server can only use SSLv23. Am I right?
 https://docs.python.org/dev/library/ssl.html#ssl.wrap_socket

I'm not sure what OpenSSL will do if you tell it to use protocol
SSLv3 and then disable this via the options again. This sounds like
it won't connect at all, since PROTOCOL_SSLv3 means: only support
SSLv3 :-)

The logic used for protocol selection in OpenSSL is, well, weird.
You have the choice between fixing one single protocol version or
selecting a range and then disabling certain protocol versions
when configuring the context options.

FWIW: The ssl_version parameter in _create_unverified_context()
already uses the correct default; IMO, exposing the parameter
in get_server_certificate() is fairly useless, unless you want
to (ab)use the function to test supported protocol versions :-)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22935
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22935] Disabling SSLv3 support

2014-12-12 Thread Kurt Roeckx

Kurt Roeckx added the comment:

Most such sites actually seem to have dropped support for SSLv3.

One site where it depends on the cipher string is bugs.cdburnerxp.se

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22935
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23034] Dynamically control debugging output

2014-12-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is (conceivably incomplete) list of debugging and tracing output (but not 
error reporting) from C code.

Controlled output.

Import and shutdown details -- controlled by the -v flag.
Parser tracing -- controlled by the -d flag.
If Py_REF_DEBUG is defined -- controlled by the -X showrefcount flag.
If PYMALLOC_DEBUG is defined -- controlled by the PYTHONMALLOCSTATS environment 
variable.
If Py_TRACE_REFS is defined -- controlled by the PYTHONDUMPREFS environment 
variable.
Garbage collecting details -- controlled by gc.set_debug().
If LLTRACE is defined -- controlled by the __ltrace__ global variable.

Uncomtrolled output.

To stderr:

In PyType_ClearCache (Objects/typeobject.c) if MCACHE_STATS is defined.
Lists allocations if SHOW_ALLOC_COUNT is defined.
Tuples allocations if SHOW_TRACK_COUNT is defined.
Interned strings statistics if __INSURE__ is defined.
In Python/ceval.c if WITH_TSC is defined.
In _PyHash_Fini if Py_HASH_STATS is defined.

To stdout:

In Modules/_ctypes/malloc_closure.c if MALLOC_CLOSURE_DEBUG is defined.
Regex matching trace in Modules/_sre.c if VERBOSE is defined.
Statistics in Modules/hashtable.c if Py_DEBUG is defined.
Allocation counts if COUNT_ALLOCS is defined.

There is also dead code in Parser/parsetok.c, Parser/tokenizer.c, 
Python/pyarena.c, Python/compile.c, Python/formatter_unicode.c, 
Modules/_elementtree.c, Modules/_tkinter.c, Objects/unicodeobject.c.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23034
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23038] #python.web irc channel is dead

2014-12-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 1edff7001f58 by Benjamin Peterson in branch '2.7':
remove reference to dead irc channel (closes #23038)
https://hg.python.org/cpython/rev/1edff7001f58

New changeset aba5f771f5ec by Benjamin Peterson in branch '3.4':
remove reference to dead irc channel (closes #23038)
https://hg.python.org/cpython/rev/aba5f771f5ec

--
nosy: +python-dev
resolution:  - fixed
stage:  - resolved
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23038
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23039] File name restriction on Windows

2014-12-12 Thread Philip Lee

New submission from Philip Lee:

when using open(filename, 'w') on Windows , File names are not allowed to 
contain any characters in \/:*?|  , however open(filename, 'w') doesn't 
throw any exceptions when the file name  contains these characters .

I think some warning should be written in the documentation or exceptions 
thrown should happen  when the file name  contains these characters .

--
components: IO
messages: 232555
nosy: iMath
priority: normal
severity: normal
status: open
title: File name restriction on Windows
type: enhancement

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23039
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23040] Better documentation for the urlencode safe parameter

2014-12-12 Thread Wojtek Ruszczewski

New submission from Wojtek Ruszczewski:

The documentation for urlencode() [1] isn't very clear on how the safe 
parameter is used, it would better not list it together with encoding and error 
as only applying to strings.

[1] https://docs.python.org/3.5/library/urllib.parse.html#urllib.parse.urlencode

--
assignee: docs@python
components: Documentation
files: urlencode-safe.diff
keywords: patch
messages: 232556
nosy: docs@python, wrwrwr
priority: normal
severity: normal
status: open
title: Better documentation for the urlencode safe parameter
type: enhancement
versions: Python 3.5
Added file: http://bugs.python.org/file37426/urlencode-safe.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23040
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23039] File name restriction on Windows

2014-12-12 Thread R. David Murray

R. David Murray added the comment:

The argument to open is a path.  Some of those characters have a meaning in a 
path.

I ran a couple of quick experiments: ab*c.txt fails with an exception.  
:16.txt created a file, which I can do an 'ls' and cat (but not rm) on in 
git-bash, but I'm not sure where it actually is in the file system.

Open is just calling the OS to do the open, so if no error is raised, the *OS* 
(Windows) is not raising the error.  I don't think there is a bug here, unless 
it is in Windows itself.

--
components: +Windows
nosy: +r.david.murray, steve.dower, tim.golden, zach.ware

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23039
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23040] Better documentation for the urlencode safe parameter

2014-12-12 Thread R. David Murray

R. David Murray added the comment:

The current documentation looks very clear to me, and I don't understand your 
changed version.  Can you give an example of how the existing text is 
inaccurate or results in confusion?

--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23040
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23039] File name restriction on Windows

2014-12-12 Thread Tim Golden

Tim Golden added the comment:

Agree with RDM: we're just passing the path through to the Windows API (on 
Windows). We don't generally carry out this kind of pre-emptive check.

--
resolution:  - not a bug
stage:  - resolved
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23039
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23041] csv needs more quoting rules

2014-12-12 Thread Samwyse

New submission from Samwyse:

The csv module currently implements four quoting rules for dialects: 
QUOTE_MINIMAL, QUOTE_ALL, QUOTE_NONNUMERIC and QUOTE_NONE.  These rules treat 
values of None the same as an empty string, i.e. by outputting two consecutive 
quotes.  I propose the addition of two new rules, QUOTE_NOTNULL and 
QUOTE_STRINGS.  The former behaves like QUOTE_ALL while the later behaves like 
QUOTE_NONNUMERIC, except that in both cases values of None are output as an 
empty field.  Examples follow.


Current behavior (which will remain unchanged)

 csv.register_dialect('quote_all', quoting=csv.QUOTE_ALL)
 csv.writer(sys.stdout, dialect='quote_all').writerow(['foo', None, 42])
foo,,42

 csv.register_dialect('quote_nonnumeric', quoting=csv.QUOTE_NONNUMERIC)
 csv.writer(sys.stdout, dialect='quote_nonnumeric').writerow(['foo', None, 
 42])
foo,,42


Proposed behavior

 csv.register_dialect('quote_notnull', quoting=csv.QUOTE_NOTNULL)
 csv.writer(sys.stdout, dialect='quote_notnull').writerow(['foo', None, 42])
foo,,42

 csv.register_dialect('quote_strings', quoting=csv.QUOTE_STRINGS)
 csv.writer(sys.stdout, dialect='quote_strings').writerow(['foo', None, 42])
foo,,42

--
components: Library (Lib)
messages: 232560
nosy: samwyse
priority: normal
severity: normal
status: open
title: csv needs more quoting rules
type: enhancement
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23041
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23041] csv needs more quoting rules

2014-12-12 Thread R. David Murray

R. David Murray added the comment:

As an enhancement, this could be added only to 3.5.  The proposal sounds 
reasonable to me.

--
keywords: +easy
nosy: +r.david.murray
stage:  - needs patch
versions:  -Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23041
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >