PyCon Singapore 2013 Call for Proposals

2013-02-08 Thread George Goh
Hi,

On behalf of the organizing committee of PyCon SG 2013, we are
inviting for Proposals for Presentations and Tutorials for the 2013
PyCon Singapore Conference, to be held in Singapore from June 13 to
15, 2013.

Presentation and Tutorial Submission detail can be found at
https://pycon.sg/proposals/

And the submission deadline for both is April 1, 2013

For enquiries, pls direct them to confere...@pycon.sg

We look forward to receiving your proposals! And to a great conference
this year.

Best regards,
George Goh
PyCon SG 2013 Programme Committee Chair
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Karlsruhe (Germany) Python User Group, February 15th 2013, 7pm

2013-02-08 Thread Jürgen A . Erhard
The Karlsruhe Python User Group (KaPy) meets again.

Friday, 2013-02-15 (February 15th) at 19:00 (7pm) in the rooms of Entropia eV
(the local affiliate of the CCC).  See http://entropia.de/wiki/Anfahrt
on how to get there.

For your calendars: meetings are held monthly, on the 3rd Friday.

There's also a mailing list at
https://lists.bl0rg.net/cgi-bin/mailman/listinfo/kapy.
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Updated Cygwin Package: python-2.7.3-1

2013-02-08 Thread Jason Tishler
New News:
=== 
  *** Cygwin has migrating from Python 2.6 to 2.7. ***

I have updated the version of Python to 2.7.3-1.  The tarballs should be
available on a Cygwin mirror near you shortly.

The following is the only change since the previous release:

o promote from experimental to current

Note that all Python dependent packages have been rebuilt against 2.7.

I would like to thank Yaakov Selkowitz for managing the migration from
Python 2.6 to 2.7.

Old News:
=== 
Python is an interpreted, interactive, object-oriented programming
language.  If interested, see the Python web site for more details:
   
http://www.python.org/ 

Please read the README file:

/usr/share/doc/Cygwin/python.README

since it covers requirements, installation, known issues, etc.

Standard News:
 
To update your installation, click on the Install Cygwin now link on
the http://cygwin.com/ web page.  This downloads setup.exe to your
system.  Then, run setup and answer all of the questions.

If you have questions or comments, please send them to the Cygwin
mailing list.

  *** CYGWIN-ANNOUNCE UNSUBSCRIBE INFO ***

If you want to unsubscribe from the cygwin-announce mailing list, please
use the automated form at:

http://cygwin.com/lists.html#subscribe-unsubscribe

If you need more information on unsubscribing, start reading here:

http://sourceware.org/lists.html#unsubscribe-simple

Please read *all* of the information on unsubscribing that is available
starting at this URL.

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

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


Re: Curious to see alternate approach on a search/replace via regex

2013-02-08 Thread Ian Kelly
On Thu, Feb 7, 2013 at 10:57 PM, rh richard_hubb...@lavabit.com wrote:
 On Thu, 7 Feb 2013 18:08:00 -0700
 Ian Kelly ian.g.ke...@gmail.com wrote:

 Which is approximately 30 times slower, so clearly the regular
 expression *is* being cached.  I think what we're seeing here is that
 the time needed to look up the compiled regular expression in the
 cache is a significant fraction of the time needed to actually execute
 it.

 By actually execute you mean to apply the compiled expression
 to the search or sub? Or do you mean the time needed to compile
 the pattern into a regex obj?

The former.  Both are dwarfed by the time needed to compile the pattern.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Curious to see alternate approach on a search/replace via regex

2013-02-08 Thread Nick Mellor
Hi RH,

It's essential to know about regex, of course, but often there's a better, 
easier-to-read way to do things in Python.

One of Python's aims is clarity and ease of reading.

Regex is complex, potentially inefficient and hard to read (as well as being 
the only reasonable way to do things sometimes.)

Best,

Nick

On Friday, 8 February 2013 16:47:03 UTC+11, rh  wrote:
 On Thu, 7 Feb 2013 04:53:22 -0800 (PST)
 
 Nick Mellor t@gmail.com wrote:
 
 
 
  Hi RH,
 
  
 
  translate methods might be faster (and a little easier to read) for
 
  your use case. Just precompute and re-use the translation table
 
  punct_flatten.
 
  
 
  Note that the translate method has changed somewhat for Python 3 due
 
  to the separation of text from bytes. The is a Python 3 version.
 
  
 
  from urllib.parse import urlparse
 
  
 
  flattened_chars = ./=?
 
  punct_flatten = str.maketrans(flattened_chars, '_' * len
 
  (flattened_chars)) parts = urlparse
 
  ('http://alongnameofasite1234567.com/q?sports=runa=1b=1')
 
  unflattened = parts.netloc + parts.path + parts.query flattened =
 
  unflattened.translate(punct_flatten) print (flattened)
 
 
 
 I like the idea of using a library but since I'm learning python I wanted
 
 to try out the regex stuff. I haven't looked but I'd think that urllib might
 
 (should?) have a builtin so that one wouldn't have to specify the 
 
 flattened_chars list. I'm sure there's a name for those chars but I don't know
 
 it. Maybe just punctuation??
 
 
 
 Also my version converts the ? into _ but urllib sees that as the query
 
 separator and removes it. Just point this out for completeness sake.
 
 
 
 This would mimic what I did:
 
 unflattened = parts.netloc + parts.path + '_' + parts.query
 
 
 
  
 
  Cheers,
 
  
 
  Nick
 
  
 
  On Thursday, 7 February 2013 08:41:05 UTC+11, rh  wrote:
 
   I am curious to know if others would have done this differently.
 
   And if so
 
   
 
   how so?
 
   
 
   
 
   
 
   This converts a url to a more easily managed filename, stripping the
 
   
 
   http protocol off. 
 
   
 
   
 
   
 
   This:
 
   
 

 
   
 
   http://alongnameofasite1234567.com/q?sports=runa=1b=1
 
   
 
   
 
   
 
   becomes this:
 
   
 
   
 
   
 
   alongnameofasite1234567_com_q_sports_run_a_1_b_1
 
   
 
   
 
   
 
   
 
   
 
   def u2f(u):
 
   
 
   nx = re.compile(r'https?://(.+)$')
 
   
 
   u = nx.search(u).group(1)
 
   
 
   ux = re.compile(r'([-:./?=]+)')
 
   
 
   return ux.sub('_', u)
 
   
 
   
 
   
 
   One alternate is to not do the compile step. There must also be a
 
   way to
 
   
 
   do it all at once. i.e. remove the protocol and replace the chars.
 
 
 
 
 
 --
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: which situations should we use thread. join() ?

2013-02-08 Thread Ulrich Eckhardt

Am 08.02.2013 07:29, schrieb Chris Angelico:

On Fri, Feb 8, 2013 at 3:32 PM, iMath redstone-c...@163.com wrote:

which situations should we use thread. join() ?
http://bpaste.net/show/yBDGfrlU7BDDpvEZEHmo/
  why do we not put thread. join() in this code ?


I've no idea why you don't put thread.join() in that code. Maybe
because it isn't needed, maybe because someone likes to live on the
edge, maybe it's not so much the edge as positively cloud cuckoo
land. When should you use it? When you want to accomplish what the
function does, the details of which can be found in the Fine Manual.
Actually, you probably know already what it does, or you wouldn't even
be asking.


It isn't needed. I personally would prefer an explicit join(), but 
according to the documentation, The entire Python program exits when no 
alive non-daemon threads are left.. In other words, the initial thread 
is not special and the interpreter will implicitly join() all non-daemon 
threads.


Which again makes me want to find out in what thread's context the 
atexit call is made...


Uli

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


Re: Curious to see alternate approach on a search/replace via regex

2013-02-08 Thread Peter Otten
Serhiy Storchaka wrote:

 On 07.02.13 11:49, Peter Otten wrote:
 ILLEGAL = -:./?=
 try:
  TRANS = string.maketrans(ILLEGAL, _ * len(ILLEGAL))
 except AttributeError:
  # python 3
  TRANS = dict.fromkeys(map(ord, ILLEGAL), _)
 
 str.maketrans()

D'oh.

ILLEGAL = -:./?=
try:
maketrans = str.maketrans
except AttributeError:
# python 2
from string import maketrans
TRANS = maketrans(ILLEGAL, _ * len(ILLEGAL))
...

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


Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread Mark Lawrence

On 08/02/2013 06:15, Chris Angelico wrote:

On Fri, Feb 8, 2013 at 4:53 PM, Rick Johnson
rantingrickjohn...@gmail.com wrote:

And which Univeristy would you recommend for studying the intricacies of 
gobbledygook? ;-)


Dunno, where'd you get your degree in logic?


From the University of Wallamaloo whilst in charge of the sheep dip?



*dives for cover*

ChrisA


--
Cheers.

Mark Lawrence

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


Re: Moving mouse, Python3 and PyObjc

2013-02-08 Thread Oneill
On Thursday, 7 February 2013 23:22:01 UTC, Oneill  wrote:
 import objc
 
 
 
 def clickMouse(x, y, button):
 
 bndl = objc.loadBundle('CoreGraphics', globals(), 
 '/System/Library/Frameworks/ApplicationServices.framework')
 
 objc.loadBundleFunctions(bndl, globals(), [('CGPostMouseEvent', 
 'v{CGPoint=ff}III')])
 
 CGPostMouseEvent((x, y), 1, button, 1)
 
 CGPostMouseEvent((x, y), 1, button, 0)
 
  
 
 clickMouse(600,500, 1)  
 
 
 
 
 
 this seems to send the mouse cursos to the top left corner, no matter what 
 coords i send on clickMouse...
 
 
 
 
 
 Also, I just can't seem to install PyObjc and use it on Python3.3 ... always 
 get No module named objc.
 
 
 
 Sighs... Made a simple python app while at work (windows 7) and was trying to 
 change it to work on Os X (home computer) but cant even get the basics done 
 (move and click mouse)
 
 
 
 
 
 Thank you.




Well i did this : sudo env CC=clang easy_install -U pyobjc

and i get alot of these: 

warning: no directories found matching 'source-deps'
warning: no previously-included files matching '.DS_Store' found anywhere in 
distribution
warning: no previously-included files matching '*.pyc' found anywhere in 
distribution
warning: no previously-included files matching '*.so' found anywhere in 
distribution
clang: warning: argument unused during compilation: '-mno-fused-madd'
Skipping installation of 
build/bdist.macosx-10.8-intel/egg/PyObjCTest/__init__.py (namespace package)
Skipping installation of 
build/bdist.macosx-10.8-intel/egg/PyObjCTest/test_abactions.py (namespace 
package)

before i tried easy_install pyobjc and it failed, with  env CC=clang it 
finishes but with alot of those warnings.


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


Re: Moving mouse, Python3 and PyObjc

2013-02-08 Thread Oneill

 
 
 
  import objc
 
 
 
  def clickMouse(x, y, button):
 
   bndl = objc.loadBundle('CoreGraphics', globals(), 
  '/System/Library/Frameworks/ApplicationServices.framework')
 
   objc.loadBundleFunctions(bndl, globals(), [('CGPostMouseEvent', 
  'v{CGPoint=ff}III')])
 
   CGPostMouseEvent((x, y), 1, button, 1)
 
   CGPostMouseEvent((x, y), 1, button, 0)
 
 
 
  clickMouse(600,500, 1)
 
 
 
 
 
  this seems to send the mouse cursos to the top left corner, no matter what 
  coords i send on clickMouse...
 
 
 
 
 
  Also, I just can't seem to install PyObjc and use it on Python3.3 ... 
  always get No module named objc.
 
 
 
  Sighs... Made a simple python app while at work (windows 7) and was trying 
  to change it to work on Os X (home computer) but cant even get the basics 
  done (move and click mouse)
 
 
 
 
 
  Thank you.
 
 
 
 
 
 What's the objc module got to do with the mouse?
 
 
 
  http://packages.python.org/pyobjc/api/module-objc.html
 
 
 
 Perhaps you meant some other module.  Could you be specific?  What 
 
 modules did you import, what other code did you write, what version of 
 
 Python are you running, and on which computer OS did you get the results 
 
 you describe?
 
 
 
 -- 
 
 DaveA



Well without PyObjc i couldnt control the mouse... I saw some examples 
importing Quartz  but that also failed...

