Re: RE Module Performance

2013-07-27 Thread Steven D'Aprano
On Fri, 26 Jul 2013 08:46:58 -0700, wxjmfauth wrote:

 BTW, I'm pleased to read sequence of bits and not bytes. Again, utf
 transformers are producing sequence of bits, call Unicode Transformation
 Units, with lengths of 8/16/32 *bits*, from there the names utf8/16/32.
 UCS transformers are (were) producing bytes, from there the names
 ucs-2/4.


Not only does your distinction between bits and bytes make no practical 
difference on nearly all hardware in common use today[1], but the Unicode 
Consortium disagrees with you, and defines UTC in terms of bytes:

A Unicode transformation format (UTF) is an algorithmic mapping from 
every Unicode code point (except surrogate code points) to a unique byte 
sequence.

http://www.unicode.org/faq/utf_bom.html#gen2




[1] There may still be some old supercomputers where a byte is more than 
8 bits in use, but they're unlikely to support Unicode.

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


Re: Contact information for Jim Hugunin?

2013-07-27 Thread greymausg
On 2013-07-24, Albert Hopkins mar...@letterboxes.org wrote:
 On Mon, Jul 22, 2013, at 05:33 PM, Larry Hastings wrote:
 
 
 Does anybody have an email address (or anything, really) for Jim 
 Hugunin?  He left Google in May and appears to have dropped off the face 
 of the internet.  Please email me privately.
 
 I swear I will use the information only for good and never for evil,

 Is that your definition of good and evil or mine?

After all, Google has its own definition!


-- 
maus
 .
  .
...
-- 
http://mail.python.org/mailman/listinfo/python-list


Cross-Platform Python3 Equivalent to notify-send

2013-07-27 Thread Devyn Collier Johnson
Linux systems with the proper software can use the notify-send 
command. Is there a cross-platform Python3 equivalent?


Mahalo,

Devyn Collier Johnson
devyncjohn...@gmail.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Cross-Platform Python3 Equivalent to notify-send

2013-07-27 Thread Chris “Kwpolska” Warrick
On Sat, Jul 27, 2013 at 12:58 PM, Devyn Collier Johnson
devyncjohn...@gmail.com wrote:
 Linux systems with the proper software can use the notify-send command. Is
 there a cross-platform Python3 equivalent?

 Mahalo,

 Devyn Collier Johnson
 devyncjohn...@gmail.com
 --
 http://mail.python.org/mailman/listinfo/python-list

You already asked this on Thursday.  And the answer is probably “no”.  Creating

Under X11-based systems, you would have to call the dbus notification
APIs and pray that the user has something to handle it running (KDE,
GNOME Shell, XFCE4’s notification daemon).  Under Mac OS X 10.7 and
further, you need to work with some system APIs, and that may not be
easy, but possible (eg. https://github.com/alloy/terminal-notifier for
Ruby).

But Windows?  GOOD LUCK!  The following options exist, none of which
is easy to implement, and one of which is not usable with most
clients:

a) Toast Notifications in Windows 8/Server 2012, which is not a
   popular platform and may require quite a lot of magic in terms of
   coding and else (VS2012);
b) Create a tray icon and do a balloon (2000 and up?, definitely in XP);
c) Create your very own Windows toast notifications framework.

-- 
Chris “Kwpolska” Warrick http://kwpolska.tk
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cross-Platform Python3 Equivalent to notify-send

2013-07-27 Thread Chris “Kwpolska” Warrick
Whoops!

On Sat, Jul 27, 2013 at 1:30 PM, Chris “Kwpolska” Warrick
kwpol...@gmail.com wrote:
 You already asked this on Thursday.  And the answer is probably “no”.  
 Creating

…a solution for this is not the easiest thing one can do.
-- 
Chris “Kwpolska” Warrick http://kwpolska.tk
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best Python book(s) for a pre-teen?

2013-07-27 Thread aliencat777
Hi,

Start Here: Python 3x Programming Made Fun and Easier is a very easy to 
understand beginners book. It also covers a basic introduction to software 
design, version systems, game logic and design, and packaging your first 
programs.
I wrote this book originally for my two sons when I was home schooling them. 
You can download the first chapters, free version to try before you buy it at 
www.toonzcat.com/book.html

Jody
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Which is the best book to learn python

2013-07-27 Thread aliencat777
On Tuesday, January 25, 2011 1:09:31 AM UTC+8, sant wrote:
 Hi All,
 i am beginner to python please tell me which is the best available
 reference for beginner to start from novice

A great up to date beginner's book/course is Start Here: Python 3x 
Programming, Made Fun and Easier. It introduces software design and makes 
everything very simple to understand. http://www.quantumsight.mobi

Jody
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Q: Best book for teaching

2013-07-27 Thread aliencat777
On Wednesday, April 8, 2009 7:34:55 AM UTC+8, John Yeung wrote:
 On Apr 6, 10:37 am, grkunt...@gmail.com wrote:
  I am considering teaching an introduction to programming
  course for continuing education adults at a local community
  college. These would people with no programming experience,
  but I will require a reasonable facility with computers.
 
  What would be a good book to use as the text for the course?
 
 For an extremely gentle introduction, perhaps take a look at _Python
 Programming for the Absolute Beginner_ by Michael Dawson:
 
   
 http://www.amazon.com/Python-Programming-Absolute-Beginner-Michael/dp/1592000738
 
 A coworker of mine recently bought this book, which is how I found out
 about it.  Besides assuming no programming experience, it tries to
 stay interesting through the use of simple games for its examples
 (eventually building up to the use of the popular pygame library).
 The writing style is definitely more fun than academic.
 
 John

An up to date book that is great for a short 21 lesson course is; Start Here: 
Python 3x Programming Made Fun and Easier by Jody S. Ginther. This is a good 
beginning programming course that introduces the entire process of software 
design including; version systems, planning, logic, and packaging. It takes a 
newbie from ground zero to making arcade style games complete with sound, 
music, graphics, and an creating an installation package in only 21 easy to 
follow lessons. 

You can find it at http://www.quantum-sight.com

Jody
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cross-Platform Python3 Equivalent to notify-send

2013-07-27 Thread Devyn Collier Johnson


On 07/27/2013 07:30 AM, Chris “Kwpolska” Warrick wrote:

On Sat, Jul 27, 2013 at 12:58 PM, Devyn Collier Johnson
devyncjohn...@gmail.com wrote:

Linux systems with the proper software can use the notify-send command. Is
there a cross-platform Python3 equivalent?

Mahalo,

Devyn Collier Johnson
devyncjohn...@gmail.com
--
http://mail.python.org/mailman/listinfo/python-list

You already asked this on Thursday.  And the answer is probably “no”.  Creating

Under X11-based systems, you would have to call the dbus notification
APIs and pray that the user has something to handle it running (KDE,
GNOME Shell, XFCE4’s notification daemon).  Under Mac OS X 10.7 and
further, you need to work with some system APIs, and that may not be
easy, but possible (eg. https://github.com/alloy/terminal-notifier for
Ruby).

But Windows?  GOOD LUCK!  The following options exist, none of which
is easy to implement, and one of which is not usable with most
clients:

a) Toast Notifications in Windows 8/Server 2012, which is not a
popular platform and may require quite a lot of magic in terms of
coding and else (VS2012);
b) Create a tray icon and do a balloon (2000 and up?, definitely in XP);
c) Create your very own Windows toast notifications framework.

That really sucks. I was hoping Python had some way of doing that. All 
that it needs to do is display a little box at one of the corners of the 
screen. I thought someone would have implemented something by now. Thank 
you anyway.


Mahalo,

DCJ
--
http://mail.python.org/mailman/listinfo/python-list


Re: My son wants me to teach him Python

2013-07-27 Thread aliencat777
Hi,

I am an IT and Learning Research professor. I wrote a set of lessons that 
became a beginning programming book for my two sons. They loved it because is 
it was simple, hands on, and funny. It covers the basics of programming, 
introducing; software design, planning a game, making/getting free assets, 
version systems, and packaging. This course takes the beginner from ground zero 
to making arcade style games complete with sound, music, graphics, and an 
installation package in 21 lessons. It also includes vast resources in the 
index. It is called; Start Here: Python 3x Programming Made Fun and Easier, 
and can be found at http://www.quantumsight.mobi or 
http://www.toonzcat.com/book.html This site also introduces graphics for web 
sites, animation, and games.

J.S.G, PhD
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: programming course

2013-07-27 Thread aliencat777
Hi,
A good step by step easy book on Python is: Start Here: Python 3x Programming 
Made Fun and Easier, at http://www.quantum-sight.com

Aliencat
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cross-Platform Python3 Equivalent to notify-send

2013-07-27 Thread Chris Angelico
On Sat, Jul 27, 2013 at 1:22 PM, Devyn Collier Johnson
devyncjohn...@gmail.com wrote:
 That really sucks. I was hoping Python had some way of doing that. All that
 it needs to do is display a little box at one of the corners of the screen.
 I thought someone would have implemented something by now. Thank you anyway.

Despite the best efforts of a pretty talented core dev team, Python is
not yet capable of magic :) If you browse the python-dev archives,
you'll see how much of a nightmare cross-platform compatibility can be
(eg the recent discussion on cloexec and passing file descriptors to
subprocesses); often, what you might think (from a user's point of
view) is fairly trivial will turn out to be quite tricky.

That said, though, a lot of GUI toolkits will have a means for you to
highlight a window. In GTK, it's called present (as in, Lord User,
may I present Sir Window and Mrs Window?). There may be window
managers that don't support the feature (and there are certainly those
that let the user disable it, which you should respect), but AFAIK all
of them should at least accept the command.

http://www.pygtk.org/docs/pygtk/class-gtkwindow.html#method-gtkwindow--present

So your best bet may be to simply create yourself a small window, then
present it. On Windows XP, I think that'll flash the window in the
task bar, which is usually enough highlight. On my Debian Wheezy with
Xfce, it brings the window to the top of the Z-order, and optionally
moves it to the current workspace (user's option, NOT program's).

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


Re: Critic my module

2013-07-27 Thread Devyn Collier Johnson


On 07/26/2013 10:48 PM, Steven D'Aprano wrote:

As requested, some constructive criticism of your module.

On Thu, 25 Jul 2013 09:24:30 -0400, Devyn Collier Johnson wrote:


#!/usr/bin/python3
#Made by Devyn Collier Johnson, NCLA, Linux+, LPIC-1, DCTS

What's NCLA, Linux+, LPIC-1, DCTS? Do these mean anything? Are we
supposed to know what they mean?

Made by has no legal significance. You probably want:

Copyright © 2013 Devyn Collier Johnson.



#Made using the Geany IDE

Nobody gives a monkey's toss what editor you used to type up the module.
You might as well mention the brand of monitor you used, or whether the
keyboard is Dvorak or Qwerty.



#LGPLv3

You can't just drop in a mention of LGPLv3 and expect it to mean
anything. You actually have to obey the licence yourself, and that
includes *actually including the licence in your work*. (You're
technically in violation of the licence at the moment, however since the
only person whose copyright you are infringing is yourself, it doesn't
matter. However anyone else using your code is at risk.)

http://www.gnu.org/licenses/gpl-howto.html

In the case of the LGPL, you have to include the text of *both* the GPL
and the LGPL, not just one.




import re, sys, subprocess, platform
def grep(regex,textf):
#Sample Command: grep.grep(^x,dir()) #Syntax:
boash.grep(regexp_string,list_of_strings_to_search)

