Twisted 13.2.0 Release Announcement

2013-11-10 Thread HawkOwl
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On behalf of Twisted Matrix Laboratories, I am honoured to announce
the release of Twisted 13.2!

The highlights of this release are:

 * Twisted now includes a HostnameEndpoint implementation which uses
IPv4 and IPv6 in parallel, speeding up the connection by using
whichever connects first (the 'Happy Eyeballs'/RFC 6555 algorithm).
(#4859)

 * Improved support for Cancellable Deferreds by kaizhang, our GSoC
student. (#4320, #6532, #6572, #6639)

 * Improved Twisted.Mail documentation by shira, our Outreach Program
for Women intern. (#6649, #6652)

 * twistd now waits for the application to start successfully before
exiting after daemonization. (#823)

 * SSL server endpoint string descriptions now support the
specification of chain certificates. (#6499)

 * Over 70 closed tickets since 13.1.0.

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

You can find the downloads at https://pypi.python.org/pypi/Twisted
(or alternatively http://twistedmatrix.com/trac/wiki/Downloads) .
The NEWS file is also available at
http://twistedmatrix.com/Releases/Twisted/13.2/NEWS.txt.

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,
HawkOwl
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.15 (GNU/Linux)

iQEcBAEBAgAGBQJSfTQUAAoJECMItHnTkkoRPWcIAKkvwudaMkHhMyJp+5KzYlQZ
Ay7+tUqteRRZ11vrVGXebidE4qDyfowMYtnxAi7024DRtEk/GF/14x/kKiWtmDTR
kyPDCf7ZgAky62gxwECCGhn6COhn1DXbQZ2czy7KXKUr2to/EDCVtv1dY2hF6zJJ
tfpRi/8mZW6DcAY9thWT1zppMdVi98j3oRXGHjM5S7vtk7ErlW2AkwDlan/KTRWe
qa43nco/FL5mY17+TmCxUrdn9GlkSNkPMAnoW3ab65E+nq7sxdG0NmXQlCs3M5Um
2Xf6Lfl/IBQ3BYQh/SS4xygiwMjZlT/kSs/eixzKTPhpCatTdyhsTD2Ozw64464=
=00LG
-END PGP SIGNATURE-
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

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


RedNotebook 1.7.3

2013-11-10 Thread Jendrik Seipp

A new RedNotebook version has been released.

You can get the tarball, Windows installer and links to distribution
packages at http://rednotebook.sourceforge.net/downloads.html


What is RedNotebook?

RedNotebook is a **graphical journal** and diary helping you keep track
of notes and thoughts. It includes a calendar navigation, customizable
templates, export functionality and word clouds. You can also format,
tag and search your entries. RedNotebook is available in the
repositories of most common Linux distributions and a Windows installer
is available. It is written in Python and uses GTK+ for its interface.


What's new in this version?
---
* Jump to a specific date on startup with --date 2013-10-31 on the 
commandline (Rob Norris).

* Display current date in the title bar (Rob Norris).
* Support inserting multiple pictures in one step.
* Add DejaVu Sans as font fallback for clouds and preview.
* Fix setting last image directory for insert dialog.
* Only allow exporting selected text if we are in edit mode (lp:1221792).


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

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


Plumbum v1.4 released

2013-11-10 Thread Tomer Filiba
Ever wished the compactness of shell scripts be put into a real programming 
language? Say hello to Plumbum Shell Combinators. Plumbum (Latin for lead, 
which was used to create pipes back in the day) is a small yet feature-rich 
library for shell script-like programs in Python. The motto of the library is 
“Never write shell scripts again”, and thus it attempts to mimic the shell 
syntax (shell combinators) where it makes sense, while keeping it all Pythonic 
and cross-platform.

Apart from shell-like syntax and handy shortcuts, the library provides local 
and remote command execution (over SSH), local and remote file-system paths, 
easy working-directory and environment manipulation, and a programmatic 
Command-Line Interface (CLI) application toolkit.

http://plumbum.readthedocs.org/en/latest/

Compatibility issue: `plumbum.utils` became `plumbum.path.utils`

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

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


Re: datetime question

2013-11-10 Thread Gene Heskett
On Saturday 09 November 2013 19:52:52 Chris Angelico did opine:

 On Sun, Nov 10, 2013 at 2:39 AM, Gene Heskett ghesk...@wdtv.com wrote:
  Ya know, folks like Nick would have me signing off.  Fortunately there
  are kill files. But the backscatter he creates I am still forced to
  read, or more usually skip.
  
  Then one of you frustrated standup comics comes along, and gives me a
  VBG, and its suddenly all worth it.  Thank You Chris.
 :
 :) Don't just thank me, Grant and Roy were key to it too - and the
 
 whole there's no shortage of newlines thing started with Steven
 D'Aprano (I think), and it's a ripe field for harvest :)

And likely not fully gleaned yet. :)  To all of you, thats some of the 
better creative writing I've read in my 79 years.  ;-)
 
 But hey. If you're going to have to read backscatter, may as well make
 it funny...

Precisely.
 
 ChrisA


Cheers, Gene
-- 
There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order.
-Ed Howdershelt (Author)

A Difficulty for Every Solution.
-- Motto of the Federal Civil Service
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
 law-abiding citizens.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread ishish

Am 09.11.2013 15:07, schrieb Steven D'Aprano:
...

Nikos, you have annoyed and alienated enough people here...


Sorry, I DO NOT AGREE! These threads keep my entire office entertained. 
I would even go so far to suggest, that we should set up an entirely new 
mailing list for Nikos only, maybe something called like 
acropolis-list(at)python.org.


Mea culpa, I am entirely aware that this is an IT list, but hey, when 
you have done 2x65ish hrs per week in a row - standing in for our Ops 
Guy, holidaying - you really start to appreciating little interruptions 
like this...


Greekings ...oops, meant greetings from Tartan-Land,

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


Re: chunking a long string?

2013-11-10 Thread Chris Angelico
On Sun, Nov 10, 2013 at 5:39 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Sun, 10 Nov 2013 09:14:28 +1100, Chris Angelico wrote:

 And
 as is typical of python-list, it's this extremely minor point that
 became the new course of the thread -

 You say that as if it were a bad thing :-P

More a curiosity than a bad thing.

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


Re: datetime question

2013-11-10 Thread Chris Angelico
On Sun, Nov 10, 2013 at 11:55 AM, Gene Heskett ghesk...@wdtv.com wrote:
 On Saturday 09 November 2013 19:52:52 Chris Angelico did opine:
 :) Don't just thank me, Grant and Roy were key to it too - and the
 whole there's no shortage of newlines thing started with Steven
 D'Aprano (I think), and it's a ripe field for harvest :)

 And likely not fully gleaned yet. :)  To all of you, thats some of the
 better creative writing I've read in my 79 years.  ;-)

Are you going to have a newyear after next year and start over with
Year 1 again?

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


Re: New user's initial thoughts / criticisms of Python

2013-11-10 Thread Jorgen Grahn
On Sat, 2013-11-09, Chris Angelico wrote:
 On Sun, Nov 10, 2013 at 12:08 AM, John von Horn j@btinternet.com wrote:
...
 * Why not allow floater=float(int1/int2) - rather than floater=float
 (int1)/float(int2)?

 Give me a float (or an error message) from evaluating everything in the
 brackets. Don't make me explicitly convert everything myself (unless I
 want to)

 As others have said, what you're asking for is actually magic. One of
 the rules of Python - one for which I'm not aware of any exceptions -
 is that you can always take a subexpression out and give it a new
 name:

And it's not just Python: programming languages have been designed
that way since at least the 1960s.  People are used to analysing
expressions inside and out according to rules common for almost all
languages.

/Jorgen

-- 
  // Jorgen Grahn grahn@  Oo  o.   . .
\X/ snipabacken.se   O  o   .
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Languages for different purposes (was Re: New user's initial thoughts / criticisms of Python)

2013-11-10 Thread Jorgen Grahn
On Sun, 2013-11-10, Chris Angelico wrote:
 On Sun, Nov 10, 2013 at 11:41 AM, Roy Smith r...@panix.com wrote:
 On 09/11/2013 22:58, Chris Angelico wrote:
 
  * Some languages are just fundamentally bad. I do not recommend ever
  writing production code in Whitespace, Ook, or Piet.

 One of the worst coding experiences I ever had was trying to build an
 app for a Roku media player.  They have a home-grown language called
 BrightScript.  Barf.

 And this is exactly why I was so strongly against the notion of
 developing an in-house scripting language. It may be a lot of work to
 evaluate Lua, Python, JavaScript, and whatever others we wanted to
 try, but it's a *lot* less work than making a new language that
 actually is worth using.

Yes.  I am baffled that people insist on doing the latter. Designing a
limited /data/ language is often a good idea; designing something
which eventually will need to become Turing-complete is not.

/Jorgen

-- 
  // Jorgen Grahn grahn@  Oo  o.   . .
\X/ snipabacken.se   O  o   .
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: my favorite line of py code so far

2013-11-10 Thread Peter Cacioppi
Chris said :

I think map is fine if you can use a named function, but if you can't
come up with a descriptive name for what you're doing, a comprehension
is probably better (as it'll have the code right there). Mapping _
across everything tells you nothing about what it's actually doing

OK, this makes a lot of sense. (Any my apologies to Peter Otten if my previous 
post was overly snarky).

How about this? I put the following in my catchall_utility.py module

  # the oneArg combinator takes a multi-argument calleable
  # and returns the equivalent single argument calleable
  oneArg = lambda c: lambda x : c(*x)


With example code

  map(oneArg(P), zip([1,2,3], [6, 5, 4]))

To my mind the idea that oneArg(P) is a calleble that behaves exactly like P, 
with the only difference being oneArg(P) accepts P's arguments packed into a 
single iterable, is very intuitive.

I actually find the oneArg version more readable than the comprehension that 
unpacks explicitly using *. At this point I probably have equal experience 
coding Lisp and Py, with the latter more recent, so I don't think this bias can 
be chalked up to experienced functional programmer, beginner py programmer.

To be clear, I was never really intending to keep the

  _ = lambda c : lambda x : c(*x)
  map(oneArg(P), zip([1,2,3], [6, 5, 4]))

code snippets in my final work product. The purpose of this thread was too fish 
around for ideas on what to replace it with when I execute the use the unit 
tests to facilitate refactoring for better names and more professional idioms 
step.

(We never, ever, skip that step, right?)

Although it is unlikely you will convince me to use the comprehension in this 
sort of situation, it's possible someone could convince me to use starmap with 
P instead of map with oneArg(P). Those two techniques are fully equivalent. 
But, to my mind, the latter just feels right, and I find that I write fewer 
bugs when I use idioms that resonate.

Thanks again, good thread for me
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: my favorite line of py code so far

2013-11-10 Thread Peter Cacioppi
Sorry, typo, meant to say

To be clear, I was never really intending to keep the

  _ = lambda c : lambda x : c(*x)
  map(_(P), zip([1,2,3], [6, 5, 4]))

code snippets in my final work product. The purpose of this thread was too fish 
around for ideas on what to replace it with... 
 

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


Re: New user's initial thoughts / criticisms of Python

2013-11-10 Thread Chris Angelico
On Sun, Nov 10, 2013 at 7:47 PM, Jorgen Grahn grahn+n...@snipabacken.se wrote:
 On Sat, 2013-11-09, Chris Angelico wrote:
 On Sun, Nov 10, 2013 at 12:08 AM, John von Horn j@btinternet.com wrote:
 ...
 * Why not allow floater=float(int1/int2) - rather than floater=float
 (int1)/float(int2)?

 Give me a float (or an error message) from evaluating everything in the
 brackets. Don't make me explicitly convert everything myself (unless I
 want to)

 As others have said, what you're asking for is actually magic. One of
 the rules of Python - one for which I'm not aware of any exceptions -
 is that you can always take a subexpression out and give it a new
 name:

 And it's not just Python: programming languages have been designed
 that way since at least the 1960s.  People are used to analysing
 expressions inside and out according to rules common for almost all
 languages.

That's true to at least some extent, but quite a few languages have
differences here and there. In C, there's no such thing as an array
literal, only an initializer list, so:

/* This works: */
int month_days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int this_month_days = month_days[this_month];

/* This doesn't: */
int three = {1, 2, 3, 4, 5}[2];

PHP had similar issues up until a *very* recent version (5.3 or 5.4 or
something), where you couldn't dereference an array returned by a
function:

//Works:
$arr = func();
$val = $arr[5];

//Didn't work until recently, and therefore can't be trusted for
//deployment to random systems across the internet:
$val = func()[5];

JavaScript has magic around the dot and function-call operators, as I
mentioned earlier. Lots of other languages have some little quirk
somewhere that breaks this rule; some have a LOT of quirks that break
this rule. Does Python have any? Aside from parsing oddities like
attribute access on a literal integer[1], are there any cases where
two expressions yielding the same object are in any way different?

ChrisA
[1] You can write (1234).to_bytes(2,'big') but omitting the parens
gives a SyntaxError because it looks like the start of a float
literal.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: datetime question

2013-11-10 Thread Gene Heskett
On Sunday 10 November 2013 04:06:06 Chris Angelico did opine:

 On Sun, Nov 10, 2013 at 11:55 AM, Gene Heskett ghesk...@wdtv.com wrote:
  On Saturday 09 November 2013 19:52:52 Chris Angelico did opine:
  :) Don't just thank me, Grant and Roy were key to it too - and the
  
  whole there's no shortage of newlines thing started with Steven
  D'Aprano (I think), and it's a ripe field for harvest :)
  
  And likely not fully gleaned yet. :)  To all of you, thats some of the
  better creative writing I've read in my 79 years.  ;-)
 
 Are you going to have a newyear after next year and start over with
 Year 1 again?
 
