Re: recursive function: use a global or pass a parameter?

2015-01-17 Thread Steven D'Aprano
Tim wrote:

 I have this type of situation and wonder if I should use a global variable
 outside the recursive function instead of passing the updated parameter
 through.

To a first approximation, the answer to:

I have a X, should I use a global variable or a parameter?

is *always* use a parameter, no matter what X is.

To a second and third approximation, the answer is still use a parameter.

Good reasons for using global variables are few and far between. Just about
the only good reason for using global variables that I can think of is if
you have one or more settings/preference that get set once at the start of
the program and then apply to the entire program.

Actually, there is one other reason... if your program is a simple script
written in imperative style:

name = steve
print Hello, name
do_this()
do_that()
do_something_else()
print Good bye, name


sort of thing.



-- 
Steven

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


Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Steven D'Aprano
Gregory Ewing wrote:

 Marko Rauhamaa wrote:
 Gregory Ewing greg.ew...@canterbury.ac.nz:
 
If those are 24-bit RGB pixels, you could encode
3 characters in each pixel.
 
 Not since Python3. Characters are Unicode now so you'll need to dedicate
 a pixel for each character.
 
 Depends on which characters you want. With the
 Flexible Chromatic Representation, it could be
 anything from 1 to 3.

Subpixel rendering is 5% slower than full pixel rendering, so it is provably
mathematically impossible to print Unicode characters.


-- 
Steven

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


Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Steven D'Aprano
Gregory Ewing wrote:

 We're really quite spoiled in Python-land. It's easy
 to forget just how spoiled we are until you go back
 and try to do something in one of the more primitive
 languages...

Every time I think I would like to learn a new language, I quite quickly run
into some obvious feature that Python has but the newer language lacks, and
I think bugger this for a game of soldiers and abandon it. E.g. Ruby and
the lack of keyword arguments. Oh, I see Ruby 2.0 added them to the
language! Perhaps it's time for me to give Ruby a go again?

Ah, wait, I forgot Ruby's brilliant feature that whitespace *between*
expressions is significant:

[steve@ando ~]$ cat ~/coding/ruby/ws-example.rb
#!/usr/bin/ruby

def a(x=4)
x+2
end

b = 1
print a + b = , (a + b), \n
print a+b   = , (a+b), \n
print a+ b  = , (a+ b), \n
print a +b  = , (a +b), \n

[steve@ando ~]$ ruby ~/coding/ruby/ws-example.rb
a + b = 7
a+b   = 7
a+ b  = 7
a +b  = 3


A shiny new penny for any non-Ruby coder who can explain that!



-- 
Steven

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


Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Jussi Piitulainen
Steven D'Aprano writes:

 Ah, wait, I forgot Ruby's brilliant feature that whitespace
 *between* expressions is significant:
 
 [steve@ando ~]$ cat ~/coding/ruby/ws-example.rb
 #!/usr/bin/ruby
 
 def a(x=4)
 x+2
 end
 
 b = 1
 print a + b = , (a + b), \n
 print a+b   = , (a+b), \n
 print a+ b  = , (a+ b), \n
 print a +b  = , (a +b), \n
 
 [steve@ando ~]$ ruby ~/coding/ruby/ws-example.rb
 a + b = 7
 a+b   = 7
 a+ b  = 7
 a +b  = 3
 
 
 A shiny new penny for any non-Ruby coder who can explain that!

I've only seen small amounts of Ruby code on the net. The only way I
can make some sense of that is if it gets analyzed as follows, using
parentheses for calls:

 a + b = 7  # a() + b = a(4) + b = 4 + 2 + 1
 a+b   = 7  # a() + b
 a+ b  = 7  # a() + b
 a +b  = 3  # a(+b)   = a(b) = a(1) = 1 + 2

I'm not quite fond of such surprise in programming language syntax.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Marko Rauhamaa
Jussi Piitulainen jpiit...@ling.helsinki.fi:

  a+ b  = 7  # a() + b
  a +b  = 3  # a(+b)   = a(b) = a(1) = 1 + 2

 I'm not quite fond of such surprise in programming language syntax.

Yes, whoever came up with the idea of whitespace having syntactic
significance!


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


EuroPython 2015: Landing in Bilbao

2015-01-17 Thread M.-A. Lemburg
After a creative and inspiring Friday afternoon, we are pleased to
announce our EuroPython 2015 landing page:

  http://ep2015.europython.eu/

This will be the URL for EuroPython 2015 - definitely worth a
bookmark, we think :-)

Enjoy,
-—
EuroPython Society (EPS)
http://www.europython-society.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Jussi Piitulainen
Marko Rauhamaa writes:
 Jussi Piitulainen:
 
   a+ b  = 7  # a() + b
   a +b  = 3  # a(+b)   = a(b) = a(1) = 1 + 2
 
  I'm not quite fond of such surprise in programming language
  syntax.
 
 Yes, whoever came up with the idea of whitespace having syntactic
 significance!

How far do you want to go? Is a  b + c the same as a(b) + c or the
same as a(b + c)?

There's meant to be two spaces between a and b but I lost one of
them, twice, to my M-q reflex when writing the above paragraph. They
may or may not be there as I send this.

And I don't really want to know which it is. I prefer parentheses.
They are not nearly as fragile.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Skip Montanaro
On Sat, Jan 17, 2015 at 5:59 AM, Jussi Piitulainen
jpiit...@ling.helsinki.fi wrote:
 How far do you want to go? Is a  b + c the same as a(b) + c or the
 same as a(b + c)?

I think there is only one practical interpretation, the one that all
shells I'm familiar with have adopted:

a(b, +, c)

 And I don't really want to know which it is. I prefer parentheses.
 They are not nearly as fragile.

Agreed. Without parens, splitting the command line arguments on white
space is the only non-fragile way to do things.

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


Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Marko Rauhamaa
Jussi Piitulainen jpiit...@ling.helsinki.fi:

 Marko Rauhamaa writes:
 Yes, whoever came up with the idea of whitespace having syntactic
 significance!

 How far do you want to go? [...]

 I prefer parentheses. They are not nearly as fragile.

*cough* braces *cough*

Seriously, though, I hate the optional semicolon rules of JavaScript and
Go. I dread the day when GvR gets it in his head to allow this syntax in
Python:

   average_drop_rate = cumulative_drop_count /
   observation_period

(although, it could be defined Pythonesquely thus: a spurious
indentation means line continuation — no more backslashes).


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


Re: Comparisons and sorting of a numeric class....

2015-01-17 Thread Steven D'Aprano
Andrew, sorry for the delay in responding. Your response has been extremely
long, so for the interest of brevity I've tried to trim things down to the
most pertinent points.

Andrew Robinson wrote:

[...]
 So -- From my perspective, Guido making Python go from an open ended and
 permissive use of anything goes as a return value that can handle
 metastable states

That absolutely has not changed. You seem to be mixing the concept of
*subclassing* with the concept of being able to handle multi-state
(metastable) logic. You can certainly write multi-state logic in Python.
 

 -- into to a historical version of 'logic' being 
 having *only* two values in a very puritanical sense, is rather -- well
 -- disappointing.  It makes me wonder -- what hit the fan?!  Is it
 lemmings syndrome ? a fight ? no idea  and is there any hope of
 recovery or a work around ?

Do you have much programming experience outside of the niche of modelling
electronic hardware?

I can tell you that it is standard for general purpose programming languages
to be restricted to two-state (Boolean) comparisons. The basic decision
construct is if...else, which is based on two states.

The only exception that I know of is the very early, and long deprecated,
Fortran Arithmetic IF statement:

IF (e) label1, label2, label3

which did a three-way jump depending on whether e was less than zero, equal
to zero, or greater than zero. Some assemblers also included three-way
jumps.

All forms of N-valued logic can be reduced to Boolean logic with appropriate
comparisons. Instead of trying to come up with syntax for a three-way
branch:

if flag: print True
else: print False
otherwise: print Indeterminate

and four-way branches, a five-way branches, ... ad infinitum, it is easier
to leave it up to the programmer to build N-way logic on top of 2-way
True/False comparisons:

# equality here returns True or False
if flag == True: print True
else:
if flag == False: print False
else: print Indeterminate


Some programming languages add syntax to make this more friendly:

if flag == True: print True
elif flag == False: print False
else: print Indeterminate

or even:

case flag of:
True: ...
False: ...
Indeterminate: ...
Maybe: ...
Uncertain: ...
Could_Be: ...

(for languages with a case or switch statement).

Not only can all N-way logics be mathematically generated from Boolean
algebra, but I'll go further and say that *almost certainly* the hardware
simulation languages you are used to with 3-way or 4-way logic use 2-way
Boolean logic under the hood.

The point of this is that you need not think of Guido taking away
anything. It is normal for programming languages to use Boolean
comparisons.

But in fact Python is *less* restrictive than many other languages. In
Pascal, for instance, comparisons like = or  etc. can only return true or
false, while Python allows them to return anything.


 eg: To me -- (as an engineer) undefined *IS* equivalent in useage to an
 acutal logic value, just as infinity is a floating point value that is
 returned as a 'float'.  You COULD/CAN separate the two values from each
 other -- but always with penalties.  They generally share an OOP 'is'
 relationship with respect to how and when they are used. (inf) 'IS' a
 float value and -- uncertain -- 'IS' a logic value.

That's fine, we have no dispute with the need for multi-state logics. But
*which* multi-state logic? There are *at least* three useful ternary
logics: Kleene logic, Łukasiewicz logic, Bochvar logic. And then there is
Belnap's four-valued relevance logic (True, False, Both True and False,
Neither True nor False), and an infinite number of other possible logics.
Which should the programming language support?

