Re: Contact information for Jim Hugunin?

2013-07-27 Thread greymausg
On 2013-07-24, Albert Hopkins  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
 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 
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
 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 
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
 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
 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 o

Re: Understanding other people's code

2013-07-27 Thread Albert van der Horst
In article ,
Azureaus   wrote:
>On Friday, 12 July 2013 15:22:59 UTC+1, Azureaus  wrote:

>
>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@spe&ar&c.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 o

Re: Critic my module

2013-07-27 Thread Dave Angel

On 07/27/2013 09:19 AM, Devyn Collier Johnson 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 "", line 1, in 
TypeError: 'str' object is not callable
 >>> pwd
'/home/collier'
 >>> pwd() = os.getcwd()
   File "", 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
 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 "", line 1, in 
> TypeError: 'str' object is not callable
 pwd
> '/home/collier'
 pwd() = os.getcwd()
>   File "", 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 
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
 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:







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 "", line 1, in 
TypeError: 'str' object is not callable
 >>> pwd
'/home/collier'
 >>> pwd() = os.getcwd()
   File "", 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
 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:






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






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

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
 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 D&D 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
>>  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
 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
 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 "", line 1, in 
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 "", line 1, in 
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 
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 ()


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

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 "", line 1, in 
 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 "", line 1, in 
 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 "", line 1, in 
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  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,   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