Nah.  I tried to put it off as long as I could, but times arrow, dammit, 
only points forward.  I might as well get used to it.  From that famous 
line about death and taxes, taxes will of course outlive me. Being a DM-II, 
I of course haven't a shred of warranty left.  Just up to pee and check on 
that falling satellite, I could fall over walking the 20 feet back to bed, 
but I'm going to do it anyway... ;-)

 ChrisA


Cheers, Gene
-- 
There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order.
-Ed Howdershelt (Author)

$100 invested at 7% interest for 100 years will become $100,000, at
which time it will be worth absolutely nothing.
-- Lazarus Long, Time Enough for Love
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
 law-abiding citizens.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: my favorite line of py code so far

2013-11-10 Thread Chris Angelico
On Sun, Nov 10, 2013 at 7:57 PM, Peter Cacioppi
peter.cacio...@gmail.com wrote:
 Chris said :

 I think map is fine if you can use a named function, but if you can't
 come up with a descriptive name for what you're doing, a comprehension
 is probably better (as it'll have the code right there). Mapping _
 across everything tells you nothing about what it's actually doing

 How about this? I put the following in my catchall_utility.py module

   # the oneArg combinator takes a multi-argument calleable
   # and returns the equivalent single argument calleable
   oneArg = lambda c: lambda x : c(*x)

Now it has a name, so I could imagine you importing it into modules
and using it usefully. I'd be inclined to call it something along the
lines of unpacked but that's just bikeshedding.

 ... I find that I write fewer bugs when I use idioms that resonate.

Absolutely! The unfortunate truth, though, is that idioms that
resonate with you _and nobody else_ are just as big a problem as bugs,
because they're unmaintainable. So hopefully what you're doing will
make sense to other people too!

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


Re: To whoever hacked into my Database

2013-11-10 Thread Νίκος Αλεξόπουλος

Στις 10/11/2013 12:20 πμ, ο/η Chris Angelico έγραψε:

On Sun, Nov 10, 2013 at 2:32 AM, Antoon Pardon
antoon.par...@rece.vub.ac.be wrote:

And i had until i made some new changes last night, which i think i have 
corrected now as we speak.


Continuing the arrogance.


Just to put that in perspective, by the way: *EVERYONE* writes
vulnerable code. Even Python itself has been found to have had
significant exploits (hash randomization had to get backported a long
way). There's nothing wrong with fixing security bugs; there's not
even a lot wrong with the iterative process of find bug, fix bug,
find another bug, fix another bug. There are two major problems with
what you did here, Nikos, and they are:

1) Starting with a hopelessly insecure system and then trying to
band-aid patch it one vulnerability at a time, which is folly; and

2) Boasting that your system was now secure.

The main issue is the boasting, which is utterly unwarranted
arrogance. All you have to do is look at how, after boasting
previously, you were provably vulnerable - which means that you
clearly still had problems while you were boasting. A more humble
attitude of Oops, well, that's fixed now without saying Ha ha, now
try to break THAT, I'm oh so perfect now would suit you far better,
based on your history.

ChrisA




Ha, ha ha!
I'm safe now!!

No breaks in this time!
--
https://mail.python.org/mailman/listinfo/python-list


Re: python operational semantics paper

2013-11-10 Thread Terry Reedy

On 11/9/2013 1:35 PM, Paul Rubin wrote:

This looks kind of interesting.

http://cs.brown.edu/~sk/Publications/Papers/Published/pmmwplck-python-full-monty/

Abstract

We present a small-step operational semantics for the Python programming
language. We present both a core language for Python, suitable for tools
and proofs, and a translation process for converting Python source to
this core. We have tested the composition of translation and evaluation
of the core for conformance with the primary Python implementa- tion,
thereby giving confidence in the fidelity of the seman- tics. We briefly
report on the engineering of these compo- nents. Finally, we examine
subtle aspects of the language, identifying scope as a pervasive concern
that even impacts features that might be considered orthogonal.


Thanks for posting this. I found it very interesting but will need more 
time to digest it. I plan to open a separate thread based on one item in 
the paper.


--
Terry Jan Reedy

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


Re: New user's initial thoughts / criticisms of Python

2013-11-10 Thread Ian Kelly
On Sun, Nov 10, 2013 at 2:22 AM, Chris Angelico ros...@gmail.com wrote:
 JavaScript has magic around the dot and function-call operators, as I
 mentioned earlier. Lots of other languages have some little quirk
 somewhere that breaks this rule; some have a LOT of quirks that break
 this rule. Does Python have any? Aside from parsing oddities like
 attribute access on a literal integer[1], are there any cases where
 two expressions yielding the same object are in any way different?

I can think of one:

class Spam:
def __init__(self):
super().__init__()  # This works.

sup = super

class Eggs:
def __init__(self):
sup().__init__()  # This doesn't.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New user's initial thoughts / criticisms of Python

2013-11-10 Thread Chris Angelico
On Sun, Nov 10, 2013 at 10:39 PM, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Sun, Nov 10, 2013 at 2:22 AM, Chris Angelico ros...@gmail.com wrote:
 JavaScript has magic around the dot and function-call operators, as I
 mentioned earlier. Lots of other languages have some little quirk
 somewhere that breaks this rule; some have a LOT of quirks that break
 this rule. Does Python have any? Aside from parsing oddities like
 attribute access on a literal integer[1], are there any cases where
 two expressions yielding the same object are in any way different?

 I can think of one:

 class Spam:
 def __init__(self):
 super().__init__()  # This works.

 sup = super

 class Eggs:
 def __init__(self):
 sup().__init__()  # This doesn't.

Ah, yes, super() is magical. In that particular instance, I think the
magic is better than the alternative, but let's face it: Multiple
inheritance is an inherently hard problem, so a solution that has so
little magic and manages to achieve the goal is doing well. The only
thing that would have been better than this would be making it a piece
of special syntax rather than something that looks like a function
call, but it's too late to change now.

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


Re: New user's initial thoughts / criticisms of Python

2013-11-10 Thread Thomas Rachel

Am 09.11.2013 14:27 schrieb Joshua Landau:


`select` is quite an odd statement, in that in most cases it's just a
weaker variant of `if`. By the time you're at the point where a
`select` is actually more readable you're also at the point where a
different control flow is probably a better idea. Things like
dictionaries or a variables pointing to functions are really useful
and can be encapsulated in a class quite well. This is a bit more
advanced but largely more rigorous.


class Switch(object):
def __init__(self, value):
self.value = value
self.called = False
def case(self, other):
def wr(func):
if not self.called and self.value == other:
self.called = True
return func(self.value)
return wr
def default(self, func):
if not self.called:
self.called = True
return func(self.value)


if __name__ == '__main__':
import random

while 1:
n = random.randrange(0, 5)
sw = Switch (n)
@sw.case(1)
def _(n): print n, is one

@sw.case(2)
def _(n): print n, is two

@sw.default
def _(n): print n, is something else

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


Re: pywin32 programming error on Win7 with shell.SHGetDesktopFolder, desktop.BindToObject, desktop.GetDisplayNameOf

2013-11-10 Thread iMath
I solved it like the following

from win32com.shell import shell, shellcon
import os
def launch_file_explorer(path, files):
'''
Given a absolute base path and names of its children (no path), open
up one File Explorer window with all the child files selected
'''
folder_pidl = shell.SHILCreateFromPath(path,0)[0]
desktop = shell.SHGetDesktopFolder()
shell_folder = desktop.BindToObject(folder_pidl, 
None,shell.IID_IShellFolder)
name_to_item_mapping = dict([(desktop.GetDisplayNameOf(item, 
shellcon.SHGDN_FORPARSING|shellcon.SHGDN_INFOLDER), item) for item in 
shell_folder])
print(name_to_item_mapping)
to_show = []
for file in files:
if file in name_to_item_mapping:
to_show.append(name_to_item_mapping[file])
# else:
# raise Exception('File: %s not found in %s' % (file, path))

shell.SHOpenFolderAndSelectItems(folder_pidl, to_show, 0)



p=r'E:\aa'
print(os.listdir(p))
launch_file_explorer(p, os.listdir(p))
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pywin32 programming error on Win7 with shell.SHGetDesktopFolder, desktop.BindToObject, desktop.GetDisplayNameOf

2013-11-10 Thread iMath
I solved it like the following

from win32com.shell import shell, shellcon
import os
def launch_file_explorer(path, files):
'''
Given a absolute base path and names of its children (no path), open
up one File Explorer window with all the child files selected
'''
folder_pidl = shell.SHILCreateFromPath(path,0)[0]
desktop = shell.SHGetDesktopFolder()
shell_folder = desktop.BindToObject(folder_pidl, 
None,shell.IID_IShellFolder)
name_to_item_mapping = dict([(desktop.GetDisplayNameOf(item, 
shellcon.SHGDN_FORPARSING|shellcon.SHGDN_INFOLDER), item) for item in 
shell_folder])
print(name_to_item_mapping)
to_show = []
for file in files:
if file in name_to_item_mapping:
to_show.append(name_to_item_mapping[file])
# else:
# raise Exception('File: %s not found in %s' % (file, path))

shell.SHOpenFolderAndSelectItems(folder_pidl, to_show, 0)



p=r'E:\aa'
print(os.listdir(p))
launch_file_explorer(p, os.listdir(p))
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Alister
On Sun, 10 Nov 2013 01:44:17 +, ishish wrote:

 Am 09.11.2013 15:07, schrieb Steven D'Aprano:
 ...
 Nikos, you have annoyed and alienated enough people here...
 
 Sorry, I DO NOT AGREE! These threads keep my entire office entertained.
 I would even go so far to suggest, that we should set up an entirely new
 mailing list for Nikos only, maybe something called like
 acropolis-list(at)python.org.
 
 Mea culpa, I am entirely aware that this is an IT list, but hey, when
 you have done 2x65ish hrs per week in a row - standing in for our Ops
 Guy, holidaying - you really start to appreciating little interruptions
 like this...
 
 Greekings ...oops, meant greetings from Tartan-Land,
 
 SasCo

I too am leaning plenty from watching Nicos' tales of woe, thank you 
Nicos.

To repay the favour one instant lesson i can see that you need to apply 
is how you are using the page variable to select pages.

Do not use the value provided as the direct source of the page name 
instead us it as a key to look up the page in a white-list, no where do i 
store that white list? I know how about another database table.
I know you don't seem to like using more than one table Nicos but that is 
daft. they are not rationed  cost nothing.

Also when you fail to find a page in the white-list return nothing, there 
is no point in giving potential hackers any more clues than necessary.

I also suggest you check your firewall you seem to have far more ports 
open to the public internet than should ever be necessary. to follow on 
from one of the other security analogy's posted here you would not put 
the door to your house safe on the outside wall even if you think it has 
a stronger lock than your front door.





-- 
He who despises himself nevertheless esteems himself as a self-despiser.
-- Friedrich Nietzsche
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: datetime question

2013-11-10 Thread unknown
On Sat, 09 Nov 2013 15:43:53 +0200, Νίκος Αλεξόπουλος wrote:

 Στις 9/11/2013 2:45 μμ, ο/η Mark Lawrence έγραψε:
 On 08/11/2013 23:02, Νίκος Αλεξόπουλος wrote:
 Στις 9/11/2013 12:49 πμ, ο/η Denis McMahon έγραψε:
 On Sat, 09 Nov 2013 00:01:37 +0200, Νίκος Αλεξόπουλος wrote:

 I saw the link and i'm wondering if it can be written in 1-liner.

 Yes, but you have to rewrite all your code in perl to do this.



 Please tell me and as a git i will provide you with 2 good pdfs i just
 found:

 You can see them at my website if you click the blue download button.

 The 1st is a Linux Bile and the 2nd is WebHosting for Dummies.

 Why is Web Security for Dummies missing?


 
 It's not missing.
 Its there, check again.
 Just click on the Blue download button and select it from the list of
 buttons.