I have python 2.7 installed and 3.3. I started building the app using Python 
3.3 at work (windows) and importing win32api and win32con. Everything went 
smoothly.

At home I was going to import OS X libs to replace the win32 ones to control 
the mouse in OS X. I tried installing autopy and it fails

clang: warning: argument unused during compilation: '-mno-fused-madd'
clang: warning: argument unused during compilation: '-mno-fused-madd'
clang: warning: argument unused during compilation: '-mno-fused-madd'
clang: warning: argument unused during compilation: '-mno-fused-madd'
clang: warning: argument unused during compilation: '-mno-fused-madd'
src/screengrab.c:48:26: warning: implicit declaration of function 
'CGDisplayBitsPerPixel' is invalid in C99 [-Wimplicit-function-declaration]
bitsPerPixel = (uint8_t)CGDisplayBitsPerPixel(displayID);
^
src/screengrab.c:191:2: warning: 'CGLSetFullScreen' is deprecated 
[-Wdeprecated-declarations]
CGLSetFullScreen(glContext);



PyObjc used to ouput similar errors but i tried with the env CC=clang and at 
least it doesnt fail, but gives me alot of skipping and warnings.


also tried PyMouse but that didn't work also, couldnt install.



At the moment I can click the mouse and it actually moves, but no matter what 
coords I place it always goes to the upper left corner.


Mac Os X 10.8.2
Python 2.7 / 3.3
Im using Komodo Edit

also installed ActivstatePython.

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


Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread Thomas Rachel

Am 08.02.2013 07:29 schrieb Rick Johnson:


Consider this:

 if connect(my:db) as db:
 do something

No need to make a call and then test for the validity of the call when you can 
do both simultaneously AND intuitively.


Would be great, but can be emulated with

def ifiter(x):
if x: yield x

for db in ifiter(connect(my:db)):
do sth with db

Is not very intuitive, however, but does its job.


Thomas

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


Re: PyWart: Namespace asinitiy and the folly of the global statement

2013-02-08 Thread Steven D'Aprano
Chris Angelico wrote:

 On Fri, Feb 8, 2013 at 3:30 PM, Rick Johnson
 rantingrickjohn...@gmail.com wrote:
 It is my strong opinion that all unqualified variables must be local to
 the containing block, func/meth, class, or module. To access any variable
 outside of the local scope a programmer MUST qualify that variable with
 the func, class, or module identifiers. Consider the following examples
 
 Okay. Now start actually working with things, instead of just making
 toys. All your builtins now need to be qualified:
 
 __builtins__.print(There
 are,__builtins__.len(self.some_list),members in this list,
 namely:,__builtins__.repr(self.some_list))


Pardon me, but since __builtins__ is a global, you have to say:

globals.__builtins__.print(screw this for a game of soldiers)

or equivalent.


-- 
Steven

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


Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread Steven D'Aprano
Rick Johnson wrote:

 On Monday, July 16, 2012 7:43:47 PM UTC-5, Steven D'Aprano wrote:

Really Rick? Digging out a post from nearly seven months ago? You must
really be bored silly.



-- 
Steven

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


Re: PyWart: Namespace asinitiy and the folly of the global statement

2013-02-08 Thread Chris Angelico
On Fri, Feb 8, 2013 at 10:29 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 Chris Angelico wrote:

 On Fri, Feb 8, 2013 at 3:30 PM, Rick Johnson
 rantingrickjohn...@gmail.com wrote:
 It is my strong opinion that all unqualified variables must be local to
 the containing block, func/meth, class, or module. To access any variable
 outside of the local scope a programmer MUST qualify that variable with
 the func, class, or module identifiers. Consider the following examples

 Okay. Now start actually working with things, instead of just making
 toys. All your builtins now need to be qualified:

 __builtins__.print(There
 are,__builtins__.len(self.some_list),members in this list,
 namely:,__builtins__.repr(self.some_list))


 Pardon me, but since __builtins__ is a global, you have to say:

 globals.__builtins__.print(screw this for a game of soldiers)

 or equivalent.

And isn't globals a builtin?

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


Re: Curious to see alternate approach on a search/replace via regex

2013-02-08 Thread Steven D'Aprano
Ian Kelly wrote:

 On Thu, Feb 7, 2013 at 10:57 PM, rh richard_hubb...@lavabit.com wrote:
 On Thu, 7 Feb 2013 18:08:00 -0700
 Ian Kelly ian.g.ke...@gmail.com wrote:

 Which is approximately 30 times slower, so clearly the regular
 expression *is* being cached.  I think what we're seeing here is that
 the time needed to look up the compiled regular expression in the
 cache is a significant fraction of the time needed to actually execute
 it.

 By actually execute you mean to apply the compiled expression
 to the search or sub? Or do you mean the time needed to compile
 the pattern into a regex obj?
 
 The former.  Both are dwarfed by the time needed to compile the pattern.

Surely that depends on the size of the pattern, and the size of the data
being worked on.

Compiling the pattern s[ai]t doesn't take that much work, it's only six
characters and very simple. Applying it to:

sazsid*100 + sat

on the other hand may be a tad expensive.

Sweeping generalities about the cost of compiling regexes versus searching
with them are risky.



-- 
Steven

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


Re: PyWart: Namespace asinitiy and the folly of the global statement

2013-02-08 Thread Steven D'Aprano
Rick Johnson wrote:

 When reading over some source code we really have no idea in which
 namespace a variable lives. Consider the following:
 
 count = 0
 class Blah:
 def meth():
 for x in range(100):
 count = x
 
 Where is count living?
 
 Of course in this simplistic example we can see that count is @ module
 level

But it isn't. It is a local variable.

Rick, I appreciate your honesty in telling us that you have no idea how to
read Python code and recognise which namespace the variables are found in,
but you really shouldn't assume others suffer under that same affliction.



-- 
Steven

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


children process

2013-02-08 Thread Rita
hi,

I currently have a bash wrapper which executes a program, something like
this

#!/usr/bin/env bash
export LD_LIBRARY_PATH=/foo:$LD_LIBRARY_PATH
exec $@

I would like to have a python process which will do process accounting for
all children, so if a process starts, I would like to get all the
children's memory  (/proc/ALL Children/stat).

Is there a way to do this?

-- 
--- Get your facts first, then you can distort them as you please.--
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python programming language?

2013-02-08 Thread Stephane Wirtel
* gmspro gms...@yahoo.com [2013-02-08 05:03:51 -0800]:

 Hello all,
 
 One said, Python is not programming language, rather scripting language, is 
 that true?
 
 Thanks.
 

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

What's the difference ?

http://openerp.com OpenERP is written with Python and this is an ERP,
Youtube is written with Python and used by Google.


-- 
Stéphane Wirtel - http://wirtel.be - @matrixise
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python programming language?

2013-02-08 Thread Stefan Behnel
gmspro, 08.02.2013 14:03:
 One said, Python is not programming language, rather scripting language, is 
 that true?

Apples and oranges. It's a bit like asking if C is an embedded systems
language or if JavaScript is a 3D graphics language. Well, no, but you can
use them for that if you want. That doesn't render them any less Turing
complete.

In the same way, Python is a programming language that can be used for
scripting, as well as lots of other things, from web programming to number
crunching.

Stefan


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


Re: Is Python programming language?

2013-02-08 Thread rusi
On Feb 8, 6:03 pm, gmspro gms...@yahoo.com wrote:
 Hello all,

 One said, Python is not programming language, rather scripting language, is 
 that true?

 Thanks.

One said: English is the language spoken in England.
Another One said: English is the language internationally used for
commerce, academics and much else.

Who is 'true'?  Is one false because the other is true?

[Amusing that this is being said at the same time as a necroposted
thread about the multi-meanings of bool in python]

More seriously: Python is one of the first serious programming
languages and scripting languages.
Those who think that one excludes the other are probably learnt their
programming/CS half a century ago and stopped learning soon after.

For many such mis-takes in CS education see my:
http://blog.languager.org/2011/02/cs-education-is-fat-and-weak-1.html
and its sequel
http://blog.languager.org/2011/02/cs-education-is-fat-and-weak-2.html
-- 
http://mail.python.org/mailman/listinfo/python-list


pxssh sendline() cmd

2013-02-08 Thread rajesh kumar
Hi

I need help in pxssh.

Steps :
1) I was login into remote machine usning pxssh and the prompt is '$'.
2) After successful login running some command and the prompt is ''.
3) Here onwards I want to execute cli commands by using sendline().

My requirement: I need to pass arguments to sendline().
var = 00:00:00:00:00:00:00
name = F2

Example : sendline (X Y var name)

in above example X and Y are keywords separated by space. var and name are 
arguments.

Could any one help quickly. 

Note : If I use sendline(X Y 00:00:00:00:00:00:00  F2) was working fine.
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python programming language?

2013-02-08 Thread Ulrich Eckhardt

Am 08.02.2013 14:03, schrieb gmspro:

One said, Python is not programming language, rather scripting language, is 
that true?


That depends on your definition of scripting language and programming 
language.


Python's not a language but an animal.

Uli

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


Re: Moving mouse, Python3 and PyObjc

2013-02-08 Thread Dave Angel

On 02/08/2013 05:32 AM, Oneill wrote:






Your emails are very hard to read, since your mailer doublespaces nearly 
everything you quote.



 snip



What's the objc module got to do with the mouse?



  http://packages.python.org/pyobjc/api/module-objc.html



Perhaps you meant some other module.  Could you be specific?  What

modules did you import, what other code did you write, what version of

Python are you running, and on which computer OS did you get the results

you describe?



--

DaveA




Well without PyObjc i couldnt control the mouse... I saw some examples 
importing Quartz  but that also failed...


Well, now I can guess some of the answers to my questions.  You 
mentioned Windows, but apparently that was a red herring.  You are 
apparently writing an objective C application (Cocoa) for the iPhone, 
and using the pyobjc module to translate Python to Objective C.


so the answer to your original problem (mouse going to 0,0) could need 
some combination of Mac development tools, Cocoa runtime environment, 
etc. to solve.  You're not writing cross-platform, so you've rejected 
the standard guis for doing this sort of thing.


Perhaps the page at
http://docs.python-guide.org/en/latest/scenarios/gui/

could be of help in choosing a different gui toolkit.

But I can't figure I'd be of any help, since I don't have a Mac, nor a 
license for their development environment, nor any docs for either.




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


Re: Is Python programming language?

2013-02-08 Thread Steven D'Aprano
gmspro wrote:

 Hello all,
 
 One said, Python is not programming language, rather scripting language,
 is that true?

Python is a high-level, object-oriented, strongly-typed programming language
with garbage collection, byte-code compilation, dynamic types, and syntax
that includes OOP, procedural and functional styles.

It is an excellent glue language for libraries written in C, C++, Fortran,
Java and CLR (dot-Net). It is also good for scripting. But that doesn't
mean it is only a scripting language.

Calling Python a scripting language is like calling an iPad a clock, just
because it has a clock app. Yes, you can use your iPad to tell the time,
and that makes it a clock. But it's not *just* a clock, and Python is not
*just* a scripting language.


-- 
Steven

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


Re: Is Python programming language?

2013-02-08 Thread Steven D'Aprano
gmspro wrote:

 One said, Python is not programming language, rather scripting language,
 is that true?

I forgot to mention, there is a FAQ about this:

http://docs.python.org/2/faq/general.html#what-is-python-good-for



-- 
Steven

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


Re: memoryview (was len() on mutables vs. immutables)

2013-02-08 Thread Oscar Benjamin
On 8 February 2013 06:24, Demian Brecht demianbre...@gmail.com wrote:
 On 2013-02-07 8:30 PM, Terry Reedy tjre...@udel.edu wrote:

 If a memoryview (3+) is representing a non-continuguous block of memory (
 1
 ndim), will len(obj) not return incorrect results? It seems to be
 reporting the shape of the 0th dim at the moment.. Or is there something
 that I'm missing altogether?

This is in keeping with the way that numpy.ndarrays work. Essentially
len and iter treat the array as if it were a list of lists (of lists
...).

 import numpy as np
 a = np.array([[1, 2], [3, 4], [5, 6], [7, 8]])
 a
array([[1, 2],
   [3, 4],
   [5, 6],
   [7, 8]])
 a.shape