Comments using # are only of use to people reading the source code. If
you want comments to be available at the interactive prompt, you should
write them as doc strings:

def grep(regex, textf):
 This string is a docstring.

 Sample command: ...
 Blah blah blah
 

Then, at the interactive prompt, the user can say:

help(boash.grep)

to read the docstring.



version = '0.2a'

That's quite useless, since it is a local variable invisible outside of
the function.

Also, why would you bother giving every individual function a version
number? That's rather pointless. The user cannot pick and choose function
A with version number 0.6 and function B with version number 0.7 if the
module provides versions 0.7 of both.



expr = re.compile(regex)
match = re.findall(expr, textf)
if match != None:
print(match)

When comparing with None, it is preferred to use is and is not rather
than equality tests.



def ls():
version = '0.3'
print(subprocess.getoutput('ls'))
def dir():
version = '0.3'
print(subprocess.getoutput('dir'))

A blank line or two between functions does wonders for readability. There
is no prize for conserving newlines.

You might like to read PEP 8, the Python style guide. It is optional, but
still makes a very good guide.

http://www.python.org/dev/peps/pep-0008/



def bash(*arg):
version = '0.3'
print(subprocess.getoutput(arg))
def shell(*arg):
version = '0.3'
print(subprocess.getoutput(arg))

bash is not a synonym for shell. The shell might be sh, csh, bash, or
any one of many other shells, all of which are slightly (or not so
slightly) different.



def clear_bash_history():
version = '0.3'
print(subprocess.getoutput('history -c'))

[...]

Do you really need ten aliases for 'history -c'?

If you want to define aliases for a function, don't recreate the entire
function ten times. Start with defining the function once, then:

clear_bash_hist = clear_hist = clear_history = clear_bash_history

etc. But really, having ten names for the one function just confuses
people, who then wonder what subtle difference there is between
delete_history and clear_history.


def firefox():
version = '0.3'
print(subprocess.Popen('(firefox )'))

Is Firefox really so important that it needs a dedicated command?

What about Debian users? Doesn't Iceweasel get a command?



def xterm():
version = '0.3'
print(subprocess.Popen('(xterm )'))

Surely the user already has an xterm open, if they are running this
interactively? Why not just use your xterm's new window or new tab
command?


[...delete more trivial calls to subprocess...]


def repeat_cmd():
version = '0.3'
print(subprocess.Popen('!!'))

[... delete two exact copies of this function...]


def ejcd():
version = '0.3'
print(subprocess.Popen('eject cdrom1'))

[... delete FOURTEEN exact copies of this function...]

Really? Is anyone going to type eject_disc_tray instead of eject?


I think that will do.

This doesn't really do anything except define a large number of trivial
wrappers to commands already available in the shell. Emphasis on the
*trivial* -- with the exception of the grep wrapper, which is all of four
lines (ignoring the useless internal version number), every single one of
these wrapper functions is a one-liner.[1] In other words, you're not
adding any value to the shell commands by wrapping them in Python. There
are plenty of big, complex shell commands that take a plethora of options
and could do with 

Re: Understanding other people's code

2013-07-27 Thread Albert van der Horst
In article b023f6e6-a11d-4d05-a126-e3cc49cb3...@googlegroups.com,
Azureaus  lo0...@my.bristol.ac.uk wrote:
On Friday, 12 July 2013 15:22:59 UTC+1, Azureaus  wrote:
SNIP

To be fair to who programmed it, most functions are commented and I
can't complain about the messiness of the code, It's actually very tidy.
(I suppose Python forcing it's formatting is another reason it's an
easily readable language!) Luckily not blanked import * were used
otherwise I really would be up the creek without a paddle.

If the code is really tidy, it is possible to understand a function
using only the *documentation* (not the code itself) of any function
or data it uses. In oo you also need a context about what an object
is supposed to do. The next step is to proof for yourself that the
function exactly does what is promised in its own documentation.

And you get nowhere without domain knowledge. If you're in railways
and don't know the difference between a normal and an English
whathaveyou, then you're lost, plain and simple.

Don't treat the original comment as sacred. Any time it is unclear
rewrite it. You may get it wrong, but that's wat source control
systems are for. If at all possible, if you add a statement about
a function, try to add a test that proves that statement.

Anytime you come across something that is unsufficiently documented,
you document it tentatively yourself, keeping in mind that what
you write down may be wrong. This does no harm! Because you must
keep in mind that everything written by the original programmer
may be wrong, there is actually no difference! Now study the places
where it is called and check whether it makes sense.
This an infinite process. After one round of improvements you
have to go through everything again. I've got pretty bad stuff under
control this way.

You'll find bugs this way. They may or may not let you fix them.

There is however not much point in working in by reading through
the code. Time is probably better spent by running and studying, maybe
creating test cases.

Trying to understand any substantial code body in detail is
a waste of time.
For example: I once had to change the call code of the gcc compiler
to be able to use a 68000 assembler library (regarding which register
contain what data passed to the function). There is absolutely no
point in studying the gcc compiler. You must have an overview
then zoom in on the relevant part. In the end maybe only a couple
of lines need change. A couple of days, and a pretty hairy problem
was solved. (The assembler library was totally undocumented.
Nobody even tried to study it. ).

There is an indication that the original programmer made it all very
easy and maybe you go about it not quite the right way.
If you have a tower of abstractions, then you must *not* go down
all the way to find out eactly what happens. You must pick
a level in the middle and understand it in terms of usage, then
understand what is on top of that in terms of that usage.
That is how good programmers build there programs. Once there is
a certain level they don't think about what's underneath, but
concentrate on how to use it. If it is done really well, each
source module can be understood on its own.

All this is of course general, not just for Python.

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

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


Re: Critic my module

2013-07-27 Thread Devyn Collier Johnson


On 07/26/2013 10:48 PM, Steven D'Aprano wrote:

As requested, some constructive criticism of your module.

On Thu, 25 Jul 2013 09:24:30 -0400, Devyn Collier Johnson wrote:


#!/usr/bin/python3
#Made by Devyn Collier Johnson, NCLA, Linux+, LPIC-1, DCTS

What's NCLA, Linux+, LPIC-1, DCTS? Do these mean anything? Are we
supposed to know what they mean?

Made by has no legal significance. You probably want:

Copyright © 2013 Devyn Collier Johnson.



#Made using the Geany IDE

Nobody gives a monkey's toss what editor you used to type up the module.
You might as well mention the brand of monitor you used, or whether the
keyboard is Dvorak or Qwerty.



#LGPLv3

You can't just drop in a mention of LGPLv3 and expect it to mean
anything. You actually have to obey the licence yourself, and that
includes *actually including the licence in your work*. (You're
technically in violation of the licence at the moment, however since the
only person whose copyright you are infringing is yourself, it doesn't
matter. However anyone else using your code is at risk.)

http://www.gnu.org/licenses/gpl-howto.html

In the case of the LGPL, you have to include the text of *both* the GPL
and the LGPL, not just one.




import re, sys, subprocess, platform
def grep(regex,textf):
#Sample Command: grep.grep(^x,dir()) #Syntax:
boash.grep(regexp_string,list_of_strings_to_search)

Comments using # are only of use to people reading the source code. If
you want comments to be available at the interactive prompt, you should
write them as doc strings:

def grep(regex, textf):
 This string is a docstring.

 Sample command: ...
 Blah blah blah
 

Then, at the interactive prompt, the user can say:

help(boash.grep)

to read the docstring.



version = '0.2a'

That's quite useless, since it is a local variable invisible outside of
the function.

Also, why would you bother giving every individual function a version
number? That's rather pointless. The user cannot pick and choose function
A with version number 0.6 and function B with version number 0.7 if the
module provides versions 0.7 of both.



expr = re.compile(regex)
match = re.findall(expr, textf)
if match != None:
print(match)

When comparing with None, it is preferred to use is and is not rather
than equality tests.



def ls():
version = '0.3'
print(subprocess.getoutput('ls'))
def dir():
version = '0.3'
print(subprocess.getoutput('dir'))

A blank line or two between functions does wonders for readability. There
is no prize for conserving newlines.

You might like to read PEP 8, the Python style guide. It is optional, but
still makes a very good guide.

http://www.python.org/dev/peps/pep-0008/



def bash(*arg):
version = '0.3'
print(subprocess.getoutput(arg))
def shell(*arg):
version = '0.3'
print(subprocess.getoutput(arg))

bash is not a synonym for shell. The shell might be sh, csh, bash, or
any one of many other shells, all of which are slightly (or not so
slightly) different.



def clear_bash_history():
version = '0.3'
print(subprocess.getoutput('history -c'))

[...]

Do you really need ten aliases for 'history -c'?

If you want to define aliases for a function, don't recreate the entire
function ten times. Start with defining the function once, then:

clear_bash_hist = clear_hist = clear_history = clear_bash_history

etc. But really, having ten names for the one function just confuses
people, who then wonder what subtle difference there is between
delete_history and clear_history.


def firefox():
version = '0.3'
print(subprocess.Popen('(firefox )'))

Is Firefox really so important that it needs a dedicated command?

What about Debian users? Doesn't Iceweasel get a command?



def xterm():
version = '0.3'
print(subprocess.Popen('(xterm )'))

Surely the user already has an xterm open, if they are running this
interactively? Why not just use your xterm's new window or new tab
command?


[...delete more trivial calls to subprocess...]


def repeat_cmd():
version = '0.3'
print(subprocess.Popen('!!'))

[... delete two exact copies of this function...]


def ejcd():
version = '0.3'
print(subprocess.Popen('eject cdrom1'))

[... delete FOURTEEN exact copies of this function...]

Really? Is anyone going to type eject_disc_tray instead of eject?


I think that will do.

This doesn't really do anything except define a large number of trivial
wrappers to commands already available in the shell. Emphasis on the
*trivial* -- with the exception of the grep wrapper, which is all of four
lines (ignoring the useless internal version number), every single one of
these wrapper functions is a one-liner.[1] In other words, you're not
adding any value to the shell commands by wrapping them in Python. There
are plenty of big, complex shell commands that take a plethora of options
and could do with 

Re: Critic my module

2013-07-27 Thread Dave Angel

On 07/27/2013 09:19 AM, Devyn Collier Johnson wrote:




SNIP


About the aliases, I have tried setting pwd() as an alias for
os.getcwd(), but I cannot type pwd() and get the desired output.
Instead, I must type pwd. I tested this in Guake running Python3.3.

  os.getcwd()
'/home/collier'
  pwd = os.getcwd()
  pwd()
Traceback (most recent call last):
   File stdin, line 1, in module
TypeError: 'str' object is not callable
  pwd
'/home/collier'
  pwd() = os.getcwd()
   File stdin, line 1
SyntaxError: can't assign to function call


How could I make pwd() work?


Don't call getcwd() when making the alias.  You want it to be called 
when USING the alias.


pwd = os.getcwd#creates the alias

pwd() #runs the alias



--
DaveA

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


Re: Critic my module

2013-07-27 Thread Chris “Kwpolska” Warrick
On Sat, Jul 27, 2013 at 3:19 PM, Devyn Collier Johnson
devyncjohn...@gmail.com wrote:
 About the aliases, I have tried setting pwd() as an alias for os.getcwd(),
 but I cannot type pwd() and get the desired output. Instead, I must type
 pwd. I tested this in Guake running Python3.3.

 os.getcwd()
 '/home/collier'
 pwd = os.getcwd()
 pwd()
 Traceback (most recent call last):
   File stdin, line 1, in module
 TypeError: 'str' object is not callable
 pwd
 '/home/collier'
 pwd() = os.getcwd()
   File stdin, line 1
 SyntaxError: can't assign to function call


 How could I make pwd() work?


 Mahalo,

 DCJ
 --
 http://mail.python.org/mailman/listinfo/python-list

 import os
 pwd = os.getcwd
 pwd()