Try Reading IT!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Antoon Pardon
Op 10-11-13 11:32, Νίκος Αλεξόπουλος schreef:
 Στις 10/11/2013 12:20 πμ, ο/η Chris Angelico έγραψε:

 There are two major problems with
 what you did here, Nikos, and they are:

 1) Starting with a hopelessly insecure system and then trying to
 band-aid patch it one vulnerability at a time, which is folly; and

 2) Boasting that your system was now secure.

 The main issue is the boasting, which is utterly unwarranted
 arrogance. 
,,,

 Ha, ha ha!
 I'm safe now!!
 
 No breaks in this time!

You just can't help yourself, can you? I predict your database will
be broken in, within a week, after which you will plug one leak
and after an other day boast again about how secure your system is,
because you hadn't had a break in after your latest fix.

-- 
Antoon Pardon

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


Re: Basic Python Questions - Oct. 31, 2013

2013-11-10 Thread sigtool
On Q4, you could try Waterloo Graphics http://waterloo.sourceforge.net. Its 
LGPLv3 and, although Java-based, runs in Python via Py4J. It has built-in mouse 
interactivity/GUI editors etc that will all be active when used from Python.

It is Java Swing-based, so e.g. data points can be drawn as standard clickable 
Swing components (see http://waterloo.sourceforge.net/R/scatter.html for an 
example using R [N.B. not interactive on the web site which just shows a 
bit-map]).

For Python examples see http://waterloo.sourceforge.net/python/grid.html







On Thursday, October 31, 2013 9:31:11 AM UTC, E.D.G. wrote:
 Posted by E.D.G. on October 31, 2013
 
 
 
The following are several relatively basic questions regarding 
 Python's 
 
 capabilities.  I am not presently using it myself.  At the moment a number 
 
 of people including myself are comparing it with other programs such as 
 
 XBasic for possible use.
 
 
 
 1.  How fast can Python do math calculations compared with other languages 
 
 such as Fortran and fast versions of Basic.  I would have to believe that it 
 
 is much faster than Perl for doing math calculations.
 
 
 
 2.  Can Python be used to create CGI programs?  These are the ones that run 
 
 on Internet server computers and process data submitted through Web site 
 
 data entry screens etc.  I know that Perl CGI programs will do that.
 
 
 
 3.  If Python can be used for CGI programming, can it draw charts such as 
 
 .png files that will then display on Web pages at a Web site?
 
 
 
 4.  How well does Python work for interactive programming.  For example, if 
 
 a Python program is running on a PC and is drawing a chart, can that chart 
 
 be modified by simply pressing a key while the Python program is running.  I 
 
 have Perl and Gnuplot program combinations that can do that.  Their 
 
 interactive speed is not that great.  But it is adequate for my own uses.
 
 
 
 5.  Can a running Python program send information to the Windows operating 
 
 system as if it were typed in from the keyboard?  Perl can do that and I 
 
 would imagine that Python probably has that same capability.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Mark Lawrence

On 10/11/2013 10:32, Νίκος Αλεξόπουλος wrote:



Ha, ha ha!
I'm safe now!!

No breaks in this time!


She's just biding her time again.  Or was it the little fingers of my 
team?  Clearly you haven't the faintest idea.


I've now come to the conclusion that someone is going to make a fortune 
from these hacking incidents, as the film industry is always looking for 
new material, and this would make one of the greatest comedies ever. 
You could play yourself, you wouldn't need a script, and you could 
certainly help with the screenplay!!!


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: To whoever hacked into my Database

2013-11-10 Thread Νίκος Αλεξόπουλος

Στις 10/11/2013 3:49 μμ, ο/η Antoon Pardon έγραψε:

Op 10-11-13 11:32, Νίκος Αλεξόπουλος schreef:

Στις 10/11/2013 12:20 πμ, ο/η Chris Angelico έγραψε:



There are two major problems with
what you did here, Nikos, and they are:

1) Starting with a hopelessly insecure system and then trying to
band-aid patch it one vulnerability at a time, which is folly; and

2) Boasting that your system was now secure.

The main issue is the boasting, which is utterly unwarranted
arrogance.

,,,


Ha, ha ha!
I'm safe now!!

No breaks in this time!


You just can't help yourself, can you? I predict your database will
be broken in, within a week, after which you will plug one leak
and after an other day boast again about how secure your system is,
because you hadn't had a break in after your latest fix.




It won't break again. 'page' variable cannot be manipulated by arbitrary 
url strings no more.


This time is fixed for good.

Your predictions are wrong.

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


Re: To whoever hacked into my Database

2013-11-10 Thread Mark Lawrence

On 10/11/2013 15:01, Νίκος Αλεξόπουλος wrote:

Στις 10/11/2013 3:49 μμ, ο/η Antoon Pardon έγραψε:

Op 10-11-13 11:32, Νίκος Αλεξόπουλος schreef:

Στις 10/11/2013 12:20 πμ, ο/η Chris Angelico έγραψε:



There are two major problems with
what you did here, Nikos, and they are:

1) Starting with a hopelessly insecure system and then trying to
band-aid patch it one vulnerability at a time, which is folly; and

2) Boasting that your system was now secure.

The main issue is the boasting, which is utterly unwarranted
arrogance.

,,,


Ha, ha ha!
I'm safe now!!

No breaks in this time!


You just can't help yourself, can you? I predict your database will
be broken in, within a week, after which you will plug one leak
and after an other day boast again about how secure your system is,
because you hadn't had a break in after your latest fix.




It won't break again. 'page' variable cannot be manipulated by arbitrary
url strings no more.

This time is fixed for good.

Your predictions are wrong.



I'm not a gambling man, but I'd put my house on the fact that your site 
is so insecure that even the little fingers of my team can get in.



--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: To whoever hacked into my Database

2013-11-10 Thread Νίκος Αλεξόπουλος

Στις 10/11/2013 4:45 μμ, ο/η Mark Lawrence έγραψε:

On 10/11/2013 10:32, Νίκος Αλεξόπουλος wrote:



Ha, ha ha!
I'm safe now!!

No breaks in this time!


She's just biding her time again.  Or was it the little fingers of my
team?



Tell your female friend to polish her nails or do her hair instead as 
she will not be successful any more to mess with any of my 3 scripts.


If it was little fingers tell him to stick those fingers you know where
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Mark Lawrence

On 10/11/2013 15:12, Νίκος Αλεξόπουλος wrote:

Στις 10/11/2013 4:45 μμ, ο/η Mark Lawrence έγραψε:

On 10/11/2013 10:32, Νίκος Αλεξόπουλος wrote:



Ha, ha ha!
I'm safe now!!

No breaks in this time!


She's just biding her time again.  Or was it the little fingers of my
team?



Tell your female friend to polish her nails or do her hair instead as
she will not be successful any more to mess with any of my 3 scripts.


Congratulations, you've just let the cat in amongst the pigeons.  I 
suggest you take cover before the brickbats quite rightly start flying.




If it was little fingers tell him to stick those fingers you know where


I hope you're not suggesting what I think you're suggesting, I couldn't 
possibly make such a statement to a group of four year olds, how dare you.


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: To whoever hacked into my Database

2013-11-10 Thread Antoon Pardon
Op 10-11-13 16:01, Νίκος Αλεξόπουλος schreef:
 Στις 10/11/2013 3:49 μμ, ο/η Antoon Pardon έγραψε:
 Op 10-11-13 11:32, Νίκος Αλεξόπουλος schreef:
 Ha, ha ha!
 I'm safe now!!

 No breaks in this time!

 You just can't help yourself, can you? I predict your database will
 be broken in, within a week, after which you will plug one leak
 and after an other day boast again about how secure your system is,
 because you hadn't had a break in after your latest fix.

 
 It won't break again. 'page' variable cannot be manipulated by
 arbitrary url strings no more.

So you fixed one specific leak and you think that is enough to
declare yourself safe?!

 This time is fixed for good.

The fact that you said this before and were wrong didn't teach
you anything?

 Your predictions are wrong.

And you wonder why people think you are arrogant. You are a perfect
example of the arrogance of the ignorant.

-- 
Antoon Pardon.

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


Re: To whoever hacked into my Database

2013-11-10 Thread Ned Batchelder
On Sunday, November 10, 2013 10:28:46 AM UTC-5, Antoon Pardon wrote:
 Op 10-11-13 16:01, Νίκος Αλεξόπουλος schreef:
  Στις 10/11/2013 3:49 μμ, ο/η Antoon Pardon έγραψε:
  Op 10-11-13 11:32, Νίκος Αλεξόπουλος schreef:
  Ha, ha ha!
  I'm safe now!!
 
  No breaks in this time!
 
  You just can't help yourself, can you? I predict your database will
  be broken in, within a week, after which you will plug one leak
  and after an other day boast again about how secure your system is,
  because you hadn't had a break in after your latest fix.
 
  
  It won't break again. 'page' variable cannot be manipulated by
  arbitrary url strings no more.
 
 So you fixed one specific leak and you think that is enough to
 declare yourself safe?!
 
  This time is fixed for good.
 
 The fact that you said this before and were wrong didn't teach
 you anything?
 
  Your predictions are wrong.
 
 And you wonder why people think you are arrogant. You are a perfect
 example of the arrogance of the ignorant.
 
 -- 
 Antoon Pardon.


Can we please just ignore Nikos' boasts?  The only way to end a Nikos thread is 
to ignore Nikos.  At this point, Mark and Antoon are as much of a problem as 
Nikos is.  Continuing to insult and bait Nikos just prolongs the noise.  Yes, 
we know he is wrong.  But no amount of nyah-nyah posts is going to convince 
him.  We have to settle for an end to the thread.

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


Re: Py 3.3.2, MacBookPro, segmentation fault, GCC issue?

2013-11-10 Thread Laurent Pointal
John Ladasky wrote:

 I am trying to help a student of mine install Python 3 on his MacBook Pro.
zip
 Follow-up questions: if I need a more current GCC for my student's Mac,
 how do I obtain it?  And are there any backwards-compatibility issues I
 might need to worry about if I do upgrade?  From my Linux experience,
 upgrading GCC has never caused problems.  But I want to be cautious, since
 this isn't my computer I'll be playing with, but someone else's.

AFAIK Apple stop delivering new gcc when it goes to GPL3 licence. 
In place, they use llvm compiler tool.

See discussions and links in
http://stackoverflow.com/questions/9353444/how-to-use-install-gcc-on-mac-os-x-10-8-xcode-4-4

There may be other solutions, but you should prefer ask in a specific MacOS
usenet group.

A+

 
 Thanks for any advice you may have.
-- 
Laurent POINTAL - laurent.poin...@laposte.net

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


Re: To whoever hacked into my Database

2013-11-10 Thread Νίκος Αλεξόπουλος

Στις 10/11/2013 5:28 μμ, ο/η Antoon Pardon έγραψε:

Op 10-11-13 16:01, Νίκος Αλεξόπουλος schreef:

Στις 10/11/2013 3:49 μμ, ο/η Antoon Pardon έγραψε:

Op 10-11-13 11:32, Νίκος Αλεξόπουλος schreef:

Ha, ha ha!
I'm safe now!!

No breaks in this time!


You just can't help yourself, can you? I predict your database will
be broken in, within a week, after which you will plug one leak
and after an other day boast again about how secure your system is,
because you hadn't had a break in after your latest fix.



It won't break again. 'page' variable cannot be manipulated by
arbitrary url strings no more.


So you fixed one specific leak and you think that is enough to
declare yourself safe?!


This time is fixed for good.


The fact that you said this before and were wrong didn't teach
you anything?


Your predictions are wrong.


And you wonder why people think you are arrogant. You are a perfect
example of the arrogance of the ignorant.


Really?

I have even pasted the code as i used to had it and the new correction i 
have made.


Since my code is so crappy try to mess with the script and databases 
since you re so competent and smart

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


Re: To whoever hacked into my Database

2013-11-10 Thread Petite Abeille

On Nov 10, 2013, at 4:28 PM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote:

 You are a perfect example of the arrogance of the ignorant.

Finally! The Dunning–Kruger effect proven beyond a doubt.


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


Re: To whoever hacked into my Database

2013-11-10 Thread Νίκος Αλεξόπουλος

Στις 10/11/2013 7:57 μμ, ο/η Petite Abeille έγραψε:


On Nov 10, 2013, at 4:28 PM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote:


You are a perfect example of the arrogance of the ignorant.