(4, 2)
 len(a)
4
 for x in a:
... print(x)
...
[1 2]
[3 4]
[5 6]
[7 8]

If you want the total number of elements in the array then that is
 a.size
8
 reduce(lambda x, y: x*y, a.shape, 1)
8

The size attribute is not present on a memoryview but the shape is:
 m = memoryview(a)
 m.size
Traceback (most recent call last):
  File stdin, line 1, in module
AttributeError: 'memoryview' object has no attribute 'size'
 m.shape
(4L, 2L)
 reduce(lambda x, y: x*y, m.shape, 1)
8L


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


Re: Is Python programming language?

2013-02-08 Thread Albert Hopkins


On Fri, Feb 8, 2013, at 08:03 AM, gmspro wrote:
 Hello all,
 
 One said, Python is not programming language, rather scripting language,
 is that true?
 

According to Wikipedia[1] a scripting languages are a subset of
programming languages so it goes that any scripting language is, be
definition, a programming language.  It also says that scripting is
not so much an attribute of the language, but an attribute of the
interpreter, so one could say that C++ is a scripting language if one
were to use a C++ interpreter.


[1] http://en.wikipedia.org/wiki/Scripting_language
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python programming language?

2013-02-08 Thread Chris Angelico
On Sat, Feb 9, 2013 at 2:28 AM, Albert Hopkins mar...@letterboxes.org wrote:
 ... one could say that C++ is a scripting language if one
 were to use a C++ interpreter.

And if one is sufficiently sadistic to actually use C++ in that way.

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


Re: Is Python programming language?

2013-02-08 Thread Kwpolska
On Fri, Feb 8, 2013 at 4:40 PM, Chris Angelico ros...@gmail.com wrote:
 On Sat, Feb 9, 2013 at 2:28 AM, Albert Hopkins mar...@letterboxes.org wrote:
 ... one could say that C++ is a scripting language if one
 were to use a C++ interpreter.

 And if one is sufficiently sadistic to actually use C++ in that way.

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

Did you mean: And if one is sufficiently sadistic to actually use C++
in any way.


-- 
Kwpolska http://kwpolska.tk | GPG KEY: 5EAAEA16
stop html mail| always bottom-post
http://asciiribbon.org| http://caliburn.nl/topposting.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: memoryview (was len() on mutables vs. immutables)

2013-02-08 Thread Demian Brecht
This helped clarify, thanks. I also went through PEP 3118 in detail (as I
should have in the first place) which also helped.

Thanks,

Demian Brecht
http://demianbrecht.github.com


On 2013-02-08 6:50 AM, Oscar Benjamin oscar.j.benja...@gmail.com wrote:

This is in keeping with the way that numpy.ndarrays work. Essentially
len and iter treat the array as if it were a list of lists (of lists
...).


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


Re: Is Python programming language?

2013-02-08 Thread Dave Angel

On 02/08/2013 10:46 AM, Kwpolska wrote:

On Fri, Feb 8, 2013 at 4:40 PM, Chris Angelico ros...@gmail.com wrote:

On Sat, Feb 9, 2013 at 2:28 AM, Albert Hopkins mar...@letterboxes.org wrote:

... one could say that C++ is a scripting language if one
were to use a C++ interpreter.


And if one is sufficiently sadistic to actually use C++ in that way.

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


Did you mean: And if one is sufficiently sadistic to actually use C++
in any way.




I suspect he meant masochistic.

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


Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread Steven D'Aprano
Rick Johnson wrote:

 GvR has always been reluctant to incorporate full OOP machinery for some
 reason.

Python is a fully object oriented language. It is *more* object oriented
than, say, Java.

- everything in Python is an object, there is no distinction between boxed
and unboxed variables;

- modules are objects;

- functions and methods are objects;

- classes are objects in Python, and have their own class (the metaclass);

- metaclasses themselves are also objects, and have classes of their own;

- it's objects all the way down, at least until you reach type itself,
which is bootstrapped into existence by the compiler.


Although Python is fully object-oriented, it does not insist on one
particular style of object syntax. It allows procedural and functional
style syntax as well.


 I am not suggesting that Python be 100% OOP, HELL NO! But 
 collections should have had an isempty method from the beginning. But
 the same argument could be made against len, any, all, etc...

No they shouldn't.

http://effbot.org/pyfaq/why-does-python-use-methods-for-some-functionality-e-g-list-index-but-functions-for-other-e-g-len-list.htm

http://lucumr.pocoo.org/2011/7/9/python-and-pola/

http://mail.python.org/pipermail/python-dev/2008-January/076612.html


Python functions operate as *protocols*. any() and all(), for example, are
excellent examples of why your suggestion fails: the principle of Don't
Repeat Yourself.

In Python today, any() and all() will work perfectly on ANY ITERABLE OBJECT,
for free. The developer of that object doesn't need to do anything to
support any() and all(), all she has to do is make it iterable.

Under your suggestion, every iterable object has to implement an any()
method, and an all() method. Every iterable type has to repeat the same old
code as every other iterable type. 

class list:
def any(self):
for x in self:
if x: return True
return False

class dict:
def any(self):
for x in self:
if x: return True
return False

class set:
def any(self):
for x in self:
if x: return True
return False

class MyFancyIterableThatIsRealCool:
# Wow, deja vu... 
def any(self):
for x in self:
if x: return True
return False


See all the pointlessly duplicated code? Now each one needs tests, and
documentation, and the amount of duplication goes through the roof.

Now, a developer of merely average intelligence will see all that duplicated
code, and factor it out into a global function (two actually, one for
any(), one for all()):

def any(iterable):
# Write this once. Test it once. Document it once.
for x in iterable:
if x: return True
return False

class list:
# Gotta have a method, or Rick will cry.
def any(self):
return any(self)

class dict:
def any(self):
return any(self)

class set:
def any(self):
return any(self)

class MyFancyIterableThatIsRealCool:
# This code seems trivial, and familiar... 
def any(self):
return any(self)


But a developer of above average intelligence will recognise that all those
x.any() boilerplate methods are *pointless and stupid*, since you have a
function that does everything you need, for every possible iterator, for
free. All you need do is use any(obj) syntax instead of obj.any() syntax,
which also saves one keystroke.

And a *really* smart language designer will have realised this ahead of
time, and designed the language to encourage the use of protocols like
this, instead of insisting on the slavish application of obj.method syntax.




-- 
Steven

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


Re: Is Python programming language?

2013-02-08 Thread Chris Angelico
On Sat, Feb 9, 2013 at 2:58 AM, Dave Angel da...@davea.name wrote:
 On 02/08/2013 10:46 AM, Kwpolska wrote:

 On Fri, Feb 8, 2013 at 4:40 PM, Chris Angelico ros...@gmail.com wrote:

 On Sat, Feb 9, 2013 at 2:28 AM, Albert Hopkins mar...@letterboxes.org
 wrote:

 ... one could say that C++ is a scripting language if one
 were to use a C++ interpreter.


 And if one is sufficiently sadistic to actually use C++ in that way.

 ChrisA


 Did you mean: And if one is sufficiently sadistic to actually use C++
 in any way.


 I suspect he meant masochistic.

Kinda both. Personally, I don't like to inflict torture on my hardware
any more than on myself.

http://xkcd.com/371/

Your C++ interpreter is grinning and holding a spatula.

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


Re: Curious to see alternate approach on a search/replace via regex

2013-02-08 Thread Ian Kelly
On Fri, Feb 8, 2013 at 4:43 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 Ian Kelly wrote:
 Surely that depends on the size of the pattern, and the size of the data
 being worked on.

Natually.

 Compiling the pattern s[ai]t doesn't take that much work, it's only six
 characters and very simple. Applying it to:

 sazsid*100 + sat

 on the other hand may be a tad expensive.

 Sweeping generalities about the cost of compiling regexes versus searching
 with them are risky.

I was referring to the specific timing measurements I made earlier in
this thread, not generalizing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Monitoring updating directory for image for GUI

2013-02-08 Thread ciscorucinski


 Who/what are you responding to here? You haven't included any context
 from what you're replying to.

Sorry, never really used Google Groups, or anything like this before. That I 
was responding to only Chris Angelico with his question of how real-time it 
needed to be...since it takes some time for Lilypond to create the images.


 So you have a thread that updates the image and then checks the stack
 to see if a new image is available? Can you not just have it only try
 to load the newest image?

That is what I am trying to figure out how to do. I have a counter that updates 
with every note that is grabbed from the stream. That counter is passed into a 
threaded class that might or might not create the image right away...but seems 
to create them sequentially from what I have seen so far (I don't know if that 
is absolute thought). 

Please let me know you thought on the above part! Each new thread should only 
take only a very small amount longer to do than the previous thread that was 
started...because it has one more note to deal with this time.

Anyways...I do have the count of the latest image that WILL BE created...but by 
the time that one is created in the directory, a new note is most likely 
streamed in and replaces that count. Therefore, I cannot really do that...I 
think.

h, I wonder. I create the images via OS command that will .wait() on a 
subprocess.Popen(). I could increment the counter there? Or do something there 
that will let me know of the most recent image file via a counter or something? 
But it needs to be thread-safe

 You say that you control the filenames of the images. I assume that
 you are notified when a file is created and given the filename of the
 new file. So you can maintain a mapping of filename-ordering. In this
 case you can determine when a file notification arrives whether the
 filename corresponds to a more recent note than the filename that is
 currently waiting to be displayed (or is currently displayed). If it
 is an older note then discard it (and delete the file?) when the
 notification arrives. If it is newer then discard the one that is
 currently waiting to be displayed. This way there are always either
 zero or one filenames waiting and if there is one then it is the most
 recent one seen so far.

I am not notified when the file is created...but like I said before, I wait on 
the subprocess and could do something there.

 Is that using something like watchdog?
 http://pypi.python.org/pypi/watchdog

I don't know about Watchdog...but from an earlier version of a tutorial 
online...

http://pypi.python.org/pypi/watchdog/0.3.6  (Yes, it is currently on v0.6.0 and 
this is older - v0.3.6)

... it looks like I COULD do something like...

class MyEventHandler(FileSystemEventHandler):
...
...
def on_created(self, event):
# update gtkImage object here!!

...right? Or no? I will say that I kind of like that. The only thing is, do you 
think that would flicker in the GUI if a bunch of new images are created in 
quick succession? Anyways, I think that would be the most desired 
outcome...with every image being used and replaced with something newer without 
a large lag...as it will happen during each creation of a new image. 


 It matters for how you monitor the directory at least.

My other question, if I do monitor the directory vs. use a queue, or stack / 
list, is how to monitor a directory that is actively being updated while I 
search for the file. This might not matter and something like os.walk() might 
work...I don't know, I don't know python that well yet.

Do you get what I mean with this?


Sorry if something seems out of place...I was going back and forth and adding / 
removing things to my reply.

Thanks,
Christopher
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread MRAB

On 2013-02-08 07:22, Steven D'Aprano wrote:

Rick Johnson wrote:


Why even have a damn bool function if you're never going to use it?


bool is for converting arbitrary objects into a canonical True or False
flag. E.g. one use-case is if you wish to record in permanent storage a
flag, and don't want arbitrary (possibly expensive) objects to be recorded.

Most of the time, you shouldn't care whether you have a canonical True/False
bool, you should only care whether you have something which duck-types as a
boolean flag: a truthy or falsey value. In Python, all objects duck-type as
flags. The usual interpretation is whether the object represents something
or nothing:

nothing, or falsey values: None, False, 0, 0.0, '', [], {}, set(), etc.
(essentially, the empty value for whichever type you are considering)

something, or truthy values: True, 1, 2.5, 'hello world', etc.
(essentially, non-empty values).


Anything that's not falsey is truey.


Prior to Python 3, the special method __bool__ was spelled __nonempty__,
which demonstrates Python's philosophy towards duck-typing bools.


Incorrect, it was spelled __nonzero__.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread Rick Johnson
On Friday, February 8, 2013 9:16:42 AM UTC-6, Steven D'Aprano wrote:
 Rick Johnson wrote:

  GvR has always been reluctant to incorporate full OOP machinery for some
  reason.

 Python is a fully object oriented language. It is *more* object oriented
 than, say, Java.

