Re: empty clause of for loops

2016-03-18 Thread Sven R. Kunze

On 16.03.2016 17:56, Sven R. Kunze wrote:

On 16.03.2016 17:37, Random832 wrote:

On Wed, Mar 16, 2016, at 11:17, Sven R. Kunze wrote:
I can imagine that. Could you describe the general use-case? From 
what I

know, "else" is executed when you don't "break" the loop. When is this
useful?


for item in collection:
if good(item):
   thing = item
   break
else:
thing = default # or raise an exception, etc


I was thinking about why we don't use it that often. My response to 
this example:


thing = item if item in collection else default


Time for a break. That is not going to work.

Will still think about why we don't use it (often/at all).

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


Re: Replace weird error message?

2016-03-18 Thread Chris Angelico
On Thu, Mar 17, 2016 at 5:53 AM, Ben Finney  wrote:
>> For example a hint that "0" does work for the given argument.
>
> I suggest: “zero-padding only allowed for numeric types, not 'str'”.

That's very slightly misleading too; zero padding is perfectly legal
as long as you force the alignment:

>>> "{:>05}".format("1")
'1'
>>> "{:>05}".format("2")
'2'
>>> "{:>05}".format("-3")
'000-3'

Though as the last example shows, this doesn't properly handle signs
("-0003" would be preferred). Dan's wording is a bit better, I think,
but I'll let people debate the exact wording on the tracker.

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


Re: sobering observation, python vs. perl

2016-03-18 Thread Ethan Furman

On 03/17/2016 10:35 AM, Charles T. Smith wrote:

On Thu, 17 Mar 2016 10:26:12 -0700, Ethan Furman wrote:


On 03/17/2016 09:36 AM, Charles T. Smith wrote:


Yes, your point was to forgo REs despite that they are useful.
I could have thought the search would have been better as:

  'release[-.:][Rr]eq'

or something else ... you're in a "defend python at all costs!" mode.


No, I'm in the "don't try to write  in Python" mode, and
"don't use 10lb sledge when 6oz hammer will do" mode:



Yes, fine.

I'd only like to add that the perl numbers might also improve
if the print in the loop were postponed.


Yup, might!  Try it and see.

--
~Ethan~

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


[issue23890] assertRaises increases reference counter

2016-03-18 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy: +haypo

___
Python tracker 

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



Re: Case Statements

2016-03-18 Thread Antoon Pardon
Op 17-03-16 om 09:57 schreef Marko Rauhamaa:
> Antoon Pardon :
>
>> Op 16-03-16 om 20:27 schreef Marko Rauhamaa:
>>> Antoon Pardon :
 Look at decorators. They don't provide functionality we wouldn't have
 without them. So we don't actually need them. Do you argue that
 introducing them wasn't progress?
>>> I do.
>> Way to miss the point.
> Just answering your question.

Just answering the question --- without regard for the context and the
purpose of the question --- sure is a way to miss the point.

-- 
Antoon.


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


[issue26563] PyMem_Malloc(): check that the GIL is hold in debug hooks

2016-03-18 Thread STINNER Victor

STINNER Victor added the comment:

Hum ok, all buildbots look to be happy again :-) I close the issue (again).

--

___
Python tracker 

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



[issue21130] equivalent functools.partial instances should compare equal

2016-03-18 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy: +haypo

___
Python tracker 

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



Re: Bash-like pipes in Python

2016-03-18 Thread Joel Goldstick
On Wed, Mar 16, 2016 at 10:57 AM, Steven D'Aprano 
wrote:

> There's a powerful technique used in shell-scripting languages like bash:
> pipes. The output of one function is piped in to become the input to the
> next function.
>
> According to Martin Fowler, this was also used extensively in Smalltalk:
>
> http://martinfowler.com/articles/collection-pipeline/
>
> and can also be done in Ruby, using method chaining.
>
> Here is a way to do functional-programming-like pipelines to collect and
> transform values from an iterable:
>
> https://code.activestate.com/recipes/580625-collection-pipeline-in-python/
>
> For instance, we can take a string, extract all the digits, convert them to
> ints, and finally multiply the digits to give a final result:
>
> py> from operator import mul
> py> "abcd12345xyz" | Filter(str.isdigit) | Map(int) | Reduce(mul)
> 120
>
>
> (For the definitions of Filter, Map and Reduce, see the code at the
> ActiveState recipe, linked above). In my opinion, this is much nicer
> looking that the standard Python `filter`, `map` and `reduce`:
>
> py> reduce(mul, map(int, filter(str.isdigit, "abcd12345xyz")))
> 120
>
> as this requires the operations to be written in the opposite order to the
> order that they are applied.
>
>
> This is interesting, but the part I'm missing is the use of the Pipe
symbol '|' in python.  Can you elaborate

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



-- 
Joel Goldstick
http://joelgoldstick.com/ 
http://cc-baseballstats.info/
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26439] ctypes.util.find_library fails when ldconfig/glibc not available (e.g., AIX)

2016-03-18 Thread Michael Felt

Michael Felt added the comment:

Ah, good news - the build is successful ONCE I open the file 
./Lib/ctypes/util.py and find the (hiding) tab characters and replace them with 
8 space characters. (And I had tried so hard to check for that in advance).

So, if you apply the patch - it may need some love.

I would be grateful for people (even just one!) looking at it.

Michael

--

___
Python tracker 

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



[issue23857] Make default HTTPS certificate verification setting configurable

2016-03-18 Thread Robert Kuska

Robert Kuska added the comment:

If test fail it will print out non-telling message which make debugging a 
little bit hard:

 FAIL: test__https_verify_envvar (test.test_ssl.ContextTests)   
 
 -- 
 
 Traceback (most recent call last): 
 
   File "/builddir/build/BUILD/Python-2.7.5/Lib/test/test_ssl.py", line 1143, 
in test__https_verify_envvar
 assert_python_ok("-c", https_is_verified, **extra_env) 
 
   File "/builddir/build/BUILD/Python-2.7.5/Lib/test/script_helper.py", line 
55, in assert_python_ok
 return _assert_python(True, *args, **env_vars) 
 
   File "/builddir/build/BUILD/Python-2.7.5/Lib/test/script_helper.py", line 
47, in _assert_python  
 "stderr follows:\n%s" % (rc, err.decode('ascii', 'ignore')))   
 
 AssertionError: Process return code is 1, stderr follows:

Would be possible to change following code which is being executed:

+https_is_verified = """import ssl, sys;\
+sys.exit(ssl._create_default_https_context is not
+ ssl.create_default_context)"""

into something like

https_is_verified = """import ssl, sys;\
value = ssl._create_default_https_context is not ssl.create_default_context;\
sys.exit('ssl._create_default_https_context should be set to verified' if value 
else value)"""

So traceback will look like this:
...
"stderr follows:\n%s" % (rc, err.decode('ascii', 'ignore')))
AssertionError: Process return code is 1, stderr follows:
ssl._create_default_https_context should be set to verified

--

___
Python tracker 

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



[issue26576] Tweak wording of decorator docos

2016-03-18 Thread Chris Angelico

Chris Angelico added the comment:

Question: Is it worth having an explanation somewhere of exactly what *does* 
happen? To what extent is it guaranteed by the language?

--

___
Python tracker 

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



[issue26578] Bad BaseHTTPRequestHandler response when using HTTP/0.9

2016-03-18 Thread Xiang Zhang

Changes by Xiang Zhang :


--
nosy: +gregory.p.smith, martin.panter

___
Python tracker 

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



Re: why x is changed in the following program?

2016-03-18 Thread Peter Otten
maurice.char...@telecom-paristech.fr wrote:

> from numpy import random
> x=random.randn(6)

In Python 

> y=x

doesn't make a copy, it binds y to the same object as x. From now on every 
modification you apply to y

> y[0]=12

 affects x, too, because x and y refer to the same object.

> print x[0]


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


Re: Case Statements

2016-03-18 Thread BartC

On 16/03/2016 14:31, Marko Rauhamaa wrote:

BartC :



Even Ruby has one.



  case
  when this
 
  when that



That's a different topic.


Yes but, if Ruby has it, why shouldn't Python? (Aren't they rivals or 
something?)



which is exactly equivalent to if this... elif that... (when the tests
are ordered), with one difference:



That is no different from a chained if/elif.


That's what I said, but it's an interesting, more symmetric alternative.


Scheme has this:



(case (die10)
  ((1 3 5 7 9)
   => (lambda (n)
n))
  (else
   => (lambda (n)
(/ n 2

which maps 1, 3, 5, 7 and 9 onto themselves but halves 2, 4, 6, 8 and
10.


I don't get this; what does the lambda do here? Why not just yield 
either n or n/2?



As for a chained if/elif, Scheme as "cond:"



(cond
 ((windy?)
  (fly-kite))
 ((shining? sun)
  (go-out))
 ((raining?)
  (play-soccer))
 (else
  (read-book)))


Which is like my Ruby case example. Simple and to the point. (Not sure 
of the significance of ?)


--
Bartc

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


[issue26040] Improve coverage and rigour of test.test_math

2016-03-18 Thread Jeff Allen

Changes by Jeff Allen :


Added file: http://bugs.python.org/file42190/stat_math.py

___
Python tracker 

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



Re: submodules

2016-03-18 Thread ast


"Peter Otten" <__pete...@web.de> a écrit dans le message de 
news:mailman.312.1458299016.12893.python-l...@python.org...

ast wrote:



ok, thx 


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


Re: retrieve key of only element in a dictionary (Python 3)

2016-03-18 Thread Chris Angelico
On Sat, Mar 19, 2016 at 8:33 AM, Fillmore  wrote:
> what am I missing? I don't want to iterate over the dictionary.
> I know that there's only one element and I need to retrieve the key

You could try:

>>> next(iter(d))

Is that clean enough for usage?

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


Re: Fetch Gmail Archieved messages

2016-03-18 Thread Arshpreet Singh
On Friday, 18 March 2016 11:14:44 UTC+5:30, Rick Johnson  wrote:

> #
> # BEGIN CODE
> #
> import imaplib
> 
> def inbox_week():
> emailAddress = '...@gmail.com'
> emailPassword = 'mypassword'
> # START ADDING CODE HERE
> #
> # END CODE
> #

Well I am asking for real help.(!suggestions)
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26588] _tracemalloc: add support for multiple address spaces (domains)

2016-03-18 Thread STINNER Victor

STINNER Victor added the comment:

Patch 3:

- avoid the memory overhead of storing domain if domains are not used
- add optional use_domain parameter to tracemalloc.start()
- by default, no change: use a C void* (pointer) as key for the trace hashtable
- if start() is called with use_domain=True, use (pointer: void*, domain: 
unsigned int) key for the trace hashtable

--
Added file: http://bugs.python.org/file42211/tracemalloc-3.patch

___
Python tracker 

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



Re: monkey patching __code__

2016-03-18 Thread Sven R. Kunze

On 18.03.2016 15:33, Sven R. Kunze wrote:

On 18.03.2016 15:23, Ian Kelly wrote:
On Fri, Mar 18, 2016 at 7:47 AM, Ian Kelly  
wrote:

Your patched version takes two extra arguments. Did you add the
defaults for those to the function's __defaults__ attribute?

And as an afterthought, you'll likely need to replace the function's
__globals__ with your own as well.



def f(a, b=None, c=None):
print(a, b, c)

def f_patch(a, b=None, c=None, d=None, e=None):
print(a, b, c, d, e)


f.__code__ = f_patch.__code__
f.__defaults__ = f_patch.__defaults__
f.__kwdefaults__ = f_patch.__kwdefaults__
f.__globals__ = f_patch.__globals__   < crashes here with 
"AttributeError: readonly attribute"



f('a', e='e')


It seems like we need to work with the globals we have aka. importing 
things locally.



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


[issue15660] Clarify 0 prefix for width specifier in str.format doc,

2016-03-18 Thread py.user

py.user added the comment:

There is a funny thing in 3.6.0a0

>>> '{:<09}'.format(1)
'1'
>>> '{:<09}'.format(10)
'1'
>>> '{:<09}'.format(100)
'1'
>>>

Actually, it behaves like a string, but the format should call internal format 
function of the passed number and the internal format function should not 
format different numbers as equal numbers.

Why does it represent number 1 as number 10?

>>> format(1, '<02')
'10'
>>> format(10, '')
'10'
>>>

I guess, there should be a restriction.
Zero padding for numbers should be correct.

--

___
Python tracker 

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



Re: Cant install virtualenv

2016-03-18 Thread Terry Reedy

On 3/17/2016 2:12 AM, Arjun Prathap wrote:


While trying to install virtualenv in my system(windows 10 Home) using pip


You need to give exact details on how you installed Python and how you 
tried to 'use pip'.



i'm getting the following error...


--
Terry Jan Reedy

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


Re: empty clause of for loops

2016-03-18 Thread Random832
On Wed, Mar 16, 2016, at 11:17, Sven R. Kunze wrote:
> I can imagine that. Could you describe the general use-case? From what I 
> know, "else" is executed when you don't "break" the loop. When is this 
> useful?


for item in collection:
   if good(item):
  thing = item
  break
else:
   thing = default # or raise an exception, etc
-- 
https://mail.python.org/mailman/listinfo/python-list


sobering observation, python vs. perl

2016-03-18 Thread Charles T. Smith
I've really learned to love working with python, but it's too soon
to pack perl away.  I was amazed at how long a simple file search took
so I ran some statistics:

$ time python find-rel.py
./find-relreq *.out | sort -u
TestCase_F_00_P
TestCase_F_00_S
TestCase_F_01_S
TestCase_F_02_M

real1m4.581s
user1m4.412s
sys 0m0.140s


$ time python find-rel.py
# modified to use precompiled REs:
TestCase_F_00_P
TestCase_F_00_S
TestCase_F_01_S
TestCase_F_02_M

real0m29.337s
user0m29.174s
sys 0m0.100s


$ time perl find-rel.pl
find-relreq.pl *.out | sort -u
TestCase_F_00_P
TestCase_F_00_S
TestCase_F_01_S
TestCase_F_02_M

real0m5.009s
user0m4.932s
sys 0m0.072s

Here's the programs:

#!/usr/bin/env python
# vim: tw=0
import sys
import re

isready = re.compile ("(.*) is ready")
relreq = re.compile (".*release_req")
for fn in sys.argv[1:]: # logfile name
tn = None
with open (fn) as fd:
for line in fd:
#match = re.match ("(.*) is ready", line)
match = isready.match (line)
if match:
tn = match.group(1)
#match = re.match (".*release_req", line)
match = relreq.match (line)
if match:
#print "%s: %s" % (tn, line),
print tn

vs.

while (<>) {
if (/(.*) is ready/) {
$tn = $1;
}
elsif (/release_req/) {
print "$tn\n";
}
}

Look at those numbers:
1 minute for python without precompiled REs
1/2 minute with precompiled REs
5 seconds with perl.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26553] Write HTTP in uppercase

2016-03-18 Thread Martin Panter

Martin Panter added the comment:

The three fix_x.y patches look good to me. I pointed out one more fix on the 
review. I think there are plenty more similar changes that could be made if 
somebody wanted to.

--
nosy: +martin.panter
stage: needs patch -> patch review

___
Python tracker 

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



Re: WP-A: A New URL Shortener

2016-03-18 Thread Chris Angelico
(Bouncing back to the list)

On Thu, Mar 17, 2016 at 10:32 PM, Vinicius  wrote:
> Sorry for my bad English guys.

Your English is fine. Don't stress about it. :)

>> Em 15 de mar de 2016, às 9:34 PM, Chris Angelico  escreveu:
>>
>>> On Wed, Mar 16, 2016 at 11:31 AM, Erik  wrote:
>>>
 I often like to make a small
 change when I reimplement, though - something that I thought was
 ill-designed in the original,
>>>
>>>
>>> OK, so maybe the idea for Vinicius (if he's still reading) to pursue is that
>>> it should be something that can be used as the basis for a URL shortening
>>> "service" that is distributed and can NOT go away (think DNS). That is what
>>> some people don't like about the URL shorteners, so maybe that's an itch
>>> that he might want to scratch.
>
> So I really don't see what you were trying to say with this paragraph, the 
> part of "that is distributed and can NOT go away". You think that the project 
> could be distributed with a range of people and get them all syncronized?
>

The problems with URL shorteners are:

1) They are centralized, and thus vulnerable to outages

2) They might be taken down completely, particularly if they're losing
money for someone

So you would need to come up with a system that's distributed (such
that one computer's inaccessibility doesn't bring everything down) and
permanent (keep on circulating that information!). It could be a
rather fun problem to tackle.

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


[issue26569] pyclbr.readmodule() and pyclbr.readmodule_ex() don't support namespace packages

2016-03-18 Thread STINNER Victor

STINNER Victor added the comment:

> Well, your patch is correct even if not ideal. :)  Landing it as a short-term 
> solution is fine.

Ok, done. Sorry, I didn't write an unit test. I only tested manually by 
removing Lib/test/__init__.py.

> Just keep this issue open so we can address the problem more completely later.

If it's a different problem, I prefer to open a new issue. But it's up to you. 
Can you please rephrase the title to put your expectations there? I understood 
that you also want to support frozen module?

--
versions: +Python 3.5

___
Python tracker 

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



[issue26563] PyMem_Malloc(): check that the GIL is hold in debug hooks

2016-03-18 Thread Roundup Robot

Roundup Robot added the comment:

New changeset ae76a1046bb9 by Victor Stinner in branch 'default':
Fix usage of PyMem_Malloc() in os.stat()
https://hg.python.org/cpython/rev/ae76a1046bb9

--

___
Python tracker 

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



Re: from a module return a class

