Re: Too many python installations. Should i remove them all and install the latest?

2013-06-01 Thread Chris Angelico
On Sat, Jun 1, 2013 at 3:35 PM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote:
 Can you please tell me HOW TO GET RID OF ALL PYTHON SETUPS except 2.6 that is 
 needed for system core and then just install 3.3.2?

Nuke the hard drive from orbit. It's the only way to be sure.

 also why cant i install 3.3.2  using yum. if i could instead of building from 
 source then i wouldn't have this installed mess but i could simply
 yum remove python*

That would require that the repo have a 3.3.2 build in it. I don't
know the Red Hat / CentOS policies there, but I know Debian stable
wouldn't have anything so new - it takes time to test things.

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


Re: netcdF4 variables

2013-06-01 Thread Andreas Perstinger

On 01.06.2013 05:30, Sudheer Joseph wrote:

some hing like a list
xx=nc,variables[:]
should get me all variable names with out other surrounding stuff??

In [4]: ncf.variables
Out[4]: OrderedDict([(u'LON', netCDF4.Variable object at 0x254aad0),

[SNIP]

It looks like variables is an OrderedDict. Thus

 ncf.variables.keys()

should return a view (or list, depending on your python version) of all 
keys, i.e. all variable names.


Bye, Andreas
--
http://mail.python.org/mailman/listinfo/python-list


RE: Short-circuit Logic

2013-06-01 Thread Carlos Nepomuceno

 From: steve+comp.lang.pyt...@pearwood.info
 Subject: Re: Short-circuit Logic
 Date: Fri, 31 May 2013 08:45:13 +
 To: python-list@python.org

 On Fri, 31 May 2013 17:09:01 +1000, Chris Angelico wrote:

 On Fri, May 31, 2013 at 3:13 PM, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
 What makes you think that the commutative law is relevant here?


 Equality should be commutative. If a == b, then b == a. Also, it's
 generally understood that if a == c and b == c, then a == b, though
 there are more exceptions to that (especially in loosely-typed
 languages).

 Who is talking about equality? Did I just pass through the Looking Glass
 into Wonderland again? *wink*

 We're talking about *approximate equality*, which is not the same thing,
 despite the presence of the word equality in it. It is non-commutative,
 just like other comparisons like less than and greater than or equal
 to. Nobody gets their knickers in a twist because the= operator is non-
 commutative.

Approximately equality CAN be commutative! I have just showed you that in the 
beginning using the following criteria:

|v-u| = ε*max(|u|,|v|)

Which is implemented as fpc_aeq():

def fpc_aeq(u,v,eps=sys.float_info.epsilon):
    au=abs(u)
    av=abs(v)
    return abs(v-u) = (eps*(au if auav else av))  # |v-u| = ε*max(|u|,|v|)


 Approximate equality is not just non-commutative, it's also intransitive.
 I'm reminded of a story about Ken Iverson, the creator of APL. Iverson
 was a strong proponent of what he called tolerant equality, and APL
 defined the = operator as a relative approximate equal, rather than the
 more familiar exactly-equal operator most programming languages use.

 In an early talk Ken was explaining the advantages of tolerant
 comparison. A member of the audience asked incredulously,
 “Surely you don’t mean that when A=B and B=C, A may not equal C?”
 Without skipping a beat, Ken replied, “Any carpenter knows that!”
 and went on to the next question. — Paul Berry

That's true! But it's a consequence of floating points (discretes representing 
a continuous set -- real numbers).
Out of context, as you put it, looks like approximate equality is 
non-commutative, but that's wrong.

Did you read the paper[1] you have suggested? Because SHARP APL in fact uses 
the same criteria I have mentioned and it supports it extensively to the point 
of applying it by default to many primitive functions, according to Lathwell[2] 
wich is reference 19 of [1].

less than      ab
less than or equal      a≤b
equal       a=b
greater than or equal       a≥b
greater than        ab
not equal           a≠b
floor       ⌊a
ceiling         ⌈a
membership      a∊b
index of        a⍳b


I'll quote Lathwell. He called tolerant comparison what we are now calling 
approximate equality.

Tolerant comparison considers two numbers to be equal if they are within some 
neighborhood. The neighborhood has a radius of ⎕ct times the larger of the two 
in absolute value.

He says larger of the two which means max(|u|,|v|). So, you reference just 
reaffirms what TAOCP have demonstrated to be the best practice.

I really don't know what the fuck you are arguing about?

Can you show me at least one case where the commutative law wouldn't benefit 
the use of the approximate equality operator?

[1] http://www.jsoftware.com/papers/APLEvol.htm
[2] http://www.jsoftware.com/papers/satn23.htm


 The intransitivity of [tolerant] equality is well known in
 practical situations and can be easily demonstrated by sawing
 several pieces of wood of equal length. In one case, use the
 first piece to measure subsequent lengths; in the second case,
 use the last piece cut to measure the next. Compare the lengths
 of the two final pieces.
 — Richard Lathwell, APL Comparison Tolerance, APL76, 1976

 See also here:

 http://www.jsoftware.com/papers/APLEvol.htm

 (search for fuzz or tolerance.



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


Re: Apache and suexec issue that wont let me run my python script

2013-06-01 Thread Νικόλαος Κούρας
Τη Σάββατο, 1 Ιουνίου 2013 8:38:17 π.μ. UTC+3, ο χρήστης Chris Angelico έγραψε:

 You posted it FIFTEEN HOURS AGO on a low-traffic forum.
 Sheesh! Learn a little patience.

I think this is enough time for to get an answer, i dont think so meone would 
answer from there but if you know some other list i can sk this question please 
let me knwo and i'll ask there. 

All my script are python 3.x readyand koukos.py is as well, oits just that damn 
suexec issue that doesnt let my last script that all it does is to set a cookie 
to work properly.

If you kwno the answer please advise me what it needs to be done.
This will be my last question, all other issues have been taker care of.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Too many python installations. Should i remove them all and install the latest?

2013-06-01 Thread Νικόλαος Κούρας
Τη Σάββατο, 1 Ιουνίου 2013 9:18:26 π.μ. UTC+3, ο χρήστης Chris Angelico έγραψε:

 That would require that the repo have a 3.3.2 build in it. I don't
 know the Red Hat / CentOS policies there, but I know Debian stable 
 wouldn't have anything so new - it takes time to test things.

Is there a way to change to some repo that contain the latest python 3.3.2 to 
yo yum it?

Do you advise me to have the peple that iam paiding the VPS to switch me from 
CentOS 6.4 to ubuntu or even better debian?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Too many python installations. Should i remove them all and install the latest?

2013-06-01 Thread Chris Angelico
On Sat, Jun 1, 2013 at 5:51 PM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote:
 Τη Σάββατο, 1 Ιουνίου 2013 9:18:26 π.μ. UTC+3, ο χρήστης Chris Angelico 
 έγραψε:

 That would require that the repo have a 3.3.2 build in it. I don't
 know the Red Hat / CentOS policies there, but I know Debian stable
 wouldn't have anything so new - it takes time to test things.

 Is there a way to change to some repo that contain the latest python 3.3.2 to 
 yo yum it?

 Do you advise me to have the peple that iam paiding the VPS to switch me from 
 CentOS 6.4 to ubuntu or even better debian?

I advise you to follow the recommendations of the Matrix Oracle and
make up rest of quote elided.

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


Re: Apache and suexec issue that wont let me run my python script

2013-06-01 Thread Chris Angelico
On Sat, Jun 1, 2013 at 5:49 PM, Νικόλαος Κούρας nikos.gr...@gmail.com wrote:
 Τη Σάββατο, 1 Ιουνίου 2013 8:38:17 π.μ. UTC+3, ο χρήστης Chris Angelico 
 έγραψε:

 You posted it FIFTEEN HOURS AGO on a low-traffic forum.
 Sheesh! Learn a little patience.

 I think this is enough time for to get an answer, i dont think so meone would 
 answer from there but if you know some other list i can sk this question 
 please let me knwo and i'll ask there.


Did you follow the usual rule of lurking on a list before posting? Or
at very least, reading the archive? I just quickly Googled the
newsgroup name and found the archive. When you see a newsgroup that
gets only a handful of posts a month, you can NOT expect
up-to-the-minute responses. Actually, you can't expect that EVER.

Now learn a little patience and courtesy.

http://www.catb.org/esr/faqs/smart-questions.html

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


RE: Python Magazine

2013-06-01 Thread Carlos Nepomuceno

 Date: Fri, 31 May 2013 04:11:06 -0700
 Subject: Re: Python Magazine
 From: rama29...@gmail.com
 To: python-list@python.org

 Hello all,
 Was busy with work. Finally finished the job of registering the domain name.
 Will be live soon. The url is http://pythonmagazine.org. Hope we will be live 
 soon.
 Regards,
 DRJ.
 --
 http://mail.python.org/mailman/listinfo/python-list

Nice! Wish you luck!

Do you have sponsors? Advertisers? What's the plan? 
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Too many python installations. Should i remove them all and install the latest?

2013-06-01 Thread Cameron Simpson
On 01Jun2013 00:51, =?utf-8?B?zp3Or866zr/PgiDOk866z4EzM866?= 
nikos.gr...@gmail.com wrote:
| Τη Σάββατο, 1 Ιουνίου 2013 9:18:26 π.μ. UTC+3, ο χρήστης Chris Angelico 
έγραψε:
|  That would require that the repo have a 3.3.2 build in it. I don't
|  know the Red Hat / CentOS policies there, but I know Debian stable 
|  wouldn't have anything so new - it takes time to test things.
| 
| Is there a way to change to some repo that contain the latest python 3.3.2 to 
yo yum it?

I asked Google:

  extra yum repositories for centos

and it pointed me at:

  http://wiki.centos.org/AdditionalResources/Repositories

Probably one of these has Python 3. Or build it from source; it's not hard.
-- 
Cameron Simpson c...@zip.com.au

Luge strategy? Lie flat and try not to die.
- Carman Boyle, Olympic Luge Gold Medalist
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Too many python installations. Should i remove them all and install the latest?

2013-06-01 Thread Νικόλαος Κούρας
Τη Σάββατο, 1 Ιουνίου 2013 11:21:14 π.μ. UTC+3, ο χρήστης Cameron Simpson 
έγραψε:
 On 01Jun2013 00:51, =?utf-8?B?zp3Or866zr/PgiDOk866z4EzM866?= 
 nikos.gr...@gmail.com wrote:
 
 | Τη Σάββατο, 1 Ιουνίου 2013 9:18:26 π.μ. UTC+3, ο χρήστης Chris Angelico 
 έγραψε:
 
 |  That would require that the repo have a 3.3.2 build in it. I don't
 
 |  know the Red Hat / CentOS policies there, but I know Debian stable 
 
 |  wouldn't have anything so new - it takes time to test things.
 
 | 
 
 | Is there a way to change to some repo that contain the latest python 3.3.2 
 to yo yum it?
 
 
 
 I asked Google:
 
 
 
   extra yum repositories for centos
 
 
 
 and it pointed me at:
 
 
 
   http://wiki.centos.org/AdditionalResources/Repositories
 
 
 
 Probably one of these has Python 3. Or build it from source; it's not hard.

Should i chnage form CentoOS 6.4 to ubuntu by your opinion?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Apache and suexec issue that wont let me run my python script

2013-06-01 Thread Νικόλαος Κούρας
I was searchign all night long yesterday an i didn manged to get this workign.
Please if someoen is expreinces with linux just help me out here a but.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Apache and suexec issue that wont let me run my python script

2013-06-01 Thread Alain Ketterlin
Νικόλαος Κούρας nikos.gr...@gmail.com writes:

[...]
 [Thu May 30 15:29:33 2013] [error] [client 46.12.46.11] suexec failure: could 
 not open log file 

Here is a link to suexec documentation (at least some version of it,
this is the second link provided by google):

http://httpd.apache.org/docs/2.2/suexec.html

Read this and check your setup to see if it matches.

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


Re: Apache and suexec issue that wont let me run my python script

2013-06-01 Thread Νικόλαος Κούρας
Τη Σάββατο, 1 Ιουνίου 2013 12:03:47 μ.μ. UTC+3, ο χρήστης Alain Ketterlin 
έγραψε:

 http://httpd.apache.org/docs/2.2/suexec.html
 Read this and check your setup to see if it matches.


I have already seen this Alan thank you and tried the command i mentioned but 
with no successfull result whatsoever.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: netcdF4 variables

2013-06-01 Thread Sudheer Joseph

Thank you very much it works for me.
with best regards,
Sudheer
On Saturday, June 1, 2013 12:51:01 PM UTC+5:30, Andreas Perstinger wrote:
 On 01.06.2013 05:30, Sudheer Joseph wrote:
 
  some hing like a list
 
  xx=nc,variables[:]
 
  should get me all variable names with out other surrounding stuff??
 
 
 
  In [4]: ncf.variables
 
  Out[4]: OrderedDict([(u'LON', netCDF4.Variable object at 0x254aad0),
 
 [SNIP]
 
 
 
 It looks like variables is an OrderedDict. Thus
 
 
 
   ncf.variables.keys()
 
 
 
 should return a view (or list, depending on your python version) of all 
 
 keys, i.e. all variable names.
 
 
 
 Bye, Andreas

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


Re: How to Begin Web Development with Python ?

2013-06-01 Thread Giorgos Tzampanakis
Chitrank Dixit wrote:

 Hello Python developers

 I have learnt python and used it for various purposes for scietific
 computing using sage and GUI development using Tkinter and lots more. I
 want to start web development using python My goal is to learn the web
 development in python from the basic level and understand the big web
 development projects like Django , MoinMoin Wiki , Plone  and network
 programming further with twisted.

 I have found Web2Py to be an easy library to quickly use and develop the
 web application. Is there any other library to start my development with.
 and
 does my plan of learning Web2Py is good for Web development and getting
 involved in the big projects like Django , MoinMoin Wiki , Plone.


I am largely in the same situation as you, i.e. I used Python mostly for
scientific applications, using scipy. I wanted to create a website
to publish my research (see my signature for the result, but keep in
mind it's still work in progress!).

I chose CherryPy as my web framework, largely because it's simple and
gets out of the way. I have found that the documentation can be somewhat
lacking in certain respects but overall it's very easy to do what you
want.

CherryPy does not specify a template library so I chose mako which is
fast and very simple to use. The only problem I had with it was getting
meaningful tracebacks when an exception was raised by the in-template
code, but I was able to rectify it once I read the relevant
documentation section carefully.

Modulok suggested using ORM software. ORM should not really be needed if
you are aiming at scientific content for your application, you should
be fine with straight SQL (many consider ORM a hindrance rather than
help for any project  [1], [2]). But if you do find the need for ORM
then SQLAlchemy is very good and is considered pretty much a de facto
standard in the Python world.

Good luck, and I'm sure comp.lang.python posters will be happy to help
you with any problems you come across!

[1] https://en.wikipedia.org/wiki/Object-relational_mapping#Controversy
[2] http://goo.gl/ECNSp

-- 
www.statsfair.com : Real (statistical) tennis and snooker player rankings and 
ratings.

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


Re: Python toplevel in a Web page

2013-06-01 Thread Giorgos Tzampanakis
On 2013-05-30, Franck Ditter wrote:

 Hello,
 I wonder if I can find some source code example
 of a Python 3 toplevel box in a Web page.
 Something simple, no mySQL, no Django hammer, etc.
 Just the basics of the technology to get the
 content of a small text editor in which the user
 writes some Python script, to be analyzed (eval'ed)
 then whose result is to be written in another text box.
 Simple, pythonistic.
 Thanks for the pointer,

 franck

Just set up a webpage with a text area that sends its content as a POST
request to the server where a cgi script will invoke python to run the
script and respond with the output.

Do you trust all possible users of this application? If not, you should
make sure that the python interpreter is running in a sandbox.

-- 
Real (i.e. statistical) tennis and snooker player rankings and ratings:
http://www.statsfair.com/ 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Cutting a deck of cards

2013-06-01 Thread Giorgos Tzampanakis
On 2013-05-26, RVic wrote:

 Suppose I have a deck of cards, and I shuffle them

 import random
 cards = []
 decks = 6
 cards = list(range(13 * 4 * decks))
 random.shuffle(cards)

 So now I have an array of cards. I would like to cut these cards at some
 random point (between 1 and 13 * 4 * decks - 1, moving the lower half of
 that to the top half of the cards array.

 For some reason, I can't see how this can be done (I know that it must
 be a simple line or two in Python, but I am really stuck here). Anyone
 have any direction they can give me on this? Thanks, RVic, python newbie


The slice notation should be your friend here:

random.shuffle(cards)
cut_point = random.choice(xrange(len(cards)))
cards = cards[cut_point :] + cards[: cut_point]

-- 
Real (i.e. statistical) tennis and snooker player rankings and ratings:
http://www.statsfair.com/ 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Magazine

2013-06-01 Thread 88888 Dihedral
Steven D'Aprano於 2013年5月26日星期日UTC+8上午11時50分31秒寫道:
 On Sat, 25 May 2013 21:54:43 -0400, Roy Smith wrote:
 
 
 
  Of course not every IPv6 endpoint will be able to talk to every other
 
  IPv6 endpoint, even if the both have globally unique addresses.  But,
 
  the access controls will be implemented in firewalls with appropriately
 
  coded security policies.
 
 
 
 Or, more likely, *not* implemented in firewalls with *inappropriately* 
 
 coded security policies.
 
 
 
 
 
 
 
 -- 
 
 Steven

Well, both the  reliabl tcpip socket and the unstable udp socket 
are supported in Python. 

Aso the html and xml part is supported for the  dirct web page content analysis 
through port 80.

I am not sure whether  Steven is interested in
the web applictions. 

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


Changing filenames from Greeklish = Greek (subprocess complain)

2013-06-01 Thread Νικόλαος Κούρας

 /home/nikos/public_html/cgi-bin/metrites.py in ()
217 template = htmldata + counter
218 elif page.endswith('.py'):
=  219 htmldata = subprocess.check_output( 
'/home/nikos/public_html/cgi-bin/' + page )
220 template = htmldata.decode('utf-8').replace( 
'Content-type: text/html; charset=utf-8', '' ) + counter
221 
htmldata undefined, subprocess = module 'subprocess' from 
'/opt/python3/lib/python3.3/subprocess.py', subprocess.check_output = 
function check_output, page = 'files.py'
 /opt/python3/lib/python3.3/subprocess.py in check_output(timeout=None, 
*popenargs=('/home/nikos/public_html/cgi-bin/files.py',), **kwargs={})
584 retcode = process.poll()
585 if retcode:
=  586 raise CalledProcessError(retcode, process.args, 
output=output)
587 return output
588 
global CalledProcessError = class 'subprocess.CalledProcessError', retcode = 
1, process = subprocess.Popen object, process.args = 
'/home/nikos/public_html/cgi-bin/files.py', output = b'Content-type: text/html; 
charset=utf-8\n\nbod...n position 74: surrogates not allowed\n\n--\n\n'
CalledProcessError: Command '/home/nikos/public_html/cgi-bin/files.py' returned 
non-zero exit status 1 
  args = (1, '/home/nikos/public_html/cgi-bin/files.py') 
  cmd = '/home/nikos/public_html/cgi-bin/files.py' 
  output = b'Content-type: text/html; charset=utf-8\n\nbod...n position 
74: surrogates not allowed\n\n--\n\n' 
  returncode = 1 
  with_traceback = built-in method with_traceback of CalledProcessError 
object


The above error message happened when i tried to reanme one of my filenames from

its greeklish name to greek charcters.

files.py is a script that allows users to downlaod fiels form my server.
But i wish to presnt filename sin Greek and not in Greeklish

http://superhost.gr/?page=files.py
as it is now.

What can i do to make pth script accept greek filenames too?
Why does subprocess is complaining?
-- 
http://mail.python.org/mailman/listinfo/python-list


problem loading Python PIL module

2013-06-01 Thread Elliot Perlman
Hi,

 

I have a Python program which worked successfully on several PCs using
version 2.2 and showed videos using the PIL module version 1.1.5 .  (All the
rest works but the videos.)  When I try to install the downloaded PIL module
on my current laptop PC, I get the error message Could not create key.  I
now have an Acer, Windows 7, 64-bit with Norton security.  I tried turning
off the firewall, but this did not help.

 

Can anyone help me out?

 

Thanks!

Elliot Perlman

 

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


Re: Cutting a deck of cards

2013-06-01 Thread Joshua Landau
On 31 May 2013 12:56, Lee Crocker leedanielcroc...@gmail.com wrote:
 Why on Earth would you want to? Cutting a deck makes no sense in software. 
 Randomize the deck properly (Google Fisher-Yates) and start dealing. 
 Cutting the deck will not make it any more random,

True

 and in fact will probably make it worse depending on how you choose the 
 cutpoint.

I'm pretty sure it won't. Otherwise you'd be lowering entropy by doing
a random thing to a random thing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can anyone please help me in understanding the following python code

2013-06-01 Thread rusi
On May 30, 2:48 pm, bhk...@gmail.com wrote:
 Code :
 -
 def mergeSort(alist):
     print(Splitting ,alist)
     if len(alist)1:
         mid = len(alist)//2
         lefthalf = alist[:mid]
         righthalf = alist[mid:]

         mergeSort(lefthalf)
         mergeSort(righthalf)

         i=0
         j=0
         k=0
         while ilen(lefthalf) and jlen(righthalf):
             if lefthalf[i]righthalf[j]:
                 alist[k]=lefthalf[i]
                 i=i+1
             else:
                 alist[k]=righthalf[j]
                 j=j+1
             k=k+1

         while ilen(lefthalf):
             alist[k]=lefthalf[i]
             i=i+1
             k=k+1

         while jlen(righthalf):
             alist[k]=righthalf[j]
             j=j+1
             k=k+1
     print(Merging ,alist)

 alist = [54,26,93,17,77,31,44,55,20]
 mergeSort(alist)
 print(alist)

 Output:
 ---
 ('Splitting ', [54, 26, 93, 17, 77, 31, 44, 55, 20])
 ('Splitting ', [54, 26, 93, 17])
 ('Splitting ', [54, 26])
 ('Splitting ', [54])
 ('Merging ', [54])
 ('Splitting ', [26])
 ('Merging ', [26])
 ('Merging ', [26, 54])
 ('Splitting ', [93, 17])
 ('Splitting ', [93])
 ('Merging ', [93])
 ('Splitting ', [17])
 ('Merging ', [17])
 ('Merging ', [17, 93])
 ('Merging ', [17, 26, 54, 93])
 ('Splitting ', [77, 31, 44, 55, 20])
 ('Splitting ', [77, 31])
 ('Splitting ', [77])
 ('Merging ', [77])
 ('Splitting ', [31])
 ('Merging ', [31])
 ('Merging ', [31, 77])
 ('Splitting ', [44, 55, 20])
 ('Splitting ', [44])
 ('Merging ', [44])
 ('Splitting ', [55, 20])
 ('Splitting ', [55])
 ('Merging ', [55])
 ('Splitting ', [20])
 ('Merging ', [20])
 ('Merging ', [20, 55])
 ('Merging ', [20, 44, 55])
 ('Merging ', [20, 31, 44, 55, 77])
 ('Merging ', [17, 20, 26, 31, 44, 54, 55, 77, 93])
 [17, 20, 26, 31, 44, 54, 55, 77, 93]

 Question:
 -
 Function mergeSort is called only once, but it is getting recursively 
 executed after the printing the last statement print(Merging ,alist). But 
 don't recursion taking place except at these places mergeSort(lefthalf), 
 mergeSort(righthalf)

 Sometimes the function execution directly starts from i=0,j=0,k=0 . Not sure 
 how.

 Can anyone please help me out here?

Not in direct answer to your question... Still see if this helps you
to understand mergesorting better.

I generally find that mixing recursion along with imperative
programming makes recursion look difficult.
Imperative programming goes scot-free and recursion gets a bad name!!

So here is a pure recursive/functional solution.  Tell me if you
understand it better (or worse!!)
Its written to demonstrate the IDEA of mergesort. Its actual
efficiency is sub-par for various reasons.

-
# merging two lists, both assumed sorted
def merge(a,b):
if a == []: return b
elif b== []: return a
elif a[0]  b[0]:
return [a[0]] + merge(a[1:],b)
else:
return [b[0]] + merge(a,b[1:])

# The same as merge above written in pure functional style
def merge1(a,b):
return (b if a == [] else
a if b == [] else
[a[0]] + merge(a[1:],b) if a[0]  b[0] else
[b[0]] + merge(a,b[1:])
   )

def mergeSort(alist):
if len(alist)1:
mid = len(alist)//2
lefthalf = alist[:mid]
righthalf = alist[mid:]
return merge1(mergeSort(lefthalf),mergeSort(righthalf) )
else:
return alist

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


Re: Future standard GUI library

2013-06-01 Thread Wolfgang Keller
  A GUI that can not be used without taking the ten fingers off the
  keyboard is indeed entirely unusable for any half-proficient
  screenworker. And anyone doing actual productive screenwork every
  day for more than just a few months will inevitably (have to) get
  proficient (unless completely braindead).
 
 My ten fingers stay on my keyboard, which looks somewhat thus:
 
 http://www.xbitlabs.com/images/mobile/lenovo-thinkpad-t61/keyboard.jpg
 
 See the red dot in the middle? Mouse.

I didn't mean trackpoints or similar devices, but full keyboard
navigation of the entire GUI through shortcuts etc.

A touch-type GUI is a must have for any application that's supposed
to be used productively. The mouse is nice to explore a GUI or for
occasional/leisurely use, but once you use an application daily to earn
your living, it's a hopeless roadblock for productivity.

As is the response time behaviour of web applications.

Besides that pathological non-operating system MS (Not Responding),
btw. 

No cursor animation ever is an absolute must have requirement for
productivity applications.

 THIS is a professional programmer's workspace. :)

And by screenworkers I didn't refer to programmers. Those people
rarely have to use the stuff that they implement.

Sincerely,

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


Re: Future standard GUI library

2013-06-01 Thread Chris Angelico
On Sun, Jun 2, 2013 at 4:18 AM, Wolfgang Keller felip...@gmx.net wrote:
  A GUI that can not be used without taking the ten fingers off the
  keyboard is indeed entirely unusable for any half-proficient
  screenworker. And anyone doing actual productive screenwork every
  day for more than just a few months will inevitably (have to) get
  proficient (unless completely braindead).

 My ten fingers stay on my keyboard, which looks somewhat thus:

 http://www.xbitlabs.com/images/mobile/lenovo-thinkpad-t61/keyboard.jpg

 See the red dot in the middle? Mouse.

 I didn't mean trackpoints or similar devices, but full keyboard
 navigation of the entire GUI through shortcuts etc.

 A touch-type GUI is a must have for any application that's supposed
 to be used productively. The mouse is nice to explore a GUI or for
 occasional/leisurely use, but once you use an application daily to earn
 your living, it's a hopeless roadblock for productivity.

You have seriously underestimated the power of the combined
keyboard+mouse interface. I absolutely agree that keyboard-only will
(almost) always beat mouse-only, but keyboard AND mouse together can
beat either alone, if the UI is designed correctly.

Case in point: Partial staging of a file in git. I can use 'git add
-p' or 'git gui'. With the former, it's all keyboard; I can step
through the hunks, choose what to stage, move on. With the latter,
it's more visual; I right-click a hunk and choose Stage this hunk
(or Stage this line, which is actually quite fiddly with 'git add
-p').

I am a self-confessed keyboard junkie. I will use the keyboard for
pretty much everything. Yet I use git gui and almost never git add -p,
the one exception being when I can't use git gui (eg it's not
installed on some remote headless system and installing it would
require fetching gobs of GUI libraries). It uses the mouse to good
result.

 As is the response time behaviour of web applications.

On a LAN, with a proper back-end, I can get instant response from a
web app. Obviously over the internet there's latency, but that's
nothing to do with the use of a web browser as a UI; you'll see that
with ssh just as much.

 No cursor animation ever is an absolute must have requirement for
 productivity applications.

Not really. There are times when the human will be legitimately
waiting for the computer. http://xkcd.com/303/ for one. But this still
has little to do with the use of a web browser UI; I can achieve
exactly that with the Yosemite Project, which can actually be a
three-computer system: the content is stored on one, the HTTP server
is on another, and the web browser is separate again. And this is only
a 100Mbit LAN. If you need moar speeed, you can always demand
gigabit or better.

 THIS is a professional programmer's workspace. :)

 And by screenworkers I didn't refer to programmers. Those people
 rarely have to use the stuff that they implement.

Of course not, programmers never use software they've themselves
written. Never. Not in a million... oh wait, what's this I have? Hmm,
gcc used to compile gcc, RosMud being used by Rosuav, Neil Hodgson
using SciTE... naw, they're all statistical anomalies, carry on!

You really have a very low opinion of programmers for someone on a
programming mailing list :)

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


Re: Create a file in /etc/ as a non-root user

2013-06-01 Thread Denis McMahon
On Fri, 31 May 2013 02:12:58 -0700, BIBHU DAS wrote:

 Any Idea how to create a file in /etc as non-root user?Can i use umask
 or chmod...confused

If you don't have root access, you probably shouldn't be trying to write 
in /etc. If you need to write in /etc, explain to the sysadmin why you 
need root access.

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Future standard GUI library

2013-06-01 Thread Terry Jan Reedy

On 6/1/2013 4:46 PM, Chris Angelico wrote:

On Sun, Jun 2, 2013 at 4:18 AM, Wolfgang Keller felip...@gmx.net wrote:



And by screenworkers I didn't refer to programmers. Those people
rarely have to use the stuff that they implement.


Of course not, programmers never use software they've themselves
written. Never. Not in a million... oh wait, what's this I have? Hmm,
gcc used to compile gcc, RosMud being used by Rosuav, Neil Hodgson
using SciTE... naw, they're all statistical anomalies, carry on!


And I use Idle to improve Idle.

I use the HgWorkbench front-end to hg because point and click is often 
*faster* for me than remember (or look up command and arg) and type 
(without error, or correction after error).


Now back to ignoring the troll.

Terry


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


Re: How to Begin Web Development with Python ?

2013-06-01 Thread Modulok
  I have learnt python and used it for various purposes for scietific
  computing using sage and GUI development using Tkinter and lots more. I
  want to start web development using python My goal is to learn the web
  development in python from the basic level and understand the big web
  development projects like Django , MoinMoin Wiki , Plone  and network
  programming further with twisted.
 
  I have found Web2Py to be an easy library to quickly use and develop the
  web application. Is there any other library to start my development with.
  and
  does my plan of learning Web2Py is good for Web development and getting
  involved in the big projects like Django , MoinMoin Wiki , Plone.
 

 Modulok suggested using ORM software. ORM should not really be needed if
 you are aiming at scientific content for your application, you should
 be fine with straight SQL (many consider ORM a hindrance rather than
 help for any project  [1], [2]). But if you do find the need for ORM
 then SQLAlchemy is very good and is considered pretty much a de facto
 standard in the Python world.

 Good luck, and I'm sure comp.lang.python posters will be happy to help
 you with any problems you come across!

 [1] https://en.wikipedia.org/wiki/Object-relational_mapping#Controversy
 [2] http://goo.gl/ECNSp


 In SQLalchemy you can use straight SQL, or a database abstraction, or a
full
ORM depending on your needs. The full ORM scared me at first. It was
over-complicated nonsense, black magic and I already had a background in
SQL on
a console. I knew the exact queries I wanted. I didn't need this technical
obfuscation wedged between me and greatness. However the more I used it the
more I started to like it. (Slowly!) It's kind of an acquired taste. It's
not
perfect for everything, but it's usually quite useful once you become
comfortable with it. Even so there are some valid points made against them.

The nice part about SQLalchemy over most other orm packages is it doesn't
really care how high or low level you interact with your data. It supports
them
all. You can do a raw SQL query on a cursor if you want. If you need more,
you
can use the database abstraction. Or more still is setting up a full ORM.
You're never locked into anything.

The down side to SQLalchemy however it is a very large library to learn.
There
are books about it alone. For leaner requirements I use psycopg2, simply
because I use postgresql as my data store and it's pretty much the
pythyon/postgresql de-facto standard. Internally this is what SQLalchemy
uses
to access a postgresql database. If you're on MySQL or Oracle or whatever
your
low level package will be different.

What you use depends on your preferred learning style: top-down or
bottom-up.
If you already know SQL the bottom-up approach of learning the low level lib
will serve you well and you'll feel more immediately productive.

Good luck!
-Modulok-
-- 
http://mail.python.org/mailman/listinfo/python-list


Need to modify a Python Gui

2013-06-01 Thread matt . doolittle33
Hi everybody,
I have a Python GUI that displays some data in labeled fields.  As new data 
comes in the fields clear and the old data is lost.  I need to make a text box 
in the GUI that will display the cleared data in a scrolling list.  I also need 
this scrolling list to be logged to a file in comma-seperated values for 
analysis at a later time.  The fields I need to scroll and log are labeled in 
the “class TrafficPane(wx.Panel):” starting at line 64.  
Thanks

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#  op25_traffic_panel.py
#  
#  Copyright 2013 Balint Seeber balint@crawfish
#  
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#  
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#  
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#  MA 02110-1301, USA.
#  
#  

import wx
import cPickle as pickle
import gnuradio.gr.gr_threading as _threading

wxDATA_EVENT = wx.NewEventType()

def EVT_DATA_EVENT(win, func):
win.Connect(-1, -1, wxDATA_EVENT, func)

class DataEvent(wx.PyEvent):
def __init__(self, data):
wx.PyEvent.__init__(self)
self.SetEventType (wxDATA_EVENT)
self.data = data

def Clone (self):
self.__class__ (self.GetId())

class traffic_watcher_thread(_threading.Thread):
def __init__(self, rcvd_pktq, event_receiver):
_threading.Thread.__init__(self)
self.setDaemon(1)
self.rcvd_pktq = rcvd_pktq
self.event_receiver = event_receiver
self.keep_running = True
self.start()

def stop(self):
self.keep_running = False

def run(self):
while self.keep_running:
msg = self.rcvd_pktq.delete_head()
de = DataEvent (msg)
wx.PostEvent (self.event_receiver, de)
del de

# A snapshot of important fields in current traffic
#
class TrafficPane(wx.Panel):

# Initializer
#
def __init__(self, parent, msgq):
wx.Panel.__init__(self, parent)

self.msgq = msgq

sizer = wx.GridBagSizer(hgap=10, vgap=10)
self.fields = {}

label = wx.StaticText(self, -1, DUID:)
sizer.Add(label, pos=(1,1))
field = wx.TextCtrl(self, -1, , size=(144, -1), style=wx.TE_READONLY)
sizer.Add(field, pos=(1,2))
self.fields[duid] = field;

label = wx.StaticText(self, -1, NAC:)
sizer.Add(label, pos=(2,1))
field = wx.TextCtrl(self, -1, , size=(144, -1), style=wx.TE_READONLY)
sizer.Add(field, pos=(2,2))
self.fields[nac] = field;

label = wx.StaticText(self, -1, Source:)
sizer.Add(label, pos=(3,1))
field = wx.TextCtrl(self, -1, , size=(144, -1), style=wx.TE_READONLY)
sizer.Add(field, pos=(3,2))
self.fields[source] = field;

label = wx.StaticText(self, -1, Destination:)
sizer.Add(label, pos=(4,1))
field = wx.TextCtrl(self, -1, , size=(144, -1), style=wx.TE_READONLY)
sizer.Add(field, pos=(4,2))
self.fields[dest] = field;

label = wx.StaticText(self, -1, MFID:)
sizer.Add(label, pos=(1,4))
field = wx.TextCtrl(self, -1, , size=(144, -1), style=wx.TE_READONLY)
sizer.Add(field, pos=(1,5))
self.fields[mfid] = field;

label = wx.StaticText(self, -1, ALGID:)
sizer.Add(label, pos=(2,4))
field = wx.TextCtrl(self, -1, , size=(144, -1), style=wx.TE_READONLY)
sizer.Add(field, pos=(2,5))
self.fields[algid] = field;

label = wx.StaticText(self, -1, KID:)
sizer.Add(label, pos=(3,4))
field = wx.TextCtrl(self, -1, , size=(144, -1), style=wx.TE_READONLY)
sizer.Add(field, pos=(3,5))
self.fields[kid] = field;

label = wx.StaticText(self, -1, MI:)
sizer.Add(label, pos=(4,4))
field = wx.TextCtrl(self, -1, , size=(216, -1), style=wx.TE_READONLY)
sizer.Add(field, pos=(4,5))
self.fields[mi] = field;

label = wx.StaticText(self, -1, TGID:)
sizer.Add(label, pos=(5,4))
field = wx.TextCtrl(self, -1, , size=(144, -1), style=wx.TE_READONLY)
sizer.Add(field, pos=(5,5))
self.fields[tgid] = field;

self.SetSizer(sizer)
self.Fit()

EVT_DATA_EVENT(self, self.display_data)

Re: Create a file in /etc/ as a non-root user

2013-06-01 Thread rusi
On Jun 2, 2:19 am, Denis McMahon denismfmcma...@gmail.com wrote:
 On Fri, 31 May 2013 02:12:58 -0700, BIBHU DAS wrote:
  Any Idea how to create a file in /etc as non-root user?Can i use umask
  or chmod...confused

 If you don't have root access, you probably shouldn't be trying to write
 in /etc. If you need to write in /etc, explain to the sysadmin why you
 need root access.

The OP is evidently working on a macbook pro.
From which I infer its his own personal notebook.
So 'explain to the sysadmin' amounts to explain to oneself!!

40 years ago, on the first Unices, with machines millions of times
weaker and costlier than today, 'sysadmin' and 'normal user' were
usually different. Today they are usually the same.

So we old Unix-heads need to change our explanations from 'explain to
the sysadmin' to 'change hat from normal-user to superuser'.  And then
why simplifying life by having only one hat --
$ sudo bash # and do everything there
is not such a good idea!

To the OP:
One thing that has not changed in 40 (or rather 60) years is the
concept of binding times.
eg C programmers cannot get off the ground if they do not distinguish
compile-time from run-time.

In the current context, it is probably good to distinguish system-
admining time from system-use time.
So as sysadmin, you can pretty much do as you please (though remember
my comments earlier on respecting your distro's space), make a
directory under /etc, chmod, chown, chgrp it to your taste, so that
the (group of) ordinary users can write to it.

And then in normal user mode you should be able to write to it.

However... as I said above it may be preferable to use /usr/local (for
programs) or /var (for data) rather than mess in /etc. [Think of /etc
as windows' registry]  Study the FHS to make the right choice.

And finally, if you are the only guy involved, why are you not doing
everything under $HOME?
-- 
http://mail.python.org/mailman/listinfo/python-list


xsd:anyType parameter in suds!

2013-06-01 Thread Tamer Higazi
Hi people!
I have a problem passing an xs:anyType Parameter in suds.

The original sample is an application, where a PHP Array is being
passed for the remoted method. What is the same type in python to
accomplish the task?!

doc with sample:
http://kasapi.kasserver.com/dokumentation/?open=soap


here the sample code with it's output:


from suds.client import Client

class KasAPI(object):
   def __init__(self):
self.__WSDL =
'https://kasserver.com/schnittstelle/soap/wsdl/KasAuth.wsdl'
self.client = Client(self.__WSDL)
   KasOBJ = KasAPI()
print KasOBJ.client


output:


Suds ( https://fedorahosted.org/suds/ )  version: 0.4 GA  build:
R699-20100913

Service ( KasApiAuthenticationService ) tns=https://kasserver.com/;
   Prefixes (0)
   Ports (1):
  (KasApiAuthenticationPort)
 Methods (1):
KasAuth(xs:anyType Params, )
 Types (0):



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


Re: Too many python installations. Should i remove them all and install the latest?

2013-06-01 Thread Cameron Simpson
On 01Jun2013 01:30, =?utf-8?B?zp3Or866zr/PgiDOk866z4EzM866?= 
nikos.gr...@gmail.com wrote:
| Τη Σάββατο, 1 Ιουνίου 2013 11:21:14 π.μ. UTC+3, ο χρήστης Cameron Simpson 
έγραψε:
|  On 01Jun2013 00:51, =?utf-8?B?zp3Or866zr/PgiDOk866z4EzM866?= 
nikos.gr...@gmail.com wrote:
|  | Τη Σάββατο, 1 Ιουνίου 2013 9:18:26 π.μ. UTC+3, ο χρήστης Chris Angelico 
έγραψε:
|  |  That would require that the repo have a 3.3.2 build in it. I don't
|  |  know the Red Hat / CentOS policies there, but I know Debian stable 
|  |  wouldn't have anything so new - it takes time to test things.
|  | 
|  | Is there a way to change to some repo that contain the latest python 
3.3.2 to yo yum it?
|  
|  I asked Google:
|extra yum repositories for centos
|  and it pointed me at:
|http://wiki.centos.org/AdditionalResources/Repositories
|  
|  Probably one of these has Python 3. Or build it from source; it's not hard.
| 
| Should i chnage form CentoOS 6.4 to ubuntu by your opinion?

No. Just sort it out on CentOS. Try the extra repos. Get Python 3
from one (I'm not sure why you think your current Python 3 install
is a problem anyway, though).

You're already slightly familiar with CentOS. Switching distros
will just cause more pain. Fix your actual problems first.

This is not a recommendation one way or another re CentOS versus
Ubunutu; it is a recommendation not to change without a better reason.
-- 
Cameron Simpson c...@zip.com.au

It takes seven or eight people to send a FAX.   - Anonymous IRS guy
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Too many python installations. Should i remove them all and install the latest?

2013-06-01 Thread Chris Angelico
On Sun, Jun 2, 2013 at 2:36 PM, Cameron Simpson c...@zip.com.au wrote:
 This is not a recommendation one way or another re CentOS versus
 Ubunutu; it is a recommendation not to change without a better reason.

Agreed. I happen to like Debian-family Linuxes, having spent most of
my Linux time on either Ubuntu or Debian (and am now happy with Debian
Wheezy on most of my computers), but there's really no point jumping
ship randomly. I'm saying this for the archive only, though. Nikos
just needs to learn the skill of figuring out where his problems
really are.

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


[issue13123] bdist_wininst uninstaller does not remove pycache directories

2013-06-01 Thread Matt Wilkie

Changes by Matt Wilkie map...@gmail.com:


--
nosy: +Matt.Wilkie

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



[issue4636] bdist_wininst installer with install script raises exception

2013-06-01 Thread Matt Wilkie

Matt Wilkie added the comment:

I confirm this is happening with 3.2.4 from an installer generated in 2.7.4 
(64bit Win7, 32bit python): 
https://pypi.python.org/pypi/leo/4.11.devel-build-5802

--
nosy: +Matt.Wilkie

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



[issue17973] FAQ entry for: '+=' on a list inside tuple both succeeds and raises an exception

2013-06-01 Thread Andy Chugunov

Andy Chugunov added the comment:

Thank you guys for all the efforts you put in solving and answering this.

Just so that we're clear.
It is perfectly legitimate to extend lists withing tuples. It just doesn't seem 
possible to make augmented assignment and simple assignment handle this 
particular operation correctly without unduly sacrificing their general 
efficiency. Use append() on the lists instead.

Is that correct?

--

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



[issue18109] os.uname() crashes if hostname contains non-ascii characters

2013-06-01 Thread Charles-François Natali

Charles-François Natali added the comment:

To reproduce the issue, try this:
# echo hostname  /proc/sys/kernel/hostname

 the locale encoding + surrogateescape error handler

Sounds reasonable.

--
nosy: +neologix

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



[issue18113] Memory leak in curses.panel

2013-06-01 Thread Serhiy Storchaka

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


--
components: +Extension Modules
keywords: +easy
nosy: +serhiy.storchaka
stage:  - needs patch
type:  - behavior
versions: +Python 3.4

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



[issue18109] os.uname() crashes if hostname contains non-ascii characters

2013-06-01 Thread Dominik Richter

Dominik Richter added the comment:

@neologix: (with current hostname showing at the left of my prompt)

none:~ # echo hât  /proc/sys/kernel/hostname
hât:~ # hostname
hât

--

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



[issue18109] os.uname() crashes if hostname contains non-ascii characters

2013-06-01 Thread Dominik Richter

Dominik Richter added the comment:

/off: nevermind, wasn't directed at me

--

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



[issue18110] Nested set comprehensions in class scope fail

2013-06-01 Thread Eric Wieser

Changes by Eric Wieser wieser.eric+py...@gmail.com:


--
status: closed - open

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



[issue18110] Nested set comprehensions in class scope fail

2013-06-01 Thread Eric Wieser

Eric Wieser added the comment:

This is not at first glance, a duplicate of 3692 - in that case, the list 
comprehension is referring to another class variable.

Most notably, that describes a behavioural change introduced by python 3 - in 
this case, python 3 handles it correctly - there's a bug in the python 2 
implementation.

--
resolution: duplicate - 

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



[issue1772673] Replacing char* with const char*

2013-06-01 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The patch is outdated. Some function prototypes were changed in issue9369, some 
were changed before.

Here is a new patch. It adds const qualifier to following public functions:
PyObject_DelAttrString, PyObject_HasAttrString, PyObject_GetAttrString, 
PyObject_SetAttrString, PyObject_DelItemString, PyMapping_DelItemString, 
PyMapping_HasKeyString, PyMapping_GetItemString, PyMapping_SetItemString, 
PyFile_FromFd, PyImport_ExecCodeModule, PyImport_ExecCodeModuleEx, 
PyImport_ExecCodeModuleWithPathnames, PyImport_ImportFrozenModule, 
PyLong_FromString, PyOS_strtoul, PyOS_strtol, PyOS_Readline, 
PyMarshal_ReadObjectFromString, PyParser_ParseFile, PyParser_ParseFileFlags, 
PyParser_ParseFileFlagsEx, PyTokenizer_FromFile. It also changes prototypes of 
some internal functions and structures and fixes documentation for 
PyDict_DelItemString. Some of functions already were documented with const 
qualifier.

--
nosy: +brett.cannon, eric.snow, ncoghlan
stage: needs patch - patch review
Added file: http://bugs.python.org/file30440/const_char_2.patch

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



[issue18020] html.escape 10x slower than cgi.escape

2013-06-01 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
assignee:  - ezio.melotti
stage:  - patch review

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



[issue17973] FAQ entry for: '+=' on a list inside tuple both succeeds and raises an exception

2013-06-01 Thread R. David Murray

R. David Murray added the comment:

I believe that summary is correct.

--

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



[issue16450] test_missing_localfile masks problems in urlopen

2013-06-01 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 60c195e89c88 by Senthil Kumaran in branch '2.7':
Fix #16450 test_missing_localfile testcase fails on misconfigured hostname.
http://hg.python.org/cpython/rev/60c195e89c88

--
nosy: +python-dev

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



[issue16450] test_missing_localfile masks problems in urlopen

2013-06-01 Thread Senthil Kumaran

Senthil Kumaran added the comment:

I noticed this only after I had a misconfigured hostname on my mac.
Fixing my hostname of course solved the problem, but in any case, changed the 
tests so that we wont be baffled by the unexpected (and misdirected error msg) 
from test for misconfigured hostname.

Thanks for bug report, Hans Mulder and sorry for taking long time to get to 
this.

--
resolution:  - fixed
stage:  - committed/rejected
status: open - closed
type:  - behavior

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



[issue17967] urllib2.open failed to access a url when a perent directory of the url is permission denied

2013-06-01 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 0a544bb539e6 by Senthil Kumaran in branch '2.7':
Fix #17967: For ftp urls CWD to target instead of hopping to each directory
http://hg.python.org/cpython/rev/0a544bb539e6

New changeset dbfbdf2b5c19 by Senthil Kumaran in branch '3.3':
Fix #17967: For ftp urls CWD to target instead of hopping to each directory
http://hg.python.org/cpython/rev/dbfbdf2b5c19

New changeset c1101f0d6c29 by Senthil Kumaran in branch 'default':
merge from 3.3
http://hg.python.org/cpython/rev/c1101f0d6c29

--
nosy: +python-dev

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



[issue17967] urllib2.open failed to access a url when a perent directory of the url is permission denied

2013-06-01 Thread Senthil Kumaran

Senthil Kumaran added the comment:

Thanks Zhaoqifa for steps to configure the ftp with acl. I could reproduce it 
manually and fix it by changes to the urllib.request code.
Unfortunately, we dont have rigorous tests for ftp handling in urllib module. 
That's noted in test_urllib2net module too.

This bug is fixed in all branches.

--
resolution:  - fixed
stage: test needed - committed/rejected
status: open - closed

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



[issue17967] urllib2.open failed to access a url when a perent directory of the url is permission denied

2013-06-01 Thread Senthil Kumaran

Senthil Kumaran added the comment:

Reopening: This change is seeing problems with Windows Buildbot
http://buildbot.python.org/all/builders/x86%20XP-4%203.x/builds/8643/steps/test/logs/stdio

--
status: closed - open

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



[issue17683] socket.getsockname() inconsistent return type with AF_UNIX

2013-06-01 Thread Charles-François Natali

Changes by Charles-François Natali cf.nat...@gmail.com:


--
nosy: +haypo

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



[issue18066] Remove SGI-specific code from pty.py

2013-06-01 Thread A.M. Kuchling

Changes by A.M. Kuchling li...@amk.ca:


--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

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



[issue18066] Remove SGI-specific code from pty.py

2013-06-01 Thread Roundup Robot

Roundup Robot added the comment:

New changeset a678f139510b by Andrew Kuchling in branch 'default':
#18066: remove vestigial code depending on the sgi module
http://hg.python.org/cpython/rev/a678f139510b

--
nosy: +python-dev

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



[issue18106] There are unused variables in Lib/test/test_collections.py

2013-06-01 Thread Terry J. Reedy

Terry J. Reedy added the comment:

To me, there are two independent improvements: using i and hence msg to 
identify the erroneous dup, and using .subTest to test all dups. I would 
combine ideas from both the first two patches to do both.

1. a fancy formatted message would be more useful with less fluff and the two 
displays each on their own line.

msg = iteration %s\ncopy: %s\norig: %s % (i, dup, words)
# or od for OrderedDict test

2. within both loops, add msg to all asserts as in the first patch. If there is 
a failure, one would want to know both the source of the dup (indicated by i) 
and the content, and how it differed from the model.

3. wrap the bodies of both loops with 'with self.subTest():' to always test all 
dups. Unrolling the loops prevents doing this.

Test the revised tests by temporarily adding both the original (failing the 
'is' test) and a partial and therefore faulty copy of the original to both list 
of dups. Verify that both errors are reported for each and that the message 
formatting looks ok.

--
nosy: +terry.reedy

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



[issue18106] There are unused variables in Lib/test/test_collections.py

2013-06-01 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

subTest() serves two purposes: identify the test case and continue testing
oother test cases after a fail. For first purpose subTest() is not well
suitable in these tests, becouse we have no a string which determine a
test. Second purpose is not relevant to original issue.

1. a fancy formatted message would be more useful with less fluff and the
 two displays each on their own line.

 msg = iteration %s\ncopy: %s\norig: %s % (i, dup, words)
 # or od for OrderedDict test


When the test fails, dup is not expected value and printing it can raise an
exception and prevent formatting useful error message. Failure report
should be succesful in any case.

3. wrap the bodies of both loops with 'with self.subTest():' to always test
 all dups. Unrolling the loops prevents doing this.


Of course you can wrap a body of the check() function.

--

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



[issue18106] There are unused variables in Lib/test/test_collections.py

2013-06-01 Thread Terry J. Reedy

Terry J. Reedy added the comment:

 becouse we have no a string which determine a test.

The original loop could be have been written as (or be changed to)

for label, dup in [
('odcopy', od.copy()),
('copycopy', copy.copy(words)),
and so on
]
and the label used to identify the test, whether passed to assertX or subTest. 
The test author (Raymond H.) thought the sequence number enough in the off 
chance there ever were a failure.

When the test fails, dup is not expected value and printing it can raise an 
exception and prevent formatting useful error message.

I do not understand this, unittest assumes that tested objects are printable. 
Indeed, assertEqual(dup, words/od) will do that (making the message redundant 
for this particular test.

So I think the best fix would be to redo the loop header as above, pass label 
to subTest so it appears for any failure (which intertwines subTest with this 
issue), and only pass a message to assert where actually needed (like the len 
test).

--

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



[issue14621] Hash function is not randomized properly

2013-06-01 Thread Donald Stufft

Changes by Donald Stufft donald.stu...@gmail.com:


--
nosy: +dstufft

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



[issue11959] smtpd cannot be used without affecting global state

2013-06-01 Thread Vinay Sajip

Changes by Vinay Sajip vinay_sa...@yahoo.co.uk:


Added file: http://bugs.python.org/file30441/d7c50c15468d.diff

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



[issue18050] embedded interpreter or virtualenv fails with ImportError: cannot import name MAXREPEAT

2013-06-01 Thread H Xu

Changes by H Xu h...@topbug.net:


--
nosy: +xuhdev

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



[issue11959] smtpd cannot be used without affecting global state

2013-06-01 Thread Vinay Sajip

Vinay Sajip added the comment:

Patch now updated to revert asyncore changes. The changes are now:

smtpd.py - changed SMTPChannel and SMTPServer to accept map argument

test_logging.py - removed subclassed SMTPChannel, not needed since the base 
SMTPChannel class now accepts a map, and simplified TestSMTPServer, since the 
base SMTPServer class now accepts a map.

--

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



[issue15903] Make rawiobase_read() read directly to bytes object

2013-06-01 Thread Dwight Guth

Dwight Guth added the comment:

I was programming something today and thought I should let you know I came 
across a situation where the current behavior of this function is able to 
expose what seems to be raw memory to the user.

import io
class A(io.RawIOBase):
  def readinto(self, b):
return len(b)

A().read(100)

--
nosy: +dwight.guth

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



[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-01 Thread Nikolaus Rath

New submission from Nikolaus Rath:

[0] nikratio@vostro:~/tmp$ cat bugme.py 
#!python
import getpass
import warnings

warnings.simplefilter('default')
getpass.getpass(What's up?)

[0] nikratio@vostro:~/tmp$ python3 --version
Python 3.3.2

[0] nikratio@vostro:~/tmp$ python3 bugme.py 
/usr/lib/python3.3/os.py:1043: ResourceWarning: unclosed file _io.FileIO 
name=3 mode='rb+'
  return io.open(fd, *args, **kwargs)
What's up?

--
components: Library (Lib)
messages: 190458
nosy: Nikratio
priority: normal
severity: normal
status: open
title: getpass.getpass() triggers ResourceWarning
type: resource usage
versions: Python 3.3

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



[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-01 Thread Alex Gaynor

Alex Gaynor added the comment:

Attached patch should fix this issue.

--
keywords: +patch
nosy: +alex
Added file: http://bugs.python.org/file30442/issue18116.diff

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



[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-01 Thread Nikolaus Rath

Nikolaus Rath added the comment:

No, it doesn't.

--

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



[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-01 Thread Alex Gaynor

Alex Gaynor added the comment:

Are you sure you applied it correctly? With and without:

Alexanders-MacBook-Pro:cpython alex_gaynor$ ./python.exe x.py
What's up?
Alexanders-MacBook-Pro:cpython alex_gaynor$ hg revert --all --no-backup
reverting Lib/getpass.py
Alexanders-MacBook-Pro:cpython alex_gaynor$ ./python.exe x.py
What's up?
x.py:6: ResourceWarning: unclosed file _io.TextIOWrapper name=3 mode='w+' 
encoding='UTF-8'
  getpass.getpass(What's up?)

--

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



[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-01 Thread Nikolaus Rath

Nikolaus Rath added the comment:

Yes, I'm pretty sure:

[0] nikratio@vostro:~/tmp$ cp  /usr/lib/python3.3/getpass.py  .
[0] nikratio@vostro:~/tmp$ patch -p2  issue18116.diff 
patching file getpass.py
Hunk #1 succeeded at 57 (offset -1 lines).

[0] nikratio@vostro:~/tmp$ python3 bugme.py 
/usr/lib/python3.3/os.py:1043: ResourceWarning: unclosed file _io.FileIO 
name=3 mode='rb+'
  return io.open(fd, *args, **kwargs)
What's up?

# Test if we're using the patched getpass.py...
[0] nikratio@vostro:~/tmp$ vim getpass.py
[0] nikratio@vostro:~/tmp$ python3 bugme.py 
Hello
/usr/lib/python3.3/os.py:1043: ResourceWarning: unclosed file _io.FileIO 
name=3 mode='rb+'
  return io.open(fd, *args, **kwargs)
What's up?

--

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



[issue17855] Implement introspection of logger hierarchy

2013-06-01 Thread Brandon Craig Rhodes

Brandon Craig Rhodes added the comment:

Adding an entirely separate API for introspection strikes me as 
counter-productive — instead of merely having to maintain the logging API that 
you already maintain, you will additionally now have an entirely separate and 
second API that also has to be maintained forever.

Reading back over the current logging documentation, it looks like the problem 
is that the documentation only includes verbs — the methods that can be invoked 
— but not adjectives: the attributes that are attached to each logger, handler, 
and filter. This is contrary to modern Python APIs, which typically document 
their attributes and offer direct access to them; within the Standard Library, 
cf the threading.Thread object for one that has done a good job of moving into 
the modern world with directly-accessible attributes.

So my guess would be that you should discard the idea of a separate 
introspection API, and simply document that attributes of each logger, handler, 
and filter that today are already perfectly introspectable. Check out the 
logging_tree code if you want to make sure that you are “promoting” into 
document-hood all of the attributes that I needed in order to do my 
introspecting there.

--

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



[issue18111] Add a default argument to min max

2013-06-01 Thread Julian Berman

Julian Berman added the comment:

Thanks for finding that, I thought there was an issue that came out of that p-i 
thread but couldn't find it.

I'd like to be more concrete, but calling max on an iterable seems concrete 
enough to me. If you'd like to know more though, personally I've wanted this at 
least twice in the past 4 or 5 months. Currently, I have code that looks like:

def best_match(stuff):
first = next(stuff, None)
if first is None:
return
return max(itertools.chain([first], stuff))

which finds the best matching (error it happens to be) in the given stuff. A 
few months ago I had a similar need in a different application.

The issues in that thread from 2009 revolved around a bunch of confusing and 
not so related things. And I definitely agree that `start` is a really bad name 
for this. But I don't find `default` to be at all confusing, and in fact this 
has come up in #python a few times and each time there hasn't really been a 
problem explaining to someone what `default` would do (or how it would interact 
with `key` for that matter, although if a precedent is desired, the default in 
`argparse` just returns the default, it doesn't call `type` or anything on it).

--

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



[issue18111] Add a default argument to min max

2013-06-01 Thread R. David Murray

R. David Murray added the comment:

So you aren't really asking for a default, you are asking for a version of 
max/min that returns a sentinel instead of raising an error on an empty list. 
You could just write utility function that has a try/except in it.  I'm not 
sure it is worth complicating min and max for this use case.  (I'm not sure it 
isn't, either.)  I wonder if we have any other functions in python that have an 
argument that turns a ValueError into a sentinel-return instead?

--

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



[issue18111] Add a default argument to min max

2013-06-01 Thread Julian Berman

Julian Berman added the comment:

Yes that's a good description. I'm not sure the type of exception is the thing 
to look at as much as the behavior, I.e. I think next() is a good precedent.

And it's not really pleasant to do this with a try/except. Of course 
everything's possible, but to catch the ValueError sanely requires checking the 
text of the exception so that the except isn't too broad.

--

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



[issue18106] There are unused variables in Lib/test/test_collections.py

2013-06-01 Thread Vajrasky Kok

Vajrasky Kok added the comment:

I redo the test as Terry J. Reedy suggested. I use label in loop, utilize 
subTest receiving label parameter, and pass messages to only necessary asserts.

So roughly if the test fails, we would get something like this:

==
FAIL: test_copying (__main__.TestOrderedDict) (label='OrderedDict(od)')
--
Traceback (most recent call last):
  File Lib/test/test_collections.py, line 1237, in test_copying
self.assertTrue(dup is not dup, msg)
AssertionError: False is not true : 
copy: OrderedDict([('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)])
od: OrderedDict([('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)])

==
FAIL: test_copying (__main__.TestCounter) (label='Counter(words)')
--
Traceback (most recent call last):
  File Lib/test/test_collections.py, line 942, in test_copying
self.assertEqual(type(dup), type(''), msg)
AssertionError: class 'collections.Counter' != class 'str' : 
copy: Counter({'which': 2, 'witches': 1, 'witch': 1, 'watch': 1, 'wrist': 1, 
'had': 1})
words: Counter({'which': 2, 'witches': 1, 'had': 1, 'watch': 1, 'witch': 1, 
'wrist': 1})

--
Added file: http://bugs.python.org/file30443/test_with_label_and_subTest.patch

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



[issue18116] getpass.getpass() triggers ResourceWarning

2013-06-01 Thread Vajrasky Kok

Vajrasky Kok added the comment:

This bug happens in Python 3.4 as well.

[sky@localhost cpython]$ ./python --version
Python 3.4.0a0
[sky@localhost cpython]$ ./python /tmp/bugme.py
/home/sky/Code/python/programming_language/cpython/Lib/os.py:1025: 
ResourceWarning: unclosed file _io.FileIO name=3 mode='rb+'
  return io.open(fd, *args, **kwargs)
What's up?

I tried to apply the patch manually (by copying, cutting and pasting) from Alex 
but Nikolaus is right. The patch does not work. The bug still happens

--
nosy: +vajrasky

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



[issue18111] Add a default argument to min max

2013-06-01 Thread R. David Murray

R. David Murray added the comment:

I don't think there's any other way to get a ValueError out of min/max, but I 
haven't actually looked at the code to check.  Of course, if we want people to 
rely on that, we'd need to document it.

'next's default is used to return a sentinel when the list is exhausted, not 
when it would otherwise raise a ValueError.  It is a somewhat related case, but 
is not exactly parallel.  The sentinel for next indicates the end of an ongoing 
process.  The proposed argument to min/max would *replace* an error with a 
sentinel value.

--

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



[issue18111] Add a default argument to min max

2013-06-01 Thread Julian Berman

Julian Berman added the comment:

It's not exactly the same of course, but calling next on a thing that might be 
empty would be somewhat close, and also is replacing an exception with a 
sentinel (an exception that is much easier to differentiate).

You can always get a ValueError out of min/max, they're going to be ultimately 
calling __lt__ on stuff which can do what it wants, but that's admittedly quite 
unlikely.

It's not really that readable though on the other hand.

--

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