Oh really? *chuckles*

 - everything in Python is an object, there is no distinction between boxed
 and unboxed variables;

Just because /everything/ in Python is an object does not mean that Python is 
100% OOP. This fact is just one of the many attributes of a 100% OOP language. 
Yes, Python allows OOP style, but python is NOT 100% OOP! Ruby on the other 
hand /is/ 100% OOP. Although it has identity issues like Python. Ruby thinks 
it's multi-paridigm and Python thinks it's a good example of OOP. Neither are 
correct.

 - modules are objects;

 - functions and methods are objects;

 - classes are objects in Python, and have their own class (the metaclass);

 - metaclasses themselves are also objects, and have classes of their own;

 - it's objects all the way down, at least until you reach type itself,
 which is bootstrapped into existence by the compiler.


 Although Python is fully object-oriented, it does not insist on one
 particular style of object syntax. It allows procedural and functional
 style syntax as well.

Well you just defeated yourself. How can Python be 100% OOP and then allow 
other paradigms? 

  I am not suggesting that Python be 100% OOP, HELL NO! But
  collections should have had an isempty method from the beginning. But
  the same argument could be made against len, any, all, etc...
 
 No they shouldn't.
 
 [...]
 
 Python functions operate as *protocols*. any() and all(), for example, are
 excellent examples of why your suggestion fails: the principle of Don't
 Repeat Yourself.
 
 In Python today, any() and all() will work perfectly on ANY ITERABLE OBJECT,
 for free. The developer of that object doesn't need to do anything to
 support any() and all(), all she has to do is make it iterable.
 
 Under your suggestion, every iterable object has to implement an any()
 method, and an all() method. Every iterable type has to repeat the same old
 code as every other iterable type.

NOT IF PYTHON WERE TRULY 100% OOP! 

If so, Python would have a supertype called Collection that wold define all 
methods that operate on collections. Some of these include:

 len, any, all, length, isempty, __getitem__, __setitem__, etc...
 
Then any collection subtype would inherit from this supertype and get the 
methods for free.

 
 [...]
 See all the pointlessly duplicated code? Now each one needs tests, and
 documentation, and the amount of duplication goes through the roof.

 Now, a developer of merely average intelligence will see all that duplicated
 code, and factor it out into a global function (two actually, one for
 any(), one for all()):

Only if that developer does not understand sub-typing! All he has to do is 
write the method ONE TIME in a super-type, and then inherit the method into ANY 
number of sub-types for free. Now, if he wants to pervert the usage of a method 
to fit some niche, THEN he will need to overload the method and provide proper 
return value.

 But a developer of above average intelligence will recognise that all those
 x.any() boilerplate methods are *pointless and stupid*, since you have a
 function that does everything you need, for every possible iterator, for
 free. All you need do is use any(obj) syntax instead of obj.any() syntax,
 which also saves one keystroke.

 And a *really* smart language designer will have realised this ahead of
 time, and designed the language to encourage the use of protocols like
 this, instead of insisting on the slavish application of obj.method syntax.

Using built-in functions to operate on objects is foolish because you are 
placing extra burden on the programmer to know which /functions/ work with 
which /types/. The *only* functions that should be global are the kind that 
will work on *ANY* object. But then again, the Object type could hold these 
methods!

len, all, and any (just to name a few) only work for collections types and as 
such should be methods of these types. The global functions:
  
  sum, len, any, all, enumerate, map, max, min, reversed, sorted, zip
  
can only be applied to sequence types, or subtypes of a sequence type. So using 
a /real/ OOP paridigm we would do the following:

## START TRUE OOP PARIDIGM ##

class Object(SuperType):
def __class__
def __delattr__
def __doc__
def __format__
def __getattribute__
def __init__
def __new__
def __repr__
def __setattr__
def __sizeof__
def __str__
def __subclasshook__
def true? # aka: bool
def callable?
def compare(other)
def dir
def hash
def help
def id
def isinstance?(Type)
def issubclass?(Type)
def super
def type

class SequenceBase(Object):
# Methods from object are free
def __add__
def __contains__
  

Jinja2 installation help

2013-02-08 Thread Robert Iulian
Hello,

I recently started learning Python. Just finished learning the basis of it, and 
now I think I'm ready to start working on a simple website but I am having some 
difficulties installing Jinja2.
Can anyone post a dummy guide on how to install it, and what to do step by step?
I am using the lastest Python version 3.3 .
Thank you!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread Roy Smith
In article ee71b775-b527-4bb3-a080-12aad962b...@googlegroups.com,
 Rick Johnson rantingrickjohn...@gmail.com wrote:

  The best way to describe Python is as promiscuous language who secretly 
  longs to be 100% OOP, and to fulfill this fantasy it cross-dresses in OOP 
  lingerie on the weekends.

+1 QOTD :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python programming language?

2013-02-08 Thread Grant Edwards
On 2013-02-08, Stephane Wirtel steph...@wirtel.be wrote:
 * gmspro gms...@yahoo.com [2013-02-08 05:03:51 -0800]:

 Hello all,
 
 One said, Python is not programming language, rather scripting language, is 
 that true?
 
 Thanks.
 

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

 What's the difference ?

IMO, a scripting language is used to automate tasks that would
otherwise be done by a human sitting at a keyboard typing commands.
[Perhaps that definition should be extended to include tasks that
would otherwise by done by a human sitting and clicking on a GUI.]


 http://openerp.com OpenERP is written with Python and this is an ERP,
 Youtube is written with Python and used by Google.

IMO, neither one of those is replacing a person typing commands or
clicking buttons, so neither of those are scripting applications.

-- 
Grant Edwards   grant.b.edwardsYow! I want EARS!  I want
  at   two ROUND BLACK EARS
  gmail.comto make me feel warm
   'n secure!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is Python programming language?

2013-02-08 Thread Mark Lawrence

On 08/02/2013 13:38, rusi wrote:

On Feb 8, 6:03 pm, gmspro gms...@yahoo.com wrote:

Hello all,

One said, Python is not programming language, rather scripting language, is 
that true?

Thanks.


One said: English is the language spoken in England.


Wrong, English is spoken in some parts of England but I've no idea what 
you'd call the language used in Newcastle upon Tyne.


--
Cheers.

Mark Lawrence

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


Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread Rick Johnson
On Friday, February 8, 2013 11:48:43 AM UTC-6, Rick Johnson wrote:

 [...] 
 
 So using a /real/ OOP paridigm we would do the following:
 
 ## START TRUE OOP PARIDIGM ##
 
 [...snip naive example...]

Actually my example API is littered with artifacts of a python global function 
architecture. In a /true/ 100% OOP language most of these dunder methods 
would become interface members of the object.

There is also the question of WHEN to use and WHEN NOT to use the dunder 
naming convention. I actually like the convention myself for clearly defining 
methods that are called by syntactic sugar. However, python employs the 
convention quite haphazardly. 

For example:  
__iadd__ is called by an expression such as: 1+=1
which is translated into: 1.__iadd__(1)

However:
__repr__ is called by the the global repr function
which is translated into: obj.__repr__()
   
I don't like the second usage because i believe this naming convention should 
be reserved for syntactical sugar only. But i digress...

Here is a better example of Python converted into true OOP paridigm (renaming 
and removing methods appropriately to fit my logical 100% OOP API).

class Object(SuperType):
def construct # aka: __init__
def desconstruct # aka: __del__
def class
def delattr(name)
def doc
def getattr(name)
def __new__ # dunder???
def repr
def setattr(name, value)
def size
def stringify # aka: __str__
def subclasshook # XXX: dunder???
def true? # aka: __bool__
def callable?
def compare(other)
def methods
def instance_methods 
def hash
def help
def id
def isinstance?(this)
def issubclass?(this)
def super
def type

class SequenceBase(Object):
# Methods from object are free
def __add__
def __contains?__
def __delitem__
def __delslice__
def __eq__
def __ge__
def __getitem__
def __getslice__
def __gt__
def __iadd__
def __imul__
def __iter__
def __le__
def __lt__
def __mul__
def __ne__
def __rmul__
def __setitem__
def __setslice__
#
# Interface
#
slice = __getslice__
extend = __add__
contains? = __contains?__
def length # pka: __len__
def any
def all
def enumerate - iterator
def filter(proc)
def map(proc)
def max
def min
def reverse
def reduce(proc)
def sort
def zip


class Sequence(SequenceBase): # aka: list
# Methods from SequenceBase and Object are free!
#
# Interface
#
def append(this)
def count(this)
def index(this)
def insert(idx, this)
def pop()
def remove(this)
def reverse
def sort
 
I'm a bit unnerved by the sum function. Summing a sequence only makes sense if 
the sequence in question contains /only/ numeric types. For that reason i 
decided to create a special type for holding Numerics. This will probably 
result in many complaints from lazy people who want to use only one Sequence 
type, which holds mixed types, THEN jamb nothing but numeric types into it, 
THEN have a sum method that throws errors when it encounters a non-numeric 
type!!! I say, too bad for you. 

Stop obfuscating your code! Of course someone could probably find a legitimate 
reason to apply a sum method to non-numeric values; if so, then inherit from 
NumericSequence and create your custom type!

class NumericSequence(Sequence):
# Methods from Sequence, SequenceBase, and Object are free!
def __setitem__(item):
if not item.isinstance(Numeric):
raise TypeError()
def __add__(other):
if not other.isinstance(NumericSequence):
raise TypeError()
def __setslice__(other):
# blah
#
# Interface
#
def sum - Integer

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


Re: Improve reduce functions of SQLite3 request

2013-02-08 Thread Steffen Mutter
Dennis Lee Bieber wrote:

   If you use separate tables you make it more difficult to generate
 the SQL (as you have to create the SQL with the season specific table
 name, instead of just using a where  clause to restrict data), and
 lose the potential to produce reports covering multiple seasons.

I think, when the season is over, the table will be closed to change its
contents, so the history data for this season will be written to
the data tables of the clubs or users. 
You gave me a lot of input about databases and how to put them together.
I removed the double time/data stuff from the seasons tables and it
works fine I made a speed-test and it is a bit faster now.

Now there are some features missing, I will put into, a checkbox 'only
today' shows you only the games played today. In combination with a
checkbox 'games without result' gives the visitor an easy way to find
out if a result wasn't reported yet - interesting for coaches, league
managers and players, too.

   snip 
   Have you considered defining views and triggers -- based upon
 the user privileges you run queries using views that only expose the
 permitted data (and use triggers to permit properly updating the
 underlying tables when edited).

I will do the user managment based on the tables in the
user/club/federation tables I am actually thinking about - views are an
interesting feature. 
This is very complex, the user table will be the beginning to start
from, where the personal data is stored. userID, name, gender, date of
birth, club and e-mail as must haves. 
Based on this there is a role table, where the roles for all persons for
an area in the system will be placed. Not very easy to do, but an
interesting task to plan...

   Fuller DBMS would allow you to define access controls on individual
 columns -- though it would mean you couldn't made the main database
 connection until you know the access level of the user, as you'd connect
 using a name/password specific to the level of the user (I'm not saying
 each user has a database name/password, though that is an alternative --
 it just means you'd have to do a lot of database administration each
 time a user is created).

Hopefully my python code will handle that for me :-)

I really like SQLite, very easy to use and to backup.
The idea behind the user managment is, that the users manage themselves,
I will only step in when something does not work as it should...


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


Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread Steven D'Aprano
MRAB wrote:

 On 2013-02-08 07:22, Steven D'Aprano wrote:

 Prior to Python 3, the special method __bool__ was spelled __nonempty__,
 which demonstrates Python's philosophy towards duck-typing bools.

 Incorrect, it was spelled __nonzero__.

Oops, so it was. Sorry for the brain-fart.

__nonzero__ or not, nevertheless the implication still applies: all types
are meant to map to nothing (zero) or not nothing (non-zero).



-- 
Steven

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


Glade + GTK.Builder() | Missing Handlers | Handler for multiple objects

2013-02-08 Thread ciscorucinski
Here is my code in PasteBin...

http://pastebin.com/ZubyV8RT

If you go to the very bottom of the paste, you will see the error messages that 
I get, but here it is again.

---
Warning (from warnings module):
  File C:\Users\rucinskic\Dropbox\SeniorDesign\cflat\frontend\CFlatGUI.py, 