In a sense, any Turing Complete programming language supports *all of them*.
All you need to do is program the details yourself. But in the sense of
which multi-state logic should the language itself include, I think that
the answer is ... none of them. Most programming languages have no need to
include this complexity, just as most languages don't include tensors as a
language primitive.

I guess this is just a long-winded way of me saying that HDLs are
effectively a Domain Specific Language for hardware, and can *and should*
contain specialist semantics needed by hardware designers, e.g. 4-way
logic. But Python is a general purpose language, and while you *can*
program your own domain specific features, you have to do so within the
constraints of the needs of a general-purpose language. In Python's case,
those constraints are actually remarkably loose (not as loose as languages
like Lisp or Forth, where you can literally redesign the interpreter on the
fly!) but they do exist.

[...]
 So -- let's look at the examples you gave:
 
 - don't use True and False at all, create your own multi-valued
truth values ReallyTrue, MaybeTrue, SittingOnTheFence, ProbablyFalse,
CertainlyFalse (or whatever names you choose to give 

Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Steven D'Aprano
Marko Rauhamaa wrote:

 Jussi Piitulainen jpiit...@ling.helsinki.fi:
 
  a+ b  = 7  # a() + b
  a +b  = 3  # a(+b)   = a(b) = a(1) = 1 + 2

 I'm not quite fond of such surprise in programming language syntax.
 
 Yes, whoever came up with the idea of whitespace having syntactic
 significance!

Yes, we should go back to the rules of ancient FORTRAN, where:

DO100X=1.10,2

and

DO 100 X = 1. 10, 2

mean exactly the same thing.

Not.


Whitespace is significant in nearly all programming languages, and so it
should be. Whitespace separates tokens, and lines, and is a natural way of
writing (at least for people using Western languages).

*Indentation* is significant to Python, while most languages enable tedious
and never-ending style wars over the correct placement of braces vis a vis
indentation, because their language is too simple-minded to infer block
structure from indentation. Python does derive block structure from
indentation, as god intended (otherwise he wouldn't have put tab keys on
typewriters) and so Python doesn't suffer from the interminable arguments
about formatting that most other languages do.



-- 
Steven

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


Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Steven D'Aprano
Jussi Piitulainen wrote:

 I've only seen small amounts of Ruby code on the net. The only way I
 can make some sense of that is if it gets analyzed as follows, using
 parentheses for calls:
 
  a + b = 7  # a() + b = a(4) + b = 4 + 2 + 1
  a+b   = 7  # a() + b
  a+ b  = 7  # a() + b
  a +b  = 3  # a(+b)   = a(b) = a(1) = 1 + 2
 
 I'm not quite fond of such surprise in programming language syntax.

Full marks!



-- 
Steven

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


Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Jussi Piitulainen
Marko Rauhamaa writes:

 Seriously, though, I hate the optional semicolon rules of JavaScript
 and Go. I dread the day when GvR gets it in his head to allow this
 syntax in Python:
 
average_drop_rate = cumulative_drop_count /
observation_period
 
 (although, it could be defined Pythonesquely thus: a spurious
 indentation means line continuation — no more backslashes).

I do that:

   average_drop_rate = ( cumulative_drop_count /
 observation_period )
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Jussi Piitulainen
Skip Montanaro writes:
 On Sat, Jan 17, 2015 at 5:59 AM, Jussi Piitulainen wrote:
  How far do you want to go? Is a  b + c the same as a(b) + c or
  the same as a(b + c)?
 
 I think there is only one practical interpretation, the one that all
 shells I'm familiar with have adopted:
 
 a(b, +, c)

Sorry, what? Oh, shells, and a called with three parameters. Ok.

But I think the + here should be the usual arithmetical operators.
It was supposed to be Ruby syntax and the question was about the
significance of different amounts of white space.

Hm. What about b  + c? Or 3 +1, is that calling 3 with 1? No,
I don't really want to know.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Chris Angelico
On Sat, Jan 17, 2015 at 9:49 PM, Jussi Piitulainen
jpiit...@ling.helsinki.fi wrote:
 I've only seen small amounts of Ruby code on the net. The only way I
 can make some sense of that is if it gets analyzed as follows, using
 parentheses for calls:

  a + b = 7  # a() + b = a(4) + b = 4 + 2 + 1
  a+b   = 7  # a() + b
  a+ b  = 7  # a() + b
  a +b  = 3  # a(+b)   = a(b) = a(1) = 1 + 2

 I'm not quite fond of such surprise in programming language syntax.

Every once in a while, someone looks at Py2's print statement and
Py3's print function and says, why not allow function calls without
parentheses. This right here is why not. Wow. That is one nasty
surprise.

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


Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Danilo Coccia
Il 17/01/2015 12.07, Marko Rauhamaa ha scritto:
 Jussi Piitulainen jpiit...@ling.helsinki.fi:
 
  a+ b  = 7  # a() + b
  a +b  = 3  # a(+b)   = a(b) = a(1) = 1 + 2

 I'm not quite fond of such surprise in programming language syntax.
 
 Yes, whoever came up with the idea of whitespace having syntactic
 significance!
 
 
 Marko
 

Maybe you already knew this esoteric language:
  http://compsoc.dur.ac.uk/whitespace/
  https://en.wikipedia.org/wiki/Whitespace_%28programming_language%29

And, just for completeness :) http://www.stroustrup.com/whitespace98.pdf
-- 
https://mail.python.org/mailman/listinfo/python-list


numpy.allclose()

2015-01-17 Thread Steven D'Aprano
Can anyone explain the rationale for numpy's allclose() semantics?

help(allclose) says:


allclose(a, b, rtol=1e-05, atol=1e-08)
Returns True if two arrays are element-wise equal within a tolerance.

The tolerance values are positive, typically very small numbers.  The
relative difference (`rtol` * abs(`b`)) and the absolute difference
`atol` are added together to compare against the absolute difference
between `a` and `b`.

[...]

If the following equation is element-wise True, then allclose returns
True.

absolute(`a` - `b`) = (`atol` + `rtol` * absolute(`b`))



I don't understand why they add the error tolerances together. I can
understand taking the minimum, or the maximum: 

* taking the maximum is equivalent to the rule numbers are close if they
  differ by no more than EITHER the absolute tolerance OR the relative
  tolerance;

* taking the minimum is equivalent to the rule numbers are close if they
  differ by no more than BOTH the absolute tolerance AND the relative
  tolerance.


But adding them together doesn't make any sense to me. That leads to the
situation where two values are deemed close if you give two tolerances
even though it fails each test individually:

py numpy.allclose([1.2], [1.0], 0.0, 0.1)  # Fails absolute error test.
False
py numpy.allclose([1.2], [1.0], 0.1, 0.0)  # Fails relative error test.
False
py numpy.allclose([1.2], [1.0], 0.1, 0.1)  # Passes!
True




-- 
Steven

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


Re: Hello World

2015-01-17 Thread Albert van der Horst
In article mailman.17471.1420721626.18130.python-l...@python.org,
Chris Angelico  ros...@gmail.com wrote:
SNIP

But sure. If you want to cut out complication, dispense with user
accounts altogether and run everything as root. That's WAY simpler!

I didn't except this strawman argument from you.
Of course you need a distinction between doing system things as
root, and working as a normal user. You just don't need sudo.


ChrisA
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spearc.xs4all.nl =n http://home.hccnet.nl/a.w.m.van.der.horst

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


Re: Hello World

2015-01-17 Thread Chris Angelico
On Sun, Jan 18, 2015 at 1:51 AM, Albert van der Horst
alb...@spenarnc.xs4all.nl wrote:
 In article mailman.17471.1420721626.18130.python-l...@python.org,
 Chris Angelico  ros...@gmail.com wrote:
 SNIP

But sure. If you want to cut out complication, dispense with user
accounts altogether and run everything as root. That's WAY simpler!

 I didn't except this strawman argument from you.
 Of course you need a distinction between doing system things as
 root, and working as a normal user. You just don't need sudo.

So you have to have a password on the root account. My systems are
more secure, as they do not have a password that someone could learn.

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


Re: Hello World

2015-01-17 Thread Albert van der Horst
In article mailman.17481.1420737102.18130.python-l...@python.org,
Chris Angelico  ros...@gmail.com wrote:
On Fri, Jan 9, 2015 at 4:02 AM, Steve Hayes hayes...@telkomsa.net wrote:
 On 08 Jan 2015 12:43:33 GMT, alb...@spenarnc.xs4all.nl (Albert van der Horst)
 wrote:

I don't trust sudo because it is too complicated.
(To the point that I removed it from my machine.)
I do

 How do you do that?

 I avoided Ubuntu because it had sudo, and then discovered that Fedora had it
 as well.

Uhh, 'apt-get remove sudo'? That ought to work on any Debian-based

That works. That is exactly what I did.

system. With Debian itself, you get the option during installation of
setting a root password, in which case it won't install sudo by
default.

ChrisA
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spearc.xs4all.nl =n http://home.hccnet.nl/a.w.m.van.der.horst

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


Re: recursive function: use a global or pass a parameter?

2015-01-17 Thread Roy Smith
In article 54ba3654$0$13008$c3e8da3$54964...@news.astraweb.com,
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:

 Good reasons for using global variables are few and far between. Just about
 the only good reason for using global variables that I can think of is if
 you have one or more settings/preference that get set once at the start of
 the program and then apply to the entire program.

I will commonly put something like:

import logging
logger = logging.getLogger(logger-name-for-my-module)

in every source file in a big project.  Now I've got a global logger I 
can use anywhere in the module (even in static functions).  But, maybe 
that's just a subset of your setting that gets set once at the start of 
the program example.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hello World

