Re: WP-A: A New URL Shortener

2016-03-15 Thread Chris Angelico
On Wed, Mar 16, 2016 at 3:27 PM, Gregory Ewing
 wrote:
> Chris Angelico wrote:
>>
>> There are many places where there are limits (hard or soft) on message
>> lengths. Some of us still use MUDs and 80-character line limits.
>> Business cards or other printed media need to be transcribed by hand.
>> Dictation of URLs becomes virtually impossible when they're
>> arbitrarily long.
>
>
> Your typical shortened URL made up of a random jumble
> of letters and numbers isn't good for dictating or
> transcribing from a business card either.
>
> For those uses, a well-chosen semantically-memorable
> URL is still the best solution. There shouldn't be
> too much trouble in arranging one of those that's
> short enough to put on a business card.

Quite a few URL shorteners allow you to pick a keyword (conditionally
on it not being in use, of course). For example,
http://bit.ly/threshvote is perfectly memorable, but is still shorter
than the address it redirects to. Given that it's a mobile app
download link, it's extremely helpful for people to be able to type
that without clicking on it; and since it's going to the Google Play
Store, the creator of the app has no power to shorten the official
URL.

In some cases, the correct solution would be a short URL at a domain
that the provider controls. But that's no different from running your
own shortener service - it still has the extra indirection and
consequent risks. So for a lot of people, a public shortener is just
as good.

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


[issue26571] turtle regression in 3.5

2016-03-15 Thread Ellison Marks

New submission from Ellison Marks:

I noticed some odd behaviour when running some turtle code I wrote using python 
3.5. A simplified example:

>>> from turtle import Turtle
>>> t = Turtle()
>>> t.getscreen().bye() # or manually close the turtle window
>>> t2 = Turtle()
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib64/python3.5/turtle.py", line 3816, in __init__
visible=visible)
  File "/usr/lib64/python3.5/turtle.py", line 2557, in __init__
self._update()
  File "/usr/lib64/python3.5/turtle.py", line 2660, in _update
self._update_data()
  File "/usr/lib64/python3.5/turtle.py", line 2646, in _update_data
self.screen._incrementudc()
  File "/usr/lib64/python3.5/turtle.py", line 1292, in _incrementudc
raise Terminator
turtle.Terminator
>>>

This code works under 3.4, opening a new turtle window the second time Turtle() 
is called. Under 3.5, a blank white window opens.

This seems to be related to https://hg.python.org/cpython/rev/1628484c9408, as 
the only point that raises Terminator is guarded by a check for `if not 
TurtleScreen._RUNNING:`

--
components: Library (Lib)
messages: 261840
nosy: Ellison Marks
priority: normal
severity: normal
status: open
title: turtle regression in 3.5
type: behavior
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



Re: WP-A: A New URL Shortener

2016-03-15 Thread Gregory Ewing

Chris Angelico wrote:

There are many places where there are limits (hard or soft) on message
lengths. Some of us still use MUDs and 80-character line limits.
Business cards or other printed media need to be transcribed by hand.
Dictation of URLs becomes virtually impossible when they're
arbitrarily long.


Your typical shortened URL made up of a random jumble
of letters and numbers isn't good for dictating or
transcribing from a business card either.

For those uses, a well-chosen semantically-memorable
URL is still the best solution. There shouldn't be
too much trouble in arranging one of those that's
short enough to put on a business card.

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


[issue19914] help([object]) returns "Not enough memory." on standard Python types, object and object functions

2016-03-15 Thread Eryk Sun

Eryk Sun added the comment:

For posterity for anyone that finds this old issue, I investigated this problem 
in the debugger in Windows 7. It turns out that more.com (the pager used by 
Python's help) calls MultiByteToWideChar [1] with dwFlags passed as 
MB_PRECOMPOSED (1), which is forbidden for UTF-8. The error message is just a 
generic error that incorrectly assumes decoding the byte string failed due to 
running out of memory.

You may be happy to learn that this problem is fixed in Windows 10.

[1]: https://msdn.microsoft.com/en-us/library/dd319072

Here are a few snapshots from the debugger.

more.com calls SetConsoleConversions from its init function, InitializeThings:

Breakpoint 0 hit
more!MORE::InitializeThings:
`ff293058 48895c2408  mov qword ptr [rsp+8],rbx
ss:`0024f7a0=
0:000> g
Breakpoint 2 hit
ulib!WSTRING::SetConsoleConversions:
07fe`f6498934 8a05d6a8mov al,byte ptr
[ulib!WSTRING::_UseAnsiConversions
 (07fe`f64a3210)] ds:07f