'/home/kwpolska'
 os.chdir('/')
 pwd()
'/'


-- 
Chris “Kwpolska” Warrick http://kwpolska.tk
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Understanding other people's code

2013-07-27 Thread Chris Angelico
On Sat, Jul 27, 2013 at 2:13 PM, Albert van der Horst
alb...@spenarnc.xs4all.nl wrote:
 If the code is really tidy, it is possible to understand a function
 using only the *documentation* (not the code itself) of any function
 or data it uses.

I'd broaden that slightly to the function's signature, which consists
of the declaration line and any associated comments (which in Python
should be in the docstring). The docstring kinda violates this
concept, but what I generally try to explain is that you should be
able to understand a function without reading any of the indented
content.

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


Re: Critic my module

2013-07-27 Thread Devyn Collier Johnson


On 07/27/2013 09:35 AM, Dave Angel wrote:

On 07/27/2013 09:19 AM, Devyn Collier Johnson wrote:




SNIP


About the aliases, I have tried setting pwd() as an alias for
os.getcwd(), but I cannot type pwd() and get the desired output.
Instead, I must type pwd. I tested this in Guake running Python3.3.

  os.getcwd()
'/home/collier'
  pwd = os.getcwd()
  pwd()
Traceback (most recent call last):
   File stdin, line 1, in module
TypeError: 'str' object is not callable
  pwd
'/home/collier'
  pwd() = os.getcwd()
   File stdin, line 1
SyntaxError: can't assign to function call


How could I make pwd() work?


Don't call getcwd() when making the alias.  You want it to be called 
when USING the alias.


pwd = os.getcwd#creates the alias

pwd() #runs the alias




Thanks! It works!

 pwd = os.getcwd
 pwd()
'/home/collier'


Mahalo, Dave!


DCJ
--
http://mail.python.org/mailman/listinfo/python-list


Re: Critic my module

2013-07-27 Thread Chris Angelico
On Sat, Jul 27, 2013 at 2:19 PM, Devyn Collier Johnson
devyncjohn...@gmail.com wrote:
 About the aliases, I have tried setting pwd() as an alias for os.getcwd(),
 but I cannot type pwd() and get the desired output. Instead, I must type
 pwd. I tested this in Guake running Python3.3.

 os.getcwd()
 '/home/collier'
 pwd = os.getcwd()
 pwd()

Try:

 pwd = os.getcwd

Otherwise you're calling it immediately.

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


Re: Critic my module

2013-07-27 Thread Dave Angel

On 07/27/2013 08:56 AM, Devyn Collier Johnson wrote:




SNIP

Somehow during this thread, you have changed your purpose for this 
library.  It used to be a library that Python programmers could import 
and use.  And now, it's a shell replacement?  The user runs the Python 
interpreter, and types the line   import boash   to get started.




Yeah, I have a VERY BAD habit of treating bash and the Linux shell (or
any/all shells) as the same thing. I know they are all very different,
but for some reason I still keep calling all shells in general BASH.


I seem to recall that BASH is an acronym, for Bourne Again SHell.



I will be sure to create aliases. I make alias commands so that it is
easier to guess or remember a command. For instance, a Python user my
want to clear the shell's history, but can only remember one form of the
command or must guess. On my Ubuntu system, I have set up numerous shell
aliases. I am addicted to aliases.


Nothing wrong with aliases.  But how does your user create his own 
aliases?  That's much more important than having yours available. 
Remember that any new globals he defines are lost when he exits the 
interpreter (or crashes).




I still need to add the other browsers. Do very many people use Iceweasel?

I did not notice that I have print(subprocess.Popen('(xterm )'))
instead of subprocess.Popen('(xterm )'). The worst computer errors
are ID-10-T errors.

True, the user my have Xterm open, but what if they use Guake (like me)
or Pterm, EvilVTE, Valaterm, Gnome-Terminal, Konsole, etc.?


Exactly.  If they're using a terminal with tabs, they might want to 
create a new tab, not a new instance of the terminal.  Or if they're 
running screen or the equivalent, they want the new terminal to show up 
on their (remote) console.




How could I add security and convenience? Okay, I will try to add wget.
Are there any other shell commands that anyone feels I should add?


How about tab?  The command-completion and filename-completion and 
parameter-completion logic of a good shell is extremely complex, and 
very useful.




The point of this module is to allow Linux shell users to use Python3 as
a regular shell. Instead of using CSH, Bash, Tcsh, FISH, etc., users
could use Python3 and import this module. Python is more powerful than
any shell, so I want to make it easier for anyone to use Python as the
default shell. For instance, instead of typing print(os.getcwd()) to
get the current working directory, users could type boash.ls(). I hope
that is easier to remember than print(os.getcwd()).


It's easier, but doesn't begin to do the same thing.

As for using this INSTEAD of csh, bash, etc., that might be likely once 
it gets beyond 10% of the usefulness.  Right now, it's at about 0.01% 
And any habits a user gets within this environment have to be unlearned 
when he returns to a standard shell.


Back in the early days of MSDOS, the FORMAT command didn't require you 
to specify a drive letter.  So people could intend to format their 
floppy, and actually trash their hard disk.  So I had colleagues who put 
a FORMAT.BAt command on their path which hard-wired the A: parameter. 
Now what happens to one of those folks when he goes to another machine 
which doesn't have that batch file?  Ouch!  Instead I wrote a batch file 
that checked to make sure you had the A: parameter.  Rapidly, my fingers 
learned that  FORMAT A:  was the valid syntax, and pretty soon the batch 
file was unnecessary (for me).


If I were going to define a dozen aliases for other people to use, I'd 
make them something like:


def clear_hist():
print The function you want is probably   clear_history()



As for the print()
command, I do not like how os.getcwd() has single quotes around the
output.


Those quotes come from the Python interpreter, not from getcwd().


Plus, Linux shell do not print output with quotes.

I want to make this a very useful and popular module, so I will use the
suggestions and add more useful wrappers. Would it help if I made a
Youtube video showing how this module can be used?

I will post the next version on this mailing list for another review.
Thanks everyone, and thanks a lot Steven D'Aprano!



Have you figured out how you're going to do things like cd  (os.chdir), 
which have to remember state?  And how to pass the new current directory 
to the shell that launched Python?


Have you looked at ipython (ipython.org) ?  At least from there, you can 
get command completion with tab, one-third of the bash functionality. 
So if you type  boash.cle   then tab  it'll fill in the rest.



--
DaveA

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


Re: Critic my module

2013-07-27 Thread Devyn Collier Johnson


On 07/27/2013 10:33 AM, Dave Angel wrote:

On 07/27/2013 08:56 AM, Devyn Collier Johnson wrote:




SNIP

Somehow during this thread, you have changed your purpose for this 
library.  It used to be a library that Python programmers could import 
and use.  And now, it's a shell replacement?  The user runs the Python 
interpreter, and types the line   import boash   to get started.




Yeah, I have a VERY BAD habit of treating bash and the Linux shell (or
any/all shells) as the same thing. I know they are all very different,
but for some reason I still keep calling all shells in general BASH.


I seem to recall that BASH is an acronym, for Bourne Again SHell.



I will be sure to create aliases. I make alias commands so that it is
easier to guess or remember a command. For instance, a Python user my
want to clear the shell's history, but can only remember one form of the
command or must guess. On my Ubuntu system, I have set up numerous shell
aliases. I am addicted to aliases.


Nothing wrong with aliases.  But how does your user create his own 
aliases?  That's much more important than having yours available. 
Remember that any new globals he defines are lost when he exits the 
interpreter (or crashes).




I still need to add the other browsers. Do very many people use 
Iceweasel?


I did not notice that I have print(subprocess.Popen('(xterm )'))
instead of subprocess.Popen('(xterm )'). The worst computer errors
are ID-10-T errors.

True, the user my have Xterm open, but what if they use Guake (like me)
or Pterm, EvilVTE, Valaterm, Gnome-Terminal, Konsole, etc.?


Exactly.  If they're using a terminal with tabs, they might want to 
create a new tab, not a new instance of the terminal.  Or if they're 
running screen or the equivalent, they want the new terminal to show 
up on their (remote) console.




How could I add security and convenience? Okay, I will try to add wget.
Are there any other shell commands that anyone feels I should add?


How about tab?  The command-completion and filename-completion and 
parameter-completion logic of a good shell is extremely complex, and 
very useful.




The point of this module is to allow Linux shell users to use Python3 as
a regular shell. Instead of using CSH, Bash, Tcsh, FISH, etc., users
could use Python3 and import this module. Python is more powerful than
any shell, so I want to make it easier for anyone to use Python as the
default shell. For instance, instead of typing print(os.getcwd()) to
get the current working directory, users could type boash.ls(). I hope
that is easier to remember than print(os.getcwd()).


It's easier, but doesn't begin to do the same thing.

As for using this INSTEAD of csh, bash, etc., that might be likely 
once it gets beyond 10% of the usefulness.  Right now, it's at about 
0.01% And any habits a user gets within this environment have to be 
unlearned when he returns to a standard shell.


Back in the early days of MSDOS, the FORMAT command didn't require you 
to specify a drive letter.  So people could intend to format their 
floppy, and actually trash their hard disk.  So I had colleagues who 
put a FORMAT.BAt command on their path which hard-wired the A: 
parameter. Now what happens to one of those folks when he goes to 
another machine which doesn't have that batch file?  Ouch!  Instead I 
wrote a batch file that checked to make sure you had the A: 
parameter.  Rapidly, my fingers learned that  FORMAT A:  was the valid 
syntax, and pretty soon the batch file was unnecessary (for me).


If I were going to define a dozen aliases for other people to use, I'd 
make them something like:


def clear_hist():
print The function you want is probably   clear_history()



As for the print()
command, I do not like how os.getcwd() has single quotes around the
output.


Those quotes come from the Python interpreter, not from getcwd().


Plus, Linux shell do not print output with quotes.

I want to make this a very useful and popular module, so I will use the
suggestions and add more useful wrappers. Would it help if I made a
Youtube video showing how this module can be used?

I will post the next version on this mailing list for another review.
Thanks everyone, and thanks a lot Steven D'Aprano!



Have you figured out how you're going to do things like cd (os.chdir), 
which have to remember state?  And how to pass the new current 
directory to the shell that launched Python?


Have you looked at ipython (ipython.org) ?  At least from there, you 
can get command completion with tab, one-third of the bash 
functionality. So if you type  boash.cle   then tab  it'll fill in 
the rest.





Thanks! I will look into IPython. I am familiar with it already. Yes, I 
have two purposes for the module, but after reading these suggestions I 
have modified my goal and purpose to achieve the goal of making a useful 
and popular Python3 module. The whole point of my boash project is to 
make a useful module. How can I make this module useful? I 

Re: Critic my module

2013-07-27 Thread Jason Swails
You've gotten plenty of good advice from people discussing the coding and
coding style itself, I'll provide some feedback from the vantage point of a
perspective user.


On Thu, Jul 25, 2013 at 9:24 AM, Devyn Collier Johnson 
devyncjohn...@gmail.com wrote:

 Aloha Python Users!