line 287
self.builder.connect_signals( event_dictionary )
RuntimeWarning: missing handler 'on_mnuHelp_activate'

Warning (from warnings module):
  File C:\Users\rucinskic\Dropbox\SeniorDesign\cflat\frontend\CFlatGUI.py, 
line 287
self.builder.connect_signals( event_dictionary )
RuntimeWarning: missing handler 'on_mnuRecord_activate'

Warning (from warnings module):
  File C:\Users\rucinskic\Dropbox\SeniorDesign\cflat\frontend\CFlatGUI.py, 
line 287
self.builder.connect_signals( event_dictionary )
RuntimeWarning: missing handler 'on_mnuEdit_activate'

Warning (from warnings module):
  File C:\Users\rucinskic\Dropbox\SeniorDesign\cflat\frontend\CFlatGUI.py, 
line 287
self.builder.connect_signals( event_dictionary )
RuntimeWarning: missing handler 'on_mnuFile_activate'
---

If you look near the bottom of the paste, you will also see code like...

self.dlgAbout.show()

...one commented out, and one not. If I uncomment that one, then dlgAbout is 
shown, but the one that I don't have commented out will NEVER work...that goes 
for all of the handler functions? Why is that?

Also, why am I getting those warning messages? I am trying to connect multiple 
menu items to one handler (like all File menu items will go to the 
on_mnuFile_activate handler).

In Glade, I am setting the GtkMenuItem's activate signal to go to the 
on_xxx_active handler (on_mnuFile_active)

Does anyone understand what is going wrong?

Thanks,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pxssh sendline() cmd

2013-02-08 Thread Piet van Oostrum
rajesh kumar chinna...@gmail.com writes:

 Hi

 I need help in pxssh.

 Steps :
 1) I was login into remote machine usning pxssh and the prompt is '$'.
 2) After successful login running some command and the prompt is ''.
 3) Here onwards I want to execute cli commands by using sendline().

 My requirement: I need to pass arguments to sendline().
 var = 00:00:00:00:00:00:00
 name = F2

 Example : sendline (X Y var name)

 in above example X and Y are keywords separated by space. var and name are 
 arguments.

 Could any one help quickly. 

 Note : If I use sendline(X Y 00:00:00:00:00:00:00  F2) was working fine.
  

sendline(X Y %s %s % (var, name))
-- 
Piet van Oostrum p...@vanoostrum.org
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread Chris Angelico
On Sat, Feb 9, 2013 at 6:58 AM, Rick Johnson
rantingrickjohn...@gmail.com wrote:
 I'm a bit unnerved by the sum function. Summing a sequence only makes sense 
 if the sequence in question contains /only/ numeric types. For that reason i 
 decided to create a special type for holding Numerics. This will probably 
 result in many complaints from lazy people who want to use only one Sequence 
 type, which holds mixed types, THEN jamb nothing but numeric types into it, 
 THEN have a sum method that throws errors when it encounters a non-numeric 
 type!!! I say, too bad for you.


Most assuredly not. The sum builtin works happily on any sequence of
objects that can be added together. It works as an excellent flatten()
method:

 nested_list = [[q], [w,e], [r,t,u], [i,o,p]]
 sum(nested_list,[])
['q', 'w', 'e', 'r', 't', 'u', 'i', 'o', 'p']
 nested_list
[['q'], ['w', 'e'], ['r', 't', 'u'], ['i', 'o', 'p']]

I'm not sure what your definition of a numeric type is, but I suspect
that list(str) isn't part of it.

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


Re: Opinion on best practice...

2013-02-08 Thread Chris Angelico
On Sat, Feb 9, 2013 at 5:29 AM, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:
 If you want the real nightmare -- look into the IBM queue scheme
 (not many REXX implementations except on IBM mainframes support that).
 One can push lines onto the queue, such that when the script exits, the
 command  processor reads those lines first before reading from
 keyboard... Or push lots of text in a way that the next script to start
 reads it without using a temporary file. IBM mainframes didn't
 multitask too well G; no easy creation of processes with pipes
 between them.

Heh. The OS/2 implementation of REXX has that too, but also has much
easier piping mechanisms... and, ironically, provides a convenient way
to pipe text into your script using the RXQUEUE external command:

some_command | rxqueue /fifo
do while queued()0
parse pull blah blah blah
end

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


Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread Rick Johnson
On Friday, February 8, 2013 6:05:54 PM UTC-6, Chris Angelico wrote:
 The sum builtin works happily on any sequence of objects
 that can be added together. It works as an excellent
 flatten() method:
 
  nested_list = [[q], [w,e], [r,t,u], [i,o,p]]
  sum(nested_list,[])
 ['q', 'w', 'e', 'r', 't', 'u', 'i', 'o', 'p']
  nested_list
 [['q'], ['w', 'e'], ['r', 't', 'u'], ['i', 'o', 'p']]

What the hell? Oh yeah, you must be using pike again. No, if it were pike the 
list would look like this:

({({q}), ({w,e}), ({r,t,u}), ({i,o,p})})

Of course you'd have to declare it first using an /expanded/ Java syntax:

 nested_list = array(array(string))
 
Folks, i couldn't make this stuff up if i wanted to. Go read for yourself if 
want a few laughs.
  
  http://pike.lysator.liu.se/docs/tutorial/data_types/container_types.xml

 I'm not sure what your definition of a numeric type is, but I suspect
 that list(str) isn't part of it.

Of course not. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Monitoring updating directory for image for GUI

2013-02-08 Thread Oscar Benjamin
 On 8 February 2013 17:09,  ciscorucin...@gmail.com wrote:
 So you have a thread that updates the image and then checks the stack
 to see if a new image is available? Can you not just have it only try
 to load the newest image?

 That is what I am trying to figure out how to do. I have a counter that 
 updates with every note that is grabbed from the stream. That counter is 
 passed into a threaded class that might or might not create the image right 
 away...but seems to create them sequentially from what I have seen so far (I 
 don't know if that is absolute thought).

 Please let me know you thought on the above part! Each new thread should only 
 take only a very small amount longer to do than the previous thread that was 
 started...because it has one more note to deal with this time.

Are you creating a new thread for each new note? I imagined that you
would have 3 threads: producer, organiser and consumer. It looks like
this:

# Producer:
for x in produce_music():
counter += 1
create_note_file(filename)
notes_map[filename] = counter

# Organiser
def on_file_notify(filename):
if notes_map[filename]  notes_map[waiting]:
waiting = filename

# Consumer
while True:
if waiting is not None:
display(waiting)
waiting = None
else:
   sleep()

[SNIP]

 I am not notified when the file is created...but like I said before, I wait 
 on the subprocess and could do something there.

I don't understand your setup.


 Is that using something like watchdog?
 http://pypi.python.org/pypi/watchdog

 I don't know about Watchdog...but from an earlier version of a tutorial 
 online...

 http://pypi.python.org/pypi/watchdog/0.3.6  (Yes, it is currently on v0.6.0 
 and this is older - v0.3.6)

 ... it looks like I COULD do something like...

I haven't actually used watchdog myself. I was just querying how you
were getting updates about file changes (and suggesting to use a PyPI
package since at least one was available for your needs).


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


Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread Ian Kelly
On Fri, Feb 8, 2013 at 12:58 PM, Rick Johnson
rantingrickjohn...@gmail.com wrote:
 I'm a bit unnerved by the sum function. Summing a sequence only makes sense 
 if the sequence in question contains /only/ numeric types. For that reason i 
 decided to create a special type for holding Numerics. This will probably 
 result in many complaints from lazy people who want to use only one Sequence 
 type, which holds mixed types, THEN jamb nothing but numeric types into it, 
 THEN have a sum method that throws errors when it encounters a non-numeric 
 type!!! I say, too bad for you.

 Stop obfuscating your code! Of course someone could probably find a 
 legitimate reason to apply a sum method to non-numeric values; if so, then 
 inherit from NumericSequence and create your custom type!

Are you aware that the approach you're advocating here is bad OOP
design?  If you declare a class NumericSequence with the property that
it contains only numeric types, and then you declare a subclass
NonnumericSequence that does not share that property, then guess what?
 You've just violated the Liskov Substitution Principle.

The goal you're trying to achieve here is nonsensical anyway.  Ask
yourself what the semantic meaning of the sum() function is, what
purpose it is meant to serve.  My answer: it is the reduction of the
addition operator.  The implication of this is that the input type of
the sum() function is not numbers, but rather things that can be
added.  That includes numbers, but since I see from your proposed
class hierarchy that you are retaining the __add__ method on
sequences, it also includes sequences.  Are you really going to tell
the user that (1, 2, 3) + (4, 5, 6) is perfectly fine, but that the
semantic equivalent sum([(1, 2, 3), (4, 5, 6)]) is nonsense?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread Chris Angelico
On Sat, Feb 9, 2013 at 11:49 AM, Rick Johnson
rantingrickjohn...@gmail.com wrote:
 On Friday, February 8, 2013 6:05:54 PM UTC-6, Chris Angelico wrote:
 The sum builtin works happily on any sequence of objects
 that can be added together. It works as an excellent
 flatten() method:

  nested_list = [[q], [w,e], [r,t,u], [i,o,p]]
  sum(nested_list,[])
 ['q', 'w', 'e', 'r', 't', 'u', 'i', 'o', 'p']
  nested_list
 [['q'], ['w', 'e'], ['r', 't', 'u'], ['i', 'o', 'p']]

 What the hell? Oh yeah, you must be using pike again. No, if it were pike the 
 list would look like this:

 ({({q}), ({w,e}), ({r,t,u}), ({i,o,p})})

 Of course you'd have to declare it first using an /expanded/ Java syntax:

  nested_list = array(array(string))

Strange... normally I have to actually bring Pike up, no idea why
you're doing it for me. But okay.

Actually, that's not a declaration, that's an assignment; and in Pike,
a 'type' is a thing, same as it is in Python (though not quite). If I
were to declare it in Pike, it would be:

array(array(string)) nested_list;

Though the part inside the parens can be omitted, in which case the
array can contain anything, rather than being restricted to strings.
In actual fact, Rick, despite your complaints about the syntax, it's
able to achieve exactly what you were thinking Python should do:
declare an array/list that contains only numbers.

 Folks, i couldn't make this stuff up if i wanted to. Go read for yourself if 
 want a few laughs.

   http://pike.lysator.liu.se/docs/tutorial/data_types/container_types.xml

Apart from some syntactic differences, which in the scheme of things
are pretty trivial, the only difference is that Pike permits (without
demanding) you to restrict an array's members. In fact, Pike lets you
declare everything as 'mixed' if you like, allowing you to put
*anything* into *anywhere*... which, yaknow, is pretty much identical
to Python's model (only with declared variables), and takes advantage
of the fact that there are no Java-style unboxed types (the Pike int
is like the Py3 int or the Py2 long, arbitrary precision).

 I'm not sure what your definition of a numeric type is, but I suspect
 that list(str) isn't part of it.

 Of course not.

And yet, in both Pike and Python, adding lists/arrays of strings
together is not just legal but extremely useful. Do we need to rewrite
the sum() function to handle lists instead of letting operator
overloading take care of it for us? Suppose I make a string subclass
with a division operator:

class divisible_string(str):
def __truediv__(self,n):
n=(len(self)+n-1)//n
return [self[pos:pos+n] for pos in range(0,len(self),n)]
# and a bunch of functions so operations on a divisible_string return
a divisible_string

Now, I should be able to divide a string by 2 and get a two-element
list. Kinda convenient, would be cool if str supported this, but it's
OOP and OOP is all about operator overloading, even if it makes your
code less readable - a language isn't 100% OOP unless this sort of
thing is normal, right?

Suppose also that I have an avg() function that does this:

def avg(it):
it=iter(it)
tot=next(it)
pos=-1
for pos,val in enumerate(it):
tot+=val
return tot/(pos+2)

I can take the avg() of a list (or other iterable) of integers, and
get back a number. Do I need to rewrite this function to handle my
divisible_string? Or do I need to have divisible_string subclass some
averageable class/interface in order to permit them to be used
inside a list that has an avg() method?

lst=avg(map(divisible_string,(asdf,qwer,a,z,f,q,asdfasdfasdf)))