2016-03-18 Thread John Gordon
In  kevind0...@gmail.com 
writes:

> As requested , full code for promptUser_PWord



So promptUser_PWord is a module?  Well, I'm confused.  You gave us this
bit of code:

user_pword = promptUser_PWord()   

But that can't work if promptUser_PWord is a module; modules aren't
callable.  promptUser_PWord() has to be a function or a class.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Re: from a module return a class

2016-03-18 Thread Laurent Pointal
John Gordon wrote:

> In <56eaecc8$0$3658$426a7...@news.free.fr> Laurent Pointal
>  writes:
> 
>> >> user_pword = promptUser_PWord()
>> > 
>> > Show us the complete definition of promptUser_PWord().
> 
>> AFAIU It looks to be the module…
> 
> If it were a module, it wouldn't be callable.  It has to be a function
> or a class.

So the error: SyntaxError: 'return' outside function





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


[issue26530] tracemalloc: add C API to manually track/untrack memory allocations

2016-03-18 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Le 18/03/2016 08:09, STINNER Victor a écrit :
> 
> If it's the minimum is 2 bytes, good. Use the lowest bit as a "GPU" flag!
> pointer|1.

So you guarantee tracemalloc itself won't use such a hack for other
purposes? ;-)

--

___
Python tracker 

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



Beautifulsoap

2016-03-18 Thread eproser
Greetings NG

please I need a little help.

I have this bs object tag:



I want extract 5.69

Some have pity of me :-)

Thanks


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


[issue26553] Write HTTP in uppercase

2016-03-18 Thread Aatish Neupane

Changes by Aatish Neupane :


Added file: http://bugs.python.org/file42201/2_fix_2.7.patch

___
Python tracker 

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



Re: Case Statements

2016-03-18 Thread Antoon Pardon
Op 17-03-16 om 00:14 schreef Chris Angelico:
> def monkeypatch(cls):
> orig = globals()[cls.__name__]
> print("Monkeypatch",id(cls),"into",id(orig))
> for attr in dir(cls):
> if not attr.startswith("_"):
> setattr(orig,attr,getattr(cls,attr))
> return orig
>
> class Foo:
> def method1(self):
> print("I am method 1")
>
> print("Foo is currently",id(Foo))
> some_object = Foo()
>
> @monkeypatch
> class Foo:
> def method2(self):
> print("I am method 2")
>
> print("Foo is now",id(Foo))
>
> some_object.method1()
> some_object.method2()

This seems close enough as far as I am concerned.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

def monkeypatch(cls, orig):
print("Monkeypatch",id(cls),"into",id(orig))
for attr in dir(cls):
if not attr.startswith("_"):
setattr(orig,attr,getattr(cls,attr))
return orig

class Foo:
def method1(self):
print("I am method 1")

print("Foo is currently",id(Foo))
some_object = Foo()

class Foo2:
def method2(self):
print("I am method 2")

monkeypatch(Foo2, Foo)

print("Foo is now",id(Foo))

some_object.method1()
some_object.method2()

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


Re: empty clause of for loops

2016-03-18 Thread Sven R. Kunze

On 17.03.2016 01:27, Steven D'Aprano wrote:

That post describes the motivating use-case for the introduction
of "if...else", and why break skips the "else" clause:


for x in data:
 if meets_condition(x):
 break
else:
 # raise error or do additional processing


It might help to realise that the "else" clause is misnamed. It should be
called "then":

for x in data:
 block
then:
 block


The "then" (actually "else") block is executed *after* the for-loop, unless
you jump out of that chunk of code by raising an exception, calling return,
or break.

As a beginner, it took me years of misunderstanding before I finally
understood for...else and while...else, because I kept coming back to the
thought that the else block was executed if the for/while block *didn't*
execute.


That's true. I needed to explain this to few people and I always need 
several attempts/starts to get it right in a simple statement:


'If you do a "break", then "else" is NOT executed.' I think the "NOT" 
results in heavy mental lifting.



I couldn't get code with for...else to work right and I didn't
understand why until finally the penny dropped and realised that "else"
should be called "then".


That's actually a fine idea. One could even say: "finally".

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


[issue26585] Use html.escape to replace _quote_html in http.server

2016-03-18 Thread Xiang Zhang

Xiang Zhang added the comment:

Thanks for your review. Set quote to False when html.escape is OK to me. But 
except for the usage in BaseHTTPRequestHandler, I think we should also set 
quote to False for the usage in SimpleHTTPRequestHandler since they do not 
appear in attribute either. And I left a reply to your comment. How do you 
think about these?

--

___
Python tracker 

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



[issue26569] pyclbr.readmodule() and pyclbr.readmodule_ex() don't support namespace packages

2016-03-18 Thread Eric Snow

Eric Snow added the comment:

Oh, and spec.loader for namespace package is set to None.

--

___
Python tracker 

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



[issue26270] Support for read()/write()/select() on asyncio

2016-03-18 Thread Guido van Rossum

Guido van Rossum added the comment:

Regular are left behind because select() won't work on them. However we do 
support certain file descriptors (e.g. pipes) and it makes sense to support 
device "files". Can you come up with a new API that lets you pass a file 
descriptor and wrap it in a stream?

--
resolution: not a bug -> 
status: closed -> open

___
Python tracker 

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



Re: Replace weird error message?

2016-03-18 Thread Chris Angelico
On Thu, Mar 17, 2016 at 7:55 AM, Terry Reedy  wrote:
> On 3/16/2016 3:08 PM, Chris Angelico wrote:
>>
>> On Thu, Mar 17, 2016 at 5:53 AM, Ben Finney 
>> wrote:

 For example a hint that "0" does work for the given argument.
>>>
>>>
>>> I suggest: “zero-padding only allowed for numeric types, not 'str'”.
>>
>>
>> That's very slightly misleading too; zero padding is perfectly legal
>> as long as you force the alignment:
>>
> "{:>05}".format("1")
>>
>> '1'
>
> "{:>05}".format("2")
>>
>> '2'
>
> "{:>05}".format("-3")
>>
>> '000-3'
>>
>> Though as the last example shows, this doesn't properly handle signs
>> ("-0003" would be preferred).
>
>
> Sign-aware 0 padding is only for numeric types.  '-3' is a string, no
> different from 'ab'.

Right, and that's not changing. But there are a lot of situations in
which '=' and '>' will be absolutely identical (eg formatting a
sequence number, starting from zero or one and moving up from there),
and it would be misleading to tell people that zero-padding isn't an
option just because of a technical difference.

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


Re: sobering observation, python vs. perl

2016-03-18 Thread Mark Lawrence

On 17/03/2016 16:36, Charles T. Smith wrote:

On Thu, 17 Mar 2016 09:21:51 -0700, Ethan Furman wrote:


well, I don't want to forgo REs in order to have python's numbers be better


The issue is not avoiding REs, but using Python's strengths and idioms.
   Write the code in Python's style, get the same results, then compare
the times.



Yes, your point was to forge REs despite that they are useful.
I could have thought the search would have been better as:

 'release[-.:][Rr]eq'

or something else ... you're in a "defend python at all costs!" mode.



I believe it is more along the lines of "In Rome, do as the Romans".

--
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


[issue26576] Tweak wording of decorator docos

2016-03-18 Thread Georg Brandl

Georg Brandl added the comment:

The patch is definitely an improvement.

What about a remark like ", except that `deco` is evaluated before the function 
`f` is created"?  That should cover the remaining difference.

--
nosy: +georg.brandl

___
Python tracker 

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



[issue26439] ctypes.util.find_library fails when ldconfig/glibc not available (e.g., AIX)

2016-03-18 Thread Michael Felt

Michael Felt added the comment:

fyi: just completed a test both as 32 and 64 bit build.

However, openssl-1.0.1.514 does not work in 64-bit mode (packaging error). 
Fortunately, openssl-1.0.1.515 (released 02-March-2016) fixes that.

In short, 64-bit build is dependent on openssl-1.0.1.515

Here is the corrected patch (tabs removed). name: python.Lib.ctypes.160317.patch

--
Added file: http://bugs.python.org/file42193/python.Lib.ctypes.160317.patch

___
Python tracker 

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



Re: How to waste computer memory?

2016-03-18 Thread Terry Reedy

On 3/18/2016 11:26 AM, Marko Rauhamaa wrote:


There's no problem providing pure Unicode strings. Things get iffy when
Python's OS abstraction pretends sys.stdin is text or filenames are
strings.


On Windows, filenames are arrays of wide chars, not bytes, and are 
better modeled as 3.x strings rather than bytes.  Hence, on Windows, the 
bytes API to filenames has been deprecated.  The unix situation is 
different.


--
Terry Jan Reedy

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


discussion group for Python in finance?

2016-03-18 Thread beliavsky--- via Python-list
Is there an active online group discussing the use of Python in finance?