I made a Python3 module that allows users to use certain Linux shell
 commands from Python3 more easily than using os.system(),
 subprocess.Popen(), or subprocess.getoutput(). This module (once placed
 with the other modules) can be used like this

 import boash; boash.ls()


I actually wrote a program recently in which I wanted access to unix ls
command, and I wanted it to behave as close to the real, UNIX ls as
possible.

This would seem like a perfect use-case for your module, but the problem is
that the 'ls' command in your module does not behave much like the real
'ls' command.  You never let any of the 'system' commands in your module
access any arguments.  More often than not, I use ls with several
command-line arguments, like:

ls --color=auto -lthr dir_basename*/

Even if you're just spawning 'ls' directly, this is actually non-trivial to
implement.  You need globbing on all non-option arguments, you may want to
pass up the return code somehow, depending on what the user wants to do:

[bash ]$ ls nodir
ls: nodir: No such file or directory
[bash ]$ echo $?
1

Also, 'ls' in the terminal behaves like ls -C when called from your
module.  In the framework of my program, my 'ls' command looks like this:

class ls(Action):
   
   Lists directory contents. Like UNIX 'ls'
   
   needs_parm = False
   def init(self, arg_list):
  from glob import glob
  self.args = []
  # Process the argument list to mimic the real ls as much as possible
  while True:
 try:
arg = arg_list.get_next_string()
if not arg.startswith('-'):
   # Glob this argument
   globarg = glob(arg)
   if len(globarg)  0:
  self.args.extend(globarg)
   else:
  self.args.append(arg)
else:
   self.args.append(arg)
 except NoArgument:
break

   def __str__(self):
  from subprocess import Popen, PIPE
  process = Popen(['/bin/ls', '-C'] + self.args, stdout=PIPE,
stderr=PIPE)
  out, err = process.communicate('')
  process.wait()
  return out + err

[I have omitted the Action base class, which processes the user
command-line arguments and passes it to the init() method in arg_list --
this listing was just to give you a basic idea of the complexity of getting
a true-er 'ls' command].

Your 'uname' command is likewise limited (and the printout looks strange:

 print(platform.uname())
('Linux', 'Batman', '3.3.8-gentoo', '#1 SMP Fri Oct 5 14:14:57 EDT 2012',
'x86_64', 'AMD FX(tm)-6100 Six-Core Processor')

Whereas:

[bash $] uname -a
Linux Batman 3.3.8-gentoo #1 SMP Fri Oct 5 14:14:57 EDT 2012 x86_64 AMD
FX(tm)-6100 Six-Core Processor AuthenticAMD GNU/Linux

You may want to change that to:

def uname():
print(' '.join(platform.uname()))

Although again, oftentimes people want only something specific from uname
(like -m or -n).

HTH,
Jason
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Critic my module

2013-07-27 Thread Chris Angelico
On Sat, Jul 27, 2013 at 3:53 PM, Devyn Collier Johnson
devyncjohn...@gmail.com wrote:
 Would a Python3 game module be more useful? I plan to make a function that
 rolls a die and prints the output (You got a 5) and other similar random
 games.

Taking someone else's module and learning to use it has a cost. Plus
there's licensing and other issues (if you release your library GPL3,
you force anyone who uses it to do the same - though I'm not 100% sure
how that goes with Python modules, since they're not 'linked' the way
others are), not to mention the time spent finding out that your
module even exists. For a module to be useful, all those costs
combined have to be lower than the cost of just writing the code
yourself when you need it.

On the other hand, it's VERY common for a programmer to have his own
*personal* utilities module. Stuff stuff in there whenever you think
it'll be useful, import it into your applications, et voila. The bar
is way lower for that. Your dice-roller is perhaps useful to yourself,
without being worth the effort for someone else to learn. Plus, you
get to decide exactly how much flexibility you need. Do you only ever
need to roll a single six-sider at a time? Then don't bother
implementing stuff like I did for Minstrel Hall, where we play
Dungeons and Dragons:

[ROLL] Rosuav (Gaston crit dmg) rolls 4d8: 7, 3, 6, 1, totalling 17.
[ROLL] Rosuav (Gaston crit dmg) rolls d6: 1 (elec)
[ROLL] Rosuav (Gaston crit dmg) rolls d10: 6 (burst)
[ROLL] Rosuav (Gaston crit dmg) rolls d8: 8 (thunder)
[ROLL] For 4d8+12 STR+10 ench+4 specialization+d6 elec+d10 burst+d8
thunder+20 PA, Rosuav (Gaston crit dmg) totals: 78

Okay, that's a somewhat extreme example, but it's common to roll
damage as, say, 2d6+13, which means two six-sided dice plus a constant
13. (This will result in damage between 15 and 25, with 20 being
significantly more likely than either of the extremes.) And even that
is probably a lot more complicated than you'll need for your
purposes... yet for a DD system, a dice roller that can only do a
single d6 at a time is utterly useless. There's actually a dice roller
module on PyPI already [1]; and it's probably of no use to you,
because it's as complicated as I described above. I personally
wouldn't use it, though, because I can't see a license - which comes
back to the issues I listed above. Again, not an issue for your own
code; if it's your copyright, you can do with it as you wish.

[1] https://pypi.python.org/pypi/diceroll

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


Re: Cross-Platform Python3 Equivalent to notify-send

2013-07-27 Thread Steven D'Aprano
On Sat, 27 Jul 2013 08:22:00 -0400, Devyn Collier Johnson wrote:

 On 07/27/2013 07:30 AM, Chris “Kwpolska” Warrick wrote:
 On Sat, Jul 27, 2013 at 12:58 PM, Devyn Collier Johnson
 devyncjohn...@gmail.com wrote:
 Linux systems with the proper software can use the notify-send
 command. Is there a cross-platform Python3 equivalent?

[snip answer no]

 That really sucks. I was hoping Python had some way of doing that. All
 that it needs to do is display a little box at one of the corners of the
 screen. I thought someone would have implemented something by now. Thank
 you anyway.

If it's that simple, how about you do it? Won't take you more than, oh, 
ten minutes, right?

*wink*

Don't underestimate the difficulty of trivial code when it has to work 
on two dozens different platforms with different capabilities:

Windows XP, 2000, Vista, 7, 8 ...
Mac OS-X
FreeBSD, OpenBSD, Linux, running KDE (3 or 4?), Gnome (2 or 3?), Trinity, 
RatPoison, XFCE, something else... or no window manager at all



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


Re: Cross-Platform Python3 Equivalent to notify-send

2013-07-27 Thread Chris Angelico
On Sat, Jul 27, 2013 at 4:59 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Sat, 27 Jul 2013 08:22:00 -0400, Devyn Collier Johnson wrote:
 That really sucks. I was hoping Python had some way of doing that. All
 that it needs to do is display a little box at one of the corners of the
 screen. I thought someone would have implemented something by now. Thank
 you anyway.

 If it's that simple, how about you do it? Won't take you more than, oh,
 ten minutes, right?

 *wink*

 Don't underestimate the difficulty of trivial code when it has to work
 on two dozens different platforms with different capabilities

That doesn't mean the question shouldn't be asked, of course. Steven
isn't (at least, I don't think he is!) scorning you for asking.
Sometimes the response is quite the opposite - that it's so utterly
trivial that there's no NEED for a library function! Never hurts to
throw the question out there...

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


Re: Critic my module

2013-07-27 Thread Alister
On Sat, 27 Jul 2013 08:56:10 -0400, Devyn Collier Johnson wrote:
 
 Good point about the Made by/Copyright suggestion. Although, I have not
 copyrighted the file, can I still say Copyrighted by -- 

There is no special process to Copyright anything.
the simple act of writing it automatically gives you the copyright on 
your own work.

Proving that it was you that created the work  when may be a little 
trickier if you do not find a reliable means of recording the event 
though.
(posting to this news group actually gives a reasonable time stamp 
provided the article has not expired by the time it is needed)
 

Stenderup's Law:
The sooner you fall behind, the more time you will have to catch 
up.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Oxycodone without a prescription online with overnight delivery | buy Oxycodone no visa online without prescription

2013-07-27 Thread Laura Burt


Laura Burt 
0400 954 448 -- 
http://mail.python.org/mailman/listinfo/python-list


Re: Critic my module

2013-07-27 Thread Dave Angel

On 07/27/2013 12:32 PM, Alister wrote:

On Sat, 27 Jul 2013 08:56:10 -0400, Devyn Collier Johnson wrote:


Good point about the Made by/Copyright suggestion. Although, I have not
copyrighted the file, can I still say Copyrighted by --


There is no special process to Copyright anything.
the simple act of writing it automatically gives you the copyright on
your own work.

Proving that it was you that created the work  when may be a little
trickier if you do not find a reliable means of recording the event
though.
(posting to this news group actually gives a reasonable time stamp
provided the article has not expired by the time it is needed)



The copyright law varies by country, and it's wise to look up your own 
country's rules, as well as investigate international law.  The 
following is based only on my limited recollection of US law.  I include 
references below, but have not re-studied them.  Nor am I a lawyer.


Generally, a copyright does belong to the author, as soon as he provably 
commits the text to medium.  However, if you ever expect to defend a 
copyright, it can be useful to register it.  Registration is limited by 
law to certain time limits.  I don't recall exactly, but I believe that 
once something is published, it has to be registered within 3 months or so.


Registration is easy, but not free.  You can copyright a number of works 
simultaneously, but I think they have to be of the same type.  And if it 
is registered, you can sue for larger amounts, and you'll have a much 
easier time getting a lawyer to take the case for you.


See:  http://www.copyright.gov/

and especially:
   http://www.copyright.gov/circs/circ01.pdf


--
DaveA

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


Re: Cross-Platform Python3 Equivalent to notify-send

2013-07-27 Thread Devyn Collier Johnson


On 07/27/2013 12:06 PM, Chris Angelico wrote:

On Sat, Jul 27, 2013 at 4:59 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:

On Sat, 27 Jul 2013 08:22:00 -0400, Devyn Collier Johnson wrote:

That really sucks. I was hoping Python had some way of doing that. All
that it needs to do is display a little box at one of the corners of the
screen. I thought someone would have implemented something by now. Thank
you anyway.

If it's that simple, how about you do it? Won't take you more than, oh,
ten minutes, right?

*wink*

Don't underestimate the difficulty of trivial code when it has to work
on two dozens different platforms with different capabilities

That doesn't mean the question shouldn't be asked, of course. Steven
isn't (at least, I don't think he is!) scorning you for asking.
Sometimes the response is quite the opposite - that it's so utterly
trivial that there's no NEED for a library function! Never hurts to
throw the question out there...

ChrisA
I wanted to make a module (boash) that would be useful, but clearly it 
is not. Here, is a feature that is useful that no one has. This may be 
the module I decide to make. So, there is no cross-platform for such a 
command any where? Would this be a useful module?


I know Steven is not scorning me. He is making me think and I have an idea.


Mahalo,

DCJ
--
http://mail.python.org/mailman/listinfo/python-list



Division and multiplication have a different behavior in the overflow case

2013-07-27 Thread Marco
In Python 3, when we hava a division and both the result and at least 
one operand are too large to convert to float, we get an exception:


 2**1028 / 2**-2
Traceback (most recent call last):
  File input, line 1, in module
OverflowError: long int too large to convert to float

When the result is inside the limits, we get the right value:

 2 ** 1025 / 2**10
3.59404027961e+305

