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', ),

[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
>>  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 au>av 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
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, Νικόλαος Κούρας  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 .

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, Νικόλαος Κούρας  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?= 
 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 

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?= 
>  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
Νικόλαος Κούρας  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', ),
> 
> [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 = , subprocess.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 = , retcode = 
1, process = , process.args = 
'/home/nikos/public_html/cgi-bin/files.py', output = b'Content-type: text/html; 
charset=utf-8\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\n\n\n' 
  returncode = 1 
  with_traceback = 


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  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 i             if lefthalf[i]                 alist[k]=lefthalf[i]
>                 i=i+1
>             else:
>                 alist[k]=righthalf[j]
>                 j=j+1
>             k=k+1
>
>         while i             alist[k]=lefthalf[i]
>             i=i+1
>             k=k+1
>
>         while j             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  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  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 
#  
#  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(

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

2013-06-01 Thread rusi
On Jun 2, 2:19 am, Denis McMahon  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?= 
 wrote:
| Τη Σάββατο, 1 Ιουνίου 2013 11:21:14 π.μ. UTC+3, ο χρήστης Cameron Simpson 
έγραψε:
| > On 01Jun2013 00:51, =?utf-8?B?zp3Or866zr/PgiDOk866z4EzM866?= 
 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 

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


Re: Cutting a deck of cards

2013-06-01 Thread Lee Crocker

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

Doing a random thing to a random thing usually *does* lower entropy when
the "random" things are actually deterministic algorithms that may have 
unexpected correlations. That's why you don't write your own PRNG unless
you have a very good understanding of the math.

If you are shuffling the deck with, say, numbers from random.org (which uses 
atmospheric noise), then cutting the deck afterward will have precisely 0 
effect, since the (51 * 52!) possible outcomes include 51 copies of each of the 
52! orderings, and so the odds of each end up the same. But if you're choosing 
the cutpoint by getting a value from the same PRNG you used to shuffle, there 
might very well be a correlation that makes some arrangements more likely
than others.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Changing filenames from Greeklish => Greek (subprocess complain)

2013-06-01 Thread Νικόλαος Κούρας
Τη Σάββατο, 1 Ιουνίου 2013 6:44:36 μ.μ. UTC+3, ο χρήστης Νικόλαος Κούρας έγραψε:
> /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 =  '/opt/python3/lib/python3.3/subprocess.py'>, subprocess.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 = , retcode 
> = 1, process = , process.args = 
> '/home/nikos/public_html/cgi-bin/files.py', output = b'Content-type: 
> text/html; charset=utf-8\n\n 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\n 74: surrogates not allowed\n\n-->\n\n' 
> 
>   returncode = 1 
> 
>   with_traceback =  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?

i tried encode and decode

elif page.endswith('.py'):
htmldata = subprocess.check_output( '/home/nikos/public_html/cgi-bin/' + 
page )
template = htmldata.decode('utf-8') + counter

bu still same error when i rename a filename with greek letters.

Any ideas? is this a bug?
-- 
http://mail.python.org/mailman/listinfo/python-list