Here are some resources for Python in finance I know of. Numpy, scipy, pandas, 
and matplotlib are useful packages discussed in the books "Python for Finance" 
by Hilpisch and "Python for Data Analysis" by McKinney. Quandl is a good 
packages for importing financial and economic data. Quantopian is a site that 
lets you backtest strategies coded in Python. IBpy is a package for trading at 
Interactive Brokers using Python. Quantstart has e-books and a blog about 
Python in finance. Robert Carver wrote a book "Systmatic Trading" that has 
Python code, and he has a blog "Investment Idiocy". Python is often discussed 
in the "programming and software" forum of wilmott.com .
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: sobering observation, python vs. perl

2016-03-18 Thread srinivas devaki
please upload the log file,

and global variables in python are slow, so just keep all that in a
function and try again. generally i get 20-30% time improvement by
doin that.


On Thu, Mar 17, 2016 at 8:59 PM, Charles T. Smith
 wrote:
> I've really learned to love working with python, but it's too soon
> to pack perl away.  I was amazed at how long a simple file search took
> so I ran some statistics:
>
> $ time python find-rel.py
> ./find-relreq *.out | sort -u
> TestCase_F_00_P
> TestCase_F_00_S
> TestCase_F_01_S
> TestCase_F_02_M
>
> real1m4.581s
> user1m4.412s
> sys 0m0.140s
>
>
> $ time python find-rel.py
> # modified to use precompiled REs:
> TestCase_F_00_P
> TestCase_F_00_S
> TestCase_F_01_S
> TestCase_F_02_M
>
> real0m29.337s
> user0m29.174s
> sys 0m0.100s
>
>
> $ time perl find-rel.pl
> find-relreq.pl *.out | sort -u
> TestCase_F_00_P
> TestCase_F_00_S
> TestCase_F_01_S
> TestCase_F_02_M
>
> real0m5.009s
> user0m4.932s
> sys 0m0.072s
>
> Here's the programs:
>
> #!/usr/bin/env python
> # vim: tw=0
> import sys
> import re
>
> isready = re.compile ("(.*) is ready")
> relreq = re.compile (".*release_req")
> for fn in sys.argv[1:]: # logfile name
> tn = None
> with open (fn) as fd:
> for line in fd:
> #match = re.match ("(.*) is ready", line)
> match = isready.match (line)
> if match:
> tn = match.group(1)
> #match = re.match (".*release_req", line)
> match = relreq.match (line)
> if match:
> #print "%s: %s" % (tn, line),
> print tn
>
> vs.
>
> while (<>) {
> if (/(.*) is ready/) {
> $tn = $1;
> }
> elsif (/release_req/) {
> print "$tn\n";
> }
> }
>
> Look at those numbers:
> 1 minute for python without precompiled REs
> 1/2 minute with precompiled REs
> 5 seconds with perl.
> --
> https://mail.python.org/mailman/listinfo/python-list



-- 
Regards
Srinivas Devaki
Junior (3rd yr) student at Indian School of Mines,(IIT Dhanbad)
Computer Science and Engineering Department
ph: +91 9491 383 249
telegram_id: @eightnoteight
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to waste computer memory?

2016-03-18 Thread Random832
On Fri, Mar 18, 2016, at 03:00, Ian Kelly wrote:
> jmf has been asked this before, and as I recall he seems to feel that
> UTF-8 should be used for all purposes, ignoring the limitations of
> that encoding such as that indexing becomes a O(n) operation.

Just to play devil's advocate, here, why is it so bad for indexing to be
O(n)? Some simple caching is all that's needed to prevent it from making
iteration O(n^2), if that's what you're worried about.

Emacs' "multibyte string" type does this. (among other trickery to
represent non-unicode characters and "raw bytes" as code points above
10 - raw bytes are 3FFF80-3F)
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26530] tracemalloc: add C API to manually track/untrack memory allocations

2016-03-18 Thread Nathaniel Smith

Nathaniel Smith added the comment:

I think we're talking past each other :-).

> If I change tracemalloc, it's not to fullfit numpy requirements, it must 
> remain very generic

Nothing about what I'm saying is relevant to numpy -- the patch attached to 
this bug report is already plenty for what numpy needs. (Well, it still needs a 
public API like PyMem_Track/Untrack or something, but never mind for now.)

The only reason I'm speaking up now is that if you're adding a manual 
track/untrack API, then a relatively trivial addition now makes tracemalloc 
vastly more powerful, so I don't want to miss this opportunity.

> void* allows to implement the rejected option of also storing the C filename 
> an C line number:

And if you want to attach some extra metadata to traces, then that's an 
interesting idea that I can potentially imagine various use cases for. But it's 
not the idea I'm talking about :-). (FWIW, I think the biggest challenge for 
your idea will be how the allocation sites -- which might be in arbitrary user 
code -- are supposed to figure out what kind of metadata they should be 
attaching. And if it's information that tracemalloc can compute itself -- like 
C backtraces -- then there's no reason for it to be in the public API, which is 
the thing I'm concerned about here.)

What I'm talking about is different: I think it should be possible to re-use 
the tracemalloc infrastructure to track other resources besides "heap 
allocations". So for my use case, it's crucial that we index by (domain, 
pointer), because the address 0xdeadbeef on the heap is different from the 
address 0xdeadbeef on the GPU. We'll never want to group by pointer alone 
without the domain, because that would cause us to actually misinterpret the 
data (if I do PyMem_Track("gpu", 0xdeadbeef); PyMem_Untrack("heap", 
0xdeadbeef), then this should not cause tracemalloc to forget about the gpu 
allocation! I think this is very different than your C backtrace example). And, 
it's always obvious to callers what kind of thing to pass here, because they 
know perfectly well whether they just allocated memory on the heap or on the 
GPU, so the public API is an appropriate place for this information. And, it's 
immediately obvious that for this use case, there will only be a few different 
domains in use a
 t one time, so it's very inefficient to literally store (domain, pointer) 
pairs -- replacing the current pointer => trace design with a domain => 
(pointer => trace) design would indeed require changing tracemalloc's design a 
bit, but not, I think, in any fundamental way?

--

___
Python tracker 

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



Re: sobering observation, python vs. perl

2016-03-18 Thread Marko Rauhamaa
"Charles T. Smith" :

> Actually, I saw a study some years ago that concluded that python
> could be both slower and faster than perl, but that perl had much less
> deviation than python. I took that and accepted it, but was surprised
> now that in exactly the field of application that I've traditionally
> used perl, it really is better, er... faster.
>
> Furthermore, the really nice thing about python is its OO, but I've
> really neglected looking into that with perl's OO capabilities.

I haven't had such log processing needs as you, nor has it come down to
performance in such a way. Do use the best tool for the job.

(When it comes to freely formatted logs, gleaning information from them
is somewhat of a lost cause. I've done my best to move to rigorously
formatted logs that are much more amenable to post processing.)

Perl might be strong on its home turf, but I am a minimalist and
reductionist -- Perl was intentionally designed to be a maximalist,
imitating the principles of natural languages. Python has concise,
crystal-clear semantics that are convenient to work with.

Compare Perl (http://www.perlmonks.org/?node_id=98357>):

   my $str = "I have a dream";
   my $find = "have";
   my $replace = "had";
   $find = quotemeta $find; # escape regex metachars if present
   $str =~ s/$find/$replace/g;
   print $str;

with Python:

   print("I have a dream".replace("have", "had"))


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


[issue26578] Bad BaseHTTPRequestHandler response when using HTTP/0.9

2016-03-18 Thread Xiang Zhang

Changes by Xiang Zhang :


--
type:  -> behavior

___
Python tracker 

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



[issue13601] sys.stderr should be line-buffered when stderr is not a TTY

2016-03-18 Thread STINNER Victor

Changes by STINNER Victor :


--
title: sys.stderr should always be line-buffered -> sys.stderr should be 
line-buffered when stderr is not a TTY

___
Python tracker 

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



Re: from a module return a class

2016-03-18 Thread Wolfgang Maier

On 3/18/2016 20:19, kevind0...@gmail.com wrote:


so what I get from the various postings is promptUser_PWord must be
converted to a class.  True?



A simple function would also do. Just make sure that the return is 
inside a callable block.


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


Re: Beautifulsoap

2016-03-18 Thread eproser

Yes, for my hobby i want extract odds.

The code is:

from bs4 import BeautifulSoup

import urllib2

url = 
"http://www.betexplorer.com/soccer/england/premier-league-2014-2015/results/;

content = urllib2.urlopen(url).read()

soup = BeautifulSoup(content)

odds = soup.find_all("td", class_="odds")
for odd in odds:
  print odd

And I have this list of object:

...




>From this object I'm interesting only 3.70 3.65 3.48 etc

I'm no a programmer, my hobby is analyze soccer matchs to try to win :-)
I chose python because I think is the best :-)

Thank you in advance




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


Re: Fetch Gmail Archieved messages

2016-03-18 Thread Arshpreet Singh
On Tuesday, 15 March 2016 22:32:42 UTC+5:30, Rick Johnson  wrote:

> Is that last line doing what you think it's doing? Let's
> break it down... Basically you have one condition, that is
> composed of two main components:
> 
> Component-1: EMAIL in str(msg[header])
> 
> and 
> 
> Component-2: str(msg[header])
>  
> 
> "Component-1" will return a Boolean. So in essence you're
> asking:
> 
> boolean = EMAIL in str(msg[header])
> if boolean in str(msg[header]):
> do_something()
>  
> Is that really what you wanted to do? I'm not sure how you
> will ever find a Boolean in a string. Unless i've missed
> something...? 

Yes I am looking for in EMAIL string is present in  str(msg[header]) then 
do_something()

>It will also help readability if you only 
> applied str() to the value *ONCE*. But, maybe you don't 
> even need the str() function???

I also run without str() but sometimes it causes weird exception errors because 
you can't predict the behaviour msg[header].
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26564] Malloc debug hooks: display memory block traceback on error

2016-03-18 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 7b079adb0774 by Victor Stinner in branch 'default':
Enhance documentation on malloc debug hooks
https://hg.python.org/cpython/rev/7b079adb0774

--

___
Python tracker 

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



[issue26530] tracemalloc: add C API to manually track/untrack memory allocations

2016-03-18 Thread STINNER Victor

STINNER Victor added the comment:

Nathaniel Smith:
> There are other leakable resources besides heap and GPU memory -- shmem 
> segments and file descriptors are two that I thought of earlier, but there 
> are probably others too. (Note that not all file descriptors are associated 
> with a python file object.) I guess one could hack most of these things into 
> pointer bit tricks somehow, but I don't really see the appeal myself :-). 
> It's fine for an internal implementation trick, but a very pythonic public 
> api...

Ok ok, you convinced me. I opened the issue #26588: "_tracemalloc: add support 
for multiple address spaces (domains)".

Hum, the idea of tracking file descriptors is appealing. In practice, I suggest 
to simply use Py_uintptr_t type in the new C API rather than void*. So it's 
more obvious that tracemalloc doesn't care of the value, it only requires the 
value to be unique.

FYI On Windows, handles and file descriptors are also different namespaces. You 
can get a handle and a file descriptor which have the same value but are 
identify different objects.

I don't know shmem.

--

Another different idea would be to annotate a "color" to a memory allocator. 
For example, group memory only used internally, and memory to store user data. 
For a network application, you can imagine an identifier per request and then 
group all allocations of this request.

It sounds very similar to the domain idea, but there is a very important 
difference: the API proposed in issue #26588 requires to pass domain to track 
*and* untrack functions. The problem with coloring allocations is that the 
color is known when the memory is allocated, but the function releasing the 
memory can be very far, and it can simply be the garbage collector. So the 
color must be stored in the hashtable *value* (the trace), whereas the domain 
is stored in the hashtable *key* (a tuple (pointer, domain)).

Since no user directly asked this feature, I propose to defer this issue and 
focus on the concrete issue #26588 to support tracking GPU(s) memory.

--

___
Python tracker 

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



crash while using PyCharm / Python3

2016-03-18 Thread Adam

Host OS:Ubuntu Desktop 14.04 LTS / Unity

System crashed while using PyCharm / Python3.
Booting takes forever and stuck at the purple screen with
the Ubuntu logo and the five dots cycling.
How to fix?


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


[issue26567] ResourceWarning: Use tracemalloc to display the traceback where an object was allocated when a ResourceWarning is emitted

2016-03-18 Thread Roundup Robot

Roundup Robot added the comment:

New changeset b8acf98beca9 by Victor Stinner in branch 'default':
Try to fix test_warnings on Windows
https://hg.python.org/cpython/rev/b8acf98beca9

--

___
Python tracker 

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



Re: retrieve key of only element in a dictionary (Python 3)

2016-03-18 Thread Terry Reedy

On 3/18/2016 5:39 PM, Daniel Wilcox wrote:

I think you're looking for something like popitem().


d = {'asdf':1}
d.popitem()[0]

'asdf'


Only if he wants the item removed.

--
Terry Jan Reedy

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


Re: retrieve key of only element in a dictionary (Python 3)

2016-03-18 Thread Fillmore


OK, this seems to do the trick, but boy is it a lot of code. Anythong more 
pythonic?

>>> l = list(d.items())
>>> l
[('squib', '007')]
>>> l[0]
('squib', '007')
>>> l[0][0]
'squib'
>>>


On 03/18/2016 05:33 PM, Fillmore wrote:


I must be missing something simple, but...

Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
 >>> d = dict()
 >>> d['squib'] = "007"
 >>> # I forget that 'squib' is my key to retrieve the only element in d
...
 >>> type(d.items())

 >>> key = d.items()[0]
Traceback (most recent call last):
   File "", line 1, in 
TypeError: 'dict_items' object does not support indexing
 >>> key,_ = d.items()
Traceback (most recent call last):
   File "", line 1, in 
ValueError: need more than 1 value to unpack
 >>> key,b = d.items()
Traceback (most recent call last):
   File "", line 1, in 
ValueError: need more than 1 value to unpack
 >>> print(d.items())
dict_items([('squib', '007')])
 >>> print(d.items()[0])
Traceback (most recent call last):
   File "", line 1, in 
TypeError: 'dict_items' object does not support indexing
 >>>

what am I missing? I don't want to iterate over the dictionary.
I know that there's only one element and I need to retrieve the key

thanks


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


[issue26589] Add HTTP Response code 451

2016-03-18 Thread Raymond Hettinger

New submission from Raymond Hettinger:

https://tools.ietf.org/html/rfc7725

--
components: Library (Lib)
files: code451.diff
keywords: patch
messages: 262000
nosy: rhettinger
priority: normal
severity: normal
stage: patch review
status: open
title: Add HTTP Response code 451
type: enhancement
versions: Python 3.6
Added file: http://bugs.python.org/file42208/code451.diff

___
Python tracker 

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



Re: How to waste computer memory?

2016-03-18 Thread Chris Angelico
On Sat, Mar 19, 2016 at 3:05 PM, Ian Kelly  wrote:
> On Fri, Mar 18, 2016 at 3:19 PM, Mark Lawrence  
> wrote:
>>
>> I have no idea at what the above can mean, other than that you are agreeing
>> with the RUE.
>
> Mark, are you aware that this is a rather classic ad hominem of guilt
> by association? "I didn't pay any attention to your actual argument,
> but you seem to be agreeing with X and X is an idiot, so you must be
> wrong."

I'm not listening to your argument, Ian. I have an Ad Hominem Blocker.

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


[issue26590] socket destructor: implement finalizer

2016-03-18 Thread STINNER Victor

New submission from STINNER Victor:

The PEP 442 helped to make object finalization safer, but it's just an API, 
it's not widely used in the Python core yet. io.FileIO has a nice 
implementation, but socket.socket and os.scandir don't.

I noticed this while working on the issue #26567 which indirectly resurected a 
destroyed socket (in test_socket).

As I workaround, I reverted my change on socket destructor, but I'm interested 
to enhance socket destructor to be able to use the new tracemalloc feature of 
the warnings module.

--
messages: 262014
nosy: haypo, pitrou
priority: normal
severity: normal
status: open
title: socket destructor: implement finalizer
type: enhancement
versions: Python 3.6

___
Python tracker 

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



Re: retrieve key of only element in a dictionary (Python 3)

2016-03-18 Thread Martin A. Brown

>> But, I still don't understand why this works and can't puzzle it
>> out.  I see a sequence on the left of the assignment operator and a
>> dictionary (mapping) on the right.
>
>When you iterate over a dictionary, you get its keys:
>
>scores = {"Fred": 10, "Joe": 5, "Sam": 8}
>for person in scores:
>print(person)
>
>So unpacking will give you those keys - in an arbitrary order. Of 
>course, you don't care about the order when there's only one.

Oh, right!  Clearly, it was nonintuitive (to me), even though I've 
written 'for k in d:' many times.

A sequence on the left hand side of an assignment, will tell the 
right hand side to iterate.

This also explains something I never quite bothered to understand 
completely, because it was so obviously wrong:

  >>> a, b = 72
  TypeError: 'int' object is not iterable

The sequence on the left hand side signals that it expects the 
result of iter(right hand side).  But, iter(72) makes no sense, so 
Python says TypeError.  I'd imagine my Python interpreter is 
thinking "Dude, why are you telling me to iterate over something 
that is so utterly not iterable.  Why do I put up with these 
humans?"

I love being able to iterate like this:

  for k in d:
  do_something_with(k)

But, somehow, this surprised me:

  [k] = d

Now that I get it, I would probably use something like the below.  
I find the addition of a few characters makes this assignment much 
clearer to me.

  # -- if len(d) > 1, ValueError will be raised
  #
  (key,) = d.keys()  

And thank you for the reply Chris,

-Martin

-- 
Martin A. Brown
http://linux-ip.net/
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue20186] Derby #18: Convert 31 sites to Argument Clinic across 23 files