Why the behavior is different in the case of the multiplication?

 2 ** 1025 * 2**-10
Traceback (most recent call last):
  File input, line 1, in module
OverflowError: long int too large to convert to float

I think the multiplication should have the same behavior than the
division:

* `inf` or `-inf` when the operands are inside the limits,
  but the result is not
* `OverflowError`  when the result, and at least one operand,
  are out of range.
--
Marco Buttu
--
http://mail.python.org/mailman/listinfo/python-list


Re: Critic my module

2013-07-27 Thread Devyn Collier Johnson


On 07/27/2013 11:14 AM, Jason Swails wrote:
You've gotten plenty of good advice from people discussing the coding 
and coding style itself, I'll provide some feedback from the vantage 
point of a perspective user.



On Thu, Jul 25, 2013 at 9:24 AM, Devyn Collier Johnson 
devyncjohn...@gmail.com mailto:devyncjohn...@gmail.com wrote:


Aloha Python Users!

   I made a Python3 module that allows users to use certain Linux
shell commands from Python3 more easily than using os.system(),
subprocess.Popen(), or subprocess.getoutput(). This module (once
placed with the other modules) can be used like this

import boash; boash.ls http://boash.ls()


I actually wrote a program recently in which I wanted access to unix 
ls command, and I wanted it to behave as close to the real, UNIX 
ls as possible.


This would seem like a perfect use-case for your module, but the 
problem is that the 'ls' command in your module does not behave much 
like the real 'ls' command.  You never let any of the 'system' 
commands in your module access any arguments.  More often than not, I 
use ls with several command-line arguments, like:


ls --color=auto -lthr dir_basename*/

Even if you're just spawning 'ls' directly, this is actually 
non-trivial to implement.  You need globbing on all non-option 
arguments, you may want to pass up the return code somehow, depending 
on what the user wants to do:


[bash ]$ ls nodir
ls: nodir: No such file or directory
[bash ]$ echo $?
1

Also, 'ls' in the terminal behaves like ls -C when called from your 
module.  In the framework of my program, my 'ls' command looks like this:


class ls(Action):
   
   Lists directory contents. Like UNIX 'ls'
   
   needs_parm = False
   def init(self, arg_list):
  from glob import glob
  self.args = []
  # Process the argument list to mimic the real ls as much as possible
  while True:
 try:
arg = arg_list.get_next_string()
if not arg.startswith('-'):
   # Glob this argument
   globarg = glob(arg)
   if len(globarg)  0:
  self.args.extend(globarg)
   else:
self.args.append(arg)
else:
 self.args.append(arg)
 except NoArgument:
break

   def __str__(self):
  from subprocess import Popen, PIPE
  process = Popen(['/bin/ls', '-C'] + self.args, stdout=PIPE, 
stderr=PIPE)

  out, err = process.communicate('')
  process.wait()
  return out + err

[I have omitted the Action base class, which processes the user 
command-line arguments and passes it to the init() method in arg_list 
-- this listing was just to give you a basic idea of the complexity of 
getting a true-er 'ls' command].


Your 'uname' command is likewise limited (and the printout looks strange:

 print(platform.uname())
('Linux', 'Batman', '3.3.8-gentoo', '#1 SMP Fri Oct 5 14:14:57 EDT 
2012', 'x86_64', 'AMD FX(tm)-6100 Six-Core Processor')


Whereas:

[bash $] uname -a
Linux Batman 3.3.8-gentoo #1 SMP Fri Oct 5 14:14:57 EDT 2012 x86_64 
AMD FX(tm)-6100 Six-Core Processor AuthenticAMD GNU/Linux


You may want to change that to:

def uname():
print(' '.join(platform.uname()))

Although again, oftentimes people want only something specific from 
uname (like -m or -n).


HTH,
Jason

For now, I will decide if it would be worth my time to make such a 
module seeing that many feel that it may not be useful. Thank you all 
for your feedback.


Mahalo,

DCJ
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cross-Platform Python3 Equivalent to notify-send

2013-07-27 Thread Devyn Collier Johnson


On 07/27/2013 11:59 AM, Steven D'Aprano wrote:

On Sat, 27 Jul 2013 08:22:00 -0400, Devyn Collier Johnson wrote:


On 07/27/2013 07:30 AM, Chris “Kwpolska” Warrick wrote:

On Sat, Jul 27, 2013 at 12:58 PM, Devyn Collier Johnson
devyncjohn...@gmail.com wrote:

Linux systems with the proper software can use the notify-send
command. Is there a cross-platform Python3 equivalent?

[snip answer no]


That really sucks. I was hoping Python had some way of doing that. All
that it needs to do is display a little box at one of the corners of the
screen. I thought someone would have implemented something by now. Thank
you anyway.

If it's that simple, how about you do it? Won't take you more than, oh,
ten minutes, right?

*wink*

Don't underestimate the difficulty of trivial code when it has to work
on two dozens different platforms with different capabilities:

Windows XP, 2000, Vista, 7, 8 ...
Mac OS-X
FreeBSD, OpenBSD, Linux, running KDE (3 or 4?), Gnome (2 or 3?), Trinity,
RatPoison, XFCE, something else... or no window manager at all



Yeah, good point Steven. It seems like it would be easy, but I know it 
is not.


DCJ
--
http://mail.python.org/mailman/listinfo/python-list


Re: RE Module Performance

2013-07-27 Thread wxjmfauth
Le samedi 27 juillet 2013 04:05:03 UTC+2, Michael Torrie a écrit :
 On 07/26/2013 07:21 AM, wxjmfa...@gmail.com wrote:
 
  sys.getsizeof('––') - sys.getsizeof('–')
 
  
 
  I have already explained / commented this.
 
 
 
 Maybe it got lost in translation, but I don't understand your point with
 
 that.
 
 
 
  Hint: To understand Unicode (and every coding scheme), you should
 
  understand utf. The how and the *why*.
 
 
 
 Hmm, so if python used utf-8 internally to represent unicode strings
 
 would not that punish *all* users (not just non-ascii users) since
 
 searching a string for a certain character position requires an O(n)
 
 operation?  UTF-32 I could see (and indeed that's essentially what FSR
 
 uses when necessary does it not?), but not utf-8 or utf-16.

--

Did you read my previous link? Unicode Character Encoding Model.
Did you understand it?

Unicode only - No FSR (I skip some points and I still attempt to
be still correct.)

Unicode is a four-steps process.
[ {unique set of characters}  -- {unique set of code points, the
labels} --  {unique set of encoded code points} ] -- implementation
(bytes)

First point to notice. pure unicode, [...], is different from
the implementation. *This is a deliberate choice*.

The critical step is the path {unique set of characters} ---
{unique set of encoded code points} in such a way so that
the implementation can work comfortably with this *unique* set
of encoded code points. Conceptualy, the implementation works
with an unique set of already prepared encoded code points.
This is a very critical step. To explain it in a dirty way:
in the above chain, this problem is already eliminated and
solved. Like a byte/char coding schemes where this step is
a no-op.

Now, and if you wish this is a seperated/different problem.
To create this unique set of encoded code points, Unicode
uses these utf(s). I repeat again, a confusing name, for the
process and the result of the process. (I neglect ucs).
What are these? Chunks of bits, group of 8/16/32 bits, words.
It is up to the implementation to convert these sequences
of bits into bytes, ***if you wish to convert these in bytes!***.
Suprise! Why not putting two of the 32-bits words in a 64-bits
machine? (see golang / rune / int32).

Back to utf. utfs are not only elements of a unique set of encoded
code points. They have an interesting feature. Each utf chunk
holds intrisically the character (in fact the code point) it is
supposed to represent. In utf-32, the obvious case, it is just
the code point. In utf-8, that's the first chunk which helps and
utf-16 is a mixed case (utf-8 / utf-32). In other words, in an
implementation using bytes, for any pointer position it is always
possible to find the corresponding encoded code point and from this
the corresponding character without any programmed information. See
my editor example, how to find the char under the caret? In fact,
a silly example, how can the caret can be positioned or moved, if
the underlying corresponding encoded code point can not be
dicerned!

Next step and one another separated problem.
Why all these utf versions? It is always the
same story. Some prefer the universality (utf-32) and
some prefer, well, some kind of conservatism. utf-8 is
more complicated, it demands more work and logically,
in an expected way, some performance regression.
utf-8 is more suited to produce bytes, utf16/32 for
internal processing. utf-8 had no choice to lose the
indexing. And so on.
Fact: all these coding schemes are working with a unique
set of encoded code points (suprise again, it's like byte
string!). The loss of performance of utf-8 is very minimal
compared to the loss of performance one can get compare to
a multiple coding scheme. This kind of work has been done,
and if my informations are correct, even by the creators
of utf-8. (There are sometimes good scientists).

There are plenty of advantages in using utf instead of
something else and advantages in other fields than just
the pure coding.
utf-16/32 schemes have the advantages to ditch ascii
for ever. The ascii concept is no more existing.

One should also understand that all this stuff has
not been created from scratch. It was a balance between
existing technologies. MS sticked with the idea, no more
ascii, let's use ucs-2 and the *x world breaks the unicode
adoption as possible. utf-8 is one of the compromise for
the adoption of Unicode. Retrospectivly, a not so good
compromise.

Computer scientists are funny scientists. They do love
to solve the problems they created themselves.

-

Quickly. sys.getsizeof() at the light of what I explained.

1) As this FSR works with multiple encoding, it has to keep
track of the encoding. it puts is in the overhead of str
class (overhead = real overhead + encoding). In such
a absurd way, that a 

 sys.getsizeof('€')
40

needs 14 bytes more than a

 sys.getsizeof('z')
26

You may vary the length of the str. The problem is
still here. Not bad for a coding scheme.

2) Take 

Re: Cross-Platform Python3 Equivalent to notify-send

2013-07-27 Thread Kevin Walzer

On 7/27/13 6:58 AM, Devyn Collier Johnson wrote:

Linux systems with the proper software can use the notify-send
command. Is there a cross-platform Python3 equivalent?

Mahalo,

Devyn Collier Johnson
devyncjohn...@gmail.com


http://pythonhosted.org/gntp/ ?

--
Kevin Walzer
Code by Kevin/Mobile Code by Kevin
http://www.codebykevin.com
http://www.wtmobilesoftware.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Division and multiplication have a different behavior in the overflow case

2013-07-27 Thread Terry Reedy

On 7/27/2013 1:48 PM, Marco wrote:

In Python 3, when we hava a division and both the result and at least
one operand are too large to convert to float, we get an exception:

  2**1028 / 2**-2


int/float gets converted to float/float and the int to float conversion 
is not possible. The result is irrelevant since it never gets calculated.



 Traceback (most recent call last):
   File input, line 1, in module
 OverflowError: long int too large to convert to float

When the result is inside the limits, we get the right value:

  2 ** 1025 / 2**10
 3.59404027961e+305


This must be doing integer division and then converting the result to 
float, which it can.



Why the behavior is different in the case of the multiplication?

  2 ** 1025 * 2**-10


Mathematically this is the same thing, but computationally, it is not 
and you cannot expect to get the same answer. Like the first example, 
2**-10 is a float, so 2**1025 must be converted to float to do float 
multiplication. But that is not possible.



 Traceback (most recent call last):
   File input, line 1, in module
 OverflowError: long int too large to convert to float

I think the multiplication should have the same behavior than the
division:

* `inf` or `-inf` when the operands are inside the limits,
   but the result is not