Finally! The Dunning–Kruger effect proven beyond a doubt.





You are a moron, no doubt! Freddy Kruger Effect!
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Petite Abeille

On Nov 10, 2013, at 7:46 PM, Νίκος Αλεξόπουλος nikos.gr...@gmail.com wrote:

 You are a moron

Rumor has it you are the head of ELSTAT, the Hellenic Statistical Authority. 
Any truth to that?

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


Re: To whoever hacked into my Database

2013-11-10 Thread Νίκος Αλεξόπουλος

Στις 10/11/2013 9:16 μμ, ο/η Petite Abeille έγραψε:


On Nov 10, 2013, at 7:46 PM, Νίκος Αλεξόπουλος nikos.gr...@gmail.com wrote:


You are a moron


Rumor has it you are the head of ELSTAT, the Hellenic Statistical Authority. 
Any truth to that?




Perhaps i'm working for NSA too and i was assigned to keep an eye on 
what's happening on Python News Lists.

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


[RELEASE] Python 2.7.6

2013-11-10 Thread Benjamin Peterson
Python 2.7.6 is now available.

This release resolves crashes of the interactive interpreter on OS X 10.9. The
final release also fixes several issues identified in the release
candidate. Importantly, a security bug in CGIHTTPServer was fixed [1]. Thank you
to those who tested the 2.7.6 release candidate and reported these bugs!

All the changes in Python 2.7.6 are described in full detail in the Misc/NEWS
file of the source tarball. You can also view online at

http://hg.python.org/cpython/raw-file/99d03261c1ba/Misc/NEWS

Downloads are at

http://python.org/download/releases/2.7.6/

As always, report bugs to

http://bugs.python.org/

Have a nice November,
Benjamin Peterson
2.7 Release Manager

[1] http://bugs.python.org/issue19435
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Petite Abeille

On Nov 10, 2013, at 8:21 PM, Νίκος Αλεξόπουλος nikos.gr...@gmail.com wrote:

 Perhaps

You're in a desert, walking along in the sand, when all of a sudden you look 
down and see a tortoise. It's crawling toward you. You reach down and you flip 
the tortoise over on its back. The tortoise lays on its back, its belly baking 
in the hot sun, beating its legs trying to turn itself over, but it can't. Not 
without your help. But you're not helping. Why is that?

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


Re: To whoever hacked into my Database

2013-11-10 Thread Rod Person
On Sun, 10 Nov 2013 20:32:11 +0100
Petite Abeille petite.abei...@gmail.com wrote:
 
 On Nov 10, 2013, at 8:21 PM, Νίκος Αλεξόπουλος
 nikos.gr...@gmail.com wrote:
 
  Perhaps
 
 You're in a desert, walking along in the sand, when all of a sudden
 you look down and see a tortoise. It's crawling toward you. You reach
 down and you flip the tortoise over on its back. The tortoise lays on
 its back, its belly baking in the hot sun, beating its legs trying to
 turn itself over, but it can't. Not without your help. But you're not
 helping. Why is that?
 

Tortoise? What's a tortoise?


LOL!  Officially now the best thread every on the internet.

From a lurker that has been watching the slow train wreck.

-- 
Rod

http://www.rodperson.com

He who knows himself to be one way and pretends it is another way is a
thief who robs his own soul.

  The Mahabharata
 Sakuntala 25
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Antoon Pardon
Op 10-11-13 17:15, Ned Batchelder schreef:
 On Sunday, November 10, 2013 10:28:46 AM UTC-5, Antoon Pardon wrote:
 Op 10-11-13 16:01, Νίκος Αλεξόπουλος schreef:
 Στις 10/11/2013 3:49 μμ, ο/η Antoon Pardon έγραψε:
 Op 10-11-13 11:32, Νίκος Αλεξόπουλος schreef:
 Ha, ha ha!
 I'm safe now!!

 No breaks in this time!

 You just can't help yourself, can you? I predict your database will
 be broken in, within a week, after which you will plug one leak
 and after an other day boast again about how secure your system is,
 because you hadn't had a break in after your latest fix.


 It won't break again. 'page' variable cannot be manipulated by
 arbitrary url strings no more.

 So you fixed one specific leak and you think that is enough to
 declare yourself safe?!

 This time is fixed for good.

 The fact that you said this before and were wrong didn't teach
 you anything?

 Your predictions are wrong.

 And you wonder why people think you are arrogant. You are a perfect
 example of the arrogance of the ignorant.

 -- 
 Antoon Pardon.
 
 
 Can we please just ignore Nikos' boasts? 

When I'm bored with them. I don't understand why you suddenly complain.
This whole thread started with what amounts to a boast. So why wait
four days before you ask for them to be ignored.

 The only way to end a Nikos thread is to ignore Nikos.  At this point,
 Mark and Antoon are as much of a problem as Nikos is. Continuing to
 insult and bait Nikos just prolongs the noise.  Yes, we know he is wrong.
 But no amount of nyah-nyah posts is going to convince him.  We have to
 settle for an end to the thread.

This much we new when the thread started. Thus IMO all those that reacted
and blew life into this thread are to blame that it could flourish. But
it seemed they were having their fun. So why shouldn't I have my fun now?
They were a problem then, I am a problem now, that seems perfectly fair.

-- 
Antoon Pardon

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


Re: To whoever hacked into my Database

2013-11-10 Thread Chris “Kwpolska” Warrick
On Nov 10, 2013 9:01 PM, Rod Person rodper...@rodperson.com wrote:
 Tortoise? What's a tortoise?
Is that a real question? If yes, then it's an animal, similar to a turtle.
Ask Google or Wikipedia for more details.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Rod Person
On Sun, 10 Nov 2013 21:41:54 +0100
Chris “Kwpolska” Warrick kwpol...@gmail.com wrote:

 On Nov 10, 2013 9:01 PM, Rod Person rodper...@rodperson.com wrote:
  Tortoise? What's a tortoise?
 Is that a real question? If yes, then it's an animal, similar to a
 turtle. Ask Google or Wikipedia for more details.

Check the movie Blade Runner.

-- 
Rod

http://www.rodperson.com

He who knows himself to be one way and pretends it is another way is a
thief who robs his own soul.

  The Mahabharata
 Sakuntala 25
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-10 Thread Rod Person
On Sun, 10 Nov 2013 21:41:54 +0100
Chris “Kwpolska” Warrick kwpol...@gmail.com wrote:

 On Nov 10, 2013 9:01 PM, Rod Person rodper...@rodperson.com wrote:
  Tortoise? What's a tortoise?
 Is that a real question? If yes, then it's an animal, similar to a
 turtle. Ask Google or Wikipedia for more details.

http://youtu.be/Umc9ezAyJv0?t=1m10s

-- 
Rod

http://www.rodperson.com

He who knows himself to be one way and pretends it is another way is a
thief who robs his own soul.

  The Mahabharata
 Sakuntala 25
-- 
https://mail.python.org/mailman/listinfo/python-list


Help - Exercise Decision

2013-11-10 Thread kennedysalvino . ks
I'm trying to make a ranking of 3 numbers and say which the greatest and 
consider whether there is a tie between them, I am not able to make the 
conditions of draws.  

Code in PT-BR: http://pastebin.com/18pYJjPC
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New user's initial thoughts / criticisms of Python

2013-11-10 Thread Chris Angelico
On Mon, Nov 11, 2013 at 4:12 AM, Dennis Lee Bieber
wlfr...@ix.netcom.com wrote:
 -123 .bit_length()
 -7

 No parens needed if a space precedes the .

Heh! I would call that an inferior alternative to the parentheses
though; it's so unusual to put a space before the dot that I wouldn't
consider it something to do in normal code. Anyone coming through and
editing would see it as a mistake to be fixed.

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


Re: To whoever hacked into my Database

2013-11-10 Thread Chris Angelico
On Mon, Nov 11, 2013 at 7:41 AM, Chris “Kwpolska” Warrick
kwpol...@gmail.com wrote:
 On Nov 10, 2013 9:01 PM, Rod Person rodper...@rodperson.com wrote:
 Tortoise? What's a tortoise?
 Is that a real question? If yes, then it's an animal, similar to a turtle.
 Ask Google or Wikipedia for more details.

The Master was an old Turtle. We called him Tortoise...

Why did you call him Tortoise if he wasn't one?

We called him Tortoise because he taught us! Really, you are very dull.

-- the Mock Turtle explaining his lessons to Alice (they lessened
every day, and I still have no idea how they managed on the twelfth
day).

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


Re: my favorite line of py code so far

2013-11-10 Thread Peter Cacioppi
Chris said :

Absolutely! The unfortunate truth, though, is that idioms that
resonate with you _and nobody else_ are just as big a problem as bugs,
because they're unmaintainable. So hopefully what you're doing will
make sense to other people too! 

There is some truth in what you say ...  but in this case we're talking about 
an algorithmically trivial portion of a project for which I am basically BDFL. 
So as long as I'm not totally in left field, I'm going with what feels truthy 
to me.

Also, 

  lambda c : lambda x : c(*x)

would make a sweet tattoo. Much better than some Kanji that might as well 
translate into dumb white guy for all I know ;)
 



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


Re: New user's initial thoughts / criticisms of Python

2013-11-10 Thread Terry Reedy

On 11/10/2013 6:29 PM, Chris Angelico wrote:

On Mon, Nov 11, 2013 at 4:12 AM, Dennis Lee Bieber
wlfr...@ix.netcom.com wrote:

-123 .bit_length()

-7

 No parens needed if a space precedes the .


Heh! I would call that an inferior alternative to the parentheses
though; it's so unusual to put a space before the dot that I wouldn't
consider it something to do in normal code. Anyone coming through and
editing would see it as a mistake to be fixed.


I have only used int methods in interactive exploration, and have always 
used space. I have never used (), but agree that they are better for 
permanent code. The -7 is really nasty (unless one were to actually want 
that).


--
Terry Jan Reedy

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


Re: python operational semantics paper

2013-11-10 Thread Gregory Ewing

Paul Rubin wrote:


http://cs.brown.edu/~sk/Publications/Papers/Published/pmmwplck-python-full-monty/

Abstract

We present a small-step operational semantics for the Python programming
language.


I noticed one thing they seem to have missed. They
assume that

   a + b

is equivalent to

   a.__add__(b)

when, as many of us know, it's considerably more
complicated than that.

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


Re: Help - Exercise Decision

2013-11-10 Thread Gary Herron

On 11/10/2013 02:56 PM, kennedysalvino...@gmail.com wrote:

I'm trying to make a ranking of 3 numbers and say which the greatest and 
consider whether there is a tie between them, I am not able to make the 
conditions of draws.

Code in PT-BR: http://pastebin.com/18pYJjPC


Please post the code directly in this message.  As a matter of 
safe-browsing practices, I won't follow that link.


One tests for equality (draws as you call them) with the == operator.
In what way does that not work for you?  Your question is so terse, that 
I'm not sure what you want.  Provide some examples please.


Gary Herron

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


Re: Help - Exercise Decision

2013-11-10 Thread Kennedy Salvino
Em domingo, 10 de novembro de 2013 21h34min39s UTC-3, Gary Herron  escreveu:
 On 11/10/2013 02:56 PM, kennedysalvino...@gmail.com wrote:
 
  I'm trying to make a ranking of 3 numbers and say which the greatest and 
  consider whether there is a tie between them, I am not able to make the 
  conditions of draws.
 
 
 
  Code in PT-BR: http://pastebin.com/18pYJjPC
 
 
 
 Please post the code directly in this message.  As a matter of 
 
 safe-browsing practices, I won't follow that link.
 
 
 
 One tests for equality (draws as you call them) with the == operator.
 
 In what way does that not work for you?  Your question is so terse, that 
 
 I'm not sure what you want.  Provide some examples please.
 
 
 
 Gary Herron


Using only if elif else, here is the code

primeira_pontuacao = int(input(Digite a primeira pontuação: ))
segunda_pontuacao = int(input(Digite a segunda pontuação: ))
terceira_pontuacao = int(input(Digite a terceira pontuação: ))
'''
empate = primeira_pontuacao == segunda_pontuacao or terceira_pontuacao
empate2 = segunda_pontuacao == primeira_pontuacao or terceira_pontuacao
empate3 = terceira_pontuacao == primeira_pontuacao or segunda_pontuacao
empate4 = primeira_pontuacao == terceira_pontuacao != segunda_pontuacao
empate5 = segunda_pontuacao == terceira_pontuacao != primeira_pontuacao
empate6 = terceira_pontuacao == segunda_pontuacao != primeira_pontuacao
empate7 = primeira_pontuacao == segunda_pontuacao == terceira_pontuacao
'''
colocacao1 = 0
colocacao2 = 0
colocacao3 = 0