2016-03-18 Thread Martin Panter

Changes by Martin Panter :


Added file: http://bugs.python.org/file33425/heapq_clinic.patch

___
Python tracker 

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



Re: How to waste computer memory?

2016-03-18 Thread Ian Kelly
On Fri, Mar 18, 2016 at 3:19 PM, Mark Lawrence  wrote:
>
> I have no idea at what the above can mean, other than that you are agreeing
> with the RUE.

Mark, are you aware that this is a rather classic ad hominem of guilt
by association? "I didn't pay any attention to your actual argument,
but you seem to be agreeing with X and X is an idiot, so you must be
wrong."
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: TSP in python ; this is code to solve tsp whenever called, where given coordinates as in name of pos and then start coordinate as in start, help me how it works ?

2016-03-18 Thread Joel Goldstick
On Fri, Mar 18, 2016 at 1:42 PM, Mark Lawrence 
wrote:

> On 18/03/2016 17:04, Qurrat ul Ainy wrote:
>
>> help required !!!
>>
>>
> For what, house cleaning?
>
> I googled TSP and found the Traveling Salesman Problem.  The shortest path
to a bunch of places that ends at the starting point.

Apparently  found code somewhere and doesn't understand it.  Where did the
code come from? Was there any description?

> --
> 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
>



-- 
Joel Goldstick
http://joelgoldstick.com/ 
http://cc-baseballstats.info/
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26585] Use html.escape to replace _quote_html in http.server

2016-03-18 Thread Martin Panter

Martin Panter added the comment:

Thanks for the tests. I left a couple comments.

About encoding quotes: Personally I don’t see much value unless you are 
encoding an attribute value, in which case I would prefer to use 
xml.sax.saxutils.quoteattr(). Encoded quotes would only become useful if the 
“error_message_format” attribute was modified.

A more practical downside is that if “error_content_type” is set to say 
text/plain, we are adding two somewhat common characters that will get messed 
up. E.g. the “explain” string for 429 Too Many Requests will include the 
double-quoted rate limiting. And an apostrophe could easily be 
given in a custom error message, e.g. “Cant write a clean error message”.

--

___
Python tracker 

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



Re: How to waste computer memory?

2016-03-18 Thread Chris Angelico
On Sat, Mar 19, 2016 at 9:03 AM, Marko Rauhamaa  wrote:
> Also, special-casing '\0' and '/' is
> lame. Why can't I have "Results 1/2016" as a filename?

Would you be allowed to have a directory named "Results 1" as well?

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


Re: How to waste computer memory?

2016-03-18 Thread Jussi Piitulainen
Ian Kelly writes:

> On Thu, Mar 17, 2016 at 1:21 PM, Rick Johnson
>  wrote:
>> In the event that i change my mind about Unicode, and/or for
>> the sake of others, who may want to know, please provide a
>> list of languages that *YOU* think handle Unicode better than
>> Python, starting with the best first. Thanks.
>
> jmf has been asked this before, and as I recall he seems to feel that
> UTF-8 should be used for all purposes, ignoring the limitations of
> that encoding such as that indexing becomes a O(n) operation. He has
> pointed at Go as an example of a language wherein Unicode "just
> works", although I think that others do not necessarily agree [1].

...

> [1] https://coderwall.com/p/k7zvyg/dealing-with-unicode-in-go

I think Julia's way of dealing with its strings-as-UTF-8 [2] is more
promising. Indexing is by bytes (1-based in Julia) but the value at a
valid index is the whole UTF-8 character at that point, and an invalid
index raises an exception.

The letters "ö" and "ä" are two bytes each in UTF-8.

julia> s = "myöhä"
"myöhä"

julia> s[3]
'ö'

julia> s[4]
ERROR: UnicodeError: invalid character index
 in next at ./unicode/utf8.jl:65
 in getindex at strings/basic.jl:37

julia> s[5]
'h'

Julia provides access to the next character at an index and the valid
index after that:

julia> next(s, 3)
('ö',5)

The last valid index:

julia> endof(s)
6

Special syntax to index at the end of a string:

julia> s[end - 1:end]
"hä"

That's not quite right. The penultimate character happened to be one
byte, so it worked. At least incorrect indexing results in an exception
rather than an incorrect value. There is a proper method to get a
previous valid index - I should have used that.

Also, the length of a string is the number of characters rather than
bytes, decoupled from the indexing.

julia> length("myöhä")
5

I work with text all the time, but I don't think I ever _need_ arbitrary
access to an nth character. What I require is access to the start and
end of a string, searching, and splitting. These all seem compatible
with using UTF-8 representations. Same with iterating over the string
(forward or backward).

Just in case: I've been quite happy with Unicode in Python 3. It's just
interesting to see a different way that also seems to work.

[2] http://docs.julialang.org/en/release-0.4/manual/strings/
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26554] PC\bdist_wininst\install.c: Missing call to fclose()

2016-03-18 Thread Aatish Neupane

Changes by Aatish Neupane :


--
keywords: +patch
Added file: http://bugs.python.org/file42212/issue26554.patch

___
Python tracker 

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



Re: How to waste computer memory?

2016-03-18 Thread Ian Kelly
On Fri, Mar 18, 2016 at 10:44 AM, Steven D'Aprano  wrote:
> On Sat, 19 Mar 2016 02:31 am, Random832 wrote:
>
>> On Fri, Mar 18, 2016, at 11:17, Ian Kelly wrote:
>>> If the string is simple UCS-2, that's easy.
>
> Hmmm, well, nobody uses UCS-2 any more, since that only covers the first
> 65536 code points. Rather, languages like Javascript and Java, and the
> Windows OS, use UTF-16, which is a *variable width* extension to UCS-2. I
> don't know about Windows, but Javascript implements this badly, so that
> 4-byte UTF-16 code points are treated as *two* surrogate code points
> instead of the single code point they are meant to be.

The reason I specifically brought up UCS-2 is because *Python* uses
UCS-2 (or Latin-1, or UCS-4 depending on the nature of the string).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: discussion group for Python in finance?

2016-03-18 Thread jogaserbia
unicode support in Python 3 is better than in python2 

https://docs.python.org/3/howto/unicode.html 

What does this refer to (what are you getting at):

> I was also told, a lot of code has been ported to
> the Go language.

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


[issue20186] Derby #18: Convert 31 sites to Argument Clinic across 23 files

2016-03-18 Thread Martin Panter

Martin Panter added the comment:

Summary of the work here as I pass through :)

Files already done:
Objects/memoryobject.c: converted to signatures without Arg Clinic (Py 3.5)
Modules/_opcode.c: Issue 19674 (3.4). Only one function I can see there 
(Larry’s original post says two sites).
Modules/_io/_iomodule.c: part of Georg’s modules_issue20186.patch, but 
already handled in Issue 20175 (3.5)

Files being worked on:
Modules/_operator.c: patch by Tal, ready for commit?
Modules/_lsprof.c: Georg’s modules_issue20186.patch
Modules/_heapqmodule.c: restored Georg’s patch; looks like he meant to add 
it to the main patch but it got lost
Objects/enumobject.c: patch by Tal
Modules/symtablemodule.c: Georg’s modules_issue20186.patch
Modules/mathmodule.c: patch by Tal
Modules/_tracemalloc.c: modules_issue20186.patch; needs update from review 
comments
Modules/_csv.c: modules_issue20186.patch; couple of review comments

That leaves the following files from OP:
Objects/tupleobject.c: 2 sites
Objects/descrobject.c: 2 sites
Objects/complexobject.c: 2 sites
Objects/weakrefobject.c: 1 sites
Objects/structseq.c: 1 sites
Objects/rangeobject.c: 1 sites
Objects/object.c: 1 sites
Objects/moduleobject.c: 1 sites
Objects/funcobject.c: 1 sites
Objects/fileobject.c: 1 sites
Objects/codeobject.c: 1 sites
Objects/boolobject.c: 1 sites

--
nosy: +martin.panter

___
Python tracker 

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



Re: retrieve key of only element in a dictionary (Python 3)

2016-03-18 Thread Joel Goldstick
On Fri, Mar 18, 2016 at 6:08 PM, Fillmore 
wrote:

>
> OK, this seems to do the trick, but boy is it a lot of code. Anythong more
> pythonic?
>
> >>> l = list(d.items())
> >>> l
> [('squib', '007')]
> >>> l[0]
> ('squib', '007')
> >>> l[0][0]
> 'squib'


Maybe this:
l = list(d.items())[0][0]