* `OverflowError`  when the result, and at least one operand,
   are out of range.


--
Terry Jan Reedy

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


Re: Is it that easy to install Python ?

2013-07-27 Thread wizzofozz
On 25-7-2013 17:11, santiago.d...@caoba.fr wrote:
 Hi there,
 
 I never write any Python program but as a system administrator, I'm often 
 asked to install python on Debian servers.
 
 I just finished downloading, configuring, making and installing.
 

As a side note to all who have replied already; as a 'regular' linux
user you can also just download, untar, configure and make.
You can't do 'make install', but that's not required to run the
executables (in this case 'python') built in the previous steps.

just nitpicking .. :-)

cheers,
Ozz
-- 
http://mail.python.org/mailman/listinfo/python-list


python import module question

2013-07-27 Thread syed khalid
I am trying to do a import shogun in my python script. I can invoke shogun 
with a command line with no problem. But I cannot with a python import 
statement.

invoking python from a command line...

Syedk@syedk-ThinkPad-T410:~/shogun-2.0.0/src/interfaces/cmdline_static$ shogun 
| more
libshogun (i686/v2.0.0_9c8012f_2012-09-04_09:08_164102447)

Copyright (C) 1999-2009 Fraunhofer Institute FIRST
Copyright (C) 1999-2011 Max Planck Society
Copyright (C) 2009-2011 Berlin Institute of Technology
Copyright (C) 2012 Soeren Sonnenburg, Sergey Lisitsyn, Heiko Strathmann
Written   (W) 1999-2012 Soeren Sonnenburg, Gunnar Raetsch et al.

( configure options: configure options --interfaces=python_static compile flag
s: -fPIC -g -Wall -Wno-unused-parameter -Wformat -Wformat-security -Wparenthese
s -Wshadow -Wno-deprecated -O9 -fexpensive-optimizations -frerun-cse-after-loop
-fcse-follow-jumps -finline-functions -fschedule-insns2 -fthread-jumps -fforce-a
ddr -fstrength-reduce -funroll-loops -march=native -mtune=native -pthread link
flags:  -Xlinker --no-undefined )
( seeding random number generator with 3656470784 (seed size 256))
determined range for x in log(1+exp(-x)) is:37 )

Trying to call python from a script in the same directory where I invoked 
the shogun from a command 
linesyedk@syedk-ThinkPad-T410:~/shogun-2.0.0/src/interfaces/cmdline_static$ 
python
Python 2.7.3 (default, Apr 10 2013, 05:46:21)
[GCC 4.6.3] on linux2
Type help, copyright, credits or license for more information.
 import shogun
Traceback (most recent call last):
  File stdin, line 1, in module
ImportError: No module named shogun




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


Re: python import module question

2013-07-27 Thread Chris Angelico
On Sun, Jul 28, 2013 at 12:15 AM, syed khalid sy...@pacificloud.com wrote:
 Syedk@syedk-ThinkPad-T410:~/shogun-2.0.0/src/interfaces/cmdline_static$ 
 shogun | more

This implies that you have something called 'shogun', without an
extension, in your $PATH. Where is the actual script? You may need to
install it by a quite different method, to make it available in
Python.

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


PyQt5 and virtualenv problem

2013-07-27 Thread D. Xenakis
I tried to install SIP and PyQt5 using the pip install command but it didnt 
work on both cases (i was getting errors), so i finally installed them using 
the windows installers provided in riverbankcomputing website.
My problem though here is that whenever i try to create a new virtualenv 
enviroment, those packages are not included and i cant import them. How can i 
add PyQt5 to my new virt enviroment? What is the logic behind this problem so i 
understand whats going on here?

Thx in advance
-- 
http://mail.python.org/mailman/listinfo/python-list


Thread is somehow interfering with a while loop called after the thread is started

2013-07-27 Thread dan . h . mcinerney
I have a simple scapy + nfqueue dns spoofing script that I want to turn into a 
thread within a larger program:

http://www.bpaste.net/show/HrlfvmUBDA3rjPQdLmdp/

Below is my attempt to thread the program above. Somehow, the only way the 
while loop actually prints running is if the callback function is called 
consistently. If the callback function isn't started, the script will never 
print running. How can that be if the while loop is AFTER the thread was 
started? Shouldn't the while loop and the thread operate independantly?

http://bpaste.net/show/0aCxSsSW7yHcQ7EBLctI/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Critic my module

2013-07-27 Thread Jason Friedman


I made a Python3 module that allows users to use certain Linux shell
 commands from Python3 more easily than using os.system(),
 subprocess.Popen(), or subprocess.getoutput(). This module (once placed
 with the other modules) can be used like this


Looks similar to https://pypi.python.org/pypi/sh.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: RE Module Performance

2013-07-27 Thread Ian Kelly
On Sat, Jul 27, 2013 at 12:21 PM,  wxjmfa...@gmail.com wrote:
 Back to utf. utfs are not only elements of a unique set of encoded
 code points. They have an interesting feature. Each utf chunk
 holds intrisically the character (in fact the code point) it is
 supposed to represent. In utf-32, the obvious case, it is just
 the code point. In utf-8, that's the first chunk which helps and
 utf-16 is a mixed case (utf-8 / utf-32). In other words, in an
 implementation using bytes, for any pointer position it is always
 possible to find the corresponding encoded code point and from this
 the corresponding character without any programmed information. See
 my editor example, how to find the char under the caret? In fact,
 a silly example, how can the caret can be positioned or moved, if
 the underlying corresponding encoded code point can not be
 dicerned!

Yes, given a pointer location into a utf-8 or utf-16 string, it is
easy to determine the identity of the code point at that location.
But this is not often a useful operation, save for resynchronization
in the case that the string data is corrupted.  The caret of an editor
does not conceptually correspond to a pointer location, but to a
character index.  Given a particular character index (e.g. 127504), an
editor must be able to determine the identity and/or the memory
location of the character at that index, and for UTF-8 and UTF-16
without an auxiliary data structure that is a O(n) operation.

 2) Take a look at this. Get rid of the overhead.

 sys.getsizeof('b'*100 + 'c')
 126
 sys.getsizeof('b'*100 + '€')
 240

 What does it mean? It means that Python has to
 reencode a str every time it is necessary because
 it works with multiple codings.

Large strings in practical usage do not need to be resized like this
often.  Python 3.3 has been in production use for months now, and you
still have yet to produce any real-world application code that
demonstrates a performance regression.  If there is no real-world
regression, then there is no problem.

 3) Unicode compliance. We know retrospectively, latin-1,
 is was a bad choice. Unusable for 17 European languages.
 Believe of not. 20 years of Unicode of incubation is not
 long enough to learn it. When discussing once with a French
 Python core dev, one with commit access, he did not know one
 can not use latin-1 for the French language!

Probably because for many French strings, one can.  As far as I am
aware, the only characters that are missing from Latin-1 are the Euro
sign (an unfortunate victim of history), the ligature œ (I have no
doubt that many users just type oe anyway), and the rare capital Ÿ
(the miniscule version is present in Latin-1).  All French strings
that are fortunate enough to be absent these characters can be
represented in Latin-1 and so will have a 1-byte width in the FSR.
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue18565] Test for closing delegating generator with cleared frame (Issue17669)

2013-07-27 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Thanks! It looks good except I think you could use the support.disable_gc() 
context manager.

--

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



[issue18568] Support \e escape code in strings

2013-07-27 Thread Steven D'Aprano

New submission from Steven D'Aprano:

I'm adding this so there is a record in the bug tracker for posterity. No 
action is needed except to close it as a Won't Fix.

As per this discussion here:

http://mail.python.org/pipermail/python-ideas/2013-June/021318.html

using \e as an escape code for ASCII ESC character might be nice to have, but 
it fails backwards compatibility and therefore must be ruled out.

(But perhaps could be re-visited in Python 4000?)

--
components: Interpreter Core
messages: 193776
nosy: stevenjd
priority: normal
severity: normal
status: open
title: Support \e escape code in strings

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



[issue18568] Support \e escape code in strings

2013-07-27 Thread Steven D'Aprano

Changes by Steven D'Aprano steve+pyt...@pearwood.info:


--
resolution:  - rejected
status: open - closed

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



[issue18537] bool.toggle()

2013-07-27 Thread Raymond Hettinger

Raymond Hettinger added the comment:

FYI, the itertools module has ifilterfalse() for inverse filtering.

--
nosy: +rhettinger
resolution: invalid - rejected

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



[issue18472] Update PEP 8 to encourage modern conventions

2013-07-27 Thread Nick Coghlan

Nick Coghlan added the comment:

Latest version is a more general cleanup patch for PEP 8 (hence the change in 
the issue title). Enumerating all the changes/additions:

1. Added an intro paragraph that makes it clear this is a living document, not 
set and forget.

2. Added a couple more explicit reasons to the foolish consistency section, 
and tweaked the header for that list to help make it clearer that there may be 
other good reasons, these are just especially good ones.

3. Updated the tabs and spaces section for Python 3

4. Changed the rationale for the line length limit. These days, it is about 
side-by-side editor windows, diff tools, and online text editing widgets, not 
ancient terminals with limited column widths.

5. Cleaned up the encoding cookie guidelines for Python 3

6. Changed the absolute vs explicit relative import discussion to state that 
while absolute imports are recommended, there are valid reasons to use explicit 
relative imports. Added an explicit admonition that the standard library should 
always absolute imports, and that *nobody* should use implicit relative imports.

7. Added a guideline to avoid wildcard imports

8. The new section on public vs internal interfaces

9. Clarified that it's not just Jython that omits the += hack, and that it is 
fairly easy to break it in CPython, too.

10. Added a guideline about using def rather than assigning a lambda to a name.

11. Rewrote the class based exception guideline to account for the requirement 
that all exceptions inherit from BaseException, as well as the exception 
hierarchy design lessons we have learned that led to the creation of PEP 3151 
(which explicitly *rejects* the per-module generic exception approach 
previously recommended by PEP 8)

12. Clarified what a non-error exception might be used for.

13. Added a guideline about exception chaining

14. For the exception raising guideline, moved Python 3 compatibility up as the 
main motivating factor

15. Added a guideline about using the as clause to bind a caught exception to 
a name

16. Added a guideline explicitly favouring PEP 3151 based exception handling 
over errno introspection

17. Added a note about the Python 3 text model changes to the isinstance 
guideline

18. Added a recommendation that third party experiments with function 
annotations combine them with a decorator that indicates how they're to be 
interpreted

--
Added file: http://bugs.python.org/file31050/issue18472_pep_8_update4.diff

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



[issue18472] Update PEP 8 to encourage modern conventions

2013-07-27 Thread Nick Coghlan

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


Removed file: http://bugs.python.org/file30938/issue18472_pep_8_update3.diff

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



[issue18472] Update PEP 8 to encourage modern conventions

2013-07-27 Thread Nick Coghlan

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


Removed file: http://bugs.python.org/file30937/issue18472_pep_8_update2.diff

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



[issue18533] Avoid error from repr() of recursive dictview

2013-07-27 Thread Raymond Hettinger

Raymond Hettinger added the comment:

+1 for backporting the fix.

--
nosy: +rhettinger

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



[issue18472] Update PEP 8 to encourage modern conventions

2013-07-27 Thread Nick Coghlan

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


Removed file: http://bugs.python.org/file30936/issue18472_pep_8_update.diff

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



[issue18472] Update PEP 8 to encourage modern conventions

2013-07-27 Thread Nick Coghlan