How do you solve the puzzle, Rick?

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


Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread Ian Kelly
On Fri, Feb 8, 2013 at 5:49 PM, Rick Johnson
rantingrickjohn...@gmail.com wrote:
 On Friday, February 8, 2013 6:05:54 PM UTC-6, Chris Angelico wrote:
 The sum builtin works happily on any sequence of objects
 that can be added together. It works as an excellent
 flatten() method:

  nested_list = [[q], [w,e], [r,t,u], [i,o,p]]
  sum(nested_list,[])
 ['q', 'w', 'e', 'r', 't', 'u', 'i', 'o', 'p']
  nested_list
 [['q'], ['w', 'e'], ['r', 't', 'u'], ['i', 'o', 'p']]

 What the hell? Oh yeah, you must be using pike again. No, if it were pike the 
 list would look like this:

 ({({q}), ({w,e}), ({r,t,u}), ({i,o,p})})

 Of course you'd have to declare it first using an /expanded/ Java syntax:

  nested_list = array(array(string))

 Folks, i couldn't make this stuff up if i wanted to. Go read for yourself if 
 want a few laughs.

Classic ad hominem.  Try to make your opponent look bad by making fun
of them on a completely unrelated topic, and then hope that nobody
notices that you entirely ignored the substance of their argument.
Sorry, it didn't work.

You didn't even do a good job of it.  Yes, Pike uses two characters
instead of one to wrap array literals.  Big friggin' whoop.  On the
minus side, it's a little more typing.  On the plus side, they stand
out better, and you don't have the [] characters doing double duty
denoting list literals and indexing alike.  Yes, Pike writes **string
as the more readable array(array(string)) -- although if my memory
serves correctly the former is also legal syntax.  Again, nobody
cares.  And by the by, Pike is a descendant of C, not Java.  Its
predecessor LPC predates Java by about 6 years.  If you're going to
start lambasting others' preferred programming languages in an effort
to make yourself look good, you can at least get your facts straight.
-- 
http://mail.python.org/mailman/listinfo/python-list


LangWart: Method congestion from mutate multiplicty

2013-02-08 Thread Rick Johnson

DISCLAIMER:
This post covers a universal programming language design flaw using both Python 
and Ruby code examples to showcase the issue. 

I really don't like to read docs when learning a language, especially a 
so-called high level language. I prefer to learn the language by interactive 
sessions and object introspection. Then, when i have exhausted all abilities to 
intuit the solution, i will roll my eyes, maybe blubber an expletive, and then 
reluctantly crack open a user manual.

However, learning a new language (be it by this method or by official docs) is 
frustrating when languages have method congestion from a need to present their 
users with both a method for in-place-mutation and method for 
mutation-of-a-copy; both sharing an almost exact spelling! 

Yes i know, naming conventions can help. And one widely used convention is to 
use weak verbs for the mutation of a copy and strong verbs for in-place 
mutation, consider:

py a.reverse - mutate 'a'
py a.reversed - new Array

However you will sooner or later encounter a word that does not have a proper 
weak verb variant to describe the copy-mutate action, consider:

rb point3d.offset(vector3d) - mutate 'point3d'
rb point3d.offseted(vector3d) - HUH?

The Ruby language attempted to save the programmer from the scourge of 
obtaining a four year degree in linguistics just to create intuitive 
identifiers on-the-fly, and they tried to remove this ambiguity by employing 
post-fix-punctuation of the exclamation mark as a visual cue for in-place 
modification of the object:

rb a = [1,2,3]
rb a.reverse!()
[3,2,1]
rb a
[3,2,1]

...think of the exclamation mark yelling out; Hey, i will modify this object 
so be careful dude!  On the other hand, a method that mutates a copy will have 
the same identifier except /without/ the exclamation mark:

rb a = [1,2,3]
rb a.reverse()
[3,2,1]
rb a
[1,2,3]

Now whilst this punctuation solves the ambiguity issue in a reasonable manner, 
it does not solve the congestion issue because for /every/ method that returns 
a copy of the object, another method will exist with an exclamation mark 
post-fixed that signifies object mutation. I don't like this because when i 
inspect the object i see redundant method names:

rb mutators = a.methods.grep(/.*!/)
rb copyers = a.methods.select{|x| mutators.include?(x+!)}
rb copyers+mutators.sort
rb [flatten, transform, collect, sort, map, uniq, offset, 
reverse, compact, reject, normalize, slice, collect!, compact!, 
flatten!, map!, normalize!, offset!, reject!, reverse!, slice!, 
sort!, transform!, uniq!]

Now that's just a small subset of the member functions of the Array object! Can 
you imagine the mental overload induced when the entire set of methods must be 
rummaged through each and every time!!! 

rb a.methods.length
141

*look-of-disapproval*


 SOLUTION


The solution is simple. Do not offer the copy-mutate methods and force all 
mutation to happen in-place: 

py l = [1,2,3]
py l.reverse
py l
[3,2,1]

If the user wants a mutated copy he should explicitly create a new object and 
then apply the correct mutator method:

py a1 = [1,2,3]
py a2 = list(a1).reverse()
py a1
[1,2,3]
py a2
[3,2,1]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Jinja2 installation help

2013-02-08 Thread Wayne Werner

On Fri, 8 Feb 2013, Robert Iulian wrote:


Hello,

I recently started learning Python. Just finished learning the basis of it, and 
now I think I'm ready to start working on a simple website but I am having some 
difficulties installing Jinja2.
Can anyone post a dummy guide on how to install it, and what to do step by step?
I am using the lastest Python version 3.3 .


Do you have easy_install or pip installed? If you do,

$ pip install jinja2

And that's it!


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


Re: Opinion on best practice...

2013-02-08 Thread John Ladasky
On Tuesday, February 5, 2013 5:55:50 PM UTC-8, Steven D'Aprano wrote:

 To do anything meaningful in bash, you need to be an expert on 
 passing work off to other programs...
[snip]
 If you took the Zen of Python, 
 and pretty much reversed everything, you might have the Zen of Bash:

I have to agree.

Recently I needed to write some glue code which would accept some input; run a 
few Linux command-line programs which were supplied that input; run some 
Matplotlib scripts of my own to graph the results; and finally, clean up some 
unwanted intermediate files.

I realized that bash was the right way to get the job done... but after 
struggling with bash for a day, I decided to try Python.  

I wrote a shell script that starts with #!/usr/bin/env python.  My program 
imports os, sys, and shlex.split.  I had my first working version within about 
four hours, even though I had never written a 
command-line Python program before.

Over the next several months, I returned to the program to make several 
improvements.  I can't imagine maintaining a bash script that does what my 
Python script does.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread Steven D'Aprano
Rick Johnson wrote:

 On Friday, February 8, 2013 9:16:42 AM UTC-6, Steven D'Aprano wrote:
 Rick Johnson wrote:

  GvR has always been reluctant to incorporate full OOP machinery for
  some reason.

 Python is a fully object oriented language. It is *more* object oriented
 than, say, Java.
 
 Oh really? *chuckles*

Yes, really.


 - everything in Python is an object, there is no distinction between
 boxed and unboxed variables;
 
 Just because /everything/ in Python is an object does not mean that Python
 is 100% OOP. This fact is just one of the many attributes of a 100% OOP
 language.

The essential features of OOP style are:

- dynamic dispatch -– Python has this

- encapsulation and/or multi-methods -- Python has this

- subtype polymorphism -- Python has this

- object inheritance or delegation -- Python has both of these