>
> >>>
>
>
> On 03/18/2016 05:33 PM, Fillmore wrote:
>
>>
>> I must be missing something simple, but...
>>
>> Python 3.4.0 (default, Apr 11 2014, 13:05:11)
>> [GCC 4.8.2] on linux
>> Type "help", "copyright", "credits" or "license" for more information.
>>  >>> d = dict()
>>  >>> d['squib'] = "007"
>>  >>> # I forget that 'squib' is my key to retrieve the only element in d
>> ...
>>  >>> type(d.items())
>> 
>>  >>> key = d.items()[0]
>> Traceback (most recent call last):
>>File "", line 1, in 
>> TypeError: 'dict_items' object does not support indexing
>>  >>> key,_ = d.items()
>> Traceback (most recent call last):
>>File "", line 1, in 
>> ValueError: need more than 1 value to unpack
>>  >>> key,b = d.items()
>> Traceback (most recent call last):
>>File "", line 1, in 
>> ValueError: need more than 1 value to unpack
>>  >>> print(d.items())
>> dict_items([('squib', '007')])
>>  >>> print(d.items()[0])
>> Traceback (most recent call last):
>>File "", line 1, in 
>> TypeError: 'dict_items' object does not support indexing
>>  >>>
>>
>> what am I missing? I don't want to iterate over the dictionary.
>> I know that there's only one element and I need to retrieve the key
>>
>> thanks
>>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com/ 
http://cc-baseballstats.info/
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue16142] ArgumentParser inconsistent with parse_known_args

2016-03-18 Thread Dario Giovannetti

Changes by Dario Giovannetti :


--
nosy: +kynikos

___
Python tracker 

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



Re: retrieve key of only element in a dictionary (Python 3)

2016-03-18 Thread Chris Angelico
On Sat, Mar 19, 2016 at 12:27 PM, Martin A. Brown  wrote:
> But, I still don't understand why this works and can't puzzle it
> out.  I see a sequence on the left of the assignment operator and a
> dictionary (mapping) on the right.

When you iterate over a dictionary, you get its keys:

scores = {"Fred": 10, "Joe": 5, "Sam": 8}
for person in scores:
print(person)

So unpacking will give you those keys - in an arbitrary order. Of
course, you don't care about the order when there's only one.

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


Another python question

2016-03-18 Thread Alan Gabriel
Sorry for the multiple questions but my while loop is not working as intended.

Here is the code :
n = 1
list1 = []
count = 0  #amount of times program repeats
steps = 0 # amount of steps to reach 1
step_list = []
while n!=0:
n= int(input())
list1.append(n)
length = len(list1)

while count < length:
num= list1[count]
while num!= 1:
if num%2 == 0:
num= int(num/2)
print(num)
steps+=1
if num%2 == 1:
num=int(3*num+1)
print(num)
steps+=1

count+=1
step_list.append(steps)
steps=0

This code is meant to get numbers from the user in different lines and convert 
into a list. When this is done the first while loop  runs until it checks all 
the numbers in the list. The 2nd while loop is meant to stop when the number is 
equal to 1 however the 2nd while loop keeps running.

Sorry for the bad naming but I was in a rush, ty anyway



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


Re: How to waste computer memory?

2016-03-18 Thread Ian Kelly
On Fri, Mar 18, 2016 at 8:56 AM, Random832  wrote:
> On Fri, Mar 18, 2016, at 03:00, Ian Kelly wrote:
>> jmf has been asked this before, and as I recall he seems to feel that
>> UTF-8 should be used for all purposes, ignoring the limitations of
>> that encoding such as that indexing becomes a O(n) operation.
>
> Just to play devil's advocate, here, why is it so bad for indexing to be
> O(n)? Some simple caching is all that's needed to prevent it from making
> iteration O(n^2), if that's what you're worried about.

What kind of caching do you have in mind? If you're just going to
index the string, then that's at least an extra byte per character,
which mostly kills the memory savings that is usually the goal of
using UTF-8 in the first place.

It's not the only drawback, either. If you want to know anything about
the characters in the string that you're looking at, you need to know
their codepoints. If the string is simple UCS-2, that's easy. Just
take the two bytes and cast them as a 16-bit integer (assuming that
the endianness of the string matches the machine). If the string is
UTF-8 then it has to be decoded, so you need to figure out exactly how
many bytes are in this particular character, and then from those
determine which bits you need and then mash those bits together to
form the actual integer codepoint. Now think about doing that over and
over again in the context of a lexicographical sort.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to waste computer memory?

2016-03-18 Thread Michael Torrie
On 03/18/2016 02:26 AM, Jussi Piitulainen wrote:
> I think Julia's way of dealing with its strings-as-UTF-8 [2] is more
> promising. Indexing is by bytes (1-based in Julia) but the value at a
> valid index is the whole UTF-8 character at that point, and an invalid
> index raises an exception.

This seems to me to be a leaky abstraction.  Julia's approach is
interesting, but it strikes me as somewhat broken as it pretends to do
O(1) indexing, but in reality it's still O(n) because you still have to
iterate through the bytes until you find, say, the nth time that doesn't
raise an exception.  Except for dealing with the ASCII subset of UTF-8,
I can't really see any time when grabbing whatever resides at the nth
byte of a UTF-8 string would be useful.

> I work with text all the time, but I don't think I ever _need_ arbitrary
> access to an nth character. What I require is access to the start and
> end of a string, searching, and splitting. These all seem compatible
> with using UTF-8 representations. Same with iterating over the string
> (forward or backward).

Indeed, this is the argument from the web site
http://utf8everywhere.org.  Their argument is that often individual
unicode code points don't make sense by themselves, so there's no point
in chopping up a Unicode string. Many unicode strings only make sense if
you start at the beginning and read and interpret the code points as you
go. Hence UTF-8's requirement that you have to always start at the
beginning you want to find the nth code point is not a burden.

I guess whether or not you need to find the nth character depends on the
strength of string functions.  If I searched a string for a particular
delimiter, I could see it being useful to get whatever is just past the
delimiter, for example.  Though Python's split() method eliminates the
need to do that by hand.


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


[issue26587] Possible duplicate entries in sys.path if .pth files are used with zip's

2016-03-18 Thread SilentGhost

SilentGhost added the comment:

Could you provide a code example of your using addsitedir that results in 
duplicates?

--
nosy: +SilentGhost
stage:  -> test needed
versions:  -Python 3.4

___
Python tracker 

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



[issue26568] Add a new warnings.showwarnmsg() function taking a warnings.WarningMessage object

2016-03-18 Thread STINNER Victor

STINNER Victor added the comment:

I pushed a change which adds a private _showwarnmsg(), but I'm still interested 
to make this new function public!

I pushed the change to unblock the issue #26567.

--
title: Add a new warnings.showmsg() function taking a warnings.WarningMessage 
object -> Add a new warnings.showwarnmsg() function taking a 
warnings.WarningMessage object

___
Python tracker 

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



Re: Need explanation of this error

2016-03-18 Thread Steven D'Aprano
On Sat, 19 Mar 2016 04:25 am, Bryan Bateman wrote:

> Having the same error with python 3.5 windows 64 bit and scipy for same on
> Windows 10.  I did dependency walker and it came up with a large number of
> DLL's.  Do you want the source of the scipy binary and the DLL list?

Before we start worrying about the source code to SciPy and the complete
list of DLLs on your system, you might start by telling us what the actual
error is.



-- 
Steven

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


Re: from a module return a class

2016-03-18 Thread John Gordon
In  Wolfgang Maier 
 writes:

> > So promptUser_PWord is a module?  Well, I'm confused.  You gave us this
> > bit of code:
> >
> >  user_pword = promptUser_PWord()
> >
> > But that can't work if promptUser_PWord is a module; modules aren't
> > callable.  promptUser_PWord() has to be a function or a class.
> >

> Yes, but I guess the OP's program will run into the SyntaxError when 
> trying to import the module, i.e., before it ever encounters the 
> TypeError: 'module' object is not callable.

Good point; I hadn't thought of that.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


[issue26567] ResourceWarning: Use tracemalloc to display the traceback where an object was allocated when a ResourceWarning is emitted

2016-03-18 Thread STINNER Victor

STINNER Victor added the comment:

For socket & scandir, I opened the issue #26590: "socket destructor: implement 
finalizer".

--

___
Python tracker 

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



Re: Case Statements

2016-03-18 Thread Chris Angelico
On Thu, Mar 17, 2016 at 9:53 PM, Steven D'Aprano  wrote:
> On Thu, 17 Mar 2016 05:48 pm, Chris Angelico wrote:
>
>> Okay. Let's try this.
> [...]
>> Decorators work. Now let's try NOT using decorators.
>
> You are still using a decorator. You're just not using @ decorator syntax.

Oops, sorry. That was sloppy wording on my part. What I meant was
"decorator syntax".

The rest of your analysis was equally correct.

> But we can fix it like this:
>
> def x(self):
> print("Getting x")
> return 42
> x = property(x)
> def y(self, value):
> print("Setting x to", value)
> x = x.setter(y)

Oh... I thought x.setter() needed the name to be the same. Okay, in
that case it's not so hard. Doesn't need the messy temporaries of the
other option.

>> This is how CPython implements this (it evaluates the decoration
>> expressions first, leaving them on the stack, then creates the
>> function, then calls the decorators), but I don't see anywhere that
>> this is guaranteed in the docs either - the only way I know this is
>> current behaviour is from trying it (with dis.dis). The documented
>> equivalence simply doesn't work.
>
> It does work. You just have to be careful to not garbage collect objects
> before you can use them :-)