e`f64a3210=00

This causes decoding byte strings to use the current console codepage instead 
of the system ANSI or OEM codepage. The intention here is to allow a user to 
correctly display a text file that's in a different encoding. The decoded text 
is written to the console as Unicode via WriteConsoleW.

Here is the bad call where dwFlags (register rdx) is passed as MB_PRECOMPOSED 
(1), which is invalid for codepage 65001 (register rcx).

0:000> g
Breakpoint 1 hit
KERNELBASE!MultiByteToWideChar:
07fe`fd191f00 fff3pushrbx
0:000> ? @rcx
Evaluate expression: 65001 = `fde9
0:000> r rdx
rdx=0001

In Windows 10 this argument is passed as 0, the correct value.

This problem occurs indirectly via a utility library named ulib.dll, which is 
used by Windows command-line utilities. It should only occur when console 
conversions are enabled. Otherwise ulib converts using the system OEM and ANSI 
codepages.  I searched for other utilities that use 
ulib!WSTRING::SetConsoleConversions:

C:\>for %f in (C:\Windows\system32\*.exe) do @(^
More? dumpbin /imports "%f" | ^
More? findstr SetConsoleConversions && echo %f)
   7FF713B8934   167 ?SetConsoleConversions@WSTRING@@SAXXZ
C:\Windows\system32\find.exe

I found that find.exe is also subject to this bug in Windows 7. It fails to 
print the result if the console is using codepage 65001:

C:\Temp\test>type test
eggs
spam

C:\Temp\test>find /n "spam" *

-- TEST
[2]spam

C:\Temp\test>chcp 65001
Active code page: 65001

C:\Temp\test>find /n "spam" *

-- TEST

This works correctly in Windows 10.

--
nosy: +eryksun

___
Python tracker 

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



[issue26570] comma-separated cookies with expires header do not parse properly

2016-03-15 Thread Ilya Kreymer

New submission from Ilya Kreymer:

This is a peculiar regression in 3.5 where a comma-separated cookie following 
an expires field is considered invalid:

Ex: which results in a silent error/empty cookie in 3.5.1

Python 3.5.1 (default, Dec 26 2015, 18:11:22) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from http.cookies import SimpleCookie
>>> SimpleCookie('A=B; expires=Thu, 01-Jan-1970 00:00:00 GMT, C=D')


compared to 3.4.2 and 2.7.9

Python 3.4.2 (default, Jan 29 2015, 06:45:30) 
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from http.cookies import SimpleCookie
>>> SimpleCookie('A=B; expires=Thu, 01-Jan-1970 00:00:00 GMT, C=D')


Python 2.7.9 (default, Jan 29 2015, 06:28:46) 
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from Cookie import SimpleCookie
>>> SimpleCookie('A=B; expires=Thu, 01-Jan-1970 00:00:00 GMT, C=D')





This seems to specifically happen when the expires field is the last field in 
the cookie.
eg, this works as expected:

>>> SimpleCookie('A=B; expires=Thu, 01-Jan-1970 00:00:00 GMT; Path=/, C=D')


I'm not sure if this is related to the other comma-related cookie bugs, such as 
issue26302 as this does not appear to use the same regex at first glance. I 
have not had a chance to track it down it further.

--
components: Library (Lib)
messages: 261839
nosy: ikreymer
priority: normal
severity: normal
status: open
title: comma-separated cookies with expires header do not parse properly
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



Re: Case Statements

2016-03-15 Thread Mark Lawrence

On 16/03/2016 01:55, jj0gen0i...@gmail.com wrote:

You have apparently mistaken me for someone who's worried.  I don't use Python, I was 
just curious as to why a construct that is found, not only to be useful in 95% of other 
languages, but is generally considered more flexible and readable than the if-elif, was 
missing in Python.  (your link "Switch Statement Code Smell" not withstanding)

Have a great day :)



So you would rather write something like:-

switch (x):
  case COW:
moo()
break

  case DUCK:
quack()
break

  default IDUNNO:
panic()

than:-

x.makeNoise()

?

--
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: Case Statements

2016-03-15 Thread Mario R. Osorio
On Tuesday, March 15, 2016 at 9:55:27 PM UTC-4, jj0ge...@gmail.com wrote:
> You have apparently mistaken me for someone who's worried.  I don't use 
> Python, I was just curious as to why a construct that is found, not only to 
> be useful in 95% of other languages, but is generally considered more 
> flexible and readable than the if-elif, was missing in Python.  (your link 
> "Switch Statement Code Smell" not withstanding)
> 
> Have a great day :)

Switch and case statements are such a waste of time that, in order to 
understand them you have to mentally use if/elseif/else/endif statements. 
Furthermore, the concepts of switch and case could not even exist without the 
notion of if/elseif/else/endif statements. Why then, add an extra level of 
complication??.

Go play with Java or Maybe C++. Have fun with their fancy if/elseif/else/endif 
statements oops, sorry, they call them switch and/or case statements.

Wish you the best and please lete us know if and when you have a deep fall 
through a breakeless case ... You must love debugging those ... they are fun, 
specially a 4:30am, with an hour and a half to deploy...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: WP-A: A New URL Shortener

2016-03-15 Thread Rick Johnson
On Tuesday, March 15, 2016 at 7:23:12 PM UTC-5, Thomas 'PointedEars' Lahn wrote:

(Note: i had to rearrange your paragraph to accommodate a more
intuitive response. I apologize for this, but i'm confident
i was able to maintain your original intent)

> You are giving bad advice to a junior developer, advising
> them to *waste* *their* *youth* developing for the recycle
> bin. Because what if it does not work out in the end?

But what if it does "work out"? There is only one way to
find out, yes?

> It can no doubt be educational to play with programming.
> But if actually the *entire* world says it [...] is a bad
> idea, then it probably is. Unfortunately, there is [...]
> the common misconception of the misunderstood genius, and
> that a real genius would sink so low as to do things just
> in order to prove everybody wrong. But to do so is not
> genial, it is outright stupid.

I completely disagree.

Even if the fruits of your labor end up in the recycle bin,
so what! There is always a valuable lesson to be learned
from every project, even if that lesson is: " Hmm, this was
a very bad idea, i should have considered the consequences
of this vector path more carefully".

But in many cases, one cannot foresee the failure, and must
travel *DEEP* into the investigatory process before the
failure becomes apparent. And just because one cannot solve
a specific problem, one would be foolish to conclude that
the problem has no attainable solution. One should simply
conclude, that they lack the intelligence to solve the
problem.

The worst attitude you can adopt is that of the pessimist,
who is defeated by his own "fear of failure" before he even
begins. None of us are Omniscient, therefore, we must realize
that in order to achieve any level of intelligence *GREATER*
than what we currently posses, we must be unafraid to reach
beyond our intellectual limits and into the "scary dark
corners" of the "unknown".

Yes, failure is highly likely in these "dark areas", and we
could be bitten by a spider lurking in the shadows, but
until we systematically map these unfamiliar areas, even if
necessary, with *BRUTE FORCE TRIAL AND ERROR*, we will never
attain a greater level of intelligence.

And perhaps some people don't want to venture "outside their
comfy little box". That's fine. But their defeatism will
never discourage me from actively expanding my "intellectual
horizons". Boxes are confining, intellectual or otherwise,
and i was born to be free!

The best method of achieving intellectual greatness, is to
take on projects/challenges that are well outside your
comfort zone. Don't worry, if you have a properly
functioning brain, then you already possess the *ONLY* tool
you will ever need to accomplish the mission.

The main reason i hang out here, answering questions, is not
so much to help others, but to learn. Learning is my primary
goal, and helping is my secondary. I have found that simply
"reading the archives" is not enough, because it is not
*READING* that motivates me to learn, no, it is the
potential of failure that motivates me put-in the extra
effort to ensure that my advice is good advice. And sure,
i've failed quite a few times, but do those failures bother
me? NO WAY! Because each time i failed, i made sure to
investigate and discover *WHY* i failed. I learned, and i
became more intelligent each time.

The same "motivational force" can be utilized when we post
our source code publicly. Every one of us, has source code
hiding in our repos that we would be ashamed to show
publicly (yes, don't lie!). Perhaps the code is not using
proper Pythonic style convention, perhaps it is missing
documentation strings, or perhaps, it is just some really
horrific algorithms that we have been too lazy to re-write.
Posting the code presents us with a high probability that
someone may find these "warts", and expose them. For that
reason, we will be motivated to repair these warts before
making them public.

So my point is: Don't be fearful of publicly posting your
code, or participating in online help groups, or, more
generally, stepping outside of your "intellectual comfort
zone" by taking on a challenging project. Because if you're
not failing on a regular basis , then that should be
*GLARING* indication that you're not pushing your boundaries
far enough.

"FAILURE IS A NATURAL BYPRODUCT OF THE LEARNING PROCESS" -- rr

> Want a more prominent example?  Linus Torvalds wrote a
> kernel for an operating system because, although it
> started his fascination for operating systems, MINIX did
> not suffice for *him*; only later he announced *on Usenet*
> (comp.os.minix) what would become the Linux kernel, and
> look what arose from that.  Because the people he
> announced it to thought, "Hey, that could be really
> *useful*!".

I too have dreamed of writing an OS, if for nothing more,
than to prove to myself i can do it. Because i know i can. A
few years back, i started hacking at the Python2.x source,
attempting to mold it into my 

Re: WP-A: A New URL Shortener

2016-03-15 Thread Gene Heskett
On Tuesday 15 March 2016 22:46:44 Thomas 'PointedEars' Lahn wrote:

> Gene Heskett wrote:
> > On Tuesday 15 March 2016 19:55:52 Chris Angelico wrote:
> >> On Wed, Mar 16, 2016 at 10:38 AM, Thomas 'PointedEars' Lahn
> >>
> >> > And as for second-level domains, consider for example “t.c”
> >> > instead of “twitter.com” as part of the short URI.
> >>
> >> That'll work only for the ones that you code in specifically, and
> >> that's only shortening your URL by 8 characters. A typical URL
> >> needing shortening is over 80 characters - maybe several hundred.
> >> You need to cut that down to a manageable length. That
> >> fundamentally cannot be reversed without readding information.
> >
> > And I submit that putting someone in charge of the drives
> > organization, and the database on that drive that the url has to dig
> > thru, can make a huge difference in the length of the resultant url.
>
> Maybe it’s just the late/early hour, but you’ve just lost me.
> Please elaborate.
>
Elaborate? Unless the database is expected to handle the whole human 
race, what 9 billion of us?, a subdir name longer than 8 chars is wasted 
space.  And we regularly see them much longer that that, with a friggin 
regex in the middle, using 6 to 15 subdirs if what I read is broken 
down. Thats assinine IMO, and if because they cannot do it right for a 
platform other than windows, it doesn't work for me, then I don't care 
if it links to the g-code (RS-274-D) that would make my machines carve 
me a key to Fort Knox.  If these ID10T's want me to see whatever the 
heck it is they're are peddling to make me last all night, they WILL fix 
it.  Heck, at 81, and diabetic for almost 30 years, nothing they can 
sell me will fix it anyway. :(
> >> >>> And with the exception of Twitter-ish sites that place a limit
> >> >>> on message length, there really is *no need* for shorter URIs
> >> >>> nowadays.  (HTTP) clients and servers are capable of processing
> >> >>> really long ones [1]; electronic communications media and
> >> >>> related software, too [2].  And data storage space as well as
> >> >>> data transmission has become exceptionally inexpensive.  A few
> >> >>> less bytes there do not count.
> >
> > They may not count for that much in terms of what the user pays for
> > bandwidth, but see below.  And some users are probably still paying
> > for their internet access by the minute in some locales.
>
> So they should loathe more the overhead measured in *kibibytes* and
> delay measured in *seconds* caused by additional HTTP requests due to
> redirection from “short URLs” than the few more *bytes* in longer,
> original URLs, yes?
>
> --
> PointedEars
>
> Twitter: @PointedEars2
> Please do not cc me. / Bitte keine Kopien per E-Mail.


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


Re: Readability counts, was Re: Use of Lists, Tupples, or Sets in IF statement.

2016-03-15 Thread Rustom Mody
On Tuesday, March 15, 2016 at 11:05:32 PM UTC+5:30, Peter Otten wrote:
> Indeed. It's still better than
> 
> "This is %s a fruit" % (x in x_list and "" or "not")
> 
> The bug is intentional; the fix is of course
> 
> "This is %s a fruit" % (x in x_list and "most likely" or "probably not")
> 
> ;)

Thanks
I wondered what/why you were bringing in this clunky, error-prone
pre-conditional meme...
And came across 
https://mail.python.org/pipermail/python-dev/2005-September/056510.html

| I propose that in Py3.0, the "and" and "or" operators be simplified to
| always return a Boolean value instead of returning the last evaluated
| argument.

Good to know that Raymond Hettinger disagrees with Guido on the
messed-up, ½-class status of bools in python
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: WP-A: A New URL Shortener

2016-03-15 Thread Thomas 'PointedEars' Lahn
Gene Heskett wrote:

> On Tuesday 15 March 2016 19:55:52 Chris Angelico wrote:
>> On Wed, Mar 16, 2016 at 10:38 AM, Thomas 'PointedEars' Lahn
>> > And as for second-level domains, consider for example “t.c” instead
>> > of “twitter.com” as part of the short URI.
>> That'll work only for the ones that you code in specifically, and
>> that's only shortening your URL by 8 characters. A typical URL needing
>> shortening is over 80 characters - maybe several hundred. You need to
>> cut that down to a manageable length. That fundamentally cannot be
>> reversed without readding information.
> 
> And I submit that putting someone in charge of the drives organization,
> and the database on that drive that the url has to dig thru, can make a
> huge difference in the length of the resultant url.

Maybe it’s just the late/early hour, but you’ve just lost me.
Please elaborate.
 
>> >>> And with the exception of Twitter-ish sites that place a limit on
>> >>> message length, there really is *no need* for shorter URIs
>> >>> nowadays.  (HTTP) clients and servers are capable of processing
>> >>> really long ones [1]; electronic communications media and related
>> >>> software, too [2].  And data storage space as well as data
>> >>> transmission has become exceptionally inexpensive.  A few less
>> >>> bytes there do not count.
> 
> They may not count for that much in terms of what the user pays for
> bandwidth, but see below.  And some users are probably still paying for
> their internet access by the minute in some locales.

So they should loathe more the overhead measured in *kibibytes* and delay 
measured in *seconds* caused by additional HTTP requests due to redirection 
from “short URLs” than the few more *bytes* in longer, original URLs, yes?
 
-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: WP-A: A New URL Shortener

2016-03-15 Thread Gene Heskett
On Tuesday 15 March 2016 19:55:52 Chris Angelico wrote:

> On Wed, Mar 16, 2016 at 10:38 AM, Thomas 'PointedEars' Lahn
>
>  wrote:
> > Chris Angelico wrote:
> >> On Wed, Mar 16, 2016 at 9:53 AM, Thomas 'PointedEars' Lahn
> >>
> >>  wrote:
> >>> […] I cannot be sure because I have not thought this through, but
> >>> with
> >
> > ^^^
> >
> >>> aliases for common second-level domains, and with text
> >>> compression, it should be possible to do this without a database.
> >>
> >> How? If you shorten URLs, you have to be able to reconstruct the
> >> long ones. Compression can't do that to arbitrary lengths.
> >> Somewhere there needs to be the rest of the information.
> >
> > First of all, you quoted me out of context.
>
> I trimmed the context. You got a problem with that?
>
> > Second, do you even read what you reply to?  See the markings above.
>
> Instead of thinking about URL shorteners specifically, think generally
> about information theory. You cannot, fundamentally, shorten all URLs
> arbitrarily. There just isn't enough room to store the information.
>
> > And as for second-level domains, consider for example “t.c” instead
> > of “twitter.com” as part of the short URI.
>
> That'll work only for the ones that you code in specifically, and
> that's only shortening your URL by 8 characters. A typical URL needing
> shortening is over 80 characters - maybe several hundred. You need to
> cut that down to a manageable length. That fundamentally cannot be
> reversed without readding information.

And I submit that putting someone in charge of the drives organization, 
and the database on that drive that the url has to dig thru, can make a 
huge difference in the length of the resultant url.

> >>> And with the exception of Twitter-ish sites that place a limit on
> >>> message length, there really is *no need* for shorter URIs
> >>> nowadays.  (HTTP) clients and servers are capable of processing
> >>> really long ones [1]; electronic communications media and related
> >>> software, too [2].  And data storage space as well as data
> >>> transmission has become exceptionally inexpensive.  A few less
> >>> bytes there do not count.

They may not count for that much in terms of what the user pays for 
bandwidth, but see below.  And some users are probably still paying for 
their internet access by the minute in some locales.

> >> There are many places where there are limits (hard or soft) on
> >> message lengths. Some of us still use MUDs and 80-character line
> >> limits.
> >
> > See above.  Covered by [2].
>
> Unrelated. Not covered by that link. Go use a MUD some time.
>
> > But speaking of length limits, the lines in your postings are too
> > long, according to Usenet convention.  I had to correct the
> > quotations so that they remained readable when word-wrapped.
>
> Oh, so you'd rather the lines be cut to... I dunno, 80 characters?
> Might be a good reason to use a URL shortener.
>
usenet generally encourages us to set our word wrap at 72 to 73 
characters so there is room for the invitable additions of the quote > 
character so we can track who said what.  That is just common good 
practice.

> >> Business cards or other printed media need to be transcribed by
> >> hand. Dictation of URLs becomes virtually impossible when they're
> >> arbitrarily long.

OTOH, url's in excess of 250 characters long exist only to polish ego's 
of the people involved or demonstrate that they could not organize a 
company picnic in a 4 person company.

Few enough recognize that problem and post their urls on the form of 
 which most email agents recognize as a url, that before 
presentation to a browser when you click on it, will then go thru it, 
stripping out the line feeds and carriage returns so that the original 
as pasted and wrecked by the emailers word wrapping, is restored and it 
has at least a snowballs chance in hell of working.

But you can't teach a winderz user to do that any better than you can 
break them from top posting.

> > (You are not reading at all, are you?)  This is covered by that:
> >>> Instead, there *is* a need for *concise*, *semantic* URIs that Web
> >>> (service) users can *easily* *remember*.  It is the duty of the
> >>> original Web authors∕developers to make sure that there are, and I
> >>> think that no kind of automation is going to ease or replace
> >>> thoughtful path design anytime soon (but please, prove me wrong):
> >>
> >> Sure.. if you control the destination server. What if you're
> >> engaging in scholarly discussion about someone else's content? You
> >> can't change the canonical URLs, and you can't simply copy their
> >> content to your own server (either for licensing reasons or to
> >> guarantee that the official version hasn't been tampered with).
> >
> > That is why I said it is the duty of the original
> > authors/developers.  It is a community effort, and it is not 

Re: Case Statements

2016-03-15 Thread jj0gen0info
You have apparently mistaken me for someone who's worried.  I don't use Python, 
I was just curious as to why a construct that is found, not only to be useful 
in 95% of other languages, but is generally considered more flexible and 
readable than the if-elif, was missing in Python.  (your link "Switch Statement 
Code Smell" not withstanding)

Have a great day :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Case Statements

2016-03-15 Thread Mark Lawrence

On 16/03/2016 00:51, BartC wrote:

On 15/03/2016 23:47, jj0gen0i...@gmail.com wrote:


Thanks for the informative post.  I've read it and disagree with the
rational, it places Python in a decided minority of the major languages.


And this proposal (3103) was by the guy who invented the language!

Good thing he didn't have design-by-committee when he was putting it
together.



Did you miss or deliberately ignore my earlier:-


The "Rejection Notice" section of the former states "A quick poll during 
my keynote presentation at PyCon 2007 shows this proposal has no popular 
support. I therefore reject it.".



What do you not understand about "has no popular support", and this at 
the big Python annual event that is attended by numerous Python 
developers, including core developers, from all around the world?


--
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: Case Statements

2016-03-15 Thread BartC

On 15/03/2016 23:47, jj0gen0i...@gmail.com wrote:


Thanks for the informative post.  I've read it and disagree with the rational, 
it places Python in a decided minority of the major languages.


And this proposal (3103) was by the guy who invented the language!

Good thing he didn't have design-by-committee when he was putting it 
together.


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


Re: Descriptors vs Property

2016-03-15 Thread Thomas 'PointedEars' Lahn
Mark Lawrence wrote:

> Please ignore 'PointedEars',

Please ignore Mark Lawrence unless he has something on-topic to say.

How does that feel, Mark?

> every month or so for some weird reason

The reason being obviously that the people to whose postings I happen to 
post a follow-up to do not post using their real names.  It has nothing at 
all to do with timing.

> he complains about people not using their real names.  Why?  I've no idea,

I have told you already, but you did not listen.

-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: WP-A: A New URL Shortener

2016-03-15 Thread Thomas 'PointedEars' Lahn
Chris Angelico wrote:

> On Wed, Mar 16, 2016 at 10:38 AM, Thomas 'PointedEars' Lahn
>  wrote:
>> Chris Angelico wrote:
>>> On Wed, Mar 16, 2016 at 9:53 AM, Thomas 'PointedEars' Lahn
>>>  wrote:
 […] I cannot be sure because I have not thought this through, but with
>> ^^^
 aliases for common second-level domains, and with text compression, it
 should be possible to do this without a database.
>>>
>>> How? If you shorten URLs, you have to be able to reconstruct the long
>>> ones. Compression can't do that to arbitrary lengths. Somewhere there
>>> needs to be the rest of the information.
>>
>> First of all, you quoted me out of context.
> 
> I trimmed the context. You got a problem with that?

Please do not insult my intelligence.  I have a problem with that you are 
not marking the omission of considerable parts of *my* text, here giving the 
wrong impression that I did not start my follow-up in an encouraging way.
 
>> Second, do you even read what you reply to?  See the markings above.
> 
> Instead of thinking about URL shorteners specifically, think generally
> about information theory. You cannot, fundamentally, shorten all URLs
> arbitrarily. There just isn't enough room to store the information.

You are the one introducing “arbitrary” here.  I am not at all convinced, 
but this discussion is beyond the scope of this newsgroup/mailing list.
 
>> But speaking of length limits, the lines in your postings are too long,
>> according to Usenet convention.  I had to correct the quotations so that
>> they remained readable when word-wrapped.
> 
> Oh, so you'd rather the lines be cut to... I dunno, 80 characters?

No, quotations ought to be word-wrapped, preserving paragraphs, in order not 
to exceed that limit.  That is why the recommended line length limit for 
posting is not 80 characters, but something from 68 to 78.

> Might be a good reason to use a URL shortener.

URIs can posted to a newsgroup/mailing list without shortening them, by 
wrapping them without breaking them.  Will you *please* read [2] to clarify 
that misconception of yours?
 
-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue18320] python installation is broken if prefix is overridden on an install target

2016-03-15 Thread Ned Deily

Ned Deily added the comment:

Allowing prefix to be overridden after configure-time is certainly not the most 
critical shortcoming of the Python build system and it is possible someone is 
relying on that behavior.  Since no one, including me, seems very interested at 
this point in trying to change it, let's close this issue.

--
resolution:  -> wont fix
stage: needs patch -> resolved
status: open -> closed
versions: +Python 3.6 -Python 3.4

___
Python tracker 

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



Re: Encapsulation in Python

2016-03-15 Thread BartC

On 15/03/2016 21:02, Christian Gollwitzer wrote:

Am 14.03.16 um 23:40 schrieb BartC:

On 14/03/2016 22:20, Mark Lawrence wrote:
 > The RUE kept stating that he was an expert in unicode, but never once
 > provided a single shred of evidence to support his claim.  Until I see
 > substantiated evidence from you I am going to state quite cleary that
 > you've no idea, you're just another RUE.

Sorry, I'm not going to do that, and I don't expect anyone here to have
to do so either. You will have to take my posts as they are.


I don't think that you make things up, your posts are much too detailed
and plausible to be made up. Nevertheless, why don't you setup a
repository on an open source server, say github, and post your language
implementation there? Actually I would try it out to see how it compares
to other dynamic languages, especially since you do not use JIT
compilation to native code, but still claim that you get good
performance. You will also profit (in the form of bug reports) if
somebody actually tries your code.


OK, I'll see what I can do. In the meantime I've put together some notes 
about how my system works, and you can probably see that it's not so 
easy! (Because I use custom languages with circular dependencies...)


But there's some info there that may or may not be of interest:

http://pastebin.com/MsGLsC23

(And I assume everyone here uses Linux? That's another minor problem...)

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


Re: WP-A: A New URL Shortener

2016-03-15 Thread Chris Angelico
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.
>
> I've no idea if other such projects already exist, it just occurred to me
> when responding.

Now THAT is an interesting idea. I don't know how it would be handled,
though; since there has to be additional information that isn't in the
URL, and has to *not* be on any server that can go down, it basically
has to be a distributed thing somehow. So you'd need to look into how
things like Bitcoin work. It'd be pretty cool if it could work!

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


Re: WP-A: A New URL Shortener

2016-03-15 Thread Erik

Hi Chris,

On 15/03/16 23:48, Chris Angelico wrote:

I agree, it's a risk. Any indirection adds that. So the benefit has to
be weighed against this inherent cost.


True, so it's not URL shorteners that I disagree with on principle, it's 
the _inappropriate_ use of URL shorteners ;) If one uses them on fora 
such as this which could be expected to exist for some considerable time 
then it's an issue. Elsewhere, then yes, the linking service may not 
last as long as the shortening service ...



 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.


I've no idea if other such projects already exist, it just occurred to 
me when responding.


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


Re: WP-A: A New URL Shortener

2016-03-15 Thread Thomas 'PointedEars' Lahn
Rick Johnson wrote:

> On Tuesday, March 15, 2016 at 5:54:46 PM UTC-5, Thomas 'PointedEars' Lahn
> wrote:
>> Vinicius Mesel wrote:
>> > I'm a 16 year old Python Programmer that wanted to do
>> > something different. But, like we know, ideas are quite
>> > difficult to find. So I decided to develop a URL
>> > Shortener to help the Python community out and share my
>> > coding knowledge, and today the project was launched
>> > with its first stable version.
> 
> Although Thomas makes some very valid points, don't let
> anybody discourage you Vinicius. If you want to build
> something, and everyone in the *ENTIRE* world say's it's a bad
> idea, do it anyway -- if for nothing else than to spite
> them. :-P

You are giving bad advice to a junior developer, advising them to *waste* 
*their* *youth* developing for the recycle bin.  It can no doubt be 
educational to play with programming.  But if actually the *entire* world 
says a it is a bad idea, then it probably is.  Unfortunately, there is 
prevailing the common misconception of the misunderstood genius, and that a 
real genius would sink so low as to do things just in order to prove 
everybody wrong.  But to do so is not genial, it is outright stupid.  
Because what if it does not work out in the end?

Instead, they should find out what problems people have, and what kind of 
software people *really* and *desperately* *need* to solve them, and *then* 
go for it no matter what other people who are not in need say.  Often the 
people that desperately need something solved are close; in fact, it is very 
likely that the first person that really needs something solved is oneself.

For example, what really got me into programming was that I was tired of 
typing commands to run my favorite DOS games, so I learned batch file 
programming to write myself a menu to start them if they were in the paths 
where I expected them to be.  Being limited by the shortcomings of that 
language, I learned Turbo Pascal to search for the games, and in doing that 
I learned a lot of other things that I had never thought of before (like 
creating GUIs, and mouse pointers with embedded Assembler code, and OOP).  
And so on, eventually to Python (IIRC, the second-last programming language 
that I learned).

Want a more prominent example?  Linus Torvalds wrote a kernel for an 
operating system because, although it started his fascination for operating 
systems, MINIX did not suffice for *him*; only later he announced *on 
Usenet* (comp.os.minix) what would become the Linux kernel, and look what 
arose from that.  Because the people he announced it to thought, “Hey, that 
could be really *useful*!”.
 
-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Missing something about timezones

2016-03-15 Thread Peter Pearson
On Mon, 14 Mar 2016 10:19:23 -0500, Skip Montanaro wrote:
> Is this correct (today, with Daylight Savings in effect)?
>
 import pytz
 i.timezone
> 'America/Chicago'
 pytz.timezone(i.timezone)
>
 ot
> datetime.datetime(2016, 3, 14, 9, 30, tzinfo= 'America/New_York' EDT-1 day, 20:00:00 DST>)
 ot.tzinfo
>


I've stubbed my toe many times on timezones and DST.  Here are
some notes I've accumulated:

 * datetime.datetime(..., tzinfo=tz) doesn't work right for timezones
   that involve daylight-saving time, but nobody gets around to fixing
   it because it's written in C; and

 * knowing this, the creators of pytz thoughtfully furnished a
   workaround, in the form of the "localize" method of a pytz.timezone
   object:

>>> loc_dt = eastern.localize(datetime(2002, 10, 27, 6, 0, 0)) 
>>> print(loc_dt.strftime(fmt))
2002-10-27 06:00:00 EST-0500


$ cat temp2.py
from datetime import datetime
from pytz import timezone

print(str(datetime(2015, 1, 31, 12, tzinfo=timezone("US/Pacific"
print(str(datetime(2015, 7, 31, 12, tzinfo=timezone("US/Pacific"

print(str(timezone("US/Pacific").localize(datetime(2015, 1, 31, 12
print(str(timezone("US/Pacific").localize(datetime(2015, 7, 31, 12

$ python temp2.py
2015-01-31 12:00:00-08:00
2015-07-31 12:00:00-08:00 <- wrong
2015-01-31 12:00:00-08:00
2015-07-31 12:00:00-07:00 <- right
$

Good luck!

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


Re: Case Statements

2016-03-15 Thread Mark Lawrence

On 15/03/2016 23:47, jj0gen0i...@gmail.com wrote:


Thanks for the informative post.  I've read it and disagree with the rational, 
it places Python in a decided minority of the major languages.

https://en.wikipedia.org/wiki/Conditional_(computer_programming)#Case_and_switch_statements

See section "Choice system cross reference"

Thanks again for the reply

JJ



If the Python core developers have decided it isn't needed, as perhaps 
explained in my link about the "Switch Statement Code Smell", why worry 
about it?


If you really think you need one start here 
http://code.activestate.com/recipes/269708-some-python-style-switches/


--
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: WP-A: A New URL Shortener

2016-03-15 Thread Chris Angelico
On Wed, Mar 16, 2016 at 10:38 AM, Thomas 'PointedEars' Lahn
 wrote:
> Chris Angelico wrote:
>
>> On Wed, Mar 16, 2016 at 9:53 AM, Thomas 'PointedEars' Lahn
>>  wrote:
>
>>> […] I cannot be sure because I have not thought this through, but with
> ^^^
>>> aliases for common second-level domains, and with text compression, it
>>> should be possible to do this without a database.
>>
>> How? If you shorten URLs, you have to be able to reconstruct the long
>> ones. Compression can't do that to arbitrary lengths. Somewhere there
>> needs to be the rest of the information.
>
> First of all, you quoted me out of context.

I trimmed the context. You got a problem with that?

> Second, do you even read what you reply to?  See the markings above.

Instead of thinking about URL shorteners specifically, think generally
about information theory. You cannot, fundamentally, shorten all URLs
arbitrarily. There just isn't enough room to store the information.

> And as for second-level domains, consider for example “t.c” instead of
> “twitter.com” as part of the short URI.

That'll work only for the ones that you code in specifically, and
that's only shortening your URL by 8 characters. A typical URL needing
shortening is over 80 characters - maybe several hundred. You need to
cut that down to a manageable length. That fundamentally cannot be
reversed without readding information.

>>> And with the exception of Twitter-ish sites that place a limit on message
>>> length, there really is *no need* for shorter URIs nowadays.  (HTTP)
>>> clients and servers are capable of processing really long ones [1];
>>> electronic communications media and related software, too [2].  And data
>>> storage space as well as data transmission has become exceptionally
>>> inexpensive.  A few less bytes there do not count.
>>
>> There are many places where there are limits (hard or soft) on message
>> lengths. Some of us still use MUDs and 80-character line limits.
>
> See above.  Covered by [2].

Unrelated. Not covered by that link. Go use a MUD some time.

> But speaking of length limits, the lines in your postings are too long,
> according to Usenet convention.  I had to correct the quotations so that
> they remained readable when word-wrapped.

Oh, so you'd rather the lines be cut to... I dunno, 80 characters?
Might be a good reason to use a URL shortener.

>> Business cards or other printed media need to be transcribed by hand.
>> Dictation of URLs becomes virtually impossible when they're
>> arbitrarily long.
>
> (You are not reading at all, are you?)  This is covered by that:
>
>>> Instead, there *is* a need for *concise*, *semantic* URIs that Web
>>> (service) users can *easily* *remember*.  It is the duty of the original
>>> Web authors∕developers to make sure that there are, and I think that no
>>> kind of automation is going to ease or replace thoughtful path design
>>> anytime soon (but please, prove me wrong):
>>
>> Sure.. if you control the destination server. What if you're
>> engaging in scholarly discussion about someone else's content? You
>> can't change the canonical URLs, and you can't simply copy their
>> content to your own server (either for licensing reasons or to
>> guarantee that the official version hasn't been tampered with).
>
> That is why I said it is the duty of the original authors/developers.  It is
> a community effort, and it is not going to happen overnight.  But evading
> the problem with unreliable replacements such as “short URLs” is not going
> to solve it either.

So, you can go fight an unwinnable battle against literally every web
creator in the world. Meanwhile, I'll keep on using URL shorteners.

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


Re: WP-A: A New URL Shortener

2016-03-15 Thread Chris Angelico
On Wed, Mar 16, 2016 at 10:40 AM, Erik  wrote:
> Hi Chris,
>
> On 15/03/16 23:16, Chris Angelico wrote:
>>
>> So URL shorteners are invaluable tools.
>
>
> Perhaps, and in the specific - transient - use-cases you describe that's
> fine. The problem I have with them is that they are a level of indirection
> controlled by a third party. If the source (let's say this list) has a
> message containing a link to something on the target which is still
> available via a "shortened" URL, then if the shortening service goes
> offline, the link is dead. Even though the target is still there.
>
> People complain about the use of pastebin in this list for showing code
> fragments. It's the same thing - one URL shortening (indirection) service
> goes offline and a ton of links are suddenly silenced. It's like a
> disturbance in the force ;)

I agree, it's a risk. Any indirection adds that. So the benefit has to
be weighed against this inherent cost.

> FWIW, I also have an issue with services that convert your ASCII text into
> unicode such that the resulting glyphs are still things a human reader will
> understand as substitutes for the original text but which can't be easily
> searched/grepped.

Oh, I totally agree. Your text should be your text.

>> However, I'm not sure what
>> this one is that others aren't.
>
>
> Vinicius didn't say his code was anything different.
>
> He said he _WANTED_ to do something different _BUT_ realised ideas are hard
> to come by, _SO_ he developed some URL-shortening software and then shared
> it.

Yeah, but there's usually _something_ different :)

> I see it as a learning exercise on his part, and that's great.

Absolutely. As such, it's excellent. I often like to make a small
change when I reimplement, though - something that I thought was
ill-designed in the original, or maybe just a simple thing of
integration somewhere (eg a little text editor embedded in a larger
program).

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


[issue26562] Large Involuntary context switches during oom-killer

2016-03-15 Thread Damian Myerscough

Damian Myerscough added the comment:

Thanks for the feedback, I will continue to dig into this. 

I know processes go crazy sometimes when OOM killer kicks off, I just wanted to 
rule out a Python bug or if anyone in the community has seen this before.

Thanks

--

___
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-15 Thread jj0gen0info

Thanks for the informative post.  I've read it and disagree with the rational, 
it places Python in a decided minority of the major languages.

https://en.wikipedia.org/wiki/Conditional_(computer_programming)#Case_and_switch_statements

See section "Choice system cross reference"

Thanks again for the reply

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


Re: WP-A: A New URL Shortener

2016-03-15 Thread Erik

Hi Chris,

On 15/03/16 23:16, Chris Angelico wrote:

So URL shorteners are invaluable tools.


Perhaps, and in the specific - transient - use-cases you describe that's 
fine. The problem I have with them is that they are a level of 
indirection controlled by a third party. If the source (let's say this 
list) has a message containing a link to something on the target which 
is still available via a "shortened" URL, then if the shortening service 
goes offline, the link is dead. Even though the target is still there.


People complain about the use of pastebin in this list for showing code 
fragments. It's the same thing - one URL shortening (indirection) 
service goes offline and a ton of links are suddenly silenced. It's like 
a disturbance in the force ;)


FWIW, I also have an issue with services that convert your ASCII text 
into unicode such that the resulting glyphs are still things a human 
reader will understand as substitutes for the original text but which 
can't be easily searched/grepped.


All for saving a byte or two.


However, I'm not sure what
this one is that others aren't.


Vinicius didn't say his code was anything different.

He said he _WANTED_ to do something different _BUT_ realised ideas are 
hard to come by, _SO_ he developed some URL-shortening software and then 
shared it.


I see it as a learning exercise on his part, and that's great.

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


Re: WP-A: A New URL Shortener

2016-03-15 Thread Thomas 'PointedEars' Lahn
Chris Angelico wrote:

> On Wed, Mar 16, 2016 at 9:53 AM, Thomas 'PointedEars' Lahn
>  wrote:

Attribution *line*, _not_ attribution novel.

>> […] I cannot be sure because I have not thought this through, but with
^^^
>> aliases for common second-level domains, and with text compression, it
>> should be possible to do this without a database.
> 
> How? If you shorten URLs, you have to be able to reconstruct the long
> ones. Compression can't do that to arbitrary lengths. Somewhere there
> needs to be the rest of the information.

First of all, you quoted me out of context.  Please do not do that again.

Second, do you even read what you reply to?  See the markings above.

And as for second-level domains, consider for example “t.c” instead of 
“twitter.com” as part of the short URI.
 
>> And with the exception of Twitter-ish sites that place a limit on message
>> length, there really is *no need* for shorter URIs nowadays.  (HTTP)
>> clients and servers are capable of processing really long ones [1];
>> electronic communications media and related software, too [2].  And data
>> storage space as well as data transmission has become exceptionally
>> inexpensive.  A few less bytes there do not count.
> 
> There are many places where there are limits (hard or soft) on message
> lengths. Some of us still use MUDs and 80-character line limits.

See above.  Covered by [2].

But speaking of length limits, the lines in your postings are too long, 
according to Usenet convention.  I had to correct the quotations so that 
they remained readable when word-wrapped.

> Business cards or other printed media need to be transcribed by hand.
> Dictation of URLs becomes virtually impossible when they're
> arbitrarily long.

(You are not reading at all, are you?)  This is covered by that:
 
>> Instead, there *is* a need for *concise*, *semantic* URIs that Web
>> (service) users can *easily* *remember*.  It is the duty of the original
>> Web authors∕developers to make sure that there are, and I think that no
>> kind of automation is going to ease or replace thoughtful path design
>> anytime soon (but please, prove me wrong):
> 
> Sure.. if you control the destination server. What if you're
> engaging in scholarly discussion about someone else's content? You
> can't change the canonical URLs, and you can't simply copy their
> content to your own server (either for licensing reasons or to
> guarantee that the official version hasn't been tampered with).

That is why I said it is the duty of the original authors/developers.  It is 
a community effort, and it is not going to happen overnight.  But evading 
the problem with unreliable replacements such as “short URLs” is not going 
to solve it either.
 
> So URL shorteners are invaluable tools.

IBTD.

-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: WP-A: A New URL Shortener

2016-03-15 Thread Rick Johnson
On Tuesday, March 15, 2016 at 5:54:46 PM UTC-5, Thomas 'PointedEars' Lahn wrote:
> Vinicius Mesel wrote:
> > I'm a 16 year old Python Programmer that wanted to do
> > something different. But, like we know, ideas are quite
> > difficult to find. So I decided to develop a URL
> > Shortener to help the Python community out and share my
> > coding knowledge, and today the project was launched
> > with its first stable version.

Although Thomas makes some very valid points, don't let
anybody discourage you Vinicius. If you want to build
something, and everyone in the *ENTIRE* world say's it's a bad
idea, do it anyway -- if for nothing else than to spite
them. :-P

> While I commend your efforts, I think that you should have
> chosen another topic for your project.  It is also hard
> for me to see in which way this is "something different" -
> are there not enough "URL Shorteners" already? -, and how
> a "URL Shortener" could "help the Python community out".

How many Python URL trimmers are there anyway? If none
exist, then he could claim the "i was the first" prize. If
others already exist, no harm, perhaps his implementation
utilizes a unique method of creating these small URLs that
could be a valuable teaching tool. And even if none of these
apply, his contribution is most welcome -- this is an open
community after all.

> Because I think that "URL Shorteners" are a bad idea in
> the first place: One never knows for how long a time a
> "short URL" works, who is listening in the middle, and
> what they are referring to, until one uses them at which
> point it is too late.  If a "short URL" expires, there is
> *no way* to retrieve the referred content; when a *real*
> URI breaks, there are services like the Internet Archive
> and the Google cache to help one out.  So when I see a
> "short URL", I tend not to use it.

I'll have to agree with Thomas here. I avoid them like the
plague for the same reasons. But don't be discouraged by
this, Vinicius, many people use them. Thankfully, not
everyone is as paranoid as Thomas and myself. :-)



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


[issue18320] python installation is broken if prefix is overridden on an install target

2016-03-15 Thread Mark Lawrence

Changes by Mark Lawrence :


--
nosy:  -BreamoreBoy

___
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-15 Thread Chris Angelico
On Wed, Mar 16, 2016 at 9:53 AM, Thomas 'PointedEars' Lahn
 wrote:
> Vinicius Mesel wrote:
>
>> I'm a 16 year old Python Programmer that wanted to do something different.
>> But, like we know, ideas are quite difficult to find.
>> So I decided to develop a URL Shortener to help the Python community out
>> and share my coding knowledge, and today the project was launched with its
>> first stable version. So if you want to see the software working, go check
>> it out at: http://wp-a.co/ Or if you want to see the source code to
>> contribute and help the project: https://github.com/vmesel/WP-A.CO
>
> I find it particularly disturbing that in wpa.py:processaURL() your software
> apparently stores the original URIs in an SQL database; in the case of your
> proof-of-concept, in *your* database.  So *you* are listening in the middle
> then.  I cannot be sure because I have not thought this through, but with
> aliases for common second-level domains, and with text compression, it
> should be possible to do this without a database.

How? If you shorten URLs, you have to be able to reconstruct the long
ones. Compression can't do that to arbitrary lengths. Somewhere there
needs to be the rest of the information.

> And with the exception of Twitter-ish sites that place a limit on message
> length, there really is *no need* for shorter URIs nowadays.  (HTTP) clients
> and servers are capable of processing really long ones [1]; electronic
> communications media and related software, too [2].  And data storage space
> as well as data transmission has become exceptionally inexpensive.  A few
> less bytes there do not count.

There are many places where there are limits (hard or soft) on message
lengths. Some of us still use MUDs and 80-character line limits.
Business cards or other printed media need to be transcribed by hand.
Dictation of URLs becomes virtually impossible when they're
arbitrarily long.

> Instead, there *is* a need for *concise*, *semantic* URIs that Web (service)
> users can *easily* *remember*.  It is the duty of the original Web
> authors∕developers to make sure that there are, and I think that no kind of
> automation is going to ease or replace thoughtful path design anytime soon
> (but please, prove me wrong):

Sure.. if you control the destination server. What if you're
engaging in scholarly discussion about someone else's content? You
can't change the canonical URLs, and you can't simply copy their
content to your own server (either for licensing reasons or to
guarantee that the official version hasn't been tampered with).

So URL shorteners are invaluable tools. However, I'm not sure what
this one is that others aren't.

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


Re: WP-A: A New URL Shortener

2016-03-15 Thread Erik

On 15/03/16 22:53, Thomas 'PointedEars' Lahn wrote:

A few
less bytes there do not count.


You mean "Fewer bytes there do not count".

E.

(But on the whole, yes, I do agree with your position in this instance.
Kudos to Vinicius for doing something productive with his time though - 
I'm sure a lot has been learned in putting that together).

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


Re: Case Statements

2016-03-15 Thread Mark Lawrence

On 15/03/2016 20:46, jj0gen0i...@gmail.com wrote:

Given that "Case Statements" are more compact and less redundant than a 
sequence of if-elif statements, and usually can contain embedded match lists:
Is there any chance future versions of Python will adopt a case structure?

Something like

select x
case in [1,2,3,5,7,9]
print 
case in [4,6,8]
print 
case else
print 

Just a thought.

JJ



Been suggested and rejected via 
https://www.python.org/dev/peps/pep-3103/ and 
https://www.python.org/dev/peps/pep-0275/.  The "Rejection Notice" 
section of the former states "A quick poll during my keynote 
presentation at PyCon 2007 shows this proposal has no popular support. I 
therefore reject it.".


See also http://c2.com/cgi/wiki?SwitchStatementsSmell

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


[issue25597] unittest.mock does not wrap dunder methods (__getitem__ etc)

2016-03-15 Thread Robert Collins

Robert Collins added the comment:

I think this is a valid mock bug; it likely needs some thoughtful exhaustive 
testing, and obviously support added for it.

--
stage:  -> test needed
title: unittest.mock does not wrap dict objects correctly -> unittest.mock does 
not wrap dunder methods (__getitem__ etc)

___
Python tracker 

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



[issue25894] unittest subTest failure causes result to be omitted from listing

2016-03-15 Thread Robert Collins

Robert Collins added the comment:

The basic model is this:
 - a test can have a single outcome [yes, the api is ambiguous, but there it is]
 - subtests let you identify multiple variations of a single test (note the id 
tweak etc) and *may* be reported differently

We certainly must not report the test as a whole passing if any subtest did not 
pass.

Long term I want to remove the error/failure partitioning of exceptions; its 
not actually useful.

The summary for the test, when subtests are used, should probably enumerate the 
states.

test_foo (3 passed, 2 skipped, 1 failure)

in much the same way the run as a whole is enumerated.

--

___
Python tracker 

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



[issue26295] Random failures when running test suite in parallel (-m test -j0) caused by test_regrtest

2016-03-15 Thread STINNER Victor

STINNER Victor added the comment:

Hum, test_doctest, test_zipfile and test_pyclbr fail if test is converted to a 
package (if Lib/test/__init__.py is removed).

Attached patch fixes test_zipfile.

I created the issue #26569 for test_pyclbr failure.

--
Added file: http://bugs.python.org/file42177/test_regrtest_tmpdir-2.patch

___
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() doens't support packages

2016-03-15 Thread STINNER Victor

New submission from STINNER Victor:

While working on the issue #26295 which converts the test module to a package, 
I noticed that pyclbr doesn't work with packages: test_pyclbr fails when test 
becomes a package.

Attached patch fixes pyclbr._readmodule():

* Replace "spec.loader.is_package(fullmodule)" test with 
"spec.submodule_search_locations is not None" to check is the module is a 
package
* for a package, use spec.submodule_search_locations to build __path__

I don't know importlib well enough to say if my usage of importlib spec is 
correct.

--
files: pyclbr.patch
keywords: patch
messages: 261832
nosy: brett.cannon, haypo
priority: normal
severity: normal
status: open
title: pyclbr.readmodule() and pyclbr.readmodule_ex() doens't support packages
versions: Python 3.6
Added file: http://bugs.python.org/file42176/pyclbr.patch

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

2016-03-15 Thread STINNER Victor

Changes by STINNER Victor :


--
title: pyclbr.readmodule() and pyclbr.readmodule_ex() doens't support packages 
-> pyclbr.readmodule() and pyclbr.readmodule_ex() don't support packages

___
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-15 Thread Thomas 'PointedEars' Lahn
Vinicius Mesel wrote:

> I'm a 16 year old Python Programmer that wanted to do something different.
> But, like we know, ideas are quite difficult to find.
> So I decided to develop a URL Shortener to help the Python community out
> and share my coding knowledge, and today the project was launched with its
> first stable version. So if you want to see the software working, go check
> it out at: http://wp-a.co/ Or if you want to see the source code to
> contribute and help the project: https://github.com/vmesel/WP-A.CO

While I commend your efforts, I think that you should have chosen another 
topic for your project.  It is also hard for me to see in which way this is 
“something different” – are there not enough “URL Shorteners” already? –, 
and how a “URL Shortener” could “help the Python community out”.

Because I think that “URL Shorteners” are a bad idea in the first place: One 
never knows for how long a time a “short URL” works, who is listening in the 
middle, and what they are referring to, until one uses them at which point 
it is too late.  If a “short URL” expires, there is *no way* to retrieve the 
referred content; when a *real* URI breaks, there are services like the 
Internet Archive and the Google cache to help one out.  So when I see a 
“short URL”, I tend not to use it.

I find it particularly disturbing that in wpa.py:processaURL() your software 
apparently stores the original URIs in an SQL database; in the case of your 
proof-of-concept, in *your* database.  So *you* are listening in the middle 
then.  I cannot be sure because I have not thought this through, but with 
aliases for common second-level domains, and with text compression, it 
should be possible to do this without a database.

So sorry, because of that already, I will certainly not use or recommend 
your service.  “Leave others the privacies of their minds and lives. 
Intimacy remains precious only insofar as it is inviolate.” ─Surak

And with the exception of Twitter-ish sites that place a limit on message 
length, there really is *no need* for shorter URIs nowadays.  (HTTP) clients 
and servers are capable of processing really long ones [1]; electronic 
communications media and related software, too [2].  And data storage space 
as well as data transmission has become exceptionally inexpensive.  A few 
less bytes there do not count.

Instead, there *is* a need for *concise*, *semantic* URIs that Web (service) 
users can *easily* *remember*.  It is the duty of the original Web 
authors∕developers to make sure that there are, and I think that no kind of 
automation is going to ease or replace thoughtful path design anytime soon 
(but please, prove me wrong):



__
[1] 
[2] 
-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2016-03-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 769dfcb701ee by Victor Stinner in branch 'default':
Issue #26564: Fix test_capi
https://hg.python.org/cpython/rev/769dfcb701ee

--

___
Python tracker 

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



[issue26538] regrtest: setup_tests() must not replace module.__path__ (_NamespacePath) with a simple list // importlib & abspath

2016-03-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 96b73b649b15 by Victor Stinner in branch 'default':
regrtest: Fix module.__path__
https://hg.python.org/cpython/rev/96b73b649b15

--
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: Obfuscating Python code

2016-03-15 Thread Thomas 'PointedEars' Lahn
Chris Angelico wrote:

> On Wed, Mar 16, 2016 at 5:59 AM, Thomas 'PointedEars' Lahn
>  wrote:
>> That said, not distributing the source code of a program as well (or at
>> least making it available to users in some way) strikes me as unpythonic
>> since Python is at least Open Source software, and Python 2.0.1, 2.1.1
>> and newer are GPL-compatible Free Software.
> 
> gcc is also free software. Does that mean that all C programs should
> be free software? No.

IMNSHO, yes.  At the very least because in using gcc you benefited from the 
free software community, so you should give back to the free software 
community accordingly.

> However, since all software can be reverse-compiled (particularly

You mean _decompiled_.

> byte-code like .pyc files),

Yes, it is easier with bytecode *if you know the VM*.

> the only truly reliable way to make completely closed software is to 
> restrict access to it in all forms.

ACK.

> In today's world, that usually means providing it as a web service.

ACK.  That’s why RMS calls it SaaSS, Service as a Software Substitute :)

> Otherwise, you have to assume that anyone can see your source. The
> only difference between open-source and closed-source is the license,
> not the ability to see stuff.

If that were the case and reverse engineering were an easy task that 
everyone could do, we would have a lot more free software variants of 
proprietary software.  Particularly, we would have a lot less proprietary 
device drivers.  ISTM that you do not know what you are talking about here.

-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2016-03-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 8215dae7ec3c by Victor Stinner in branch 'default':
Oops, revert unwanted change used to create an example
https://hg.python.org/cpython/rev/8215dae7ec3c

--

___
Python tracker 

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



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

2016-03-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset cef6a32d805f by Victor Stinner in branch 'default':
On memory error, dump the memory block traceback
https://hg.python.org/cpython/rev/cef6a32d805f

--

___
Python tracker 

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



Re: Encapsulation in Python

2016-03-15 Thread Christian Gollwitzer

Am 14.03.16 um 23:40 schrieb BartC:

On 14/03/2016 22:20, Mark Lawrence wrote:
 > The RUE kept stating that he was an expert in unicode, but never once
 > provided a single shred of evidence to support his claim.  Until I see
 > substantiated evidence from you I am going to state quite cleary that
 > you've no idea, you're just another RUE.

Sorry, I'm not going to do that, and I don't expect anyone here to have
to do so either. You will have to take my posts as they are.


I don't think that you make things up, your posts are much too detailed 
and plausible to be made up. Nevertheless, why don't you setup a 
repository on an open source server, say github, and post your language 
implementation there? Actually I would try it out to see how it compares 
to other dynamic languages, especially since you do not use JIT 
compilation to native code, but still claim that you get good 
performance. You will also profit (in the form of bug reports) if 
somebody actually tries your code.


Christian


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


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

2016-03-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 18a19e62bac5 by Victor Stinner in branch 'default':
Enhance and rewrite traceback dump C functions
https://hg.python.org/cpython/rev/18a19e62bac5

New changeset fea3c6e9a38e by Victor Stinner in branch '3.5':
_tracemalloc: store lineno as unsigned int
https://hg.python.org/cpython/rev/fea3c6e9a38e

--
nosy: +python-dev

___
Python tracker 

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



WP-A: A New URL Shortener

2016-03-15 Thread Vinicius Mesel
Hey guys,

I'm a 16 year old Python Programmer that wanted to do something different.
But, like we know, ideas are quite difficult to find.
So I decided to develop a URL Shortener to help the Python community out and 
share my coding knowledge, and today the project was launched with its first 
stable version.
So if you want to see the software working, go check it out at: http://wp-a.co/
Or if you want to see the source code to contribute and help the project: 
https://github.com/vmesel/WP-A.CO


Hugs,
Vinicius Mesel
Brazilian and Portuguese Speaker
http://www.vmesel.com



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


Case Statements

2016-03-15 Thread jj0gen0info
Given that "Case Statements" are more compact and less redundant than a 
sequence of if-elif statements, and usually can contain embedded match lists:
Is there any chance future versions of Python will adopt a case structure?

Something like

select x
   case in [1,2,3,5,7,9]
   print 
   case in [4,6,8]
   print 
   case else
   print 

Just a thought.

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


[issue18320] python installation is broken if prefix is overridden on an install target

2016-03-15 Thread Martin Panter

Martin Panter added the comment:

I agree with Martin v. Löwis that this is not a real bug. Cosmicduck doesn’t 
seem aware of the “configure --prefix=. . .” option, but I don’t think it is 
right to add hacks to the makefile to prevent overriding variables.

--
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: Obfuscating Python code

2016-03-15 Thread Chris Angelico
On Wed, Mar 16, 2016 at 5:59 AM, Thomas 'PointedEars' Lahn
 wrote:
> That said, not distributing the source code of a program as well (or at
> least making it available to users in some way) strikes me as unpythonic
> since Python is at least Open Source software, and Python 2.0.1, 2.1.1 and
> newer are GPL-compatible Free Software.

gcc is also free software. Does that mean that all C programs should
be free software? No.

However, since all software can be reverse-compiled (particularly
byte-code like .pyc files), the only truly reliable way to make
completely closed software is to restrict access to it in all forms.
In today's world, that usually means providing it as a web service.
Otherwise, you have to assume that anyone can see your source. The
only difference between open-source and closed-source is the license,
not the ability to see stuff.

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


[issue22359] Remove incorrect uses of recursive make

2016-03-15 Thread Xavier de Gaye

Xavier de Gaye added the comment:

> But I am a bit worried at the new makefile syntax [ifeq directive and 
> $(findstring) function]. I suspect it is Gnu specific, and that Python tries 
> to support other versions of Make as well.

Yes, they are both GNU extensions :(

To avoid modifying configure.ac since the information is already available, the 
recipes could be modified with the following conditional:

cross_compiling=$$(echo $(PYTHON_FOR_BUILD) | sed 
"s/.*_PYTHON_HOST_PLATFORM.*/yes/"); \
if [ "$$cross_compiling" = "yes" ]; then \
  touch $@;
else \
  # The original recipes.
fi

So the built binaries $(PGEN) and Programs/_freeze_importlib would be dummy 
empty files, but that would not prevent Programs/_freeze_importlib.o, 
$(LIBRARY_OBJS_OMIT_FROZEN) and $(PGENOBJS) to be needlessly cross-compiled.

--

___
Python tracker 

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



Re: Different sources of file

2016-03-15 Thread Wildman via Python-list
On Mon, 14 Mar 2016 20:56:44 +, Val Krem wrote:

> #!/usr/bin/python

On some Linux systems python is installed in /usr/local/bin.
I would suggest using the hash-bang below.  It will insure
python will run no matter where it was installed.

#!/usr/bin/env python

-- 
 GNU/Linux user #557453
May the Source be with you.
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2016-03-15 Thread STINNER Victor

STINNER Victor added the comment:

I'm not sure about the method names showmsg() and formatmsg().

Maybe: showwarnmsg() and formatwarnmsg()?

First I used warnings.show() and warnings.format(), but "format()" is already 
the name of a builtin function.

By the way, I would prefer to use underscore between names, like show_msg() or 
show_warn_msg(). But I don't know if it's ok to use a different naming scheme 
in an existing module :-/

--

___
Python tracker 

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



[issue24263] unittest cannot load module whose name starts with Unicode

2016-03-15 Thread Robert Collins

Robert Collins added the comment:

sih4sing5hong5  - I think we do need a test in fact - it can be done using 
mocks, but right now I think the patch has a bug - it looks for isidentifier on 
$thing.py, but not on just $thing (which we need to do to handle packages, vs 
modules).

--

___
Python tracker 

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



Re: OTish Wells Fargo sucks

2016-03-15 Thread Rick Johnson
On Tuesday, March 15, 2016 at 1:23:58 PM UTC-5, MRAB wrote:
> Failure is not inevitable.

Inevitable? No. 

Highly probable? Yes.

(This message sponsored by: The Magic Eight Ball)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OTish Wells Fargo sucks

2016-03-15 Thread Rick Johnson
On Tuesday, March 15, 2016 at 9:38:16 AM UTC-5, Grant Edwards wrote:
> How difficult a web site is to use is proportional to the
> size of organization that owns it and how much money they
> spent developing it.

I would also add: "The quality of the engineers who design
and implement it". This is actually the most import part!
You can't just throw money at a project and assume it's
quality will increase proportionally. Money creates more
problems than it solves.

> That's also why the national health insurance marketplace
> web site was such a debacle.

The "debacle", or "evil", existed long before the
marketplace did, and it goes by the name of "Politics".
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Obfuscating Python code

2016-03-15 Thread Thomas 'PointedEars' Lahn
Ben Finney wrote:

> Swanand Pashankar  writes:
>> Embedding a Python file in C code works, but it exposes your Python
>> script. Didn't find any free fool-proof way to obfuscate Python code
>> either.
> 
> What exactly is it you want to prevent? Why do you think obfuscating the
> code will achieve that?

On a more constructive note, python(1) (CPython) creates a binary (byte-
code) “.pyc” file from “.py” files when it runs them.  ISTM that you can 
then run the “.pyc” file as if it were the “.py” file (if the “.pyc” file is 
given the executable flag, you can even execute it as a standalone command, 
but that might only work on my system).  So apparently you do not have to 
distribute the source code of a program written in Python if you do not want 
to.

If you want to distribute the “.pyc” file (perhaps under another name), then 
the “-O” and “-OO” optimization switches for python(1) could come in handy 
(see “python --help”).  [It is then perhaps not a coincidence that “-O” is 
documented to change the filename suffix from “.pyc” to “.pyo”; cf. “.so”]

(The Python manual should have more on this, I have not checked.)

That said, not distributing the source code of a program as well (or at 
least making it available to users in some way) strikes me as unpythonic 
since Python is at least Open Source software, and Python 2.0.1, 2.1.1 and 
newer are GPL-compatible Free Software.




-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-15 Thread BartC

On 15/03/2016 14:58, BartC wrote:

On 15/03/2016 11:52, BartC wrote:

On 15/03/2016 01:55, Steven D'Aprano wrote:



switch obj:
 case "Hello", None: ...
 case [1, 2, 3]: ...
 case 23.01, 15+2j, Fraction(10, 11): ...
 case 100**100, {}: ...


and more. This is not negotiable: having a switch statement limited to
small
ints is simply not an option.


Not a problem: http://pastebin.com/qdQintSZ


The solution I posted tested the values one after another. I was
interested in whether it was that much faster than if-elif in CPython 3,



data=["Hello",None,[1,2,3],23.01,15+2j,Fraction(10,11),100**100,{},12345]



> ... so something is slowing down the Python in this test

The culprit here was Fraction. Whatever Fraction does, it's slow! And 
when removed from the test expressions, it was still in the data list.


Replacing Fraction with a dummy class gave a more reasonable timing of 
1.5 seconds (compared with 0.17s for the external language using 
'general' switch, and 0.28s when it also uses an if-else chain).


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


Re: Python Advanced Help

2016-03-15 Thread Thomas 'PointedEars' Lahn
Luke Charlton wrote:

> Okay, So basically I created a python script around 1 year ago to grab an
> explain_plan from a Greenplum system (Normal SQL) and change it around and
> explain each step/section, the thing is, I've came back to the python code
> and I don't understand anything of what it's doing (the code
> specifically).

OK, so, basically, RTFM and STFW.  Also, you can print($object.__doc__) for 
each $object that you do not understand.

> The Script does work but I just want to explain each section to myself and
> understand it a bit more as I've forgot Python. This means putting
> comments/notes in next to each section to explain it but hidden so it
> doesn't show up when ran, so using the # commenting out #.

It is sufficient for Python single-line comments if the line starts with “#” 
(optionally preceded by whitespace).  Everything else is decoration.
I use leading “##” and “###” to tell documentation comments (other than 
docstrings) from comment lines that disable code (lines starting with “#” 
only) before it is cleaned up.  (WFM.  There might be a PEP about this that 
recommends otherwise.)
 
> […]
> Code (Python) - http://pastebin.com/sVhW34fc (This is the one I'm trying
> to understand) Before & After of an Explain_Plan in SQL Greenplum -
> http://pastebin.com/81kNWVcy
> 
> What we're aiming for (Teradatas Explain_Plan) -
> http://pastebin.com/Nm4g12B3



-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OTish Wells Fargo sucks

2016-03-15 Thread MRAB

On 2016-03-15 14:37, Grant Edwards wrote:

On 2016-03-14, Seymore4Head  wrote:


Wells Fargo online will not allow you to change a payee's address. You
have to delete the account and re enter it.


Wells Fargo is a pretty large company with a lot of money to spend.

How difficult a web site is to use is proportional to the size of
organization that owns it and how much money they spent developing it.

That's also why the national health insurance marketplace web site was
such a debacle.

After the failure of "NHS Connecting for Health" 
(https://en.wikipedia.org/wiki/NHS_Connecting_for_Health), the UK 
government got its act together with the "Government Digital Service" 
(https://en.wikipedia.org/wiki/Government_Digital_Service). It no longer 
tries to do everything in one go.


Failure is not inevitable.

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


Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-15 Thread Rick Johnson
On Tuesday, March 15, 2016 at 7:21:02 AM UTC-5, Chris Angelico wrote:
> I'm sure implementing Python is a lot more fun than reimplementing 
> Windows APIs!

There's not much on this earth, that is worse than Windows APIs.


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


Re: Python Advanced Help

2016-03-15 Thread Peter Otten
Luke Charlton wrote:

> Okay, So basically I created a python script around 1 year ago to grab an
> explain_plan from a Greenplum system (Normal SQL) and change it around and
> explain each step/section, the thing is, I've came back to the python code
> and I don't understand anything of what it's doing (the code
> specifically). The Script does work but I just want to explain each
> section to myself and understand it a bit more as I've forgot Python. This
> means putting comments/notes in next to each section to explain it but
> hidden so it doesn't show up when ran, so using the # commenting out #.
> 
> 
> The aim of the script is to make the explain_plan understandable because
> it comes out all garbled, so i've turned it upside down because thats how
> you read it, it goes from bottom to top instead of the default top to
> bottom. I've put step 1/2 in etc... but I want to know in the code what
> does what and where etc so I can then expand on the explanation of the
> explain_plan.
> 
> Code (Python) - http://pastebin.com/sVhW34fc (This is the one I'm trying
> to understand) Before & After of an Explain_Plan in SQL Greenplum -
> http://pastebin.com/81kNWVcy
> 
> What we're aiming for (Teradatas Explain_Plan) -
> http://pastebin.com/Nm4g12B3

You are about to learn a valuable lesson early in your programming career:

Throw away convoluted code that while trying to solve a simple problem is 
hard to follow.

Instead take the time necessary to read an introductory text on Python. Then 
describe the problem you want to solve in plain English. 

Finally translate the English into Python. Use descriptive variable names. 
If you run into problems that you cannot solve yourself come back here or 
ask on the tutor mailing list.

I expect that the resulting script will need only the input file and one 
list to reverse its lines, but no temporary files.

You may even be able to still understand it next year ;)

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


Re: Readability counts, was Re: Use of Lists, Tupples, or Sets in IF statement.

2016-03-15 Thread Peter Otten
Rustom Mody wrote:

> On Tuesday, March 15, 2016 at 2:00:25 PM UTC+5:30, Peter Otten wrote:
>> Rustom Mody wrote:
>> 
>> > Others have answered some parts
>>  if x in x_list:
>> > ... print("That is a fruit.")
>> > ... else:
>> > ... print("That is not a fruit.")
>> > ...
>> > 
>> > However one can distribute the print out of the if; Thus
>> > 
>>  "This is %s a fruit" % ("" if x in x_list else "not")
>> 
>> Which of the two versions will most readers grasp at first sight?
>> Which one is easier to modify so that it works for arbitrary attributes?
>> Which one is easier to internationalize?
> 
> I think you are saying that my (last) version is clever in a rather stupid
> sort of way. Yes?

Well, yes ;)

> Well if that is what someone recommends for serious programming then
> guilty as charged
> 
> But there is a world of difference between
> - What one SHOULD (or not) do
> - What one CAN do
> 
> The first is about serious|professional software engineering
> The second is about getting an education beyond basic to some more
> familiarity
> 
> I assumed that OP is in the noob stage and was welcome some learning.
> So what I wanted to convey is not so much that such expressions are nice
> to have in serious code. Rather that
> 1. Like algebra has laws so does programming
> 2. That these laws can be used to massage one program into another
> 3. That expressions (like %-format) can occur elsewhere than in prints

That (the % part) is a lesson for C programmers rather than newbies ;)

> 4. That prints are usually unnecessary (and an abomination)

They aren't. They are often misused by beginners when they occur where a 
function should return a value.
 
> Not that 3 and 4 come out so well as 1,2 in the above example.
> 
> However to answer your questions specifically.
> 
> Internationalization: Terrible
> Arbitrary attributes: not sure what you are referring to
> Readability: Very much like beauty -- in the eye of the beholder
> Some things are universally beautiful; some only in some cultural contexts
> Likewise readability
> 
> Partly people find if-expressions unreadable because they are not used to
> them.
> This is backward because expressions are as basic than statements  -- if
> anything more basic.

I think the problem is not that you prefer a programming paradigm that is 
not Python's default -- it's that you crammed too many ideas into one 
example. It's probably most helpful to concentrate on your main point, e. g.

(You can) Use an expression:

>>> x = "flying saucer"
>>> "This is a fruit" if x in x_list else "This is not a fruit"
'This is not a fruit'

> It is *symmetric*  Unfortunately understood as lopsided
> More such symmetries in this table:
> http://blog.languager.org/2016/01/primacy.html#expstat
> 
> Partly python if-expressions are unreadable because they are backward
> compared to if-statements. A minor syntactic nuisance but yes it does
> impact readability

Indeed. It's still better than

"This is %s a fruit" % (x in x_list and "" or "not")

The bug is intentional; the fix is of course

"This is %s a fruit" % (x in x_list and "most likely" or "probably not")

;)

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


Re: Fetch Gmail Archieved messages

2016-03-15 Thread Rick Johnson
On Tuesday, March 15, 2016 at 5:48:15 AM UTC-5, Arshpreet Singh wrote:

> def inbox_week():
> import imaplib
> EMAIL = 'myusern...@gmail.com'

I admit that this is pedantic, but you should really use
ADDRESS instead of EMAIL. ADDRESS more correctly complements
PASSWORD. But in any event, you did do well by spelling them
as constants, which implicitly means: "Hey, don't mutate
these values!"

> PASSWORD = 'mypassword'
> mail = imaplib.IMAP4_SSL('imap.gmail.com')
> mail.login(  EMAIL, PASSWORD )
> mail = imaplib.IMAP4_SSL('imap.gmail.com')
> mail.select("[Gmail]/All Mail")
> interval = (date.today()-timedelta(d)).strftime("%d-%b-%Y")
> _, data = mail.uid('search', 
> None,'(SENTSINCE{date})'.format(date=interval))
> 
> for num in data[0].split():
> _, data = mail.uid('fetch', num, '(BODY.PEEK[])')
> 
> for response_part in data:
> if isinstance(response_part, tuple):
> msg = email.message_from_string(response_part[1])
> for header in ['to']:
>
> # This is logic for inbox-archieved messages
> if (EMAIL in str(msg[header]) in str(msg[header])):

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

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


[issue26560] Error in assertion in wsgiref.handlers.BaseHandler.start_response

2016-03-15 Thread SilentGhost

Changes by SilentGhost :


--
nosy: +pje
type:  -> behavior
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



[issue26565] [ctypes] Add value attribute to non basic pointers.

2016-03-15 Thread SilentGhost

Changes by SilentGhost :


--
nosy: +amaury.forgeotdarc, belopolsky, meador.inge
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



[issue20891] PyGILState_Ensure on non-Python thread causes fatal error

2016-03-15 Thread STINNER Victor

STINNER Victor added the comment:

Attached patch should fix the issue.

--
keywords: +patch
Added file: http://bugs.python.org/file42174/PyGILState_Ensure.patch

___
Python tracker 

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



[issue20891] PyGILState_Ensure on non-Python thread causes fatal error

2016-03-15 Thread STINNER Victor

STINNER Victor added the comment:

ptest.c: Portable example using Python API.

--
Added file: http://bugs.python.org/file42173/ptest.c

___
Python tracker 

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



[issue26102] access violation in PyErrFetch if tcur==null in PyGILState_Release

2016-03-15 Thread STINNER Victor

STINNER Victor added the comment:

Good news: it looks like I fixed the Py_FatalError() bug in the issue #26558. 
Py_FatalError() can again be called with the GIL released.

The bug was introduced in Python 3.0.

Since your issue is a bug in your code and that Py_FatalError() was fixed, I 
close the issue. Thanks for your bug report.

--
nosy: +haypo
resolution:  -> fixed
status: open -> closed
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



[issue26558] Disable PyGILState_Check() when Py_NewInterpreter() is called and add more checks on the GIL

2016-03-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset b394fc71f92a by Victor Stinner in branch '3.5':
Fix Py_FatalError() if called without the GIL
https://hg.python.org/cpython/rev/b394fc71f92a

New changeset c298c6d8b324 by Victor Stinner in branch '3.5':
faulthandler: Test Py_FatalError() with GIL released
https://hg.python.org/cpython/rev/c298c6d8b324

--

___
Python tracker 

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



[issue26558] Disable PyGILState_Check() when Py_NewInterpreter() is called and add more checks on the GIL

2016-03-15 Thread STINNER Victor

STINNER Victor added the comment:

Ok, it looks like buildbots are happy. I close the issue.

--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

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



Re: common mistakes in this simple program

2016-03-15 Thread Ganesh Pal
On Tue, Mar 1, 2016 at 2:41 AM, Martin A. Brown  wrote:

> Please read below.  I will take a stab at explaining the gaps of
> understanding you seem to have (others have tried already, but I'll
> try, as well).
>
> I am going to give you four different functions which demonstrate
> how to use exceptions.  You may find it instructive to paste these
> functions into an interactive Python shell and try them out, as
> well.
>

Thanks Martin for beautifully demonstrating the use of exception  with
an example that's easy to understand.

Step 1: catch a specific Exception
Step 2: catch a specific Exception
Step 3: catch several different classes of Exception
Step 4: catch many different classes of Exception
-- 
https://mail.python.org/mailman/listinfo/python-list


Leo 5.2-b1 released

2016-03-15 Thread Edward K. Ream
Leo  5.2 b1 is now available on SourceForge
. Leo is a PIM, an IDE and
an outliner.

*The highlights of Leo 5.2*

- Easy install with PyInstaller packaging
- c.cloneFindByPredicate
- clone-find-marked commands
- decorators create all Leo commands
- find-def and find-var
- help-for-keystroke
--ipyhon command-line option works with latest IPython versions
- Optional line numbers in the body pane
- show-invisibles uses Qt characters
- Themes
- Wildcard file names on Leo's command line

*Links*

Leo's home page 
Documentation 
Tutorials 
Video tutorials 
Forum 
Download 
Leo on Github 
What people are saying about Leo 
A web page that displays .leo files 
More links 

March 15, 2016
--
Edward K. Ream: edream...@gmail.com Leo: http://leoeditor.com/
--
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

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


Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-15 Thread BartC

On 15/03/2016 11:52, BartC wrote:

On 15/03/2016 01:55, Steven D'Aprano wrote:



switch obj:
 case "Hello", None: ...
 case [1, 2, 3]: ...
 case 23.01, 15+2j, Fraction(10, 11): ...
 case 100**100, {}: ...


and more. This is not negotiable: having a switch statement limited to
small
ints is simply not an option.


Not a problem: http://pastebin.com/qdQintSZ


The solution I posted tested the values one after another. I was 
interested in whether it was that much faster than if-elif in CPython 3, 
so I tried the test similar to that below, except that k, c and f were 
literal values in the loop to start with.


Initial timings were 5 seconds for mine, 12.5 seconds for Python. That's 
in line with what I expected when dealing with more complex objects.


However, I then took the 100**100 outside the loop in my version (as 
that expression was not reduced to a constant). The timing then reduced 
to 170ms (I have a slow big num library).


But doing the same with Python made no difference. Taking Complex and 
Fraction outside reduced the timing to 8 seconds, still 50 times slower.


(My language doesn't understand Complex and Fraction, so testing against 
those is a quick process. Taking those out completely as well as 
100**100 made a difference, but there was the same discrepancy)


I know my language isn't that fast, so something is slowing down the 
Python in this test (and I don't /think/ I've left a zero out in my 
version!)


So maybe it makes the case for a proper Switch in Python stronger where 
such comparisons could be streamlined.



from fractions import Fraction

def test():

data=["Hello",None,[1,2,3],23.01,15+2j,Fraction(10,11),100**100,{},12345]
#print (data)
k=100**100
c=15+2j
f=Fraction(10,11)

for n in range(10):
for obj in data:
if obj=="hello" or obj==None:
pass
elif obj==[1,2,3]:
pass
elif obj==23.01 or obj==c or obj==f:
pass
elif obj==k or obj=={}:
pass


test()


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


Re: OTish Wells Fargo sucks

2016-03-15 Thread Grant Edwards
On 2016-03-14, Seymore4Head  wrote:

> Wells Fargo online will not allow you to change a payee's address. You
> have to delete the account and re enter it.

Wells Fargo is a pretty large company with a lot of money to spend.

How difficult a web site is to use is proportional to the size of
organization that owns it and how much money they spent developing it.

That's also why the national health insurance marketplace web site was
such a debacle.

-- 
Grant Edwards   grant.b.edwardsYow! I just remembered
  at   something about a TOAD!
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2016-03-15 Thread STINNER Victor

STINNER Victor added the comment:

I reviewed my own patch on Rietveld :-)

--

___
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.showmsg() function taking a warnings.WarningMessage object

2016-03-15 Thread STINNER Victor

New submission from STINNER Victor:

Currently, the warnings.showformat() function take between 4 and 6 parameters 
and it's not possible to add new parameters.

warnings.showformat() calls warnings.formatwarnings() with 5 parameters. Again, 
it's not easy to pass new parameters.

I would like to add a new "source" parameter for ResourceWarning: see issue 
#26567 "ResourceWarning: Use tracemalloc to display the traceback where an 
object was allocated when a ResourceWarning is emitted".

To make warnings extensible, I propose to:

* Add new showmsg() and formatmsg() functions to the warnings module, these 
functions take a warnings.WarningMessage instance
* The _warnings module calls warnings.showmsg() rather than 
warnings.showwarning()
* For backward compatibility, warnings.showmsg() calls warnings.showwarning() 
if warnings.showwarning() was replaced. Same for warnings.formatmsg(): call 
warnings.formatwarning() if replaced.

Attached patch implements these changes.

With these changes, the warnings looks a little bit more like the logging 
module and its logging.LogRecord class.

The patch is incomplete, it doesn't add much tests yet and it doesn't touch the 
documentation. I would prefer to get the new API (and the whole idea) approved 
before going too far.

Note: If warnings.showwarning is deleted ("del warnings.showwarning"), 
showmsg() uses its own implementation. Same for formatmsg().

--
files: warnings_showmsg.patch
keywords: patch
messages: 261814
nosy: haypo
priority: normal
severity: normal
status: open
title: Add a new warnings.showmsg() function taking a warnings.WarningMessage 
object
versions: Python 3.6
Added file: http://bugs.python.org/file42172/warnings_showmsg.patch

___
Python tracker 

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



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

2016-03-15 Thread STINNER Victor

STINNER Victor added the comment:

> Backward-compatibility problem: The C function PyErr_ResourceWarning() always 
> call warnings.showwarning() with the keyword parameter source. If an 
> application replaces the warnings.showwarning() function, it will probably 
> fail because it doesn't know the source parameter.

I proposed the issue #26568 "Add a new warnings.showmsg() function taking a 
warnings.WarningMessage object" to fix this issue.

--

___
Python tracker 

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



Re: Seekable files

2016-03-15 Thread Jon Ribbens
On 2016-03-15, Marko Rauhamaa  wrote:
> Jon Ribbens :
>> On 2016-03-15, Marko Rauhamaa  wrote:
>>> I think it points to a big practical problem in the whole exception
>>> paradigm.
>>
>> Well, no. That one individual language screwed up its implementation
>> of exceptions does not mean the whole concept of exceptions is broken.
>
> Python and Java make two.

Except Python didn't screw up its implementation of exceptions at all.
That the documentation could be better doesn't make it "broken".
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Seekable files

2016-03-15 Thread Marko Rauhamaa
Jon Ribbens :

> On 2016-03-15, Marko Rauhamaa  wrote:
>> Having to specify the possible exceptions in Java is very painful and
>> has complicated the introduction of closures to Java quite a bit.
>
> It is one of the extremely serious design errors in Java, I think.
>
>> I think it points to a big practical problem in the whole exception
>> paradigm.
>
> Well, no. That one individual language screwed up its implementation
> of exceptions does not mean the whole concept of exceptions is broken.

Python and Java make two.

>> Makes you wonder if the old error code mechanism would have
>> been better, after all. ("Why does Go not have exceptions?" > https://golang.org/doc/faq>.)
>
> I think they are wrong, and indeed their argument seems to be a
> ludicrous one based upon a misunderstanding of the English meaning of
> the word "exception"!
>
> Any high-level language that does not include exceptions is not fit
> for purpose, in my opinion.

I reserve my judgement for now. However, let it be said that exceptions
are supposed to make the code flow better. Instead, they are often
making code awkward-looking and "bouncy."


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


Re: Seekable files

2016-03-15 Thread Jon Ribbens
On 2016-03-15, Marko Rauhamaa  wrote:
> Jon Ribbens :
>> I'd just do something like:
>>
>>   try:
>>   fileobj.seek(where-i-want-to-seek-to)
>>   except (AttributeError, EnvironmentError):
>>   # file is not seekable
>
> Unlike Java, Python does not declare syntactically which exceptions the
> caller should expect. Unfortunately, the library documentation is not
> clear on it, either. So it is often a bit difficult to write proper
> try-except logic around a function.

This is true, although I'm not sure why you are mentioning it here
since I'm fairly sure the above code suggestion is reasonably correct
and the documentation is pretty clear.

> Having to specify the possible exceptions in Java is very painful and
> has complicated the introduction of closures to Java quite a bit.

It is one of the extremely serious design errors in Java, I think.

> I think it points to a big practical problem in the whole exception
> paradigm.

Well, no. That one individual language screwed up its implementation
of exceptions does not mean the whole concept of exceptions is broken.

> Makes you wonder if the old error code mechanism would have
> been better, after all. ("Why does Go not have exceptions?"  https://golang.org/doc/faq>.)

I think they are wrong, and indeed their argument seems to be a
ludicrous one based upon a misunderstanding of the English meaning of
the word "exception"!

Any high-level language that does not include exceptions is not fit
for purpose, in my opinion.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26040] Improve coverage and rigour of test.test_math

2016-03-15 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +christian.heimes, eric.smith, lemburg, serhiy.storchaka, stutzbach
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



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

2016-03-15 Thread STINNER Victor

STINNER Victor added the comment:

See also the issue #26567: "Use tracemalloc to display the traceback where an 
object was allocated when a ResourceWarning is emitted".

--

___
Python tracker 

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



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

2016-03-15 Thread STINNER Victor

Changes by STINNER Victor :


--
title: Use tracemalloc to display the traceback where an object was allocated 
when a ResourceWarning is emitted -> ResourceWarning: Use tracemalloc to 
display the traceback where an object was allocated when a ResourceWarning is 
emitted

___
Python tracker 

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



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

2016-03-15 Thread STINNER Victor

New submission from STINNER Victor:

Python emits ResourceWarning when an object using limited resource is destroyed 
without being explicitly closed: files, sockets, etc. The problem is that it's 
hard to find where the object comes from, since the warning can occur very 
late, in the garbage collector, etc.

I propose to reuse tracemalloc.get_object_traceback() to show were the object 
was allocated, when tracemalloc traces memory allocations. In practice, I 
propose to add a new "source" parameter to warnings.showwarning().

Attached patch:

* Add a new keyword-only source parameter to warnings.showwarning()
* Add C function PyErr_ResourceWarning() to pass source
* showwarning() uses tracemalloc.get_object_traceback() to get the traceback 
were the object was allocated
* Modify socket.socket, io.FileIO and os.scandir destructor to use 
PyErr_ResourceWarning()


Backward-compatibility problem: The C function PyErr_ResourceWarning() always 
call warnings.showwarning() with the keyword parameter source. If an 
application replaces the warnings.showwarning() function, it will probably fail 
because it doesn't know the source parameter.

I don't know how to handle this backward compatibility issue.


The patch is incomplete, it's not possible yet to emit a warning in pure Python 
with a source parameter.


x.py script used for examples below:
-
import warnings
import os
import socket

def func2():
#f=open("/etc/issue")
#f=os.scandir('.')
f=socket.socket()
f=None

def func():
func2()

func()
-


Output with Python 3.5:
-
x.py:9: ResourceWarning: unclosed 
  f=None
-


Output with -X tracemalloc=5 command line option and patched Python 3.6:
-
x.py:9: ResourceWarning: unclosed 
  f=None
Object allocated at (most recent call first):
  File "x.py", lineno 8
f=socket.socket()
  File "x.py", lineno 12
func2()
  File "x.py", lineno 14
func()
-

It's much easier to understand where the warning comes from, no? At x.py:8, 
line "f=socket.socket()".

Note: the traceback doesn't contain the function name, since tracemalloc only 
stores filename and line number.


See also the issue #26564 "Malloc debug hooks: display memory block traceback 
on error".


For Python < 3.6, I wrote "res_warn.py" script which monkey-patches io.FileIO 
and socket.socket to implement something similar. The script is a fragile hack. 
I would prefer to have the feature built-in Python.

https://bitbucket.org/haypo/misc/src/0a40f27360424145bad0f9b62c9e9148ffdbb169/python/res_warn.py

--
files: warnings_tracemalloc.patch
keywords: patch
messages: 261812
nosy: haypo, serhiy.storchaka, yselivanov
priority: normal
severity: normal
status: open
title: Use tracemalloc to display the traceback where an object was allocated 
when a ResourceWarning is emitted
versions: Python 3.6
Added file: http://bugs.python.org/file42171/warnings_tracemalloc.patch

___
Python tracker 

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



Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-15 Thread Chris Angelico
On Tue, Mar 15, 2016 at 11:02 PM, BartC  wrote:
> Anyway, what I'm saying is, trying to implement a language is also a good
> way of learning it, especially of finding out how it works.

Same goes for a lot of things. Want to know how Windows ticks? Try
reimplementing it - or read the comments left behind by people who've
done that, by browsing the Wine sources. There have been times when
I've been trying to figure out how to use a particular Windows API
function or window message, and couldn't understand some edge case
based solely on the docs, so I dug into the Wine source code, found
how they did it (and in at least one case, found a comment stating
that observed behaviour differed from the docs!), and was able to
deploy to Windows on that basis.

I'm sure implementing Python is a lot more fun than reimplementing Windows APIs!

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


Twisted 16.0 Released

2016-03-15 Thread Amber "Hawkie" Brown
On behalf of Twisted Matrix Laboratories, I am honoured to announce the release 
of Twisted 16.0!

Twisted 16.0 brings some important changes, and some nice-to-haves as well. The 
major things are:

- TLS endpoints have arrived! They're like the old `ssl:` endpoints, but 
support faster IPv4/IPv6 connections (using HostnameEndpoint) and always do 
hostname verification.
- Conch now uses Cryptography instead of PyCrypto for underlying cryptographic 
operations. This means it'll work much better on PyPy!
- Headers objects (notably used by t.web.server.Request) now support Unicode 
for the vast majority of cases, encoding keys to ISO-8859-1 and values to UTF-8.
- WSGI support and AMP have been ported to Python 3, along with a handful of 
other modules.
- More shedding of the past, with the GTK+ 1 reactor being removed.
- Over 45 tickets have been closed since 15.5.

For more information, check the NEWS file (link provided below).

You can find the downloads at  (or 
alternatively ). The NEWS file is 
also available at .

Many thanks to everyone who had a part in this release - the supporters of the 
Twisted Software Foundation, the developers who contributed code as well as 
documentation, and all the people building great things with Twisted!

Twisted Regards,

Amber Brown (HawkOwl)
Twisted Release Manager


signature.asc
Description: Message signed with OpenPGP using GPGMail
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

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


Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-15 Thread BartC

On 15/03/2016 09:20, alister wrote:


Why would i do somthing so pointless?


Name references are pointless? OK, you're the expert ...


how does this grab you (it often catches newbies out)

def test(x):
a.append('oops')

a=['a list']
test(a)
print (a)


Not any more.



I sugest you may want to start reading a good python tutorial.


Last year I started implementing a Python clone. I stopped the project 
because it meant losing too many features I was used to. Also I had 
doubts whether I could even make it as fast as CPython (which had a 
25-year head start).


I've since introduced some aspects of Python (object references) into an 
existing language, while still keeping name references.


Anyway, what I'm saying is, trying to implement a language is also a 
good way of learning it, especially of finding out how it works.


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


Re: The Cost of Dynamism (was Re: Pyhon 2.x or 3.x, which is faster?)

2016-03-15 Thread BartC

On 15/03/2016 01:55, Steven D'Aprano wrote:

On Tue, 15 Mar 2016 04:53 am, BartC wrote:




I get it. The author doesn't like switch statements!


I don't think you do -- there's no "the author". It's a wiki. There's
potentially *thousands* of "authors". The page you (might have) read is a
discussion between many different people, debating the pros and cons of
switches.


I got the impression it was mostly cons, and that everyone was keen to 
replace them with OO constructs.



But they can be a succinct and convenient way of expressing some code
patterns.



One of the problems with switch statements is that they are *anything but*
succinct. Compare this:


switch X
when A,B   then S1
when C then S2
when D,E,F then S3
elseS4
end switch


to the object-oriented solution, using polymorphism:

X.foo()

where foo returns S1, S2, ... S4 as appropriate, according to the type of X.


(1) X.foo only looks more succinct because you've conveniently removed 
A..F and S1..S4. Presumably they have to be provided somewhere else.


(2) My version switches on the *value* of X not the type. (Except of 
course when you use switch type(X) then X.foo() might be better, *if* 
you've done the prerequisite work of setting up the classes and methods 
needed.)



there have been two proposals to introduce a
switch/case statement to Python, including one by Guido himself.

https://www.python.org/dev/peps/pep-3103/


Which starts by saying it's been rejected. But when you read the rest, 
you can sort of understand why! So many complications are put forward, 
and some half-depend on the introduction of constants, that there is no 
clear single solution. It comes across as a mess.



The typical characteristics - when A to F are known at compile-time - are:

* X is only evaluated once


That's easy to emulate with a temporary variable.


You mean when X is complex? Sure, but Python is such that even with a 
local temporary, evaluating LOAD_FAST is needed before each test, with 
all the reference counting that goes with it. And a STORE_FAST before 
the lot. (And some switch statements may be outside a function.)


(My byte-code uses special switch compare operators that leave the test 
value on the stack.)



* None of A to F need to be evaluated
* Only a single test is needed, no matter how many case expressions


How does the compiler know which case matches from a single test?

I think that you might be assuming that the switch statement uses a jump
table. In your case, since you wrote the language, you might be right, but
that's certainly not the case in general.


Not in general, but, in my code at least, testing an integer value 
against a set of integer constants (literals, enums, named constants) is 
used extensively. And things such as enums tend to have a compact span 
of values.


And where a jump-table is not possible, then you just have to locate one 
integer value within a list of constant integers (with a label 
associated with each), and there are many ways to do that. Via hashing 
for example, which would be done in the interpreter and would still 
count as a single test.



But of course, in Python any switch statement would have to support values
of any and every type, not just integers. So any implementation you are
thinking of would have to support cases like this:


switch obj:
 case "Hello", None: ...
 case [1, 2, 3]: ...
 case 23.01, 15+2j, Fraction(10, 11): ...
 case 100**100, {}: ...


and more. This is not negotiable: having a switch statement limited to small
ints is simply not an option.


Not a problem: http://pastebin.com/qdQintSZ


This syntax I find interesting, although it is rather limited in that you
can only switch on integers:


(I use switch-when for integer-only and case-when for anything else, or 
when a jumptable is not viable. See above paste.)



Here's another pattern, which can also be implemented with an underlying
switch:

   X = (N |A, B, C, ... |Z)

This selects the N'th value from A, B, C (in Python, probably 0-based).
Z is the default if N is out of range. A, B, C can be any expressions.

The main characteristic is that only *one* of A, B, C  or Z evaluated,
which is the difference between just using a list.


Are there any well-known languages which support this or similar syntax?


I pinched this syntax from Algol-68. (I think 'when' comes from Ada.)


Of course, the syntax won't work in Python, because ( ... ) is already used
for tuples, and N|A would be ambiguous with bitwise-or. The closest we have
in Python would be:


Is ¦ available? Then (N¦A,B,C¦Z) would work, but is more fiddly to type. 
But the syntax is not important; you could just use:


   select n in a,b,c,d else z

(I think Algol68, when not using the compact form, used case n in a,b,c 
out z esac or some such thing.)


--
Bartc



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


Python Advanced Help

2016-03-15 Thread Luke Charlton
Okay, So basically I created a python script around 1 year ago to grab an 
explain_plan from a Greenplum system (Normal SQL) and change it around and 
explain each step/section, the thing is, I've came back to the python code and 
I don't understand anything of what it's doing (the code specifically). The 
Script does work but I just want to explain each section to myself and 
understand it a bit more as I've forgot Python. This means putting 
comments/notes in next to each section to explain it but hidden so it doesn't 
show up when ran, so using the # commenting out #.


The aim of the script is to make the explain_plan understandable because it 
comes out all garbled, so i've turned it upside down because thats how you read 
it, it goes from bottom to top instead of the default top to bottom. I've put 
step 1/2 in etc... but I want to know in the code what does what and where etc 
so I can then expand on the explanation of the explain_plan.

Code (Python) - http://pastebin.com/sVhW34fc (This is the one I'm trying to 
understand)
Before & After of an Explain_Plan in SQL Greenplum - 
http://pastebin.com/81kNWVcy

What we're aiming for (Teradatas Explain_Plan) - http://pastebin.com/Nm4g12B3


Regards,

Luke Charlton
Technical Consultant

[cid:4BEA1319-4F97-4ED8-96FE-1A3EDF7DEC22]
lcharl...@vldbsolutions.com
Mobile : +44 (0) 773 431 3140
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue24230] tempfile.mkdtemp() doesn't work with bytes paths

2016-03-15 Thread STINNER Victor

STINNER Victor added the comment:

"""
Today we're doing something like this:

tmpdir = tempfile.mkdtemp('', 'hgtests.', d and 
d.decode('utf-8')).encode('utf-8')
"""

Don't do that. UTF-8 is not the right encoding.

Use os.fsencode() and os.fsdecode(). Internally, Python uses 
sys.getfilesystemencoding() with 'surrogateescape' error handler (but 'strict' 
error handler on Windows).

If you use UTF-8, you can get indirectly mojibake.

--

___
Python tracker 

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



[issue24230] tempfile.mkdtemp() doesn't work with bytes paths

2016-03-15 Thread STINNER Victor

STINNER Victor added the comment:

I don't understand the rationale to add new functions using bytes filenames.

IMHO it's a bad practice to pass bytes filenames to write portable code. On 
Windows, bytes lead to strange bugs: os.listdir(bytes) gives you filenames 
which don't exist when a filename cannot be encoded to the ANSI code page.

On UNIX, os.fsencode() and os.fsdecode() allows you to convert filenames 
between unicode and bytes. It provides nice properties like 
os.fsencode(os.fsdecode(value))==value where value is bytes. No need to add new 
APIs, use existing APIs an use os.fsencode() and os.fsdecode() on top of them.

Bytes filenames are deprecated on Windows since Python 3.2. The new 
os.scandir() function doesn't support bytes for example, it's a deliberate 
choice.

Maybe I missed an important technical issue?

--
nosy: +haypo

___
Python tracker 

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



[issue26562] Large Involuntary context switches during oom-killer

2016-03-15 Thread STINNER Victor

STINNER Victor added the comment:

> When oom-killer is trigger

IMHO this is your root problem.

> When oom-killer is trigger I see a large number of involuntary context 
> switches ...

The principle of *involuntarty* context switches is that the application is not 
responsible for them.

> I tried the same test using NodeJS/C++ and I could see a lot less involuntary 
> context switches and major page faults which indicates this could be a Python 
> issue.

Your rationale cannot be good.

It is not a Python bug.

OOM Killer is not a bug but a feature to limit abuse of resources on Linux.

But yeah, in my experience, Linux becomes crazy when it reachs OOM Killer. You 
can try to tune your kernel, but it's much better to always avoid using all 
memory ;-)

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

___
Python tracker 

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



Re: Seekable files

2016-03-15 Thread Marko Rauhamaa
Jon Ribbens :

> I'd just do something like:
>
>   try:
>   fileobj.seek(where-i-want-to-seek-to)
>   except (AttributeError, EnvironmentError):
>   # file is not seekable

Unlike Java, Python does not declare syntactically which exceptions the
caller should expect. Unfortunately, the library documentation is not
clear on it, either. So it is often a bit difficult to write proper
try-except logic around a function.

Having to specify the possible exceptions in Java is very painful and
has complicated the introduction of closures to Java quite a bit. I
think it points to a big practical problem in the whole exception
paradigm. Makes you wonder if the old error code mechanism would have
been better, after all. ("Why does Go not have exceptions?" https://golang.org/doc/faq>.)


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


Re: Readability counts, was Re: Use of Lists, Tupples, or Sets in IF statement.

2016-03-15 Thread Rustom Mody
On Tuesday, March 15, 2016 at 2:00:25 PM UTC+5:30, Peter Otten wrote:
> Rustom Mody wrote:
> 
> > Others have answered some parts
>  if x in x_list:
> > ... print("That is a fruit.")
> > ... else:
> > ... print("That is not a fruit.")
> > ...
> > 
> > However one can distribute the print out of the if; Thus
> > 
>  "This is %s a fruit" % ("" if x in x_list else "not")
> 
> Which of the two versions will most readers grasp at first sight?
> Which one is easier to modify so that it works for arbitrary attributes?
> Which one is easier to internationalize?

Heh!
I think you are saying that my (last) version is clever in a rather stupid
sort of way. Yes?
Well if that is what someone recommends for serious programming then guilty
as charged

But there is a world of difference between
- What one SHOULD (or not) do
- What one CAN do

The first is about serious|professional software engineering
The second is about getting an education beyond basic to some more familiarity

I assumed that OP is in the noob stage and was welcome some learning.
So what I wanted to convey is not so much that such expressions are nice to
have in serious code. Rather that
1. Like algebra has laws so does programming
2. That these laws can be used to massage one program into another
3. That expressions (like %-format) can occur elsewhere than in prints
4. That prints are usually unnecessary (and an abomination)

Not that 3 and 4 come out so well as 1,2 in the above example.

However to answer your questions specifically.

Internationalization: Terrible
Arbitrary attributes: not sure what you are referring to
Readability: Very much like beauty -- in the eye of the beholder
Some things are universally beautiful; some only in some cultural contexts
Likewise readability

Partly people find if-expressions unreadable because they are not used to them.
This is backward because expressions are as basic than statements  -- if
anything more basic.

It is *symmetric*  Unfortunately understood as lopsided
More such symmetries in this table:
http://blog.languager.org/2016/01/primacy.html#expstat

Partly python if-expressions are unreadable because they are backward compared
to if-statements. A minor syntactic nuisance but yes it does impact readability
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple exercise

2016-03-15 Thread Oscar Benjamin
On 14 March 2016 at 23:59, Steven D'Aprano  wrote:
> On Tue, 15 Mar 2016 02:06 am, Oscar Benjamin wrote:
>
>> On 14 March 2016 at 14:35, Rick Johnson 
>> wrote:
>>>
>>> I would strongly warn anyone against using the zip function
>>> unless
>> ...
>>> I meant to say: absolutely, one hundred percent *SURE*, that
>>> both sequences are of the same length, or, absolutely one
>>> hundred percent *SURE*, that dropping values is not going to
>>> matter. For that reason, i avoid the zip function like the
>>> plague. I would much rather get an index error, than let an
>>> error pass silently.
>>
>> I also think it's unfortunate that zip silently discards items.
>
> Are you aware of itertools.zip_longest?

I am.

> That makes it easy to build a zip_strict:
>
> def zip_strict(*iterables):
> pad = object()
> for t in itertools.zip_longest(*iterables, fillvalue=pad):
> if pad in t:
> raise ValueError("iterables of different length")
> yield t

There are many ways to build a zipstrict. As I said in my own usage of
zip I would almost always want it to raise an error because I almost
always give zip iterables of the same length. However the situation
where zipstrict would benefit is often the kind of situation where
you're not really thinking about the fact that zip truncates. Also if
you only have one zip call in a script it'd be easier (and clearer) to
write:

if len(x) != len(y):
raise ValueError

> Unfortunate or not, it seems to be quite common that "zip" (convolution)
> discards items when sequences are of different lengths. I think the usual
> intent is so that you can zip an infinite (or near infinite) sequence of
> counters 1, 2, 3, 4, ... with the sequence you actually want, to get the
> equivalent of Python's enumerate().

That's fine but in the Python code I see zip is much more often used
with equal length finite iterables than with infinite ones. One of the
things I like about Python (especially since I'm learning JS right
now) that you can write your code in the obvious way and then most of
your error checking comes for free: I want loud error messages instead
of corrupted data. I would rather have the potentially bug-prone
zip_shortest be an opt-in itertools feature and zip_strict the default
behaviour for zip. I realise it's not going to change but I think it
would be better.

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


Re: Seekable files

2016-03-15 Thread Jon Ribbens
On 2016-03-15, Steven D'Aprano  wrote:
> Suppose somebody passes me an open file handle. What's the right way to tell
> if it is seekable in Python 2?
>
> I see that stdin has a seek and tell method, but they raise:
>
> py> sys.stdin.tell()
> Traceback (most recent call last):
>   File "", line 1, in 
> IOError: [Errno 29] Illegal seek
>
> Are seek and tell guaranteed to exist on all files?

Expecting strict object types isn't really how Python works - while
all subclasses of 'file' are guaranteed to have methods called 'seek'
and 'tell' (although they're not of course guaranteed to do anything
useful), most Python code that says it expects a 'file' doesn't really
mean it wants a subclass of 'file', it means it wants something that
provides a certain subset of the usual file-like methods.

So the answer to your question rather depends on what you mean by
"guaranteed to exist" and "all files". Even actual standard 'file'
objects, while having 'seek' and 'tell', may well just throw an
exception if you try and call those methods as the underlying
operating system file handle the object is attached to does not
support seeking.

> Is there some other way to tell whether the file supports seeking other than
> to try it and see?

No.

> (In Python 3, files have a seekable method.)

Yes, but all it is is a wrapper that does try-it-and-see for you.

I'd just do something like:

  try:
  fileobj.seek(where-i-want-to-seek-to)
  except (AttributeError, EnvironmentError):
  # file is not seekable
-- 
https://mail.python.org/mailman/listinfo/python-list


Fetch Gmail Archieved messages

2016-03-15 Thread Arshpreet Singh
Hi, I am using imaplib to fetch Gmail's Inbox Archived message but results are 
not that much accurate. Here is code+logic:


def inbox_week():
import imaplib
EMAIL = 'myusern...@gmail.com'
PASSWORD = 'mypassword'
mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login(  EMAIL, PASSWORD )
mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.select("[Gmail]/All Mail")
interval = (date.today()-timedelta(d)).strftime("%d-%b-%Y")
_, data = mail.uid('search', None,'(SENTSINCE{date})'.format(date=interval))

for num in data[0].split():
_, data = mail.uid('fetch', num, '(BODY.PEEK[])')

for response_part in data:
if isinstance(response_part, tuple):
msg = email.message_from_string(response_part[1])
for header in ['to']:
   
# This is logic for inbox-archieved messages
if (EMAIL in str(msg[header]) in str(msg[header])):

main_tuple = email.utils.parsedate_tz(msg['Date'])   

yield main_tuple

I am not sure how to get the list of only Inbox-messages as well as Sentbox 
messages from [All-mail]. Do I need to any other library ?
-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   >