- open recursion (a special variable or keyword, normally called this
or self, that allows method bodies to invoke another method of the same
object -- Python has this

- abstraction -- Python has this

http://en.wikipedia.org/wiki/Object-oriented_programming#Fundamental_features_and_concepts


What does not matter is syntax. Whether you write:

object#method   (OCaml)
object-method  (C++, Perl, PHP (non-static methods))
object::method  (PHP (static methods))
object - method(E)
[object method] (Objective C)
object:method   (Lua)
object.method   (Java, Python, VisualBasic)
object method   (Smalltalk, some OOP dialects of Forth)
method object   (Other OOP dialects of Forth)
object \ method (Pountain Forth)
method(object)  (Ada, Dylan, Matlab)
send method to object   (Hypertalk, OpenXION)


or something else even more exotic, is entirely irrelevant. What matters is
behaviour, not syntax.



 Although Python is fully object-oriented, it does not insist on one
 particular style of object syntax. It allows procedural and functional
 style syntax as well.
 
 Well you just defeated yourself. How can Python be 100% OOP and then allow
 other paradigms?

Your reading comprehension is lacking.

Python allows procedural and functional STYLE syntax. It does not force you
to use a dot out of some slavish attention to an artificial philosophy of
programming language:

http://steve-yegge.blogspot.com.au/2006/03/execution-in-kingdom-of-nouns.html

Python is pragmatic and human-centric. When OOP syntax is best, it will use
OOP syntax. If functional syntax is best, it will wrap objects in a thin
functional layer and use that. If procedural syntax is best, it will use
procedural-style coding. Where a pipeline or flow-based paradigm is best,
Python gives you iterators such as generator expressions. Most of the major
programming paradigms are available in Python, wrapped around a core that
is entirely objects.


 In Python today, any() and all() will work perfectly on ANY ITERABLE
 OBJECT, for free. The developer of that object doesn't need to do
 anything to support any() and all(), all she has to do is make it
 iterable.
 
 Under your suggestion, every iterable object has to implement an any()
 method, and an all() method. Every iterable type has to repeat the same
 old code as every other iterable type.
 
 NOT IF PYTHON WERE TRULY 100% OOP!
 
 If so, Python would have a supertype called Collection that wold define
 all methods that operate on collections. Some of these include:
 
  len, any, all, length, isempty, __getitem__, __setitem__, etc...
  
 Then any collection subtype would inherit from this supertype and get the
 methods for free.

No they wouldn't. They would inherit an abstract method that raises an
error Abstract method must be overridden by the subclass for free.

Do you really think that *every* collection's __getitem__ could possibly use
the *same* implementation?

Should frozenset and set share the same __setitem__?

And what about objects which are not *collections*, and so cannot inherit
from Collection, but still need to implement some of those methods? Strings
are not collections. Should generators be forced to inherit __setitem__ so
that they can share any() and all() methods with lists? What length()
should a lazy generator expression return?

[...]
 Using built-in functions to operate on objects is foolish because you are
 placing extra burden on the programmer to know which /functions/ work with
 which /types/. The *only* functions that should be global are the kind
 that will work on *ANY* object. But then again, the Object type could hold
 these methods!

If you can remember that lists have a sort() method and floats don't, then
you can remember that sorted() works on lists but not floats.



-- 
Steven

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


Re: LangWart: Method congestion from mutate multiplicty

2013-02-08 Thread Steven D'Aprano
Rick Johnson wrote:

 The solution is simple. Do not offer the copy-mutate methods and force
 all mutation to happen in-place:
 
 py l = [1,2,3]
 py l.reverse
 py l
 [3,2,1]
 
 If the user wants a mutated copy he should explicitly create a new
 object and then apply the correct mutator method:
 
 py a1 = [1,2,3]
 py a2 = list(a1).reverse()


Oh wow, Rick has re-discovered programming in Python during the mid to late
1990s!

I was there, and I remember what it was like. For about a month, you try
hard to follow Rick's prescription. Then you realise that with a small
helper function, you can halve the amount of code it takes to do a common
operation:

def reversed(sequence):
seq = list(sequence)
seq.reverse()
return seq


Soon you've copied this reversed() function into all your projects. And of
course, they start to diverge... in project A, you only care about lists.
In project B, you realise that you also need to support tuples and strings:


def reversed(sequence):
seq = sequence[:]
try:
seq.reverse()
except AttributeError:
seq = seq[::-1]
return seq

which in project C you realise can be shortened:

def reversed(sequence):
return sequence[::-1]


until you get to project D when you realise that you also want this to work
on dicts:

def reversed(sequence):
everything = list(sequence)
return everything[::-1]


and then in project E you wonder why reversed(string) returns a list:

def reversed(sequence):
everything = list(sequence)[::-1]
if isinstance(sequence, tuple):
return tuple(everything)
elif isinstance(sequence, str):
return ''.join(everything)
return everything


and then finally you learn about iterators and generators and become more
comfortable with a flow-based programming paradigm and generators:

def reversed(sequence):
for item in list(sequence)[::-1]:
yield item

at which point you realise that, hell, this is so useful that pretty much
everyone has implemented it a dozen times or more in their own projects,
and you start to agitate for it to be added to the builtins so that there
is *one* implementation, done *right*, that everyone can use.

And then you get told that Guido's time machine has struck again, because
Python has already had this since Python 2.4.



-- 
Steven

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


Re: PyWart: Namespace asinitiy and the folly of the global statement

2013-02-08 Thread Michael Torrie
On 02/08/2013 04:45 AM, Steven D'Aprano wrote:
 Rick Johnson wrote:
 Of course in this simplistic example we can see that count is @ module
 level
 
 But it isn't. It is a local variable.
 
 Rick, I appreciate your honesty in telling us that you have no idea how to
 read Python code and recognise which namespace the variables are found in,
 but you really shouldn't assume others suffer under that same affliction.

Very interesting to hear the crickets chirping over this one as the
trolling continues on another thread.  Rick seems to know his stuff
about Tk programming, but his knowledge of programming language theory
and formal computing seems quite informal.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: LangWart: Method congestion from mutate multiplicty

2013-02-08 Thread Chris Angelico
On Sat, Feb 9, 2013 at 12:50 PM, Rick Johnson
rantingrickjohn...@gmail.com wrote:
 I really don't like to read docs when learning a language, especially a 
 so-called high level language. I prefer to learn the language by 
 interactive sessions and object introspection. Then, when i have exhausted 
 all abilities to intuit the solution, i will roll my eyes, maybe blubber an 
 expletive, and then reluctantly crack open a user manual.


What Rick means: I want to claim that I've learned a new language,
but I want it to work exactly like the imaginary language in my mind,
and if it doesn't, I'm going to complain about it, rather than,
yaknow, actually learn a new language.

I have learned *many* languages in the past couple of decades. Some of
them are excellent and I keep using them (Pike). Others are excellent
and I keep talking about them (Python). Some are mediocre or poor, but
I keep using them anyway (bash). Some are not particularly enjoyable
to me and I use them only in the one application that embeds them
(Lua, Scheme, DML). And some, I'm just not going to touch any more
(Q-BASIC). But there is not a single language that hasn't taught me
something new. I'm a better C++ programmer for having learned Python;
a better Python programmer for having grokked Scheme and Lua; and,
believe it or not, a better Scheme programmer for having mastered DML.
And that's a language so obscure it doesn't even have a Wikipedia
page... just a redlink here[1].

Learning a language requires accepting something from it into your
brain, not forcing something from your brain onto the language.

ChrisA

[1] 
http://en.wikipedia.org/wiki/List_of_programming_languages_by_type#Extension_languages
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: best way to share an instance of a class among modules?

2013-02-08 Thread Michael Torrie
On 02/07/2013 07:14 PM, Rick Johnson wrote:

 So if you want to use global variables , (bka: Module level
 variables), then simply declare them with a None value like this:
 
 globalVariable = None

This is a nice convention, but at best it's just a helpful notation that
helps a programmer know something useful may likely be bound to this
name in the future.

The '=' sign in Python isn't an assignment operator, at least in this
case; it's a binding operator.  Thus any future line that sets
globalVariable to something isn't assigning a value to this
already-declared variable.  Instead it's binding the name globalValue to
a new object, and overwriting the name in the module dictionary.  That's
of course why the global keyword is required, so that Python will use
the module dictionary instead of the local scope one.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Implicit conversion to boolean in if and while statements

2013-02-08 Thread Chris Angelico
On Sat, Feb 9, 2013 at 12:29 PM, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Fri, Feb 8, 2013 at 5:49 PM, Rick Johnson
 rantingrickjohn...@gmail.com wrote:
 What the hell? Oh yeah, you must be using pike again. No, if it were pike 
 the list would look like this:

 ({({q}), ({w,e}), ({r,t,u}), ({i,o,p})})

 Folks, i couldn't make this stuff up if i wanted to. Go read for yourself if 
 want a few laughs.

 You didn't even do a good job of it.  Yes, Pike uses two characters
 instead of one to wrap array literals.  Big friggin' whoop.  On the
 minus side, it's a little more typing.  On the plus side, they stand
 out better, and you don't have the [] characters doing double duty
 denoting list literals and indexing alike.

Oh, is *THAT* what he meant. I had no idea why it was so laughable.

Another advantage of using two characters: There's no conflict between
set and dict literals. How do you notate an empty set in Python? {}
means an empty dict. In Pike, a mapping is ([]) and a multiset (you
can actually have duplicates, though I don't usually make use of that)
is (). But that's a pretty minor design decision, and I wouldn't
laugh at either for the choice. It's like choosing to paint your car
blue or red.

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


Spawn a process, then exit, whilst leaving process running?

2013-02-08 Thread Victor Hooi
Hi,

I have a Python script that I'd like to spawn a separate process (SSH client, 
in this case), and then have the script exit whilst the process continues to 
run.

I looked at Subprocess, however, that leaves the script running, and it's more 
for spawning processes and then dealing with their output.

Somebody mentioned multiprocessing, however, I'm not sure quite sure how that 
would work here.

What's the most Pythontic way of achieving this purpose?

Cheers,
Victor
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue17128] OS X system openssl deprecated - installer should build local libssl

2013-02-08 Thread Ned Deily

Ned Deily added the comment:

After spending some time on this, I'm downgrading this from release blocker 
status.  First, no one has yet identified any immediate need for openssl 1.0.x 
features to support possible PyPI enhancements, which was my original concern.  
Second, since the openssl build system does not support OS X universal builds 
or SDKs and is not autoconf-based, it does not fit well into the current OS X 
installer build process.  I have a working first cut of building the libs but 
there is more to do.  Third, there is the open issue of how to make root certs 
available.  Ronald, I'm probably missing something obvious here but I don't see 
which Apple patch you are referring to.  Can you elaborate?

There is also the issue of government export restrictions that seems to always 
come up with crypto software.  AFAICT, as of a couple of years ago, there is no 
longer any restriction on shipping openssl binaries with any encryption 
algorithm from the US to any other country.  There are still a few well-known 
patent issue which seem easy to avoid.  But I am not a lawyer.
 
Unless someone objects, I'm going to treat this as a new feature for now and, 
once ready, we can re-examine backporting.

--
priority: release blocker - high
versions:  -Python 2.7, Python 3.2, Python 3.3

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



[issue17156] Tools/i18n/pygettext.py doesn't parse unicode string.

2013-02-08 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


Removed file: http://bugs.python.org/file28992/pygettext.py.patch

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



[issue4331] Can't use _functools.partial() created function as method

2013-02-08 Thread Ramchandra Apte

Changes by Ramchandra Apte maniandra...@gmail.com:


--
versions: +Python 3.3, Python 3.4 -Python 3.0

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



[issue17128] OS X system openssl deprecated - installer should build local libssl

2013-02-08 Thread Ronald Oussoren

Ronald Oussoren added the comment:

See also: issue 15740


A version of OpenSSL as included in some versions of OSX can be downloaded from 
http://opensource.apple.com/tarballs/OpenSSL098/, as mentioned in issue 15740 
the versions as included in the most recent OS updates doesn't seem to be there.

I've downloaded OpenSSL098-35.1 and that includes files 
./src/crypto/x509/x509_vfy_apple.h and ./src/crypto/x509/x509_vfy_apple.c which 
implement the behavior I mentioned earlier: first try to verify using the 
default OpenSSL mechanism, then verify using the TrustEvaluationAgent. 

Now that I look at that code again: we can't extract that code and use it to 
patch upstream OpenSSL, the TrustEvaluationAgent framework is a private 
framework and hence off limits.

It is probably possible to reimplement the same feature using public APIs, but 
that's new development and should be off-limits for a bugfix release (and isn't 
something that can be done very soon without risking to introduce new bugs in 
security-related code).

Direct link to the source code I mentioned: 
http://opensource.apple.com/source/OpenSSL098/OpenSSL098-32/src/crypto/x509/x509_vfy_apple.c,
 
http://opensource.apple.com/source/OpenSSL098/OpenSSL098-32/src/crypto/x509/x509_vfy_apple.h


A blog about this feature by the one of the curl developers: 
http://daniel.haxx.se/blog/2011/11/05/apples-modified-ca-cert-handling-and-curl/


P.S. Apple doesn't exactly make it easy to find this information.

--

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



[issue11448] docs for HTTPConnection.set_tunnel are ambiguous

2013-02-08 Thread Michael Stahn

Michael Stahn added the comment:

I thought the same as Ryan when reading the API. The best way would have been 
to call set_tunnel - set_proxy and to implement the behaviour you expect 
on this: setting a proxy. There are some more places at this code which are not 
quite clear eg:

def putheader(self, header, *values):
  Send a request header line to the server.

Here the methodname putheader is ok but the documentation is misleading: this 
just adds a new header-line to the buffer, it won't send it directly. But 
that's the problem with naming in APIs: once it's in the code you won't get it 
changed that fast..

--
nosy: +m1kes

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



[issue17153] tarfile extract fails when Unicode in pathname

2013-02-08 Thread Hynek Schlawack

Changes by Hynek Schlawack h...@ox.cx:


--
nosy: +hynek

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



[issue17156] Tools/i18n/pygettext.py doesn't parse unicode string.

2013-02-08 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
assignee:  - serhiy.storchaka
nosy: +serhiy.storchaka

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



[issue17149] random.vonmisesvariate() results range is inconsistent for small and not small kappa

2013-02-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Sorry, I was wrong. I missed that z is in range -1..1. Original report is 
invalid, random.vonmisesvariate() always returns a value on the full circle.

However there is some inconsistency. For small kappa (= 1e-6) result range is 
0 to 2pi, for other kappa it is (mu%2pi)-pi to (mu%2pi)+pi. For consistency we 
should either shift a range for small kappa:

if kappa = 1e-6:
return (mu % TWOPI) - _pi + TWOPI * random()

or normalize a result in another case:

if u3  0.5:
theta = (mu + _acos(f)) % TWOPI
else:
theta = (mu - _acos(f)) % TWOPI

--
title: random.vonmisesvariate() returns a value only on the half-circle - 
random.vonmisesvariate() results range is inconsistent for small and not small 
kappa

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



[issue14516] test_tools assumes BUILDDIR=SRCDIR

2013-02-08 Thread Ronald Oussoren

Ronald Oussoren added the comment:

I've closed the issue because I can no longer reproduce the issue, the 
changesets mentioned by Ned have fixed the problem.

--
status: pending - closed

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



[issue17156] Tools/i18n/pygettext.py doesn't parse unicode string.

2013-02-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch for 3.x, which correctly detects input file encoding and 
correctly escapes non-ascii output files if -E specified (and only if it 
specified).

For 2.7 we should just negate an argument for make_escapes.

--
components: +Unicode
nosy: +ezio.melotti, loewis
stage:  - patch review
versions: +Python 3.3, Python 3.4
Added file: http://bugs.python.org/file29001/pygettext_unicode.patch

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



[issue17156] Tools/i18n/pygettext.py doesn't parse unicode string.

2013-02-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch for 2.7. pygettext doesn't try to detect input encoding and 
transparently works with bytes, but it no longer escapes non-ascii bytes if -E 
is not specified.

--
versions: +Python 2.7
Added file: http://bugs.python.org/file29002/pygettext_unicode-2.7.patch

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



[issue17116] xml.parsers.expat.(errors|model) don't set the __loader__ attribute

2013-02-08 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
dependencies: +__loader__ = None should be fine

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



[issue17157] issubclass should accept iterables

2013-02-08 Thread Ramchandra Apte

Changes by Ramchandra Apte maniandra...@gmail.com:


--
nosy: kushou, ramchandra.apte
priority: normal
severity: normal
status: open
title: issubclass should accept iterables
type: enhancement
versions: Python 3.3, Python 3.4

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



[issue17157] issubclass should accept iterables

2013-02-08 Thread Ramchandra Apte

Changes by Ramchandra Apte maniandra...@gmail.com:


--
components: +Interpreter Core

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



[issue17157] issubclass should accept iterables

2013-02-08 Thread Ramchandra Apte

New submission from Ramchandra Apte:

kushou pointed this out on #python-dev

--

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



[issue17157] issubclass() should accept iterables in 2nd arg