The "documented equivalence" is what's written here:

https://docs.python.org/3/reference/compound_stmts.html#function
"""
For example, the following code

@f1(arg)
@f2
def func(): pass

is equivalent to

def func(): pass
func = f1(arg)(f2(func))
"""

Saying "is equivalent to" implies a correlation that, in this case, is
imperfect. But to be fair, these kinds of edge cases are (a) only of
interest to language developers and the curious, and (b) exist in
quite a few places in the language. The correspondence between
operators and magic methods [1] has the same flaw; saying that xhttps://docs.python.org/3/reference/datamodel.html#object.__lt__
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26573] Method Parameters can be Accepted as Keyword Arguments?

2016-03-18 Thread Zachary Ware

Changes by Zachary Ware :


--
resolution:  -> not a bug
stage:  -> resolved

___
Python tracker 

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



Re: Bash-like pipes in Python

2016-03-18 Thread Sven R. Kunze

On 16.03.2016 16:09, Joel Goldstick wrote:

symbol '|' in python.  Can you elaborate


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


Re: DSLs in perl and python (Was sobering observation)

2016-03-18 Thread MRAB

On 2016-03-17 22:22, Mark Lawrence wrote:

On 17/03/2016 17:47, Rustom Mody wrote:

On Thursday, March 17, 2016 at 10:09:27 PM UTC+5:30, Charles T. Smith wrote:

or something else ... you're in a "defend python at all costs!" mode.

So now my questions:

How do you in perl make regexps readable like python's VERBOSE?
Can you do better in perl?



I neither know, nor do I care.  Why not ask on a perl list?


Stick an "x" on the end of the regex: /something/x or s/old/new/x.

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


[issue26470] Make OpenSSL module compatible with OpenSSL 1.1.0

2016-03-18 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy:  -haypo

___
Python tracker 

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



monkey patching __code__

2016-03-18 Thread Sven R. Kunze

Hi,

we got an interesting problem. We need to monkeypatch Django's reverse 
function:



First approach:

urlresolvers.reverse = patched_reverse


Problem: some of Django's internal modules import urlresolvers.reverse 
before we can patch it for some reasons.



Second approach:

urlresolvers.reverse.__code__ = patched_reverse.__code__


Unfortunately, we got this error:

>>> reverse('login')

patched_reverse() takes at least 3 arguments (1 given)


These are the functions' signatures:

def patched_reverse(viewname, urlconf=None, args=None, kwargs=None, 
prefix=None, current_app=None, get=None, fragment=None):
def reverse(viewname, urlconf=None, args=None, kwargs=None, prefix=None, 
current_app=None):



Some ideas?

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


[issue26583] test_timestamp_overflow of test_importlib fails if PYTHONDONTWRITEBYTECODE is set

2016-03-18 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 915f158633f4 by Ned Deily in branch '3.5':
Issue #26583: Skip test_timestamp_overflow in test_import if bytecode
https://hg.python.org/cpython/rev/915f158633f4

New changeset e8cab14d8a47 by Ned Deily in branch 'default':
Issue #26583: merge from 3.5
https://hg.python.org/cpython/rev/e8cab14d8a47

--
nosy: +python-dev

___
Python tracker 

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



AIX build and (potentially missing modules

2016-03-18 Thread Michael Felt
I have been packaging python for AIX - and wanting minimal dependancies 
I have been ignoring the final messages from make.


Personally, I do not see any real harm in the missing *audio "bits", but 
how terrible are the other missing "bits" for normal python programs?


Many thanks for feedback!

...
building dbm using ndbm
INFO: Can't locate Tcl/Tk libs and/or headers

Python build finished, but the necessary bits to build these modules 
were not found:

_bsddb _curses_panel  _sqlite3
_tkinter   bsddb185   dl
gdbm   imageoplinuxaudiodev
ossaudiodevreadline   spwd
sunaudiodev

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


[issue26578] Bad BaseHTTPRequestHandler response when using HTTP/0.9

2016-03-18 Thread Martin Panter

Martin Panter added the comment:

As I understand it, you are saying if you override the undocumented (but 
publicly-named) default_request_version attribute, HTTP 0.9 requests no longer 
work.

I suspect it is even broken by default. My understanding is with HTTP 0.9 you 
should be able to send b"GET \r\n" and get a response, but Python’s 
server will deadlock waiting for a second blank line or EOF. It looks like this 
deadlock has been there since ~forever (1995).

See Issue 10721 which already proposes to remove 0.9 server support. I would be 
weakly in favour of this (or more strongly if someone can prove my theory that 
the current support is broken).

--

___
Python tracker 

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



Re: Case Statements

2016-03-18 Thread Mark Lawrence

On 16/03/2016 11:16, BartC wrote:

On 16/03/2016 11:07, Mark Lawrence wrote:


I don't want to discourage you too much, but I think that adding a
switch statement comes *very* low on the list of improvements we would
like to make in Python 3.5.

We should probably focus on speed ...


OK, you're coming round...



No, those were the words of the BDFL, not me.  Further, please do not 
deliberately cut words to change the context. The original said quite 
clearly "We should probably focus on speed (or aspects of it, like 
startup)...".


--
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


Beginner Python Help

2016-03-18 Thread Alan Gabriel
Hey there,

I just started out python and I was doing a activity where im trying to find 
the max and min of a list of numbers i inputted.

This is my code..

num=input("Enter list of numbers")
list1=(num.split())

maxim= (max(list1))
minim= (min(list1))

print(minim, maxim)



So the problem is that when I enter numbers with an uneven amount of digits 
(e.g. I enter 400 20 36 85 100) I do not get 400 as the maximum nor 20 as the 
minimum. What have I done wrong in the code?

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


Re: Bash-like pipes in Python

2016-03-18 Thread Chris Angelico
On Fri, Mar 18, 2016 at 1:10 AM, Steven D'Aprano  wrote:
> At the moment, the data being processed by the Map, Filter, etc. are
> ordinary lists or iterators. In order to give them a customer __repr__, I
> would have to change the Map and Filter __ror__ method to return some
> custom type which behaves as an iterable but has the appropriate __repr__.
> I don't want to do that: I want the pipeline functions to return ordinary
> lists or iterators, whichever is appropriate.

They don't have to be iterators, just iterables, right? They could
return a one of these:

class QuantumList:
def __init__(self, iterable):
self.iter = iter(iterable)
self.list = []
def __iter__(self):
yield from self.list
while "moar stuff":
try: val = next(self.iter)
except StopIteration: return
self.list.append(val)
yield val
def __repr__(self):
self.list.extend(self.iter)
return repr(self.list)

This object has a generator/list duality, but if you observe it, it
collapses to a list. When used interactively, it'd be pretty much the
same as calling list() as the last step, but in a script, they'd
operate lazily.

Quantum computing is here already!

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


Re: WP-A: A New URL Shortener

2016-03-18 Thread Rick Johnson
On Wednesday, March 16, 2016 at 7:02:16 AM UTC-5, Daniel Wilcox wrote:
> I dare say I'm with Rick on this point[...]

Contrary to "pseudo popular belief", it's perfectly okay to
agree with Rick (from time to time). Hey, even a stopped
clock is correct twice a day!
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26568] Add a new warnings.showmsg() function taking a warnings.WarningMessage object

2016-03-18 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 79888b970cc4 by Victor Stinner in branch 'default':
Add _showwarnmsg() and _formatwarnmsg() to warnings
https://hg.python.org/cpython/rev/79888b970cc4

--
nosy: +python-dev

___
Python tracker 

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



Re: Fetch Gmail Archieved messages

2016-03-18 Thread Rick Johnson
On Thursday, March 17, 2016 at 11:14:48 PM UTC-5, Arshpreet Singh wrote:

> Yes I am looking for in EMAIL string is present in
> str(msg[header]) then do_something()
> 
> I also run without str() but sometimes it causes weird
> exception errors because you can't predict the behavior
> msg[header].

My suggestion is that you start over, you have too many
issues here.

  (1) Your importing a module from within a function, that's
  almost always a bad idea.
  
  (2) You spelling your local variable names like constants,
  i wouldn't do that.
  
  (3) You're repeating yourself too much.
  
  (4) You're logic is invalid, and appears to possibly have
  syntax errors.

Start from the beginning, and slowly add code "line-by-
line", checking for proper outputs along the way.
#
# BEGIN CODE
#
import imaplib

def inbox_week():
emailAddress = '...@gmail.com'
emailPassword = 'mypassword'
# START ADDING CODE HERE
#
# END CODE
#
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26553] Write HTTP in uppercase

2016-03-18 Thread Aatish Neupane

Changes by Aatish Neupane :


Added file: http://bugs.python.org/file42199/fix_3.6.patch

___
Python tracker 

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



  1   2   >