if (primeira_pontuacao  segunda_pontuacao):
if(segunda_pontuacao  terceira_pontuacao):
colocacao1 = primeira_pontuacao
colocacao2 = segunda_pontuacao
colocacao3 = terceira_pontuacao 
else:
colocacao1 = primeira_pontuacao
colocacao2 = terceira_pontuacao
colocacao3 = segunda_pontuacao
elif (segunda_pontuacao  terceira_pontuacao):
if(terceira_pontuacao  primeira_pontuacao):
colocacao1 = segunda_pontuacao  
colocacao2 = terceira_pontuacao
colocacao3 = primeira_pontuacao
else:
colocacao1 = segunda_pontuacao
colocacao2 = primeira_pontuacao
colocacao3 = terceira_pontuacao
elif (terceira_pontuacao  segunda_pontuacao):
if(segunda_pontuacao  primeira_pontuacao):
colocacao1 = terceira_pontuacao
colocacao2 = segunda_pontuacao 
colocacao3 = primeira_pontuacao
else:
colocacao1 = terceira_pontuacao
colocacao2 = primeira_pontuacao 
colocacao3 = segunda_pontuacao
elif (primeira_pontuacao  terceira_pontuacao):
if(terceira_pontuacao  segunda_pontuacao):
colocacao1 = primeira_pontuacao
colocacao2 = terceira_pontuacao
colocacao3 = segunda_pontuacao
else:
colocacao1 = primeira_pontuacao
colocacao2 = segunda_pontuacao
colocacao3 = terceira_pontuacao
elif (segunda_pontuacao  primeira_pontuacao):
if (primeira_pontuacao  terceira_pontuacao):
colocacao1 = segunda_pontuacao
colocacao2 = primeira_pontuacao
colocacao3 = terceira_pontuacao
else:
colocacao2 = segunda_pontuacao
colocacao3 = terceira_pontuacao
colocacao1 = primeira_pontuacao
elif (terceira_pontuacao  primeira_pontuacao):
if(primeira_pontuacao  segunda_pontuacao):
colocacao1 = terceira_pontuacao
colocacao2 = primeira_pontuacao
colocacao3 = segunda_pontuacao
else:
colocacao1 = terceira_pontuacao
colocacao2 = segunda_pontuacao
colocacao3 = primeira_pontuacao

print(O primeiro:  , colocacao1)
print(O segundo: , colocacao2)
print(O terceiro: , colocacao3)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Code with random module faster on the vm than the vm host...

2013-11-10 Thread alex23

On 9/11/2013 3:48 AM, Pascal Bit wrote:

from random import random

 [...]


Running on win7 python 2.7 32 bit it uses around 30 seconds avg.
Running on xubuntu, 32 bit, on vmware on windows 7: 20 seconds!
The code runs faster on vm, than the computer itself...
The python version in this case is 1.5 times faster...
I don't understand.

What causes this?


The random module uses os.urandom, which relies on OS implementations of 
randomness functionality:


On a UNIX-like system this will query /dev/urandom, and on Windows it 
will use CryptGenRandom().


http://docs.python.org/2/library/os.html#miscellaneous-functions

The linux implementation appears to be faster.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Code with random module faster on the vm than the vm host...

2013-11-10 Thread Robert Kern

On 2013-11-11 00:49, alex23 wrote:

On 9/11/2013 3:48 AM, Pascal Bit wrote:

from random import random

  [...]


Running on win7 python 2.7 32 bit it uses around 30 seconds avg.
Running on xubuntu, 32 bit, on vmware on windows 7: 20 seconds!
The code runs faster on vm, than the computer itself...
The python version in this case is 1.5 times faster...
I don't understand.

What causes this?


The random module uses os.urandom,


No, it doesn't. random.random() is an alias to the random() method on the 
random.Random class, which uses the Mersenne Twister to generate values. 
os.urandom() gets called in the initial default seeding, but not for each value.


--
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco

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


Re: Code with random module faster on the vm than the vm host...

2013-11-10 Thread Ned Batchelder
On Friday, November 8, 2013 12:48:04 PM UTC-5, Pascal Bit wrote:
 Here's the code:
 
 from random import random
 from time import clock
 
 s = clock()
 
 for i in (1, 2, 3, 6, 8):
  M = 0
  N = 10**i
 
  for n in xrange(N):
  r = random()
  if 0.5  r  0.6:
  M += 1
 
  k = (N, float(M)/N)
 
 print (clock()-s)
 
 Running on win7 python 2.7 32 bit it uses around 30 seconds avg.
 Running on xubuntu, 32 bit, on vmware on windows 7: 20 seconds!
 The code runs faster on vm, than the computer itself...
 The python version in this case is 1.5 times faster...
 I don't understand.
 
 What causes this?

The docs for time.clock() make clear that the meaning on Windows and Unix are 
different:

On Unix, return the current processor time as a floating point number 
expressed in seconds.

On Windows, this function returns wall-clock seconds elapsed since the first 
call to this function...

Try the experiment again with time.time() instead.

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


Re: Code with random module faster on the vm than the vm host...

2013-11-10 Thread Mark Lawrence

On 11/11/2013 01:15, Ned Batchelder wrote:

On Friday, November 8, 2013 12:48:04 PM UTC-5, Pascal Bit wrote:

Here's the code:

from random import random
from time import clock

s = clock()

for i in (1, 2, 3, 6, 8):
  M = 0
  N = 10**i

  for n in xrange(N):
  r = random()
  if 0.5  r  0.6:
  M += 1

  k = (N, float(M)/N)

print (clock()-s)

Running on win7 python 2.7 32 bit it uses around 30 seconds avg.
Running on xubuntu, 32 bit, on vmware on windows 7: 20 seconds!
The code runs faster on vm, than the computer itself...
The python version in this case is 1.5 times faster...
I don't understand.

What causes this?


The docs for time.clock() make clear that the meaning on Windows and Unix are 
different:

On Unix, return the current processor time as a floating point number expressed in 
seconds.

On Windows, this function returns wall-clock seconds elapsed since the first call 
to this function...

Try the experiment again with time.time() instead.

--Ned.



http://www.python.org/dev/peps/pep-0418/ for some related reading about 
Python time functions.


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: [Python-Dev] [RELEASE] Python 2.7.6

2013-11-10 Thread Victor Stinner
2013/11/10 Benjamin Peterson benja...@python.org:
 All the changes in Python 2.7.6 are described in full detail in the Misc/NEWS
 file of the source tarball. You can also view online at

 http://hg.python.org/cpython/raw-file/99d03261c1ba/Misc/NEWS

- Issue #18747: Re-seed OpenSSL's pseudo-random number generator after fork.
  A pthread_atfork() parent handler is used to seed the PRNG with pid, time
  and some stack data.

Is this changeset in Python 2.7.6 or not?

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


Re: [Python-Dev] [RELEASE] Python 2.7.6

2013-11-10 Thread Benjamin Peterson
2013/11/10 Victor Stinner victor.stin...@gmail.com:
 2013/11/10 Benjamin Peterson benja...@python.org:
 All the changes in Python 2.7.6 are described in full detail in the Misc/NEWS
 file of the source tarball. You can also view online at

 http://hg.python.org/cpython/raw-file/99d03261c1ba/Misc/NEWS

 - Issue #18747: Re-seed OpenSSL's pseudo-random number generator after fork.
   A pthread_atfork() parent handler is used to seed the PRNG with pid, time
   and some stack data.

 Is this changeset in Python 2.7.6 or not?

It was backed out, but evidently the news entry wasn't removed.


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


Re: Code with random module faster on the vm than the vm host...

2013-11-10 Thread alex23

On 11/11/2013 11:19 AM, Robert Kern wrote:

On 2013-11-11 00:49, alex23 wrote:

The random module uses os.urandom,


No, it doesn't. random.random() is an alias to the random() method on
the random.Random class, which uses the Mersenne Twister to generate
values. os.urandom() gets called in the initial default seeding, but not
for each value.


That's what I get for rapidly skimming the module rather than looking at 
it carefully.


Cheers.

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



Re: Help - Exercise Decision

2013-11-10 Thread Gary Herron

On 11/10/2013 04:48 PM, Kennedy Salvino wrote:

Em domingo, 10 de novembro de 2013 21h34min39s UTC-3, Gary Herron  escreveu:

On 11/10/2013 02:56 PM, kennedysalvino...@gmail.com wrote:


I'm trying to make a ranking of 3 numbers and say which the greatest and 
consider whether there is a tie between them, I am not able to make the 
conditions of draws.
Code in PT-BR: http://pastebin.com/18pYJjPC



Please post the code directly in this message.  As a matter of

safe-browsing practices, I won't follow that link.



One tests for equality (draws as you call them) with the == operator.

In what way does that not work for you?  Your question is so terse, that

I'm not sure what you want.  Provide some examples please.



Gary Herron


Using only if elif else, here is the code