2013-02-08 Thread Ramchandra Apte

Changes by Ramchandra Apte maniandra...@gmail.com:


--
title: issubclass should accept iterables - issubclass() should accept 
iterables in 2nd arg

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



[issue17157] issubclass() should accept iterables in 2nd arg

2013-02-08 Thread Ramchandra Apte

Changes by Ramchandra Apte maniandra...@gmail.com:


--
status: open - languishing

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



[issue17157] issubclass() should accept iterables in 2nd arg

2013-02-08 Thread Ramchandra Apte

Changes by Ramchandra Apte maniandra...@gmail.com:


--
status: languishing - open

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



[issue17158] help() module searcher text improvement

2013-02-08 Thread Ramchandra Apte

New submission from Ramchandra Apte:

help(modules spam) prints out Here is a list of matching modules.  Enter any 
module name to get more help. before it has even found the modules. This gives 
the impression that it has found the modules yet it hasn't printed the modules 
yet. I would suggest that it prints Searching for the matching modules... 
without the newline and then once the matching modules have been found prints 
done. (End result will have Searching for the matchine modules... done. 
Then it should print Here is a list of matching modules. Enter any ...

--
components: Interpreter Core
messages: 181671
nosy: ramchandra.apte
priority: normal
severity: normal
status: open
title: help() module searcher text improvement
type: enhancement
versions: Python 3.3, Python 3.4

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



[issue17158] help() module searcher text is misleading

2013-02-08 Thread Ramchandra Apte

Changes by Ramchandra Apte maniandra...@gmail.com:


--
title: help() module searcher text improvement - help() module searcher text 
is misleading

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



[issue17157] issubclass() should accept iterables in 2nd arg

2013-02-08 Thread Mark Dickinson

Mark Dickinson added the comment:

What's the use case for this?  issubclass already accept tuples, just like 
isinstance:

 issubclass(bool, (int, float))
True

--
nosy: +mark.dickinson
versions:  -Python 3.3

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



[issue17149] random.vonmisesvariate() results range is inconsistent for small and not small kappa

2013-02-08 Thread Mark Dickinson

Mark Dickinson added the comment:

Agreed that this seems inconsistent.  The current normalization for non-small 
kappa is a little odd:  e.g, if mu is small and negative (-0.01, say), then we 
get a range that goes roughly from pi to 3*pi, when a range from -pi to pi 
would have made more sense.

Any of (1) returning values in the range [mu - pi, mu+pi], (2) returning values 
in the range [-pi, pi], or (3) returning values in the range [0, 2*pi] would 
seem reasonable.

Unassigning (the original problem is solved by not being there!)

--
assignee: mark.dickinson - 

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



[issue17159] Remove explicit type check from inspect.Signature.from_function()

2013-02-08 Thread Stefan Behnel

New submission from Stefan Behnel:

I can't see a reason why Signature.from_function() should explicitly check the 
type of the object being passed in. As long as the object has all required 
attributes, it should be accepted.

This is specifically an issue with Cython compiled functions, which are not 
Python functions but look the same.

--
components: Library (Lib)
messages: 181674
nosy: scoder
priority: normal
severity: normal
status: open
title: Remove explicit type check from inspect.Signature.from_function()
type: behavior
versions: Python 3.3, Python 3.4

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



[issue15580] fix True/False/None reST markup

2013-02-08 Thread Zearin

Zearin added the comment:

I agree that globally linking all occurrences of True/False/None is overkill. 

Perhaps linking the first occurrence per webpage would be a good standard?



However, I *strongly* believe that:

1. The words be capitalized
2. The words should be marked up as ``True``, ``False``, or ``None``

Of course, these two items only apply when appropriate.  But after attempting 
this myself in #17074, I can say with certainty that this is the case *most of 
the time*.

--

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



[issue17159] Remove explicit type check from inspect.Signature.from_function()

2013-02-08 Thread Stefan Behnel

Stefan Behnel added the comment:

This patch removes the type check from Signature.from_function() and cleans up 
the type tests in signature() to use whatever the inspect module defines as 
isfunction() and isbuiltin(), so that it becomes properly monkey-patchable.

It also adds a test that makes sure the signature relies only on the four 
relevant special attributes, not on the type of the object being inspected.

--
keywords: +patch
nosy: +benjamin.peterson, ncoghlan
Added file: http://bugs.python.org/file29003/inspect_sig.patch

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



[issue17159] Remove explicit type check from inspect.Signature.from_function()

2013-02-08 Thread Éric Araujo

Éric Araujo added the comment:

Patch looks good, but I’m worried about the change from TypeError to 
AttributeError in a stable version.

Could you also make clear that all function-like objects are accepted in the 
doc?

--
nosy: +eric.araujo

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



[issue17159] Remove explicit type check from inspect.Signature.from_function()

2013-02-08 Thread Stefan Behnel

Stefan Behnel added the comment:

The method doesn't seem to be documented, and I'm not sure if the docstring 
really benefits from this lengthy addition. Anyway, here's a patch that 
includes the docstring update.

The exception could be kept the same if we catch an AttributeError and 
explicitly raise a TypeError instead.

--
Added file: http://bugs.python.org/file29004/inspect_sig_with_docstring.patch

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



[issue4483] Error to build _dbm module during make

2013-02-08 Thread ddve...@ucar.edu

ddve...@ucar.edu added the comment:

This is still an issue in Python 2.7.3 but there is a quick manual workaround. 
I know it's trivial and one can easily develop it from what is said in the 
thread or maybe looking at the patches, but for reference this is a nice recipe 
as oppose to digging through many messages

1) build as usual, but redirect the output/error stream in a file, for example 
if your shell is bash (I find this to always be a good idea):

make  make.log 21

2) Towards the end of make.log there will be the following message. If you 
don't see this message, you don't have this problem, but possibly a different 
one:

Failed to build these modules:
dbm


3) execute
grep \-o .*/dbmmodule.o make.log

This will find a compiler line. Cut, paste and and execute that command

4) grep \-o .*/dbm.so make.log

This will find another compiler line. Cut, paste and and execute that command, 
ADDING (this is essential) -lgdbm_compat

5) (optional) you may want to remove dbm_failed.so (in the same directory where 
the previous bullet creates dbm.so)

--
nosy: +ddve...@ucar.edu

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



[issue15580] fix True/False/None reST markup

2013-02-08 Thread R. David Murray

R. David Murray added the comment:

They should be capitalized and marked up as code if they refer to the objects.  
If they refer only to (to use bad english) the truthiness or falsiness of the 
value in question, then they should be lower case and not marked up as code.  
Quickly scanning the start of the patch in 17074, about half the changes to 
true/false markup were incorrect.

Ideally we should never have True unless it is marked up as ``True`` (same for 
False), but there are *many* cases in the docs where true or false is correct.  
My guess would be that those cases outnumber the cases where ``True`` or 
``False`` is correct, but I haven't tried to measure :)

--

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



[issue17047] Fix double double words words

2013-02-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

 I cannot find python-gdb.py.

This is a copy of Tools/gdb/libpython.py.

--

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



[issue17160] test_urllib2net fails

2013-02-08 Thread ddve...@ucar.edu

New submission from ddve...@ucar.edu:

test_urllib2net fails as follows. Looking at test_urllib2net.py line 165 does 
not reveal anything interesting to me

./python Lib/test/regrtest.py -uall -v test_urllib2net
== CPython 2.7.3 (default, Feb 8 2013, 08:28:21) [GCC 4.7.2]
==   Linux-2.6.32-220.13.1.el6.x86_64-x86_64-with-redhat-6.2-Santiago 
little-endian
==   /glade/scratch/ddvento/build/Python-2.7.3-westmere/build/test_python_7544
Testing with flags: sys.flags(debug=0, py3k_warning=0, division_warning=0, 
division_new=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, 
no_user_site=0, no_site=0, ignore_environment=0, tabcheck=0, verbose=0, 
unicode=0, bytes_warning=0, hash_randomization=0)
test_urllib2net
test_custom_headers (test.test_urllib2net.OtherNetworkTests) ... ok
test_file (test.test_urllib2net.OtherNetworkTests) ... ok
test_fileno (test.test_urllib2net.OtherNetworkTests) ... ok
test_ftp (test.test_urllib2net.OtherNetworkTests) ... ok
test_sites_no_connection_close (test.test_urllib2net.OtherNetworkTests) ... ok
test_urlwithfrag (test.test_urllib2net.OtherNetworkTests) ... FAIL
test_close (test.test_urllib2net.CloseSocketTest) ... ok
test_ftp_basic (test.test_urllib2net.TimeoutTest) ... ok
test_ftp_default_timeout (test.test_urllib2net.TimeoutTest) ... ok
test_ftp_no_timeout (test.test_urllib2net.TimeoutTest) ... ok
test_ftp_timeout (test.test_urllib2net.TimeoutTest) ... ok
test_http_basic (test.test_urllib2net.TimeoutTest) ... ok
test_http_default_timeout (test.test_urllib2net.TimeoutTest) ... ok
test_http_no_timeout (test.test_urllib2net.TimeoutTest) ... ok
test_http_timeout (test.test_urllib2net.TimeoutTest) ... ok

==
FAIL: test_urlwithfrag (test.test_urllib2net.OtherNetworkTests)
--
Traceback (most recent call last):
  File 
/glade/scratch/ddvento/build/Python-2.7.3-westmere/Lib/test/test_urllib2net.py,
 line 165, in test_urlwithfrag
http://docs.python.org/glossary.html#glossary;)
AssertionError: 'http://docs.python.org/2/glossary.html' != 
'http://docs.python.org/glossary.html#glossary'

--
Ran 15 tests in 14.684s

FAILED (failures=1)
test test_urllib2net failed -- Traceback (most recent call last):
  File 
/glade/scratch/ddvento/build/Python-2.7.3-westmere/Lib/test/test_urllib2net.py,
 line 165, in test_urlwithfrag
http://docs.python.org/glossary.html#glossary;)
AssertionError: 'http://docs.python.org/2/glossary.html' != 
'http://docs.python.org/glossary.html#glossary'

1 test failed:
test_urllib2net

--
components: Tests
messages: 181682
nosy: ddve...@ucar.edu
priority: normal
severity: normal
status: open
title: test_urllib2net fails
versions: Python 2.7

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



[issue17160] test_urllib2net fails

2013-02-08 Thread R. David Murray

R. David Murray added the comment:

It passes on all our buildbots, and for me locally.  Is it possible there is a 
proxy server between you and python.org that is changing the url returned?

--
nosy: +r.david.murray

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



[issue17161] make install misses the man and the static library

2013-02-08 Thread ddve...@ucar.edu

New submission from ddve...@ucar.edu:

This is for python 2.7.3 built with 

0) ./configure --enable-shared --with-system-expat

1) I need both static and shared object, however libpython2.7.a is not copied 
in the installation target lib. Is this on purpose, or am I missing a flag in 
configure?

2) In share/man/man1/ there are two issues:
2a) the manual is for 2.7.1 instead of 2.7.3
2b) the man command looks for a python.1 file, therefore one must issue:
ln -s python2.7.1 python.1

--
components: Installation
messages: 181684
nosy: ddve...@ucar.edu
priority: normal
severity: normal
status: open
title: make install misses the man and the static library
versions: Python 2.7

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



[issue17160] test_urllib2net fails

2013-02-08 Thread ddve...@ucar.edu

ddve...@ucar.edu added the comment:

Yes, it is possible, do you want me to investigate more with my network 
people?

--

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



[issue17161] make install misses the man and the static library

2013-02-08 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
nosy: +eric.araujo

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



[issue17160] test_urllib2net fails

2013-02-08 Thread R. David Murray

R. David Murray added the comment:

I think only if you want to.  As far as we are concerned the test is correct 
and passing.  (And this kind of thing is the reason that that test set is only 
run when -uall is specified.)

I'm going to close the issue.  If you do investigate, and feel that you've 
found a real bug, please reopen it.

--
resolution:  - works for me
stage:  - committed/rejected
status: open - closed

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



[issue17108] import silently prefers package over module when both available

2013-02-08 Thread Éric Araujo

Éric Araujo added the comment:

I knew that a package would win over a module, but an initless package does 
not?  Yuck :(

--
nosy: +eric.araujo

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



  1   2   >