2015-01-17 Thread cl
Chris Angelico ros...@gmail.com wrote:
 On Sun, Jan 18, 2015 at 1:51 AM, Albert van der Horst
 alb...@spenarnc.xs4all.nl wrote:
  In article mailman.17471.1420721626.18130.python-l...@python.org,
  Chris Angelico  ros...@gmail.com wrote:
  SNIP
 
 But sure. If you want to cut out complication, dispense with user
 accounts altogether and run everything as root. That's WAY simpler!
 
  I didn't except this strawman argument from you.
  Of course you need a distinction between doing system things as
  root, and working as a normal user. You just don't need sudo.
 
 So you have to have a password on the root account. My systems are
 more secure, as they do not have a password that someone could learn.
 
Yes, they do (if you use sudo) it's *your* password and IMHO it's less
secure as you only need to know one password to get root access.

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


Re: Hello World

2015-01-17 Thread Michael Torrie
On 01/17/2015 07:51 AM, Albert van der Horst wrote:
 In article mailman.17471.1420721626.18130.python-l...@python.org,
 Chris Angelico  ros...@gmail.com wrote:
 SNIP

 But sure. If you want to cut out complication, dispense with user
 accounts altogether and run everything as root. That's WAY simpler!
 
 I didn't except this strawman argument from you.
 Of course you need a distinction between doing system things as
 root, and working as a normal user. You just don't need sudo.

I just don't see the distinction.  What's the difference between having
to type in a root password and having to type in your own administrative
user password?  Guess we're all just struggling to understand your logic
here.

On my laptop sudo has a huge advantage over su, and that is I can use my
fingerprint reader to access root. Now I could set up root to accept a
fingerprint as well which would work with su, but the sudo solution is
much quicker to configure.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why do the URLs of posts here change?

2015-01-17 Thread Albert van der Horst
In article mailman.17551.1420862015.18130.python-l...@python.org,
Chris Angelico  ros...@gmail.com wrote:
On Sat, Jan 10, 2015 at 2:21 PM, Gregory Ewing
greg.ew...@canterbury.ac.nz wrote:
 Skip Montanaro wrote:

 The way this is done, is
 that the message is removed from the underlying mbox file, and the
 archive regenerated. That changes the counter for every message after
 that point


 Would it help to replace the message with a stub
 instead of deleting it altogether?

I had the same thought, but apparently not, according to the page
Peter Otten linked to:

http://wiki.list.org/display/DEV/Stable+URLs

Knowing that the source is an mbox file, I don't need to follow
that link to conclude that one is not very inventive.
It suffices to replace the content of the message by
a repetition of '\n'. Maybe also the sender and the subject.


ChrisA
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spearc.xs4all.nl =n http://home.hccnet.nl/a.w.m.van.der.horst

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


Re: Hello World

2015-01-17 Thread cl
Michael Torrie torr...@gmail.com wrote:
 On 01/17/2015 07:51 AM, Albert van der Horst wrote:
  In article mailman.17471.1420721626.18130.python-l...@python.org,
  Chris Angelico  ros...@gmail.com wrote:
  SNIP
 
  But sure. If you want to cut out complication, dispense with user
  accounts altogether and run everything as root. That's WAY simpler!
  
  I didn't except this strawman argument from you.
  Of course you need a distinction between doing system things as
  root, and working as a normal user. You just don't need sudo.
 
 I just don't see the distinction.  What's the difference between having
 to type in a root password and having to type in your own administrative
 user password?  Guess we're all just struggling to understand your logic
 here.
 
One big distinction is that you need to know two passwords to get root
access if there's a real root account as opposed to using sudo.  This
only applies of course if direct root login isn't allowed (via ssh or
whatever).

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


Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Roy Smith
In article 54ba39e0$0$13008$c3e8da3$54964...@news.astraweb.com,
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:

 Every time I think I would like to learn a new language, I quite quickly run
 into some obvious feature that Python has but the newer language lacks, and
 I think bugger this for a game of soldiers and abandon it.

Wow.  Another wonderful English phrase to add to my vocabulary.  That's 
up there with Bob's your uncle :-)

 Ah, wait, I forgot Ruby's brilliant feature that whitespace *between*
 expressions is significant:
 
 [steve@ando ~]$ cat ~/coding/ruby/ws-example.rb
 #!/usr/bin/ruby
 
 def a(x=4)
 x+2
 end
 
 b = 1
 print a + b = , (a + b), \n
 print a+b   = , (a+b), \n
 print a+ b  = , (a+ b), \n
 print a +b  = , (a +b), \n
 
 [steve@ando ~]$ ruby ~/coding/ruby/ws-example.rb
 a + b = 7
 a+b   = 7
 a+ b  = 7
 a +b  = 3
 
 
 A shiny new penny for any non-Ruby coder who can explain that!

The last time I looked at Ruby was when it was brand new.  I bought the 
original pickaxe book and read it on a plane trip.  It looked pretty 
cool at the time, but I never really got into it.  So I think I qualify.

Anyway, I'm going to guess from the above examples, that uttering a name 
means, If the referent is callable, call it, if not, get its value.  
This is the same, for example, as django's template language.  Or, kind 
of like Python's properties.  So

(a + b)

means Call a(), and add the value of b to that.  I'm going to further 
guess that

def a(x=4)

means a() takes an optional argument, with a default value of 4, just 
like in Python.  So

a

returns 6, i.e. 4 + 2.  I'm going to further guess that

(a +b)

is parsed as call a, passing +b as an argument, and the + is taken 
as a unary prefix.

I want my penny.

This is not the only example of significant whitespace in programming 
languages.

Old-style C/C++ allowed either += or =+ for the increment operator.  
This led to parsing ambiguity for things like a=+b, where (IIRC), a = 
+b was parsed as an assignment and unary +, and a =+ b was parsed as 
an increment.  Eventually, the syntax was changed to make += the only 
legal way to write increment.

There was also the problem with nested template operators in C++, where 
FooT1T2 was mis-parsed, and you had to write it as Foo T1 T2 
 (or something like that) to get it to parse right.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Roy Smith
In article mailman.17811.1421497179.18130.python-l...@python.org,
 Skip Montanaro skip.montan...@gmail.com wrote:

 On Sat, Jan 17, 2015 at 5:59 AM, Jussi Piitulainen
 jpiit...@ling.helsinki.fi wrote:
  How far do you want to go? Is a  b + c the same as a(b) + c or the
  same as a(b + c)?
 
 I think there is only one practical interpretation, the one that all
 shells I'm familiar with have adopted:
 
 a(b, +, c)
 
  And I don't really want to know which it is. I prefer parentheses.
  They are not nearly as fragile.
 
 Agreed. Without parens, splitting the command line arguments on white
 space is the only non-fragile way to do things.
 
 Skip

I once worked with a language (with vaguely C-like syntax) in which:

if(x == 4)

and

y = f (x)

were both syntax errors.  If statements *required* a space before the 
paren, and function calls *forbid* it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Roy Smith
In article 54ba5a25$0$12991$c3e8da3$54964...@news.astraweb.com,
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:

 Whitespace is significant in nearly all programming languages, and so it
 should be. Whitespace separates tokens, and lines, and is a natural way of
 writing (at least for people using Western languages).

 x ==   x  
False

 *Indentation* is significant to Python, while most languages enable tedious
 and never-ending style wars over the correct placement of braces vis a vis
 indentation, because their language is too simple-minded to infer block
 structure from indentation. Python does derive block structure from
 indentation, as god intended (otherwise he wouldn't have put tab keys on
 typewriters) and so Python doesn't suffer from the interminable arguments
 about formatting that most other languages do.

Well, we do get to argue about

x = [1,
 2,
 3]

vs.

x = [1,
 2,
 3,
]

vs. a few other variations based on how you group the first element with 
the opening bracket, or the last element with the closing bracket, and, 
of course, whether you use the last trailing comma or not.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: recursive function: use a global or pass a parameter?

2015-01-17 Thread Albert van der Horst
In article 5e4ccec6-7a00-467d-8cf6-258ab0421...@googlegroups.com,
Tim  jtim.arn...@gmail.com wrote:
I have this type of situation and wonder if I should use a global
variable outside the recursive function instead of passing the updated
parameter through.

I want to get a union of all the values that any 'things' key may have,
even in a nested dictionary (and I do not know beforehand how deep the
nesting might go):

d = {'things':1, 'two':{'things':2}}

def walk(obj, res):
if not hasattr(obj, 'keys'):
return set(), set()

if 'things' in obj:
res.add(obj['things'])

for k in obj:
walk(obj[k], res)

return res

walk(d, set()) # returns {1, 2}

Is it better to use a global to keep track of the values or does it even 
matter?

Neither. You shouldn't pass superfluous parameters, and you shouldn't
abuse globals.

The proper technique is make the global local to the normal subroutine,
then make the subroutine with those parameters you don't want to see
also local to that subroutine.
E.g.

def fib(n):
' return the n-th Fibonacci number '
a,b = 0,1
def fib1(ap,bp):
   ' for f_n,f_n+1, return f_n+1,f_n+2 '
   return bp,ap+b
for i in xrange(n):
   a,b = fib1(a,b)
return a


thanks,
--Tim

Groetjes Albert
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spearc.xs4all.nl =n http://home.hccnet.nl/a.w.m.van.der.horst

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


EuroPython 2015: Landing in Bilbao

2015-01-17 Thread M.-A. Lemburg
After a creative and inspiring Friday afternoon, we are pleased to
announce our EuroPython 2015 landing page:

  http://ep2015.europython.eu/

This will be the URL for EuroPython 2015 - definitely worth a
bookmark, we think :-)

Enjoy,
-—
EuroPython Society (EPS)
http://www.europython-society.org/
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

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


Re: Hello World

2015-01-17 Thread Mark Lawrence

On 17/01/2015 16:47, c...@isbd.net wrote:

Michael Torrie torr...@gmail.com wrote:

On 01/17/2015 07:51 AM, Albert van der Horst wrote:

In article mailman.17471.1420721626.18130.python-l...@python.org,
Chris Angelico  ros...@gmail.com wrote:
SNIP


But sure. If you want to cut out complication, dispense with user
accounts altogether and run everything as root. That's WAY simpler!


I didn't except this strawman argument from you.
Of course you need a distinction between doing system things as
root, and working as a normal user. You just don't need sudo.


I just don't see the distinction.  What's the difference between having
to type in a root password and having to type in your own administrative
user password?  Guess we're all just struggling to understand your logic
here.


One big distinction is that you need to know two passwords to get root
access if there's a real root account as opposed to using sudo.  This
only applies of course if direct root login isn't allowed (via ssh or
whatever).



Bah humbug, this has reminded me of doing secure work whereby each 
individual had two passwords, both of which had to be changed every 
thirty days, and rules were enforced so you couldn't just increment the 
number at the end of a word or similar.


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

Mark Lawrence

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


[issue21817] `concurrent.futures.ProcessPoolExecutor` swallows tracebacks

2015-01-17 Thread Roundup Robot

Roundup Robot added the comment:

New changeset a36b402b099b by Antoine Pitrou in branch 'default':
Issue #21817: When an exception is raised in a task submitted to a 
ProcessPoolExecutor, the remote traceback is now displayed in the parent 
process.
https://hg.python.org/cpython/rev/a36b402b099b

--
nosy: +python-dev

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



[issue21862] cProfile command-line should accept -m module_name as an alternative to script path

2015-01-17 Thread Mayank Tripathi

Mayank Tripathi added the comment:

Now allows parameters after the -m option.

--
nosy: +oquanox
Added file: http://bugs.python.org/file37749/cProfile_module_option.patch

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



[issue23258] Cannot Install Python 3.4.2 on Windows 7 64 bit / screen print attached

2015-01-17 Thread Steve Dower

Steve Dower added the comment:

You can close those applications, or ignore the message and continue, just like 
the dialog says (if you ignore it, you may need to reboot for installation to 
complete). You could also try doing a Just for Me installation.

Python is not trying to update those programs, which means those programs are 
blocking Python. You should look for their documentation on how to close them, 
or report this as a problem to them.

--

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



[issue23253] Delay-load ShellExecute

2015-01-17 Thread Tim Golden

Tim Golden added the comment:

I'm +0.75. I think the idea's fine in principle and the patch (by 
inspection) seems to do the right things.

My only concerns are: that posixmodule.c becomes even longer and more 
involved; and that the benefit might not quite be great enough to 
justify the added complexity.

--
title: Delay-load ShellExecute[AW] in os.startfile - Delay-load ShellExecute

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



Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Gregory Ewing

Jussi Piitulainen wrote:

I prefer parentheses.
They are not nearly as fragile.


So do I, but the other day I had occasion to write a
small piece of VBScript, and I discovered that it
actually *forbids* parens around the arguments to
procedure calls (but not function calls).

Fortunately, it requires (or at least allows, not
sure which) commas between the args, so things aren't
as bad as they *could* be.

Also fortunately, the error message was, by the
usual standard of Microsoft error messages,
remarkably helpful.

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


Re: Hello World

2015-01-17 Thread Albert van der Horst
In article h9gqob-c3e@esprimo.zbmc.eu,  c...@isbd.net wrote:
Michael Torrie torr...@gmail.com wrote:
 On 01/17/2015 07:51 AM, Albert van der Horst wrote:
  In article mailman.17471.1420721626.18130.python-l...@python.org,
  Chris Angelico  ros...@gmail.com wrote:
  SNIP
 
  But sure. If you want to cut out complication, dispense with user
  accounts altogether and run everything as root. That's WAY simpler!
 
  I didn't except this strawman argument from you.
  Of course you need a distinction between doing system things as
  root, and working as a normal user. You just don't need sudo.

 I just don't see the distinction.  What's the difference between having
 to type in a root password and having to type in your own administrative
 user password?  Guess we're all just struggling to understand your logic
 here.

One big distinction is that you need to know two passwords to get root
access if there's a real root account as opposed to using sudo.  This
only applies of course if direct root login isn't allowed (via ssh or
whatever).

The other is that if a dozen users have sudo possibility, one compromised
password compromises the whole system. The same administrators that like
sudo will force the users into a safe password of at least 8 characters
a special sign a number and a capital, instead of educating them to
use a strong password like the_horse_eats_yellow_stones. 1]
Chances are that one of the users has a password like
! (first special sign) 1 (first number) Q (first capital)
followed by a weak 5 letter word (or even a guessable one).

Compare that to
Dear administrator, I've to do this. Can I have the root password.
Sure here it is Looks over users shoulder. Are you ready?
Make sure he's logged out. Uses random generator for a new password.

If there is something, anything, change the root password and check
the disk for suid-root files.

There is no such thing as automatic security.
Security requires one thing: attention. And effort. So two things:
attention and effort. And simplicity. So three things: attention,
effort and simplicity.

sudo makes administrators careless, lazy and it is not simple at all.

--
Chris Green

Groetjes Albert

1] I don't claim this is *very* strong, just strong.
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spearc.xs4all.nl =n http://home.hccnet.nl/a.w.m.van.der.horst

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


[issue23248] Update ssl data

2015-01-17 Thread Antoine Pitrou

Antoine Pitrou added the comment:

New patch merges in the old codes.

--
Added file: http://bugs.python.org/file37748/update_ssl_data2.patch

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



[issue23199] libpython27.a in amd64 release is 32-bit

2015-01-17 Thread Steve Dower

Steve Dower added the comment:

So I've grabbed gendef and dlltool from the latest mingw-w64 and will look at 
using those in the future for both 2.7 and 3.5.

According to objdump, I can use these to create file format pe-i386 and 
pe-x86-64 with the same tools. Are these the correct formats for 32-bit and 
64-bit respectively?

My commands are (approximately):

  gendef - python35.dll  mingwlib.def

  dlltool --dllname python35.dll --def mingwlib.def --output-lib 
amd64\libpython35.a -m i386:x86-64

  dlltool --dllname python35.dll --def mingwlib.def --output-lib 
win32\libpython35.a -m i386

--

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



[issue18022] Inconsistency between quopri.decodestring() and email.quoprimime.decode()

2015-01-17 Thread Martin Panter

Changes by Martin Panter vadmium...@gmail.com:


--
nosy: +vadmium

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



Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread alister
On Sat, 17 Jan 2015 21:33:19 +1100, Steven D'Aprano wrote:

 Gregory Ewing wrote:
 
 Marko Rauhamaa wrote:
 Gregory Ewing greg.ew...@canterbury.ac.nz:
 
If those are 24-bit RGB pixels, you could encode 3 characters in each
pixel.
 
 Not since Python3. Characters are Unicode now so you'll need to
 dedicate a pixel for each character.
 
 Depends on which characters you want. With the Flexible Chromatic
 Representation, it could be anything from 1 to 3.
 
 Subpixel rendering is 5% slower than full pixel rendering, so it is
 provably mathematically impossible to print Unicode characters.

:-)



-- 
It's union rules. There's nothing we can do about it. Sorry.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23251] mention in time.sleep() docs that it does not block other Python threads

2015-01-17 Thread R. David Murray

R. David Murray added the comment:

Yes, on consideration I agree with Antoine.  That last sentence should be 
deleted.  Otherwise we'd need to mention that the gil was released every place 
that the gil was released, which would be very redundant.  The general rule is 
that anything that blocks in python releases the GIL, therefore as Antoine says 
the only time we need to document GIL behavior is when that *doesn't* happen.

--

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



[issue20284] patch to implement PEP 461 (%-interpolation for bytes)

2015-01-17 Thread Ethan Furman

Ethan Furman added the comment:

Better patch, along the lines of my original thought:

  - byarrayformat converts bytearray to bytes
  - calls bytesformat (now _PyBytes_Format) to do the heavy lifting
  - uses PyByteArray_FromObject to tranform back to bytearray

Now working on in-place format.

--
Added file: http://bugs.python.org/file37745/issue20284.stoneleaf.03.patch

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



Re: numpy.allclose()

2015-01-17 Thread Ian Kelly
On Sat, Jan 17, 2015 at 7:26 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 I don't understand why they add the error tolerances together. I can
 understand taking the minimum, or the maximum:

The usual idea is that the tolerance is calculated as a relative
value, but an absolute tolerance is used instead when the values get
close to zero, so under normal circumstances the relative tolerance
will dominate and the absolute tolerance will be very small in
comparison. So why add them instead of taking the maximum? I'm not
sure, but I would guess it's probably for efficiency. Determining the
maximum requires the CPU to perform a conditional branch that a simple
addition does not. In any case, this is not unique to numpy.  See
e.g.:

https://books.google.com/books?id=CbH0AwAAQBAJpg=PA164
(equation 8.26)

or:

https://books.google.com/books?id=j0rY3D9fx-0Cpg=PA71
(equation 7.437)

On the other hand, Matlab evidently uses the maximum:
http://www.mathworks.com/help/simbio/ref/absolutetolerance.html

 * taking the minimum is equivalent to the rule numbers are close if they
   differ by no more than BOTH the absolute tolerance AND the relative
   tolerance.

This is generally not the desired semantic, and it's not unheard of to
pass 0 for one of the tolerances, in which case the minimum would
clearly be incorrect.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hello World