Nick Coghlan added the comment:

Guido, if you have time to review these proposed PEP 8 changes, that would be 
great. Most should be unobjectionable, but I seem to recall you disliking the 
recommendation for third party function annotation experiments to use an 
explicit decorator, so I'm happy to drop that one if you don't like it.

I'm also willing to send it back to python-dev at large for further feedback, 
but I'm not sure that's necessary (the two big changes are the ones about 
public APIs and the import recommendations, and those have had discussion 
threads already)

--

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



[issue18472] Update PEP 8 to encourage modern conventions

2013-07-27 Thread Nick Coghlan

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


--
nosy: +gvanrossum

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



[issue18569] Set PATHEXT in the Windows installer

2013-07-27 Thread Paul Moore

New submission from Paul Moore:

Make the Windows Python installer set PATHEXT when Register Python extensions 
is set. This allows users to run a scripy by typing the name of the .py file at 
the command line without the .py extension.

The patch needs review - I have not been able to build the MSI installer and so 
this patch is untested :-(

--
assignee: loewis
components: Installation, Windows
files: pathext.patch
keywords: needs review, patch
messages: 193781
nosy: loewis, pmoore
priority: normal
severity: normal
stage: patch review
status: open
title: Set PATHEXT in the Windows installer
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file31051/pathext.patch

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



[issue18472] Update PEP 8 to encourage modern conventions

2013-07-27 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

 1. Added an intro paragraph that makes it clear this is a living document, 
 not set and forget.

If we want to make this a living document, I think the PEP will
have to receive its own internal version number and a history
section at the end explaining the changes (basically what you
just summarized for the patch).

Doing so is important, since companies and tools often reference
PEP 8 in internal coding guidelines and any changes need to
be easily identifiable for readers of those guidelines.

--
nosy: +lemburg

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



[issue18570] OverflowError during division: wrong message

2013-07-27 Thread Marco Buttu

New submission from Marco Buttu:

When the integer division result is too large to converto to float, and the 
operands are inside the limits, the result is `inf` or `-inf`::

 2**1023 / 2**-3
inf
 2**1022 / 2**-4
inf
 2**1023 / 2**-1074
inf

When both the result and an operand are too large to converto to float, we 
raise an OverflowError::

 2**1028 / 2**-2
Traceback (most recent call last):
  File input, line 1, in module
OverflowError: long int too large to convert to float

The message says: long int too large to convert to float. I think in Python 3 
it should be int too large to convert In any case, the most important 
thing is that in the same situation we get a different message [1]_::

 2**1032 / 2**2
Traceback (most recent call last):
  File input, line 1, in module
OverflowError: integer division result too large for a float

and I think is it muddleheaded, because it should be long int too large to 
convert to float, as we got in the case `2**1028 / 2**-2`. I think we should 
never show integer division result too large for a float, but just:

* `inf` or `-inf` when the operands are inside the limits, but the result 
  does not
* `OverflowError: long int too large to convert to float` when the result, 
  and at least one operand, are out of range.


.. [1] In this situation, we get the message OverflowError: integer division 
result too large for a float only when the denominator exponent is positive.

--
messages: 193783
nosy: marco.buttu
priority: normal
severity: normal
status: open
title: OverflowError during division: wrong message
type: behavior
versions: Python 3.1, Python 3.2, Python 3.3, Python 3.4

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



[issue18570] OverflowError during division: wrong message

2013-07-27 Thread Christian Heimes

Changes by Christian Heimes li...@cheimes.de:


--
nosy: +christian.heimes, mark.dickinson
versions:  -Python 3.1, Python 3.2

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



[issue8425] a -= b should be fast if a is a small set and b is a large set

2013-07-27 Thread Michele Orrù

Michele Orrù added the comment:

ping.

--

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



[issue18472] Update PEP 8 to encourage modern conventions

2013-07-27 Thread Guido van Rossum

Guido van Rossum added the comment:

This is mostly fine.

FWIW I disagree with MAL's assertion that we need to start adding internal 
versioning; people who lawyer about which version of the PEP should apply are 
focused on the wrong thing entirely.  IIUC the occasional Python-3-specific 
rule is already flagged as such.  Also for real nitpickers there's the Hg 
revision. :-)

My nits on the diff:

- You're missing a comma after Barry's name (i.e. before your own).

- Also a period at the end of point 3 starting near line 55.

- I think we should recommend against tabs outright.  They are getting more and 
more misunderstood.