Holy HELL man, that's a lot of code for such a simple problem. But 
perhaps your assignment requires you to do it this way. (In which case 
I'd have a word with your teacher.)


But assuming you've got the sorting part correct, (which you don't quite 
-- the three numbers 2 1 3 entered in that order don't sort correctly), 
I'll guess the problem is in the 8 lines you have triple-quoted out, true?


The first of those lines won't do what I think you are trying to do. Try 
this instead (I'm using a, b, and c instead of your variables):

empate = a==b or a==c
Each == test produces a True/False value and the or combines the two 
into a single True/False. Your code

empata = a == b or c
does something much different.

That being said, I have to question what you are going to do with 8 such 
computations. A single test like

if a==b or b==c or a==c:
would tell you if any two of the three values are equal. Do you need 
more information than that?


And then I feel compelled to add one more comment: Your method of 
sorting three numbers is extremely wordy and inefficient. What part of 
that did you invent, and what part is forced on you by your teacher? Are 
you allowed to be “smarter” about it, and would you like some advice on 
that part?


Gary Herron





primeira_pontuacao = int(input(Digite a primeira pontuação: ))
segunda_pontuacao = int(input(Digite a segunda pontuação: ))
terceira_pontuacao = int(input(Digite a terceira pontuação: ))
'''
empate = primeira_pontuacao == segunda_pontuacao or terceira_pontuacao
empate2 = segunda_pontuacao == primeira_pontuacao or terceira_pontuacao
empate3 = terceira_pontuacao == primeira_pontuacao or segunda_pontuacao
empate4 = primeira_pontuacao == terceira_pontuacao != segunda_pontuacao
empate5 = segunda_pontuacao == terceira_pontuacao != primeira_pontuacao
empate6 = terceira_pontuacao == segunda_pontuacao != primeira_pontuacao
empate7 = primeira_pontuacao == segunda_pontuacao == terceira_pontuacao
'''
colocacao1 = 0
colocacao2 = 0
colocacao3 = 0

if (primeira_pontuacao  segunda_pontuacao):
 if(segunda_pontuacao  terceira_pontuacao):
 colocacao1 = primeira_pontuacao
 colocacao2 = segunda_pontuacao
 colocacao3 = terceira_pontuacao
 else:
 colocacao1 = primeira_pontuacao
 colocacao2 = terceira_pontuacao
 colocacao3 = segunda_pontuacao
elif (segunda_pontuacao  terceira_pontuacao):
 if(terceira_pontuacao  primeira_pontuacao):
 colocacao1 = segunda_pontuacao
 colocacao2 = terceira_pontuacao
 colocacao3 = primeira_pontuacao
 else:
 colocacao1 = segunda_pontuacao
 colocacao2 = primeira_pontuacao
 colocacao3 = terceira_pontuacao
elif (terceira_pontuacao  segunda_pontuacao):
 if(segunda_pontuacao  primeira_pontuacao):
 colocacao1 = terceira_pontuacao
 colocacao2 = segunda_pontuacao
 colocacao3 = primeira_pontuacao
 else:
 colocacao1 = terceira_pontuacao
 colocacao2 = primeira_pontuacao
 colocacao3 = segunda_pontuacao
elif (primeira_pontuacao  terceira_pontuacao):
 if(terceira_pontuacao  segunda_pontuacao):
 colocacao1 = primeira_pontuacao
 colocacao2 = terceira_pontuacao
 colocacao3 = segunda_pontuacao
 else:
 colocacao1 = primeira_pontuacao
 colocacao2 = segunda_pontuacao
 colocacao3 = terceira_pontuacao
elif (segunda_pontuacao  primeira_pontuacao):
 if (primeira_pontuacao  terceira_pontuacao):
 colocacao1 = segunda_pontuacao
 colocacao2 = primeira_pontuacao
 colocacao3 = terceira_pontuacao
 else:
 colocacao2 = segunda_pontuacao
 colocacao3 = terceira_pontuacao
 colocacao1 = primeira_pontuacao
elif (terceira_pontuacao  primeira_pontuacao):
 if(primeira_pontuacao  segunda_pontuacao):
 colocacao1 = terceira_pontuacao
 colocacao2 = primeira_pontuacao
 colocacao3 = segunda_pontuacao
 else:
 colocacao1 = terceira_pontuacao
 colocacao2 = segunda_pontuacao
 colocacao3 = primeira_pontuacao

print(O primeiro:  , colocacao1)
print(O segundo: , colocacao2)
print(O terceiro: , colocacao3)


Re: Help - Exercise Decision

2013-11-10 Thread Mark Lawrence

On 11/11/2013 02:26, Gary Herron wrote:

On 11/10/2013 04:48 PM, Kennedy Salvino wrote:

Em domingo, 10 de novembro de 2013 21h34min39s UTC-3, Gary Herron
escreveu:

On 11/10/2013 02:56 PM, kennedysalvino...@gmail.com wrote:


I'm trying to make a ranking of 3 numbers and say which the greatest
and consider whether there is a tie between them, I am not able to
make the conditions of draws.
Code in PT-BR: http://pastebin.com/18pYJjPC



Please post the code directly in this message.  As a matter of

safe-browsing practices, I won't follow that link.



One tests for equality (draws as you call them) with the == operator.

In what way does that not work for you?  Your question is so terse, that

I'm not sure what you want.  Provide some examples please.



Gary Herron


Using only if elif else, here is the code




Holy HELL man, that's a lot of code for such a simple problem. But
perhaps your assignment requires you to do it this way. (In which case
I'd have a word with your teacher.)

But assuming you've got the sorting part correct, (which you don't quite
-- the three numbers 2 1 3 entered in that order don't sort correctly),
I'll guess the problem is in the 8 lines you have triple-quoted out, true?

The first of those lines won't do what I think you are trying to do. Try
this instead (I'm using a, b, and c instead of your variables):
empate = a==b or a==c
Each == test produces a True/False value and the or combines the two
into a single True/False. Your code
empata = a == b or c
does something much different.

That being said, I have to question what you are going to do with 8 such
computations. A single test like
if a==b or b==c or a==c:
would tell you if any two of the three values are equal. Do you need
more information than that?

And then I feel compelled to add one more comment: Your method of
sorting three numbers is extremely wordy and inefficient. What part of
that did you invent, and what part is forced on you by your teacher? Are
you allowed to be “smarter” about it, and would you like some advice on
that part?

Gary Herron




Regardless of the way the OP goes about it the use of print functions or 
a debugger wouldn't go amiss.


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


PyWart: Packages (oh how thou art lacking!)

2013-11-10 Thread Rick Johnson


 The Pros of Python Packages:


  Python packages require no special syntax to declare which
  modules are members of the package. Instead, Python simply
  allows the programmer to utilize the hierarchy of his file
  system to decide *which* modules are in *which* packages.

  Sure you've got to create a __init__.py file under the
  directory which will become the package, which is just one
  operation to preform, as opposed to writing uses package
  blah in every damn source file!

  But the real genius is in the consistency!

  By utilizing such a novel approach to packaging, the
  implementation of Python packages remains consistent with
  Python modules. Let's face it people, packaging by any
  other means is just re-inventing the wheel!


 The Cons of Python Packages:


  1. No ability to EASILY share state between package
  members. Sure you can import and inject symbols until
  you're fingers bleed, but all you've done is create an
  unmaintainable spaghetti mess!

  2. Attempting to use packages to create a hierarchy of
  library modules is even more difficult and opens a
  Pandora's box of confusion, circular imports, name errors,
  unintended side effects, etc, etc...


 What should a package be anyway?


  Whilst python packages can be useful, their design is so
  woefully inadequate as to render them almost useless. To
  describe the disparities using an example:

Imagine if classes were nothing more than an
encapsulation of N functions that share information via
a global variable self -- no inheritance, no
polymorphism, no overloading, no blah blah blah...

  Sure, i could find a use for such a type, but the usage
  would be painfully limited.

  So now we find ourselves faced with the reality of the
  glaring question -- What the hell should a python package
  be exactly?

  A package SHOULD be an extrapolation of the namespace
  methodology, in the purest form. You start with local
  scope, then you proceed to module level scope, then
  package level scope (well, that's my wish anyway!), and
  finally, global scope[*]

  Just as class members can share information easily via
  self, package members should have this ability also.


 Some food for thought...


  Namespaces are one honking great idea -- let's do more of
  those!


 REFERENCES:

  [*] Even though Python does not officially support
  global variables, you can emulate such functionality by
  injecting objects into __builtins__, since __builtins__ is
  available in every module namespace.
-- 
https://mail.python.org/mailman/listinfo/python-list


PyWart: Python modules are not so modular after all!

2013-11-10 Thread Rick Johnson


 The Pros of Python Modules:


  Python modules require no special syntax to create, nor do
  they induce extra indentation in your source code to
  maintain readability. Simply write some Python code in an
  editor, save it with a py|pyw extension, throw in a
  directory that python can find, and WHAMO, you've got
  yourself an importable module namespace!

  Of all the package implementations i've seen, Python's use
  of the source file as a module is absolutely my favorite

  But don't pucker up your benevolent anus just yet!


 The Cons of Python Modules:


  1. Modules cannot be extended or manipulated by the
  programmer. Basically the PyGods have handed us modules,
  but they failed to give us any tools to manipulate them --
  heck, they might as well have blessed us an unlimited
  supply of high carbon steel but cursed us with an
  atmosphere that does not support combustion.

  What good is ANY namespace when you cannot override it's
  fundamental interface? And interfaces are the key to OOP!

  Is __setattr__/__getattr__ ringing a bell people?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New user's initial thoughts / criticisms of Python

2013-11-10 Thread Rick Johnson
On Saturday, November 9, 2013 10:30:26 AM UTC-6, rusi wrote:
 [...]
 Well

 print ( {mon:mondays suck,
  tue:at least it's not monday,
  wed:humpday
 }.get(day_of_week,its some other day)
   )
 may be dense
 Separate into named dictionary and its ok (I think!)

Proper code formatting can do WONDERS for readability!

## START CODE ##
d = {
mon:mondays suck,
tue:at least it's not monday,
wed:humpday
}
default = some other day
target = tue
print d.get(target, default)
target = blah
print d.get(target, default)
## END CODE ##

Of course you could create something reusable and interface-ee.

## START CODE ##
class UsageError(Exception):
pass

class Case(object):
def __init__(self, defaultDict=None, defaultValue=None):
self.d = defaultDict or {}
self.defaultValue = defaultValue

def __str__(self):
return Case({0}).format(self.d)

def __call__(self, key):
try:
v = self.d[key]
except KeyError:
v = self.defaultValue
return v

def __getitem__(self, k):
raise UsageError(RTFS MAN!!!)

if __name__ == '__main__':
import calendar
d = {
mon:mondays suck,
tue:at least it's not monday,
wed:humpday
}
case = Case(d, some other day)
try:
case[tue]
except UsageError:
print 'Stopped improper useage.'
print case
lst = [s.lower() for s in calendar.weekheader(3).split(' ')]
for dayName in lst:
print Case.__call__({0!r}) - {1!r}.format(dayName, case(dayName))
## END CODE ##

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


Re: The narcissism of small code differences

2013-11-10 Thread Rick Johnson
On Saturday, November 9, 2013 6:42:04 AM UTC-6, Steven
D'Aprano wrote: 
 Uses an example written in Ruby, but don't
 let that put you off:

Why would it? I write Ruby code all the time. Ruby code in
and of itself does not bother me, what bothers me about Ruby
is the ease at which a programmer can write inconsistent and
convoluted code -- evidenced by the poor examples in your
linked article. Case in point.

To save anyone else from reading this long-winded blab
fest chalk full the driest humor and cyclic illogical
meandering that could make a ferris-wheel blush with
jealousy...

  In a nutshell the author attempts to plead for the
  longevity of old code bases simply on the basis of his
  assertion that old code bases are less buggy and
  contain more wisdom than their new brethren -- both of
  which are absurd conclusions!
  
Now, whilst he is correct regarding the narcissism of
programmers (i must admit we are all guilty of this deadly
sin), his attempts to draw parallels between Freudian
pathologies and software development idiosyncrasies is,
in fact, the very HEIGHT of sophistry!

Has the author considered that new functionality often
renders old code bases useless, or at the very least,
antiquated? Even code bases that are in fact bug free (for
*some* definition of bug free!)

Has the author consider that changes in external
dependencies can render a code base useless? Py3000 ring
a bell folks?

Is the author also unaware of evolution? 

Doth he falsely believe that even the BEST programmer can
look back on code he wrote a few years ago and not think of
some way it could be improved? GvR had such a realization
not so long ago -- and then there was Py3000!!!

From something as simple as code restructuring for
readabilities sake; to choosing better naming conventions;
to improving consistency; reformulating algorithms to
eliminate bottlenecks; taking advantage of new functionality
in external libraries; or implementing new design patterns,
and on and on -- the list is limitless man!

The fact is, no code base will ever be perfect. Code will
constantly need updating and upgrading. The challenge is to
remove the old crusty bits and inject consistency everywhere
we can. That's not narcissism, that's altruism.








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


Re: PyWart: Python modules are not so modular after all!

2013-11-10 Thread Steven D'Aprano
On Sun, 10 Nov 2013 20:13:45 -0800, Rick Johnson wrote:

   What good is ANY namespace when you cannot override it's fundamental
   interface? And interfaces are the key to OOP!
 
   Is __setattr__/__getattr__ ringing a bell people?


import sys
sys.modules[mymodule] = any_object_you_like()


Want a module with __setattr__ and __getattr__? Make a class, instantiate 
it, and shove it in sys.modules.


This has worked since Python 2.1:

http://code.activestate.com/recipes/65207-constants-in-python/



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


[issue19249] Enumeration.__eq__

2013-11-10 Thread Nick Coghlan

Nick Coghlan added the comment:

Since the default eq implementation handles ducktyping correctly, dropping the 
Enum specific __eq__ implementation should be fine.

Just make sure this still works:

 class AlwaysEqual:
... def __eq__(self, other):
... return True
... 
 from enum import Enum
 class MyEnum(Enum):
... a = 1
... 
 MyEnum.a == AlwaysEqual()
True
 AlwaysEqual() == MyEnum.a
True

--
nosy: +ncoghlan
stage:  - test needed

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



[issue19530] cross thread shutdown of UDP socket exhibits unexpected behavior

2013-11-10 Thread Charles-François Natali

Charles-François Natali added the comment:

 After some research...

 Which is normal, since UDP sockets aren't connected.

 But UDP sockets can be connected!


No, they can't.
Connecting a UDP socket doesn't established a duplex connection like
in TCP: it's just a shortand for not having to repeat the destination
address upon every sendto()/sendmsg().

 FYI, the FreeBSD (and OpenBSD) shutdown manpages anticipate calling shutdown 
 on DGRAM sockets.  And the Linux connect manpage discusses connecting DGRAM 
 sockets.

And since shutdown() is designed for duplex connection, it doesn't
really make much sense. It might very well work when you passe SHUT_RD
because it can be interpreted as triggering an EOF, but I wouldn't
rely on this.

 Here is the updated Python code.  I do expect to try to report this upstream. 
  (Also, I now have C/pthreads code, if you want to see it.  As expected, C 
 behaves identically.)

So you see it's not a Python bug. It's really not a bug at all, but
if you want to report this upstream, have fun :-).

--

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



[issue19542] WeakValueDictionary bug in setdefault()pop()

2013-11-10 Thread Armin Rigo

New submission from Armin Rigo:

WeakValueDictionary.setdefault() contains a bug that shows up in multithreaded 
situations using reference cycles.  Attached a test case: it is possible for 
'setdefault(key, default)' to return None, although None is never put as a 
value in the dictionary.  (Actually, being a WeakValueDictionary, None is not 
allowed as a value.)

The reason is that the code in setdefault() ends in return wr(), but the 
weakref wr might have gone invalid between the time it was fetched from 
self.data and the wr() itself, thus returning None.

A similar problem occurs in pop(), leading it to possibly raise KeyError even 
if it is called with a default argument.

--
components: Library (Lib)
messages: 202510
nosy: arigo
priority: normal
severity: normal
status: open
title: WeakValueDictionary bug in setdefault()pop()
versions: Python 2.7, Python 3.3

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



[issue19542] WeakValueDictionary bug in setdefault()pop()

2013-11-10 Thread Armin Rigo

Changes by Armin Rigo ar...@users.sourceforge.net:


Added file: http://bugs.python.org/file32557/x.py

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



[issue19542] WeakValueDictionary bug in setdefault()pop()

2013-11-10 Thread Armin Rigo

Changes by Armin Rigo ar...@users.sourceforge.net:


Added file: http://bugs.python.org/file32558/weakref.slice

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



[issue19499] import this is cached in sys.modules

2013-11-10 Thread Terry J. Reedy

Terry J. Reedy added the comment:

 Having import this behave differently from any other import is 
 counter-intuitive

I agree. My proposal (by design) does not change the property of executing only 
when first imported. I merely proposed that the text either start as cleartext 
or that the decrypted text be saved as a module attribute. *This* would make 
'this' *more* like normal modules.

Having side-effect code executed on import, as opposed to when running as main, 
is unusual. (Idlelib.idle is another intentional example, and one which 
currently has the same problem.) But I agree that this unusual behavior should 
remain for both.

Having module code that is intentionally obfuscated and as about as inefficient 
as possible without being totally ridiculous is, I hope, unique, and not at all 
like other modules.

Even if Tim wants to keep the literal encrypted, and the rot13 codec is not 
available in Py3 (?), the decoding would, I believe, be much more efficient 
using str.translate. Or the text could be encoded and decoded with one of the 
pairs in the binascii or base64 modules.

--

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



[issue19543] Add -3 warnings for codec convenience method changes

2013-11-10 Thread Nick Coghlan

New submission from Nick Coghlan:

The long discussion in issue 7475 and some subsequent discussions I had with 
Armin Ronacher have made it clear to me that the key distinction between the 
codec systems in Python 2 and Python 3 is the following differences in type 
signatures of various operations:

Python 2 (8 bit str):

codecs module: object - object
convenience methods: basestring - basestring
available codecs: unicode - str, str - str, unicode - unicode

Python 3 (Unicode str):

codecs module: object - object
convenience methods: str - bytes
available codecs: str - bytes, bytes - bytes, str - str

The significant distinction is the fact that, in Python 2, the convenience 
methods covered all standard library codecs, but for Python 3, the codecs 
module needs to be used directly for the bytes - bytes codecs and the one str 
- str codec (since those codecs no longer satisfy the constraints of the text 
model related convenience methods).

After attempting to implement a 2to3 fixer for these non-Unicode codecs in 
issue 17823, I realised that wouldn't really work properly (since it's a data 
driven error based on the behaviour of the named codec), so I'm rejecting that 
proposal and replacing it with this one for additional Py3k warnings in Python 
2.7.7.

My proposal is to take the following cases and make them produce warnings under 
Python 2.7.7 when Py3k warnings are enabled (remember, these are the 2.7 types, 
not the 3.x ones):

- the str.encode method is called (redirect to codecs.encode to handle 
arbitrary input types in a forward compatible way)

- the unicode.decode method is called (redirect to codecs.decode to handle 
arbitrary input types)

- PyUnicode_AsEncodedString produces something other than an 8-bit string 
(redirect to codecs.encode for arbitrary output types)

- PyUnicode_Decode produces something other than a unicode string (redirect to 
codecs.decode for arbitrary output types)

For the latter two cases, issue 17828 includes updates to the Python 3 error 
messages to similarly redirect to the convenience functions in the codecs 
module. However, the removed convenience methods will continue to simply 
trigger AttributeError in Python 3 with no special casing.

--
components: Interpreter Core
messages: 202512
nosy: ncoghlan
priority: normal
severity: normal
stage: needs patch
status: open
title: Add -3 warnings for codec convenience method changes
type: enhancement
versions: Python 2.7

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



[issue17823] 2to3 fixers for missing codecs

2013-11-10 Thread Nick Coghlan

Nick Coghlan added the comment:

Due to the data driven nature of this particular incompatibility, I'm rejecting 
this in favour of the Py3k warning based approach in issue 19543.

--
dependencies:  -codecs missing: base64 bz2 hex zlib hex_codec ...
resolution:  - rejected
stage:  - committed/rejected
status: open - closed

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



[issue7475] codecs missing: base64 bz2 hex zlib hex_codec ...

2013-11-10 Thread Nick Coghlan

Nick Coghlan added the comment:

Issue 17823 is now closed, but not because it has been implemented. It turns 
out that the data driven nature of the incompatibility means it isn't really 
amenable to being detected and fixed automatically via 2to3.

Issue 19543 is a replacement proposal for the introduction of some additional 
codec related Py3k warnings in Python 2.7.7.

--

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



[issue19020] Regression: Windows-tkinter-idle, unicode, and 0xxx filename

2013-11-10 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I read your explanation in relation to the code and got part of it but not all. 
I need to try another run through. I may try to locally (and temporarily), 
print to the console to see what is happening.

I am also not clear on the relation between the UnicodeDecodeError and tuple 
splitting. Does '_flatten((self._w, cmd)))' call split or splitlist on the 
tuple arg? Is so, do you know why a problem with that would lead to the 
UDError? Does your patch fix the leading '0' regression?

--

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



[issue19532] compileall -f doesn't force to write bytecode files

2013-11-10 Thread Vajrasky Kok

Vajrasky Kok added the comment:

Ah, I missed that. I made this assumption because when I executed other modules 
manually, they were there just for testing functionality (such as shlex and 
aifc).

Added test.

--
Added file: http://bugs.python.org/file32559/compileall_force_v2.patch

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



[issue19532] compileall -f doesn't force to write bytecode files

2013-11-10 Thread Vajrasky Kok

Vajrasky Kok added the comment:

Tidied up the test.

--
Added file: http://bugs.python.org/file32560/compileall_force_v3.patch

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



[issue19543] Add -3 warnings for codec convenience method changes

2013-11-10 Thread Martin Panter

Martin Panter added the comment:

Just thinking the first case might get quite a few false positives. Maybe that 
would still be acceptable, I dunno.

 - the str.encode method is called (redirect to codecs.encode to handle 
 arbitrary input types in a forward compatible way)

I guess you are trying to catch cases like this, which I have come across quite 
a few times:

data.encode(hex)  # data is a byte string

But I think you would also catch cases that depend on Python 2 “str” objects 
automatically converting to Unicode. Here are some examples taken from real 
code:

file_name.encode(utf-8)  # File name parameter may be str or unicode

# Code meant to be compatible with both Python 2 and 3:
?xml . . . encoding=iso-8859-1?.encode(iso-8859-1)
(data %s\n % len(...)).encode(ascii)

--
nosy: +vadmium

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



[issue19543] Add -3 warnings for codec convenience method changes

2013-11-10 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 10.11.2013 10:20, Nick Coghlan wrote:
 
 The long discussion in issue 7475 and some subsequent discussions I had with 
 Armin Ronacher have made it clear to me that the key distinction between the 
 codec systems in Python 2 and Python 3 is the following differences in type 
 signatures of various operations:
 
 Python 2 (8 bit str):
 
 codecs module: object - object
 convenience methods: basestring - basestring
 available codecs: unicode - str, str - str, unicode - unicode
 
 Python 3 (Unicode str):
 
 codecs module: object - object
 convenience methods: str - bytes
 available codecs: str - bytes, bytes - bytes, str - str
 
 The significant distinction is the fact that, in Python 2, the convenience 
 methods covered all standard library codecs, but for Python 3, the codecs 
 module needs to be used directly for the bytes - bytes codecs and the one 
 str - str codec (since those codecs no longer satisfy the constraints of 
 the text model related convenience methods).

Please remember that the codec sub-system is extensible. It's
easily possible to add more codecs via registered codec
search functions.

Whatever you add as warning has to be aware of the fact that
there may be codecs in the system that are not part of the
stdlib and which can potentially implement codecs that use
other type combinations that the ones you listed above.

--
nosy: +lemburg

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



[issue19373] Tkinter apps including IDLE may not display properly on OS X 10.9 Mavericks

2013-11-10 Thread Ned Deily

Ned Deily added the comment:

Update:  ActiveTcl 8.5.15.1 is now available and includes the fix for the 10.9 
refresh problem documented here.

Unfortunately, the built-in versions of Tcl/Tk 8.5 included with the 
pre-release python.org OS X 64-bit/32-bit x86-64/i386 installers for 3.3.3rc1 
and 2.7.6rc1 (as described above) inadvertently broke compatibility with 
several third-party projects.  As a result, as of 3.3.3rc2 and 2.7.6 final, the 
built-in Tcl/Tk support has been removed and these Pythons once again 
dynamically link with third-party Tcl and Tk 8.5 frameworks in 
/Library/Frameworks, such as those from ActiveState.  You should install 
ActiveTcl 8.5.15.1 (or later 8.5.x versions) for use with these releases, if 
possible.

http://www.python.org/download/mac/tcltk/

--

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



[issue19537] Fix misalignment in fastsearch_memchr_1char

2013-11-10 Thread Stefan Krah

Changes by Stefan Krah stefan-use...@bytereef.org:


--
nosy: +skrah

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



[issue17828] More informative error handling when encoding and decoding

2013-11-10 Thread Nick Coghlan

Nick Coghlan added the comment:

Updated patch (v5) with a more robust chaining mechanism provided as a private 
_PyErr_TrySetFromCause API. This version eliminates the previous whitelist in 
favour of checking directly for the ability to replace the exception with 
another instance of the same type without losing information.

This version also has more direct tests of the exception wrapping behaviour as 
a dedicated test class.

If I don't hear any objections in the next couple of days, I plan to commit 
this version.

--
Added file: 
http://bugs.python.org/file32561/issue17828_improved_codec_errors_v5.diff

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



[issue18861] Problems with recursive automatic exception chaining

2013-11-10 Thread Nick Coghlan

Nick Coghlan added the comment:

It may not immediately look like it, but I think issue 17828 offers an example 
of a related problem. In that issue, I didn't want to *change* the exception 
raised, I wanted to annotate it to say Hey, something I called raised an 
exception, here's some relevant local state to help you figure out what is 
going on (in that case, the information to be added is the specific codec 
being invoked and whether it is an encoding or decoding operation).

Setting the context is somewhat similar - you don't just want to know which 
specific exception happened to be active when the eventually caught exception 
was first raised - you also want to know which already active exception 
handlers you passed through while unwinding the stack.

So really, what may be desirable here is almost an annotated traceback, where 
the interpreter can decide to hang additional information off the frame 
currently being unwound in the exceptions traceback, while leaving the 
exception itself alone.

That's definitely PEP territory, but there are two distinct problems with the 
current exception chaining mechanism to help drive a prospective design for 3.5 
(the status quo doesn't bother me enough for me to work on it myself, but if 
you're interested Nikolaus...)

--

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



[issue17828] More informative error handling when encoding and decoding

2013-11-10 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 10.11.2013 14:03, Nick Coghlan wrote:
 
 Updated patch (v5) with a more robust chaining mechanism provided as a 
 private _PyErr_TrySetFromCause API. This version eliminates the previous 
 whitelist in favour of checking directly for the ability to replace the 
 exception with another instance of the same type without losing information.
 
 This version also has more direct tests of the exception wrapping behaviour 
 as a dedicated test class.
 
 If I don't hear any objections in the next couple of days, I plan to commit 
 this version.

This doesn't look right:

diff -r 1ee45eb6aab9 Include/pyerrors.h
--- a/Include/pyerrors.hSat Nov 09 23:15:52 2013 +0200
+++ b/Include/pyerrors.hSun Nov 10 22:54:04 2013 +1000
...
+PyAPI_FUNC(PyObject *) _PyErr_TrySetFromCause(
+const char *prefix_format,   /* ASCII-encoded string  */
+...
+);

BTW: Why don't we make that API a public one ? It could be useful
in C extensions as well.

In the error messages, I'd use codecs.encode() and codecs.decode()
(ie. with parens) instead of codecs.encode and codecs.decode.

--

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



[issue18861] Problems with recursive automatic exception chaining

2013-11-10 Thread Nick Coghlan

Nick Coghlan added the comment:

Unrelated to my previous comment, I'm also wondering if this may actually 
represent a behavioural difference between contextlib.ExitStack and the 
interpreter's own exception handling machinery.

ExitStack uses a recursive-iterative transformation for its stack unwinding 
(see issue 14963), and it needs to do a bit of fiddling to get the context 
right (see issue 19092).

While the contextlib test suite goes to great lengths to try to ensure the 
semantics of normal stack unwinding are preserved, that definitely doesn't 
currently cover this case, and I'm thinking the way it works may actually be 
more like the behaviour Nikolaus expected in the original post (i.e. setting 
the context as the stack is unwound rather than when the replacement exception 
is raised).

--
nosy: +alonho, hniksic

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



[issue19533] Unloading docstrings from memory if -OO is given

2013-11-10 Thread Stefan Krah

Stefan Krah added the comment:

It looks like the memory management is based directly on Py_Arenas:

def f():
squeamish ossifrage
pass

Breakpoint 1, PyArena_Free (arena=0x9a5120) at Python/pyarena.c:159
159 assert(arena);
(gdb) p arena-a_objects
$1 = ['f', 'squeamish ossifrage']
(gdb) bt
#0  PyArena_Free (arena=0x9a5120) at Python/pyarena.c:159
#1  0x00425af5 in PyRun_FileExFlags (fp=0xa1b780, 
filename_str=0x77f37eb0 docstr.py, start=257, globals=
{'f': function at remote 0x77f04058, '__builtins__': module at 
remote 0x77f6a358, '__name__': '__main__', '__file__': 'docstr.py', 
'__package__': None, '__loader__': SourceFileLoader(name='__main__', 
path='docstr.py') at remote 0x77ede608, '__cached__': None, '__doc__': 
None}, locals=
{'f': function at remote 0x77f04058, '__builtins__': module at 
remote 0x77f6a358, '__name__': '__main__', '__file__': 'docstr.py', 
'__package__': None, '__loader__': SourceFileLoader(name='__main__', 
path='docstr.py') at remote 0x77ede608, '__cached__': None, '__doc__': 
None}, closeit=1, flags=0x7fffe490) at Python/pythonrun.c:2114
#2  0x00423a0c in PyRun_SimpleFileExFlags (fp=0xa1b780, 
filename=0x77f37eb0 docstr.py, closeit=1, flags=
0x7fffe490) at Python/pythonrun.c:1589
#3  0x0042289c in PyRun_AnyFileExFlags (fp=0xa1b780, 
filename=0x77f37eb0 docstr.py, closeit=1, flags=0x7fffe490)
at Python/pythonrun.c:1276
#4  0x0043bc83 in run_file (fp=0xa1b780, filename=0x9669b0 
Ldocstr.py, p_cf=0x7fffe490) at Modules/main.c:336
#5  0x0043c8c5 in Py_Main (argc=3, argv=0x964020) at Modules/main.c:780
#6  0x0041cdb5 in main (argc=3, argv=0x7fffe688) at 
./Modules/python.c:69