2015-01-17 Thread Michael Ströder
alb...@spenarnc.xs4all.nl (Albert van der Horst) wrote:
 In article h9gqob-c3e@esprimo.zbmc.eu,  c...@isbd.net wrote:
 Michael Torrie torr...@gmail.com wrote:
 On 01/17/2015 07:51 AM, Albert van der Horst wrote:
 In article mailman.17471.1420721626.18130.python-l...@python.org,
 Chris Angelico  ros...@gmail.com wrote:
 SNIP

 But sure. If you want to cut out complication, dispense with user
 accounts altogether and run everything as root. That's WAY simpler!

 I didn't except this strawman argument from you.
 Of course you need a distinction between doing system things as
 root, and working as a normal user. You just don't need sudo.

 I just don't see the distinction.  What's the difference between having
 to type in a root password and having to type in your own administrative
 user password?  Guess we're all just struggling to understand your logic
 here.

 One big distinction is that you need to know two passwords to get root
 access if there's a real root account as opposed to using sudo.  This
 only applies of course if direct root login isn't allowed (via ssh or
 whatever).
 
 The other is that if a dozen users have sudo possibility, one compromised
 password compromises the whole system.

Hmm, but it's much worse if a dozen users have to know the root password. With
this they can circumvent sudo completely (e.g. going over IPMI console).

 Compare that to
 Dear administrator, I've to do this. Can I have the root password.
 Sure here it is Looks over users shoulder. Are you ready?
 Make sure he's logged out. Uses random generator for a new password.

This process does not work for dozens of admins maintaining thousands of
machines. Especially when something goes wrong in the night shift and has to
be fixed quickly.

 If there is something, anything, change the root password and check
 the disk for suid-root files.

Better require public key authc for SSH access and the user's own (one-time)
password for sudo. If your security requirements are really high mandate going
through a SSH gateway / jumphost.

 Security requires one thing: attention. And effort. So two things:
 attention and effort. And simplicity. So three things: attention,
 effort and simplicity.

Yes.

 sudo makes administrators careless, lazy and it is not simple at all.

Admins must have separate accounts with separate credentials for
administrative work and must be careful when using an administrative account.

Ciao, Michael.

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


Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Grant Edwards
On 2015-01-17, Roy Smith r...@panix.com wrote:
 In article 54ba39e0$0$13008$c3e8da3$54964...@news.astraweb.com,
  Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:

 Every time I think I would like to learn a new language, I quite quickly run
 into some obvious feature that Python has but the newer language lacks, and
 I think bugger this for a game of soldiers and abandon it.

 Wow.  Another wonderful English phrase to add to my vocabulary.  That's 
 up there with Bob's your uncle :-)

Yup, that one's brilliant.  While it's pretty much obvious what
phrases like that mean when one stumbles across them for the first
time, I find I sometimes don't have a very good grasp of where they
fall on the offensive-polite scale...

--
Grant

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


Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Dan Sommers
On Sat, 17 Jan 2015 18:44:42 +, Grant Edwards wrote:

 ... somebody who only knows how to write C++ [though he can do it in
 several different languages].

+1 QOTW (brilliant phrases in other threads are off topic and are
disqualified)

I have also suffered through such maintenance, but I have never described
it quite so succinctly.

 There was lot's of quiet swearing.

Quiet is *not* one of my strong points.

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


Re: recursive function: use a global or pass a parameter?

2015-01-17 Thread Chris Angelico
On Sun, Jan 18, 2015 at 4:30 AM, Albert van der Horst
alb...@spenarnc.xs4all.nl wrote:
 The proper technique is make the global local to the normal subroutine,
 then make the subroutine with those parameters you don't want to see
 also local to that subroutine.
 E.g.

 def fib(n):
 ' return the n-th Fibonacci number '
 a,b = 0,1
 def fib1(ap,bp):
' for f_n,f_n+1, return f_n+1,f_n+2 '
return bp,ap+b
 for i in xrange(n):
a,b = fib1(a,b)
 return a

That's a fairly useless use of a nested function... you could in-line
it without any effort at all:

def fib(n):
a,b = 0,1
for i in xrange(n):
a,b = b,a+b
return a

Even in the OP's example, where the inner function needs to call
itself recursively, it doesn't need to be a closure; a simple
out-of-line helper function does work (and has already been suggested;
Gregory was, I think, first). In my opinion, it's not materially
different from having an argument with a default.

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


[issue23248] Update ssl data

2015-01-17 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
versions: +Python 2.7, Python 3.4

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



Re: recursive function: use a global or pass a parameter?

2015-01-17 Thread Gregory Ewing

Roy Smith wrote:

I will commonly put something like:

import logging
logger = logging.getLogger(logger-name-for-my-module)


But that's not really a global variable, it's a
global constant. There's nothing wrong with those,
we use them all the time -- classes, functions, etc.

If you were to rebind logger to a different one from
time to time in your code, *then* it would be a global
variable, subject to the usual cautions.

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


[issue23255] SimpleHTTPRequestHandler refactor for more extensible usage.

2015-01-17 Thread Martin Panter

Changes by Martin Panter vadmium...@gmail.com:


--
nosy: +vadmium

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



[issue23259] Remove dummy reuse optimization from sets

2015-01-17 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This can be a common case in following algorithm (mesh optimization):

while elems:
elem = elems.pop()
changed = optimize(elem)
if changed:
elems.update(neighbors(elem))

--
nosy: +serhiy.storchaka

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



[issue22919] Update PCBuild for VS 2015

2015-01-17 Thread Steve Dower

Steve Dower added the comment:

Closing again, as Victor's issue was resolved (VS 2010 SP1 is needed, and I'm 
updating the devguide to specify that on #23257).

--
resolution:  - fixed
status: open - closed

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



[issue23239] SSL match_hostname does not accept IP Address

2015-01-17 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
keywords: +patch
Added file: http://bugs.python.org/file37746/ip_certs.patch

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



[issue21817] `concurrent.futures.ProcessPoolExecutor` swallows tracebacks

2015-01-17 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Thank you very much. Everything is now committed.

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

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



[issue23258] Cannot Install Python 3.4.2 on Windows 7 64 bit / screen print attached

2015-01-17 Thread steve

New submission from steve:

I down loaded and tried to install version 3.4.2 on a Windows 7 64 bit system.

2 error messages came up saying that I had to stop two Windows systems tasks to 
allow the install to complete.  Please see the attached screen print for 
details. 

What can I do to resolve this install problem ???

--
components: Windows
files: Python_install-error-mgg.png
messages: 234193
nosy: 20scanman, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Cannot Install Python 3.4.2  on Windows 7 64 bit / screen print attached
versions: Python 3.4
Added file: http://bugs.python.org/file37747/Python_install-error-mgg.png

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



Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread alister
On Sat, 17 Jan 2015 19:08:21 +, Dan Sommers wrote:

 On Sat, 17 Jan 2015 18:44:42 +, Grant Edwards wrote:
 
 ... somebody who only knows how to write C++ [though he can do it in
 several different languages].
 
 +1 QOTW (brilliant phrases in other threads are off topic and are
 disqualified)
 
 I have also suffered through such maintenance, but I have never
 described it quite so succinctly.
 
 There was lot's of quiet swearing.
 
 Quiet is *not* one of my strong points.

How about Some programmes have 20 years of experience, some have 1 year 
of experience 20 times

it covers pretty much the same poor coding practices.

-- 
Ditat Deus.
[God enriches]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Gregory Ewing

Steven D'Aprano wrote:


def a(x=4)
x+2
end

a + b = 7
a+b   = 7
a+ b  = 7
a +b  = 3

A shiny new penny for any non-Ruby coder who can explain that!


Seems pretty obvious to me: the Ruby interpreter is
infested with demons.

DWIM = Demonic Whim Infers Meaning

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


[issue23253] Delay-load ShellExecute

2015-01-17 Thread Steve Dower

Steve Dower added the comment:

Yeah, I hate touching posixmodule.c for the same reason. It'd be nice to split 
it up into separate platform files, but nobody is volunteering for that.