- Regarding line length, I think it is reasonable to mention that many 
organizations are settling on 100 as a compromise.  On newer laptops you can 
still fit two terminal windows (with a reasonable font size) side by side.  
(Also many people checking code into the stdlib ignore the 80 char limit. :-( )

- The section about Latin-1 author names sounds a little confused (why 
recommend Latin-1 over UTF-8 at all?).  I believe what is left unsaid is that 
you don't need a coding cookie when using Latin-1 in comments in Python 2?  But 
in strings the cookie would still be required IIRC.  But this will cause 
problems when the file is converted Python 3 because the UTF-8 default will 
complain about non-ASCII Latin-1 bytes.

- In performance sensitive parts of the library -- are we suddenly clinging 
to the fiction that PEP 8 only applies to the stdlib?  I'd change parts of the 
library to code. Also, it's performance-sensitive.

- Eliminate this:

+- Use class-based exceptions (recent versions of Python require that all
+  exceptions inherit from BaseException).

Instead, I'd add an admonition to derive exceptions from Exception rather than 
BaseException unless you really know what you're doing.  

- Which reminds me.  Do we have a recommendation yet to write
  except Exception:
instead of
  except:
If not, we should.

- I wouldn't mind seeing at least a mild recommendation against using 
exceptions for non-local control flow.  The lessons of StopIteration suggest 
that such designs are often fraught with subtle problems.

- About third party experiments: can you strike highly?  I don't want mypy to 
feel out of line (http://www.mypy-lang.org/).

--

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



[issue17036] Implementation of the PEP 433: Easier suppression of file descriptor inheritance

2013-07-27 Thread STINNER Victor

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


Added file: http://bugs.python.org/file31052/ecc10f0afb76.diff

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



[issue17036] Implementation of the PEP 433: Easier suppression of file descriptor inheritance

2013-07-27 Thread STINNER Victor

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


Removed file: http://bugs.python.org/file31052/ecc10f0afb76.diff

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



[issue18571] Implementation of the PEP 446: non-inheriable file descriptors

2013-07-27 Thread STINNER Victor

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


--
nosy: haypo
priority: normal
severity: normal
status: open
title: Implementation of the PEP 446: non-inheriable file descriptors
type: enhancement
versions: Python 3.4

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



[issue18571] Implementation of the PEP 446: non-inheriable file descriptors

2013-07-27 Thread STINNER Victor

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


--
hgrepos: +205

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



[issue18571] Implementation of the PEP 446: non-inheriable file descriptors

2013-07-27 Thread STINNER Victor

New submission from STINNER Victor:

Implementation of the PEP 446.

--

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



[issue18572] Remove redundant note about surrogates in string escape doc

2013-07-27 Thread Steven D'Aprano

New submission from Steven D'Aprano:

The documentation for string escapes suggests that \u escapes can be used 
to generate characters in the Supplementary Multilingual Planes by using 
surrogate pairs:

Individual code units which form parts of a surrogate pair can be encoded 
using this escape sequence.

http://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals

E.g. in Python 3.2:

py '\uD80C\uDC80' == '\U00013080'
True

but that is no longer the case in Python 3.3. I suggest the documentation 
should just remove that note.

--
assignee: docs@python
components: Documentation
messages: 193787
nosy: docs@python, stevenjd
priority: normal
severity: normal
status: open
title: Remove redundant note about surrogates in string escape doc
versions: Python 3.3

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



[issue18571] Implementation of the PEP 446: non-inheriable file descriptors

2013-07-27 Thread STINNER Victor

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


--
keywords: +patch
Added file: http://bugs.python.org/file31053/327133193321.diff

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



[issue18573] In unittest.TestCase.assertWarns doc there is some text about assertRaises()

2013-07-27 Thread py.user

New submission from py.user:

http://docs.python.org/3/library/unittest.html#unittest.TestCase.assertWarns
When used as a context manager, assertRaises() accepts
... is to perform additional checks on the exception raised

--
assignee: docs@python
components: Documentation
files: issue.diff
keywords: patch
messages: 193788
nosy: docs@python, py.user
priority: normal
severity: normal
status: open
title: In unittest.TestCase.assertWarns doc there is some text about 
assertRaises()
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file31054/issue.diff

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



[issue18572] Remove redundant note about surrogates in string escape doc

2013-07-27 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
stage:  - needs patch
type:  - behavior
versions: +Python 3.4

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



[issue18573] In unittest.TestCase.assertWarns doc there is some text about assertRaises()

2013-07-27 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
stage:  - needs patch
versions: +Python 2.7, Python 3.3

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



[issue18539] Idle 2.7: Calltip wrong if def contains float default value

2013-07-27 Thread ariel brunner

ariel brunner added the comment:

Superb, and thanks for doing the actual work on fixing it.

--

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



[issue18570] OverflowError in division: wrong message

2013-07-27 Thread Marco Buttu

Changes by Marco Buttu marco.bu...@gmail.com:


--
title: OverflowError during division: wrong message - OverflowError in 
division: wrong message

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



[issue18572] Remove redundant note about surrogates in string escape doc

2013-07-27 Thread Terry J. Reedy

Terry J. Reedy added the comment:

3.3.2:
 '\uD80C\uDC80' == '\U00013080'
False

The statement that surrogate code units can be encoded this way is still true. 
Indeed, it is now the only way to get such code units into a string. The 
suggestion that a pair will make an astral char is now false. The sentence 
could be changed to 

Individual surrogate code units can be encoded using this escape sequence.

On the other hand, the same is true of *any* BMP char, including all the 
*other* non-graphic chars that can only be entered this way. So I think the 
sentence, if not deleted, should be replaced by what seems to me a more useful 
(complete) statement.

Any Basic Multilingual  Plane (BMP) codepoint can be encoded using this escape 
sequence.

--
nosy: +terry.reedy

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



[issue18573] In unittest.TestCase.assertWarns doc there is some text about assertRaises()

2013-07-27 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
assignee: docs@python - terry.reedy
nosy: +terry.reedy

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



[issue18573] In unittest.TestCase.assertWarns doc there is some text about assertRaises()

2013-07-27 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 55dcf9e065be by Terry Jan Reedy in branch '3.3':
Issue #18573: Complete copy-paste from assertRaises entry to assertWarns entry.
http://hg.python.org/cpython/rev/55dcf9e065be

--
nosy: +python-dev

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



[issue18573] In unittest.TestCase.assertWarns doc there is some text about assertRaises()

2013-07-27 Thread Terry J. Reedy

Terry J. Reedy added the comment:

assertWarns is new in 3.2 and not in 2.7.
The sentence was copied from the assertRaises section but not changed.
Thanks for reporting.

--
resolution:  - fixed
stage: needs patch - committed/rejected
status: open - closed
type: enhancement - behavior
versions:  -Python 2.7

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



[issue18570] OverflowError in division: wrong message

2013-07-27 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Yes, 'long int' should just be 'int' in 3.x.

However, int/int (integer division) is *not* the same thing as int/float. In 
the latter case, the int is converted to float first and if that conversion 
fails, there is no result.

Now that int/int is always converted to float, it seems sensible that out of 
float range results be +-inf. But there may be an issue with back 
compatibility. I know there has been discussion on overflow vs. inf in various 
contexts.

--
nosy: +terry.reedy

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



[issue18565] Test for closing delegating generator with cleared frame (Issue17669)

2013-07-27 Thread Phil Connell

Phil Connell added the comment:

Good suggestion, updated patch attached.

--
Added file: http://bugs.python.org/file31055/gen_close_with_cleared_frame.diff

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



[issue18564] Integer overflow in socketmodule

2013-07-27 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Instead of writing try / except / self.fail, you could simply use the context 
manager form of assertRaises.

--
nosy: +neologix, pitrou

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




[issue18112] PEP 442 implementation

2013-07-27 Thread Christian Heimes

Changes by Christian Heimes li...@cheimes.de:


--
nosy: +christian.heimes

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



[issue18566] In unittest.TestCase docs for setUp() and tearDown() don't mention AssertionError

2013-07-27 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I re-ran with setUp 'raise' changed to 'pass' to see the effect of raise 
AssertionError or unittest.SkipTest in tearDown and indeed the test fails or 
skips even then. I suggest adding ', other than AssertionError or SkipTest,' 
just after 'method'. The same is true of test_xxx methods.

A slight anomaly is that AssertionError in test_nothing and SkipTest in 
tearDown results in FAILED (failures=1, skipped=1), which is not really a 
skip.

For setUpClass and setUpModule, AssertionErrors *are* errors, not failures, 
while SkipTest works everywhere.

--
nosy: +terry.reedy
versions: +Python 2.7, Python 3.3

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



[issue17669] Segfault caused by weird combination of imports and yield from

2013-07-27 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 516303f32bad by Benjamin Peterson in branch '3.3':
add a test for issue #17669 (closes #18565)
http://hg.python.org/cpython/rev/516303f32bad

--

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



[issue18565] Test for closing delegating generator with cleared frame (Issue17669)

2013-07-27 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 516303f32bad by Benjamin Peterson in branch '3.3':
add a test for issue #17669 (closes #18565)
http://hg.python.org/cpython/rev/516303f32bad

New changeset f90e7540dcba by Benjamin Peterson in branch 'default':
merge 3.3 (#18565)
http://hg.python.org/cpython/rev/f90e7540dcba

--
nosy: +python-dev
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

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



[issue18564] Integer overflow in socketmodule

2013-07-27 Thread Michele Orrù

Changes by Michele Orrù maker...@gmail.com:


Added file: http://bugs.python.org/file31056/issue18564.1.patch

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



[issue18441] Idle: Make test.support.requires('gui') skip when it should.

2013-07-27 Thread Roundup Robot

Roundup Robot added the comment:

New changeset dd9941f5fcda by Terry Jan Reedy in branch '2.7':
Issue #18441: Make test.support.requires('gui') skip when it should.
http://hg.python.org/cpython/rev/dd9941f5fcda

New changeset d9a53ab464ea by Terry Jan Reedy in branch '2.7':
Issue #18441: Correct previous patch, which hg committed before I wanted it to.
http://hg.python.org/cpython/rev/d9a53ab464ea

--

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



[issue18564] Integer overflow in socketmodule

2013-07-27 Thread STINNER Victor

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


--
nosy: +haypo

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



[issue18112] PEP 442 implementation

2013-07-27 Thread STINNER Victor

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


--
nosy: +haypo

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



[issue18574] BaseHTTPRequestHandler.handle_expect_100() sends invalid response

2013-07-27 Thread Nikolaus Rath

New submission from Nikolaus Rath:

The handle_expect_100() implementation in BaseHTTPRequestHandler currently 
calls send_response_only(100) followed by flush_headers(). However, even a 1xx 
response is always followed by a (potentially empty) set of response headers 
(cf. http://tools.ietf.org/html/rfc2616#section-9.9). Therefore, clients will 
block waiting for an additional '\r\n' before sending the buffer.

The attached patch fixes the problem.

--
components: Library (Lib)
files: handle_expect.diff
keywords: patch
messages: 193800
nosy: Nikratio
priority: normal
severity: normal
status: open
title: BaseHTTPRequestHandler.handle_expect_100() sends invalid response
versions: Python 3.3, Python 3.4, Python 3.5
Added file: http://bugs.python.org/file31057/handle_expect.diff

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



[issue18574] BaseHTTPRequestHandler.handle_expect_100() sends invalid response

2013-07-27 Thread Nikolaus Rath

Nikolaus Rath added the comment:

The correct link is http://tools.ietf.org/html/rfc2616#section-10.1:

10.1 Informational 1xx

   This class of status code indicates a provisional response,
   consisting only of the Status-Line and optional headers, and is
   terminated by an empty line.
   [...]

Currently handle_expect_100() does not send this empty line.

--

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



[issue18571] Implementation of the PEP 446: non-inheriable file descriptors

2013-07-27 Thread STINNER Victor

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


Added file: http://bugs.python.org/file31058/c066794c85cd.diff

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



[issue18571] Implementation of the PEP 446: non-inheriable file descriptors

2013-07-27 Thread STINNER Victor

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


Removed file: http://bugs.python.org/file31053/327133193321.diff

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



[issue18441] Idle: Make test.support.requires('gui') skip when it should.

2013-07-27 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 9a4c62c1a4c0 by Terry Jan Reedy in branch '2.7':
Issue #18441: add Mac (darwin) gui check. This is not needed today, but has been
http://hg.python.org/cpython/rev/9a4c62c1a4c0

New changeset ba5c264d67ea by Terry Jan Reedy in branch '2.7':
Issue #18441: Comment out code that will not compile because the standard
http://hg.python.org/cpython/rev/ba5c264d67ea

New changeset 6420dcd377f9 by Terry Jan Reedy in branch '2.7':
Issue #18441: whitespace
http://hg.python.org/cpython/rev/6420dcd377f9

--

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



[issue1521051] Allow passing DocTestRunner and DocTestCase in doctest

2013-07-27 Thread Jason Myers

Jason Myers added the comment:

The attached file contains a simple test for this code to make sure the test 
runner is being applied.  I've never submitted anything before, so it might be 
totally naive.

--
nosy: +jasonamyers
Added file: http://bugs.python.org/file31059/test.patch

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



[issue12129] Document Object Model API - validation

2013-07-27 Thread John Cassidy

John Cassidy added the comment:

I added the line print(str(doc)) after the call to getDomImplementation and 
verified that the errors that I'm seeing are coming from the xml.dom.minidom 
implemenation of xml.dom.  Checking minidom.py I did not see any validation on 
the tagName that gets passed to createElement.  
http://www.w3.org/TR/xml11/#NT-NameStartChar lists the format of allowed names. 
 Attached is a file containing the functions I was working on.  My thinking is 
that if the tagName is not valid a ValueError should be thrown.

--
nosy: +jocassid
Added file: http://bugs.python.org/file31060/xmlNameVerification.py

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



[issue18441] Idle: Make test.support.requires('gui') skip when it should.

2013-07-27 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I tried to run the currently unnecessary Mac 'darwin' check in 2.7 with
if sys.platform == 'darwin':
from lib-tk.test.runtktests import check_tk_availability
# tkinter.test.suppport in 3.x
try:
check_tk_availability()
except unittest.SkipTest:
raise tk.TclError

This fails because 'lib-tk' is not a legal module name. There are workarounds 
in test/test_tk.py and test_ttk_guionly, but I decided not to bother with them 
now because I would rather work on moving the function to test.support (and 
perhaps the package could be given a legal name). If, before that is done, 
someone adds a Mac buildbot that will not run gui tests but requests that they 
be run anyway, the above could be added with the different changes needed for 
2.7 and 3.x.

--

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



[issue18441] Idle: Make test.support.requires('gui') skip when it should.

2013-07-27 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c3936a52f215 by Terry Jan Reedy in branch '3.3':
Issue #18441: Make test.support.requires('gui') skip when it should.
http://hg.python.org/cpython/rev/c3936a52f215

New changeset 858a72d91162 by Terry Jan Reedy in branch '2.7':
Issue #18441: Move commented out code to issue message.
http://hg.python.org/cpython/rev/858a72d91162

--

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



[issue8425] a -= b should be fast if a is a small set and b is a large set

2013-07-27 Thread Raymond Hettinger

Raymond Hettinger added the comment:

There's no rush on this.  I have other work I want to do on set objects before 
applying further optimizations, so I want to hold off on it for a bit.

--

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



[issue18472] Update PEP 8 to encourage modern conventions

2013-07-27 Thread Raymond Hettinger

Raymond Hettinger added the comment:

- I think we should recommend against tabs outright.  They are getting more and 
more misunderstood.

+1  Perhaps also mention that Python 3 now raises TabError for inconsistent 
tabs and spaces.


- Regarding line length, I think it is reasonable to mention that many 
organizations are settling on 100 as a compromise.  On newer laptops you can 
still fit two terminal windows (with a reasonable font size) side by side

+1  I've seen too many atrocities committed by people trying to scrunch code 
into 80 columns (weird line splits, over-abbreviated variable names, etc).

- The section about Latin-1 author names sounds a little confused (why 
recommend Latin-1 over UTF-8 at all?).  I believe what is left unsaid is that 
you don't need a coding cookie when using Latin-1 in comments in Python 2?  But 
in strings the cookie would still be required IIRC.  But this will cause 
problems when the file is converted Python 3 because the UTF-8 default will 
complain about non-ASCII Latin-1 bytes.

+1 for UTF-8 as the default preference for everything in the Python world.


- Eliminate this:

+- Use class-based exceptions (recent versions of Python require that all
+  exceptions inherit from BaseException).

Instead, I'd add an admonition to derive exceptions from Exception rather than 
BaseException unless you really know what you're doing.  

+1

- I wouldn't mind seeing at least a mild recommendation against using 
exceptions for non-local control flow.  The lessons of StopIteration suggest 
that such designs are often fraught with subtle problems.

I'm afraid even a mild admonition would lead of over zealous rejection of 
legitimate use cases for exceptions.

For uses cases that actually need non-local control flow, there are worse 
things you can do than use exceptions (i.e. returning an error token up a chain 
of function calls requiring if-error logic at every step along the way).

In particular, exceptions for control-flow are a good solution to some 
challenges that arise in larger programs (i.e. problems encountered in low 
level logic can only be handled by high level user interface logic, and the 
intermediate level business logic serves only as a pass through).

It seems to me that the issues with StopIteration were mostly caused by having 
multiple control conditions all sharing the same exception (i.e. a function 
inside a for-loop can't use StopIteration to control an outer loop; the latter 
would need its own distinction exception).

P.S.  For those who are interested, the book The Little MLer does a great job 
showing how exceptions for control-flow can be used simplify recursive 
functions.

--
nosy: +rhettinger

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



[issue18472] Update PEP 8 to encourage modern conventions

2013-07-27 Thread Nick Coghlan

Nick Coghlan added the comment:

The exception one is near-and-dear to my heart at the moment, as we're in
the process of refactoring a large app that currently does various checks
in the UI layer so it can present nice errors, when it should really be
leaving those checks to the business logic layer and then throwing app
specific exceptions that the UI layer understands and can present to the
users.

As Raymond noted, I think we need to be very cautious when it comes to
exception handling, especially with Go advocates propagating all sorts of
foolishness about the evils of exceptions and the notion that return codes
are somehow now a superior approach :P

However, I'm not sure we have a guideline about using deterministic
resource management to better cope with unexpected exceptions - I'll look
into that.

--

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