So the string 'squeamish ossifrage' is still in arena-a_objects right until
end of PyRun_FileExFlags(), even with -OO.

--

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



[issue19543] Add -3 warnings for codec convenience method changes

2013-11-10 Thread Nick Coghlan

Nick Coghlan added the comment:

Martin: you're right, it wouldn't be feasible to check for the 8-bit str 
encoding case, since the types of string literals will implicitly change 
between the two versions. However, the latter three cases would be feasible to 
check (the unicode.decode one is particularly pernicious, since it's the 
culprit that can lead to UnicodeEncodeErrors on a decoding operation as Python 
implicitly tries to encode a Unicode string as ASCII).

MAL: The latter two Py3k warnings would be in the same place as the 
corresponding output type errors in Python 3 (i.e. all in unicodeobject.c), so 
they would never trigger for the general codecs machinery.

Python 2 actually already has output type checks in the same place as the 
proposed warnings, it just only checks for basestring rather than anything 
more specific. Those two warnings would just involve adding the more 
restrictive Py3k-style check when -3 was enabled.

A Py3k warning for unicode.decode is just a straight this method won't be 
there any more in Python 3 warning, since there's no way for the conversion 
from Python 2 to Python 3 to implicitly replace a Unicode string with 8-bit 
data the way string literals switch from 8-bit data to Unicode text.