If you focus on the performance, then yeah, this change probably isn't worth 
it. OTOH, the number of Windows platforms keep increasing (e.g. ARM, 
phone/tablet/various sandboxes, etc.) and the fewer dependencies we have the 
more likely Python will Just Work in them. (And the more value that a split up 
posixmodule.c will have... guess it'll have to happen eventually.)

--

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



Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Gregory Ewing

Chris Angelico wrote:

Every once in a while, someone looks at Py2's print statement and
Py3's print function and says, why not allow function calls without
parentheses. This right here is why not.


There's also the fact that the parens are needed to
distinguish between calling a function and using the
function itself as a value.

Ruby doesn't have that problem because it doesn't
have functions, only methods, and the only thing you
can do with a method in Ruby is call it.

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


Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Chris Angelico
On Sun, Jan 18, 2015 at 8:56 AM, Gregory Ewing
greg.ew...@canterbury.ac.nz wrote:
 Ruby doesn't have that problem because it doesn't
 have functions, only methods, and the only thing you
 can do with a method in Ruby is call it.

So functions aren't first-class objects in Ruby? Bleh. I've become
quite accustomed to passing them around casually, in several
languages. Even C lets you pass function pointers around.

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


Re: Why do the URLs of posts here change?

2015-01-17 Thread Gregory Ewing

Albert van der Horst wrote:

Knowing that the source is an mbox file, I don't need to follow
that link to conclude that one is not very inventive.
It suffices to replace the content of the message by
a repetition of '\n'.


Editing the mbox file isn't the problem. From what I
gather, telling mailman to regenerate the web pages
from the mbox file causes all the messages to be given
new ID numbers, even if they remain in the same places
in the mbox.

So the web pages as well as the mbox would have to
be edited by hand, instead of using the auto regen
process.

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


[issue23260] Update Windows installer

2015-01-17 Thread Mark Lawrence

Changes by Mark Lawrence breamore...@yahoo.co.uk:


--
nosy: +BreamoreBoy

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



Re: lambdak: multi-line lambda implementation in native Python

2015-01-17 Thread Grant Edwards
On 2015-01-16, Gregory Ewing greg.ew...@canterbury.ac.nz wrote:

 We're really quite spoiled in Python-land. It's easy
 to forget just *how* spoiled we are until you go back
 and try to do something in one of the more primitive
 languages...

I had to do some work in PHP yesterday -- fixing up some code that was
written by somebody who only knows how to write C++ [though he can do
it in several different languages].

There was lot's of quiet swearing.

--
Grant


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


[issue23239] SSL match_hostname does not accept IP Address

2015-01-17 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Here is a patch.

--
stage: needs patch - patch review

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



[issue23259] Remove dummy reuse optimization from sets

2015-01-17 Thread Raymond Hettinger

New submission from Raymond Hettinger:

The lookkey routines in Object/setobject.c have logic to track the first open 
freeslot in a search.  

The benefit is that new keys can reuse previously deleted slots.  The benefit 
only occurs in cases where keys are added, then some removed, and then more 
added with no intervening resizes (which clear all dummy entries) and only when 
the newly added keys happen to land on previously deleted entries.

The cost of the optimization is the extra logic in the inner search loop, an 
extra freeslot stackframe field that needs to be saved and restored, and extra 
logic on the loop exit.  It also causes dummies to leak out of the lookkey 
routines so that the code in contains(), discard(), and insert() all have to 
check for the dummy case.

This patch removes the freeslot tracking.  It saves one field on the 
stackframe, simplifies the lookkey inner-loop logic, simplifies the lookkey 
found_null logic, it confines knowledge of dummies to just the lookkey 
functions, and it simplifies the code in the insert(), contains(), and 
discard() functions.

In short, it looks like the freeslot idea was a net negative -- it optimized an 
uncommon case at the cost of slowing and complicating the common cases.

--
assignee: rhettinger
components: Interpreter Core
files: late8.diff
keywords: patch
messages: 234198
nosy: rhettinger
priority: low
severity: normal
stage: patch review
status: open
title: Remove dummy reuse optimization from sets
type: performance
versions: Python 3.5
Added file: http://bugs.python.org/file37750/late8.diff

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



Re: recursive function: use a global or pass a parameter?

2015-01-17 Thread Gregory Ewing

Yawar Amin wrote:


Cool ... but it looks like this can still potentially hit the max
recursion limit?


It depends on the nature of your data. If the data is
a tree, it's very unlikely you'll reach the recursion
limit unless the tree is massively unbalanced.

If there's a chance of that, or if the data structure
is really a graph that could contain long linear
chains, then a non-recursive solution is safer.

Incidentally, Python's pickle suffers from this
problem -- it's possible to create a structure that
can't be pickled due to excessive recursion depth:

 x = []
 for i in range(5000):
...  x = [x]
...
 import pickle
 s = pickle.dumps(x)
Traceback (most recent call last):
  File stdin, line 1, in module
RuntimeError: maximum recursion depth exceeded while pickling an object

Fortunately, the kinds of structures that cause this
tend not to be used in Python, e.g. we normally use
Python list objects instead of linked lists. So most
of the time, pickle gets away with using recursion.

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


[issue23259] Remove dummy reuse optimization from sets

2015-01-17 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Even in the mesh algorithm, we let resizing periodically clean-up the dummies.  
 The idea is to not pay the freeslot tracking cost on every lookup and instead 
only clean-up periodically (which would likely give better performance for the 
mesh algorithm as well, since making a single pass clean-up during resizing is 
cheaper than doing multi-step tracking for every insertion).  The slots do get 
reused, just not immediately.

Also, the idea is to not let the possibility of pop-change-update algorithms 
create a cost for the more common uses of sets (uniquification, fast membership 
testing, and set-to-set operations such as union, intersection, and difference).

--

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



[issue23260] Update Windows installer

2015-01-17 Thread Steve Dower

Steve Dower added the comment:

Patch. I'm also revising Doc/using/windows.rst, but I don't want to delay the 
initial reviews.

I don't think this is perfect, but it works well enough for the first alpha 
(scheduled for 8 Feb), so I want to get it in and stabilised now rather than at 
the last minute. There'll be more features and work to do.

There's a README.txt file (which I'll attach next) that has an overview of the 
installer. It'll be worth reading that first before looking at the code.

And apologies if the code makes no sense. I'm happy to explain sections, but 
WiX is about 90% magic (and the rest is MSBuild magic) and so any explanation 
is likely to be unsatisfactory. I've been working with both of these pretty 
intently for the last few years and I still don't feel like I've mastered 
them...

--
keywords: +patch
Added file: http://bugs.python.org/file37751/23260_1.diff

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



[issue23260] Update Windows installer

2015-01-17 Thread Steve Dower

Changes by Steve Dower steve.do...@microsoft.com:


Added file: http://bugs.python.org/file37752/README.txt

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



Re: Hello World

2015-01-17 Thread Steven D'Aprano
Mark Lawrence wrote:

 Bah humbug, this has reminded me of doing secure work whereby each
 individual had two passwords, both of which had to be changed every
 thirty days, and rules were enforced so you couldn't just increment the
 number at the end of a word or similar.

I hate and despise systems that force you to arbitrarily change a good
strong password after N days for no good reason.

The utterly bad reason often given by people who don't understand
probability is that if hackers try to guess your password by brute-force,
changing the password regularly will make it harder for them. That's simply
wrong, and is based on a misunderstanding of probability.

The merely poor reason given by the more thoughtful sys admins is, if the
password hashes get stolen, the hacker has a maximum of N days (and
possibly less) to crack the hashes and recover the passwords before they
get changed. That's okay as far as it goes, but it's the wrong solution for
the problem. The right solution is to salt the passwords, and to secure the
hashes from theft. Users should only be forced to change their password if
the hashes are stolen, not at arbitrary intervals.

The problem with regular password changes is that it makes it significantly
harder remember passwords, especially one that you might only use rarely.
It encourages users to pick weak, trivial passwords that can be trivially
incremented each time the computer insists they change it, blahblah-JAN
or blahblahblah1, or to simply write the password down or a Post-it note
on their computer. In isolation, regular password changes seems like a good
idea, but in practice they are not.

Password management is hard enough without having to throw away perfectly
good, strong, memorable passwords every N days just in case.



-- 
Steven

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


[issue23260] Update Windows installer

2015-01-17 Thread Steve Dower

New submission from Steve Dower:

Updating the installer for better security and robustness. Large patch coming 
soon (just getting an issue number to put in NEWS).

--
assignee: steve.dower
components: Windows
messages: 234203
nosy: steve.dower, tim.golden, zach.ware
priority: release blocker
severity: normal
status: open
title: Update Windows installer
type: enhancement
versions: Python 3.5

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



[issue23231] Fix codecs.iterencode/decode() by allowing data parameter to be omitted

2015-01-17 Thread Martin Panter

Martin Panter added the comment:

Another idea that doesn’t involve changing the incremental codec APIs is kind 
of described in https://bugs.python.org/issue7475#msg145986: to add format 
parameters to iterencode() and iterdecode(), which would allow it to determine 
the right data type to finalize the codecs with.

--

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



[issue23260] Update Windows installer

2015-01-17 Thread Steve Dower

Steve Dower added the comment:

As I expected, shortly after posting this I find a significant issue with the 
way the installer will work.

Expect a revised patch soon :)

--

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



Re: numpy.allclose()

2015-01-17 Thread Steven D'Aprano
Ian Kelly wrote:

 On Sat, Jan 17, 2015 at 7:26 AM, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
 I don't understand why they add the error tolerances together. I can
 understand taking the minimum, or the maximum:
 
 The usual idea is that the tolerance is calculated as a relative
 value, but an absolute tolerance is used instead when the values get
 close to zero, so under normal circumstances the relative tolerance
 will dominate and the absolute tolerance will be very small in
 comparison. 

That suggests that approx_equal() should return True if the actual error is
smaller than *either* the absolute or relative error, that is, using the
maximum.


 So why add them instead of taking the maximum? I'm not 
 sure, but I would guess it's probably for efficiency. Determining the
 maximum requires the CPU to perform a conditional branch that a simple
 addition does not.

That's... horrible. 

Tell me whether these two numbers differ by at most X or Y%.

Oh, that would take a nanosecond longer than I think is reasonable, so I'm
instead going to tell you whether they differ by some arbitrary Z instead.

I'm guessing that can only have come from the mindset of C/C++ programmers,
where this sort of thing is considered acceptable:

http://blogs.msdn.com/b/oldnewthing/archive/2014/06/27/10537746.aspx

:-)


 In any case, this is not unique to numpy.  See 
 e.g.:
 
 https://books.google.com/books?id=CbH0AwAAQBAJpg=PA164
 (equation 8.26)

Ah, well as soon as you start using GPUs for numerical computation, you're
already living in a state of sin. GPU's attitude to numerical correctness
is best described as meh, close enough.

Seriously, anyone familiar with the horrible state of numeric computing
prior to IEEE-756 surely cannot look at GPU numerics without having
flashbacks to the bad old days where:

if x != 0:
y = 1/x

could crash with a divide by zero!


[...]
 * taking the minimum is equivalent to the rule numbers are close if they
   differ by no more than BOTH the absolute tolerance AND the relative
   tolerance.
 
 This is generally not the desired semantic, and it's not unheard of to
 pass 0 for one of the tolerances, in which case the minimum would
 clearly be incorrect.

True. In that case, you would have to treat 0 as a special case, which
starts getting messy.




-- 
Steven

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


[issue23180] Rename IDLE's Windows menu item to Window

2015-01-17 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I cannot currently test or commit a patch.  So go ahead.

--

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



[issue23180] Rename IDLE's Windows menu item to Window

2015-01-17 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 9a451aaa8ddb by Ned Deily in branch '2.7':
Issue #23180: Rename IDLE Windows menu item to Window.
https://hg.python.org/cpython/rev/9a451aaa8ddb

New changeset 8c0e5b507794 by Ned Deily in branch '3.4':
Issue #23180: Rename IDLE Windows menu item to Window.
https://hg.python.org/cpython/rev/8c0e5b507794

New changeset af092c1d3747 by Ned Deily in branch 'default':
Issue #23180: merge from 3.4
https://hg.python.org/cpython/rev/af092c1d3747

--
nosy: +python-dev

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



[issue20121] quopri_codec newline handling

2015-01-17 Thread Martin Panter

Martin Panter added the comment:

Here is a patch that clarifies in the documentation and test suite how newlines 
work in the “quopri” and “binascii” modules. It also fixes the native Python 
implementation to support CRLFs.

* \n is used by default (e.g. for soft line breaks if the input has no hard 
line breaks)
* CRLF is used instead if found in input (even in non-text mode!)
* Typo errors in documentation
* quopri uses istext=True
* header flag does not affect newline encoding; only istext affects it

One corner case concerns me slightly: binascii.b2a_qp(istext=False) will use \n 
for soft line breaks by default, but will suddenly switch to CRLF if the input 
data happens to contain a CRLF sequence. This is despite the CRLFs from the 
data being encoded and therefore not appearing in the output themselves.

--
assignee:  - docs@python
components: +Documentation
keywords: +patch
nosy: +docs@python
Added file: http://bugs.python.org/file37756/quopri-newline.patch

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



Re: Hello World

2015-01-17 Thread Devin Jeanpierre
Sorry for necro.

On Sat, Dec 20, 2014 at 10:44 PM, Chris Angelico ros...@gmail.com wrote:
 On Sun, Dec 21, 2014 at 5:31 PM, Terry Reedy tjre...@udel.edu wrote:
 Just to be clear, writing to sys.stdout works fine in Idle.
 import sys; sys.stdout.write('hello ')
 hello  #2.7

 In 3.4, the number of chars? bytes? is returned and written also.

 Whether you mean something different by 'stdout' or not, I am not sure.  The
 error is from writing to a non-existent file descriptor.

 That's because sys.stdout is replaced. But stdout itself, file
 descriptor 1, is not available:

It surprises me that IDLE, and most other shells, don't dup2
stdout/err/in so that those FDs talk to IDLE.

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


Re: Hello World

2015-01-17 Thread Michael Torrie
On 01/17/2015 11:47 AM, Michael Ströder wrote:
 sudo makes administrators careless, lazy and it is not simple at all.
 
 Admins must have separate accounts with separate credentials for
 administrative work and must be careful when using an administrative account.

Right.  This is not a bad idea in a large organization.

In any case, Sudo is more auditable than su in my opinion, but more
importantly, it's much easier to revoke.  With su, if I fire an admin, I
have to change root passwords on every machine, and redistribute the new
password to every admin that needs it.  With sudo, I might still change
the root password, but I'll lock the root password up in a safe box
somewhere, and life goes on for everyone else.  In fact with root
disabled entirely, the whole root password needing to be changed when a
person leaves the company is completely eliminated.  sudo allows us
(especially with the idea about separate admin credentials) to have
multiple, controllable, auditable, root passwords in effect.  Surely the
benefit of this can be seen.

Another good alternative to sudo is ksu, which is a kerberized su.  This
also provides an excellent audit trail, and is easy to revoke.  This may
be more to Mr. van der Horst's liking, as normally ksu is configured to
accept only principals with a /admin suffix (arbitrarily chosen). So
admins would have their normal principal, and their admin principal.
It's a pretty slick system if you have Kerberos up and running.

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


Re: Hello World

2015-01-17 Thread Steven D'Aprano
Albert van der Horst wrote:

 In article h9gqob-c3e@esprimo.zbmc.eu,  c...@isbd.net wrote:
Michael Torrie torr...@gmail.com wrote:
 On 01/17/2015 07:51 AM, Albert van der Horst wrote:
  In article mailman.17471.1420721626.18130.python-l...@python.org,
  Chris Angelico  ros...@gmail.com wrote:
  SNIP
 
  But sure. If you want to cut out complication, dispense with user
  accounts altogether and run everything as root. That's WAY simpler!
 
  I didn't except this strawman argument from you.
  Of course you need a distinction between doing system things as
  root, and working as a normal user. You just don't need sudo.

 I just don't see the distinction.  What's the difference between having
 to type in a root password and having to type in your own administrative
 user password?  Guess we're all just struggling to understand your logic
 here.

One big distinction is that you need to know two passwords to get root
access if there's a real root account as opposed to using sudo.  This
only applies of course if direct root login isn't allowed (via ssh or
whatever).
 
 The other is that if a dozen users have sudo possibility, one compromised
 password compromises the whole system. The same administrators that like
 sudo will force the users into a safe password of at least 8 characters
 a special sign a number and a capital, instead of educating them to
 use a strong password like the_horse_eats_yellow_stones. 1]

Sigh. I like XKCD, I really do, but anyone who thinks that brute force
attacks cannot simply replace words for characters is deluding themselves.

Consider a password like mg93H$8s. Each character is taken from an
alphabet of lowercase and uppercase letters plus digits, plus 32
punctuation characters and other symbols available on a US keyboard. There
are 26+26+10+32 = 94 different letters in this alphabet. If your password
is ten characters long, there is a potential pool of 94**10 available
passwords. Let's say we strip out 90% of them for being too easy to guess
(say, eight As in a row, or it happens to contain your username). That
still leaves us with:

94**10//10 = 5386151140948997017

potential passwords.

Now consider the XKCD scheme. You pick four words from a dictionary and
concatenate them. On my system, /usr/share/dict/words has a little less
than 500,000 words. The problem is, most of them are not really memorable,
and many of them are very low entropy. Here's a selection from the first
few starting with A:

A  A.  a  a'  a-  a.  A-1  A1  a1  A4  A5  AA  aa
A.A.A.  AAA  aaa  

So in practice people are going to choose words from a much, much smaller
selection. I estimate that most people are going to choose words from a
pool of about 10,000 words or so, but let's imagine that you have four
times the vocabulary (or imagination) of the average person and pick from a
pool of 40,000 words, specially crafted to avoid low-entropy selections
such as AAA A4 aa a. That gives:

4**4 = 256

potential passwords, half that of the conventional scheme. And if people
have biases in the words they pick -- and you better believe they will --
that will be reduced even further. Password crackers will take advantage of
the fact that most XKCD-style passwords will include at least one of the
most common thousand or so words, reducing the search space significantly.

I believe that the state of the art of password cracking is such now that
people cannot realistically expect to remember sufficiently strong
passwords for all the things they need passwords for. I believe that the
only good solution is to have one strong passphrase that you use to protect
a password manager, which in turn uses long (12 character or more),
completely random passwords.

Even that doesn't protect you, because your security is controlled by
websites and banks etc. with stupid security policies. E.g. I am forced to
deal with one bank that uses a cryptographic key to sign in to their bank,
but your passphrase is limited to exactly eight characters. Another bank I
use limits you to SIX characters, taken from case-insensitive(!) letters,
digits, and a small set of punctuation.

At least they do enforce rate limiting on account logins: three wrong login
attempts and they lock your account and force you to go to a branch in
person to recover it. (Can you say Denial Of Service Attack? I can.)



 Compare that to
 Dear administrator, I've to do this. Can I have the root password.
 Sure here it is Looks over users shoulder. Are you ready?
 Make sure he's logged out. Uses random generator for a new password.

That is a ridiculously impractical system for anything other than a home
system.

Problems include:

- You have a single point of failure, the one administrator who controls
access to the root password. The day he stays home with his phone switched
off to play WOW is the day the mail server dies and you need root to fix
it. The Bus Factor (what do you do when the administrator gets hit by a
bus?) is critical.

- 

Re: Hello World

2015-01-17 Thread Steven D'Aprano
Roy Smith wrote:

 In article 54bb1c83$0$12979$c3e8da3$54964...@news.astraweb.com,
  Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
 
 Even that doesn't protect you, because your security is controlled by
 websites and banks etc. with stupid security policies. E.g. I am forced
 to deal with one bank that uses a cryptographic key to sign in to their
 bank, but your passphrase is limited to exactly eight characters. Another
 bank I use limits you to SIX characters, taken from case-insensitive(!)
 letters, digits, and a small set of punctuation.
 
 Tell me about it.  I have an E-Trade ATM card.  When I first got it, I
 set it up with a 6 digit PIN.  I was shocked to discover some time later
 that it actually only looks at the first 4 digits.  And, no, I'm not
 talking *characters*, I'm talking *digits*.  There are 10**4 possible
 PINs.  The mind boggles.
 
 On the other hand, E-Trade gave me an RSA key fob so I use two-factor
 authentication on their web site.

You know that two-factor authentication doesn't offer any real security
against Man In The Middle attacks? Scenario:

* You log in to the bank, and transfer $1 to me.
* Evil haxor intercepts the transfer between your PC and the Internet,
  changing it to a request to transfer ONE MILLION DOLLARS to evil 
  haxor's account.
* Bank receives the request and sends you a token.
* You receive the token and approve the transfer.
* Evil haxor makes the money disappear.
* When you complain to the bank that your account is ONE MILLION DOLLARS
  overdrawn, they insist that you authorized the transfer so their 
  liability is limited to exactly Sweet FA.

(I am very cynical about most of the security features the banks are
pushing for, since in my opinion they are more about giving the banks
plausible deniablity so they can push responsibility for security breaches
onto the customer.)


As soon as I heard that banks were turning to two-factor authentication I
predicted that attackers would trivially move to man-in-the-middle and
man-in-the-browser attacks to get around them. And sure enough, as long ago
as 2006 that's exactly what happened:

http://blog.washingtonpost.com/securityfix/2006/07/citibank_phish_spoofs_2factor_1.html

More here:

https://www.schneier.com/blog/archives/2012/09/man-in-the-midd_5.html

(read the comments for more examples)

All of the MITM attacks I know of involve social engineering attacks, but if
and when customers get too sophisticated to fall for phishing attacks[1],
the bad guys will move to scenarios like the one I described, where they
hijack your own legitimate transactions.




[1] Try not to laugh. It could happen.

-- 
Steven

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


[issue23180] Rename IDLE's Windows menu item to Window

2015-01-17 Thread Ned Deily

Ned Deily added the comment:

Thanks for the patches, Al.  Pushed for release in 2.7.10, 3.4.3, and 3.5.0.

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

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



[issue23255] SimpleHTTPRequestHandler refactor for more extensible usage.

2015-01-17 Thread Ent

Ent added the comment:

@vadmium: My Mistake. It should read file path not file object. (500 error 
when submitting to review page.)

Renaming get_html_or_dir_path to get_path_or_dir for accurate description.

Also renaming copyfile to more pythonic copy_file.

--
Added file: http://bugs.python.org/file37757/simplehttp-fcn-rnm-doc.patch

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



Re: Hello World

2015-01-17 Thread Chris Angelico
On Sun, Jan 18, 2015 at 2:50 PM, Tim Chase
python.l...@tim.thechases.com wrote:
 You think that's bad, one million Google Authenticator 2-factor
 verification codes were leaked:

 https://twitter.com/paulmutton/status/509991378647277568

 Those hackers are a wily bunch.  ;-)

http://torrent-city.net/download/Li/List-of-ALL-ip-addresses-[hacking-tool]-[source-code-included].5185923.html

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


[issue23211] test.test_logging.SMTPHandlerTest failing on Snow Leopard

2015-01-17 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 90b664532d1c by Ned Deily in branch '3.4':
Issue #23211: Workaround test_logging failure on some OS X 10.6 systems:
https://hg.python.org/cpython/rev/90b664532d1c

New changeset e3dfe942697e by Ned Deily in branch 'default':
Issue #23211: merge from 3.4
https://hg.python.org/cpython/rev/e3dfe942697e

--
nosy: +python-dev

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



[issue23211] test.test_logging.SMTPHandlerTest failing on Snow Leopard

2015-01-17 Thread Ned Deily

Ned Deily added the comment:

I *thought* I had tested 3.4 before; sorry about that!

--

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



[issue23211] test.test_logging.SMTPHandlerTest failing on Snow Leopard

2015-01-17 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 65ac2b992673 by Ned Deily in branch '3.4':
Issue #23211: Fix patch for 3.4 differences.
https://hg.python.org/cpython/rev/65ac2b992673

New changeset 2d71d0f954fb by Ned Deily in branch 'default':
Issue #23211: null merge
https://hg.python.org/cpython/rev/2d71d0f954fb

--

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



Re: Hello World

2015-01-17 Thread Chris Angelico
On Sun, Jan 18, 2015 at 10:46 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 The merely poor reason given by the more thoughtful sys admins is, if the
 password hashes get stolen, the hacker has a maximum of N days (and
 possibly less) to crack the hashes and recover the passwords before they
 get changed. That's okay as far as it goes, but it's the wrong solution for
 the problem.

Related to that is another reason I've heard: if your password is
figured out by some means other than hash theft [1], there's a maximum
of N days to make use of it. But let's face it, if someone gets hold
of one of your accounts, it won't take long to do serious damage. Even
if it's not a high-profile target like email or banking, a service
with your password known by someone else is a problem *now*, not
after a month of research or something.

Password maximum age is the wrong solution to a few problems, and is
itself a problem. Don't do it.

ChrisA

[1] eg http://xkcd.com/792/
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23259] Remove dummy reuse optimization from sets

2015-01-17 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 In short, it looks like the freeslot idea was a net negative -- it
 optimized an uncommon case at the cost of slowing and complicating the 
 common cases.

Do you have a benchmark showing the slowing down?

--
nosy: +pitrou

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



[issue23261] Clean-up set.pop() search finger logic

2015-01-17 Thread Raymond Hettinger

New submission from Raymond Hettinger:

The existing search finger is stored in a hackish way (using the hash field of 
entry zero in the hash table).  Replace this with normal coding techniques 
(saving the field in the set object).

Cost one extra field in the set object.  Benefit, remove an arcane hack and 
simplify the set.pop() code just a little bit.

--
assignee: rhettinger
components: Interpreter Core
files: finger.diff
keywords: patch
messages: 234216
nosy: rhettinger
priority: low
severity: normal
status: open
title: Clean-up set.pop() search finger logic
versions: Python 3.5
Added file: http://bugs.python.org/file37753/finger.diff

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



[issue23211] test.test_logging.SMTPHandlerTest failing on Snow Leopard

2015-01-17 Thread Ned Deily

Ned Deily added the comment:

OK, the workaround is applied for 3.4.3 and 3.5.0.

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

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



[issue23259] Remove dummy reuse optimization from sets

2015-01-17 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I've observed the generated assembly has fewer instructions on the critical 
path and that a register was freed-up.  That's enough for me in this case (it's 
too easy to get trapped in local minimums in timing small changes like this).

Do either of you have a technical comment on the patch?  If it isn't broken or 
seriously misguided, I will likely apply it shortly.

--
nosy: +tim.peters

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



[issue23180] Rename IDLE's Windows menu item to Window

2015-01-17 Thread Ned Deily

Ned Deily added the comment:

LGTM.  Terry, should I apply them?

--

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



[issue23260] Update Windows installer

2015-01-17 Thread Steve Dower

Steve Dower added the comment:

New patch with some changes to how optional debug symbols and binaries are 
handled. (I misunderstood how a particular WiX feature worked...)

--
Added file: http://bugs.python.org/file37754/23260_2.diff

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



[issue6671] webbrowser doesn't respect xfce default browser

2015-01-17 Thread Stephan Sokolow

Changes by Stephan Sokolow bugs_python_org.zen.ssoko...@spamgourmet.com:


--
nosy: +ssokolow

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



[issue23262] webbrowser module broken with Firefox 36+

2015-01-17 Thread Stephan Sokolow

New submission from Stephan Sokolow:

As of Firefox 36 (currently in beta channel), the -remote option has been 
removed.

https://www.mozilla.org/en-US/firefox/36.0a2/auroranotes/
https://www.mozilla.org/en-US/firefox/36.0beta/releasenotes/

As such, attempting to open http://www.example.com/ using webbrowser.open() or 
webbrowser.open_new_tab() results in File not Found tabs pointing to these 
two URLs, respectively:

file:///home/ssokolow/openURL%28http://www.example.com/%29
file:///home/ssokolow/openURL%28http://www.example.com/,new-tab%29

As I happen to have the Dead Snakes PPA set up on Lubuntu 14.04 for use with 
tox, I was able to confirm this as an issue in Python 2.7, 3.1, 3.2, 3.3, and 
3.4.

--
components: Library (Lib)
messages: 234218
nosy: ssokolow
priority: normal
severity: normal
status: open
title: webbrowser module broken with Firefox 36+
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4

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



Re: Hello World

2015-01-17 Thread Tim Chase
On 2015-01-17 22:18, Roy Smith wrote:
 Tell me about it.  I have an E-Trade ATM card.  When I first got
 it, I set it up with a 6 digit PIN.  I was shocked to discover some
 time later that it actually only looks at the first 4 digits.  And,
 no, I'm not talking *characters*, I'm talking *digits*.  There are
 10**4 possible PINs.  The mind boggles.

You think that's bad, one million Google Authenticator 2-factor
verification codes were leaked:

https://twitter.com/paulmutton/status/509991378647277568

Those hackers are a wily bunch.  ;-)


-tkc




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


[issue23263] Python 3 gives misleading errors when validating unicode identifiers

2015-01-17 Thread Matt Bachmann

New submission from Matt Bachmann:

PEP 3131 changed the definition of valid identifiers to match this pattern

XID_Start XID_Continue* .

Currently if you have an invalid character in an identifier you get this error

☺ = 4
SyntaxError: invalid character in identifier


This is fine in most cases. But in some cases the problem is not the character 
is invalid so much as the character may not be used to START the identifier. 
One example of this is the combining grave accent which is an XID_CONTINUE 
character but not an XID_START

So ̀e is an invalid identifier but è is a valid identifier. So the ̀ character 
is not invalid in all cases.

The attached patch attempts to clarify this by providing a different error when 
the start character is invalid.

 ̀e = 4
  File stdin, line 1
̀e = 4
 ^
SyntaxError: invalid start character in identifier

However, if the character is simply not allowed (as it is neither an XID_START 
or an XID_CONTINUE character) the original error is used.
 ☺smile = 4
  File stdin, line 1
☺smile = 4
 ^
SyntaxError: invalid character in identifier

--
components: Unicode
files: clarify_unicode_identifier_errors.patch
keywords: patch
messages: 234222
nosy: Matt.Bachmann, ezio.melotti, haypo
priority: normal
severity: normal
status: open
title: Python 3 gives misleading errors when validating unicode identifiers
type: enhancement
versions: Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6
Added file: 
http://bugs.python.org/file37755/clarify_unicode_identifier_errors.patch

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



[issue23259] Remove dummy reuse optimization from sets

2015-01-17 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Fewer instructions doesn't necessarily translate into better performance. The 
bottleneck in superscalar, pipelined processors is often the data dependency 
path between instructions. Adding instructions may as well not slow anything 
down, if those instructions don't lengthen the dependency path.

It would be interesting to know what the impact of the patch is on the 
workloads that were supposed to be helped by the removed logic.

--

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



  1   2   >