--

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



[issue17828] More informative error handling when encoding and decoding

2013-11-10 Thread Nick Coghlan

Nick Coghlan added the comment:

On 10 November 2013 23:21, Marc-Andre Lemburg rep...@bugs.python.org wrote:

 Marc-Andre Lemburg added the comment:

 On 10.11.2013 14:03, Nick Coghlan wrote:

 Updated patch (v5) with a more robust chaining mechanism provided as a 
 private _PyErr_TrySetFromCause API. This version eliminates the previous 
 whitelist in favour of checking directly for the ability to replace the 
 exception with another instance of the same type without losing information.

 This version also has more direct tests of the exception wrapping behaviour 
 as a dedicated test class.

 If I don't hear any objections in the next couple of days, I plan to commit 
 this version.

 This doesn't look right:

 diff -r 1ee45eb6aab9 Include/pyerrors.h
 --- a/Include/pyerrors.hSat Nov 09 23:15:52 2013 +0200
 +++ b/Include/pyerrors.hSun Nov 10 22:54:04 2013 +1000
 ...
 +PyAPI_FUNC(PyObject *) _PyErr_TrySetFromCause(
 +const char *prefix_format,   /* ASCII-encoded string  */
 +...
 +);

The signature? That API doesn't currently let you change the exception
type, only the message (since the codecs machinery doesn't need to
change the exception type, and changing the exception type is fraught
with peril from a backwards compatibility point of view).

 BTW: Why don't we make that API a public one ? It could be useful
 in C extensions as well.

Because I'm not sure it's a good idea in general and hence am wary of
promoting it too much at this point in time (especially given the
severe limitations of what it can currently wrap). I'm convinced it's
worth it in this particular case (since being told the codec involved
directly makes the meaning of codec errors much clearer and even with
the limitations it can still wrap most errors from standard library
codecs), and the implementation *has* to be in exceptions.c since it
pokes around comparing the exception details to the internals of
BaseException to figure out if it can safely wrap the exception or
not.

Issue 18861 also makes me wonder if there's an underlying structural
problem in the way exception chaining currently works that could be
better solved by making it possible to annotate traceback frames while
unwinding the stack, which also makes me disinclined to add to the
public C API in this area before 3.5.

--

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



[issue17828] More informative error handling when encoding and decoding

2013-11-10 Thread Nick Coghlan

Nick Coghlan added the comment:

On 10 November 2013 23:21, Marc-Andre Lemburg rep...@bugs.python.org wrote:

 This doesn't look right:

 diff -r 1ee45eb6aab9 Include/pyerrors.h
 --- a/Include/pyerrors.hSat Nov 09 23:15:52 2013 +0200
 +++ b/Include/pyerrors.hSun Nov 10 22:54:04 2013 +1000
 ...
 +PyAPI_FUNC(PyObject *) _PyErr_TrySetFromCause(
 +const char *prefix_format,   /* ASCII-encoded string  */
 +...
 +);

After sending my previous reply, I realised you may have been
referring to the comment. I copied that from the PyErr_Format
signature. According to
http://docs.python.org/dev/c-api/unicode.html#PyUnicode_FromFormat,
the format string still has to be ASCII-encoded, and if that's no
longer true, it's a separate bug from this one that will require a
docs fix as well.

 In the error messages, I'd use codecs.encode() and codecs.decode()
 (ie. with parens) instead of codecs.encode and codecs.decode.

Forgot to reply to this part - I like it, will switch it over before committing.

--

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



[issue17828] More informative error handling when encoding and decoding

2013-11-10 Thread Nick Coghlan

Changes by Nick Coghlan ncogh...@gmail.com:


Added file: 
http://bugs.python.org/file32562/issue17828_improved_codec_errors_v6.diff

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



[issue19406] PEP 453: add the ensurepip module

2013-11-10 Thread Nick Coghlan

Nick Coghlan added the comment:

Donald, I know you've been busy with PyPI v2.0 the last few days, but I see the 
pull request to resolve https://github.com/pypa/pip/issues/1294 has been merged.

If we can get an updated patch that sets ENSUREPIP_OPTIONS appropriately in the 
process environment, it should be possible to commit this one and let Ned and 
Martin get started on the installers.

--

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



[issue19407] PEP 453: update the Installing Python Modules documentation

2013-11-10 Thread Nick Coghlan

Nick Coghlan added the comment:

Larry, just a heads up that as a docs patch that isn't directly affected by the 
feature freeze, I likely won't get to this one until after beta 1.

We'll make sure issue 19406 and the other functional changes are resolved, 
though.

--

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



[issue17828] More informative error handling when encoding and decoding

2013-11-10 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 10.11.2013 15:39, Nick Coghlan wrote:
 
 On 10 November 2013 23:21, Marc-Andre Lemburg rep...@bugs.python.org wrote:

 This doesn't look right:

 diff -r 1ee45eb6aab9 Include/pyerrors.h
 --- a/Include/pyerrors.hSat Nov 09 23:15:52 2013 +0200
 +++ b/Include/pyerrors.hSun Nov 10 22:54:04 2013 +1000
 ...
 +PyAPI_FUNC(PyObject *) _PyErr_TrySetFromCause(
 +const char *prefix_format,   /* ASCII-encoded string  */
 +...
 +);

Sorry about the false warning. After looking at those lines
again, I realized that the ... is the argument ellipsis,
not some omitted code. At first this look like a function
definition to me :-)

 After sending my previous reply, I realised you may have been
 referring to the comment. I copied that from the PyErr_Format
 signature. According to
 http://docs.python.org/dev/c-api/unicode.html#PyUnicode_FromFormat,
 the format string still has to be ASCII-encoded, and if that's no
 longer true, it's a separate bug from this one that will require a
 docs fix as well.

Also note that it's not clear whether the ASCII
refers to the format string or the resulting formatted string.
For the format string, ASCII would probably be fine, but
for the formatted string, UTF-8 should be allowed, since it's
not uncommon to add e.g. parameter strings that caused the
error to the error string.

That's a separate ticket, though.

 In the error messages, I'd use codecs.encode() and codecs.decode()
 (ie. with parens) instead of codecs.encode and codecs.decode.
 
 Forgot to reply to this part - I like it, will switch it over before 
 committing.

Thanks.

--

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



[issue11473] upload command no longer accepts repository by section name

2013-11-10 Thread Jason R. Coombs

Jason R. Coombs added the comment:

Indeed, the issue as reported is invalid.

--
resolution:  - invalid
status: open - closed

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



[issue19544] Port distutils as found in Python 2.7 to Python 3.x.

2013-11-10 Thread Jason R. Coombs

New submission from Jason R. Coombs:

Following from issue7457, in which a single feature was identified to have gone 
missing in 29a3eda89995, this ticket captures the need to bring the Python 3 
codebase up to match Python 2.7.

--
assignee: eric.araujo
components: Distutils
messages: 202534
nosy: eric.araujo, jason.coombs, tarek
priority: normal
severity: normal
status: open
title: Port distutils as found in Python 2.7 to Python 3.x.
versions: Python 3.4

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



[issue7457] Adding a read_pkg_file to DistributionMetadata

2013-11-10 Thread Jason R. Coombs

Jason R. Coombs added the comment:

As suggested, I created issue19544 to track the larger effort.

--

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



[issue19545] time.strptime exception context

2013-11-10 Thread Claudiu.Popa

New submission from Claudiu.Popa:

time.strptime leaks an IndexError, as seen in the following traceback. 

[root@clnstor /tank/libs/cpython]# ./python
Python 3.4.0a4+ (default:0aa2aedc6a21+, Nov  5 2013, 17:10:42)
[GCC 4.2.1 20070831 patched [FreeBSD]] on freebsd8
Type help, copyright, credits or license for more information.
 import time
 time.strptime('19', '%Y %')
Traceback (most recent call last):
  File /tank/libs/cpython/Lib/_strptime.py, line 320, in _strptime
format_regex = _TimeRE_cache.compile(format)
  File /tank/libs/cpython/Lib/_strptime.py, line 268, in compile
return re_compile(self.pattern(format), IGNORECASE)
  File /tank/libs/cpython/Lib/_strptime.py, line 262, in pattern
self[format[directive_index]])
IndexError: string index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File stdin, line 1, in module
  File /tank/libs/cpython/Lib/_strptime.py, line 494, in _strptime_time
tt = _strptime(data_string, format)[0]
  File /tank/libs/cpython/Lib/_strptime.py, line 332, in _strptime
raise ValueError(stray %% in format '%s' % format)
ValueError: stray % in format '%Y %'


The attached patch suppresses the exception. This issue is similar (and based 
on) the issue17572.

--
components: Library (Lib)
files: time_strptime.patch
keywords: patch
messages: 202536
nosy: Claudiu.Popa, belopolsky
priority: normal
severity: normal
status: open
title: time.strptime exception context
versions: Python 3.4
Added file: http://bugs.python.org/file32563/time_strptime.patch

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



[issue19537] Fix misalignment in fastsearch_memchr_1char

2013-11-10 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Current code assumes that PyUnicode_DATA() is aligned to PyUnicode_KIND() 
bytes. If this is not true on some platform it will be easer to add a padding 
than rewrite a code. A lot of code depends on this assumption. See also 
issue14422.

I afraid that proposed patch may slow down a search.

--
nosy: +pitrou

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



  1   2   >