Re: Most discussion on comp.lang.python is about developing with Python

2013-11-14 Thread Antoon Pardon
Op 14-11-13 00:48, Steven D'Aprano schreef:
> On Wed, 13 Nov 2013 15:35:56 -0500, bob gailer wrote:
> 
>> Is there a moderator for this list?
> 
> Sadly no.
> 
>  
>> Is there some other place for discussions that are completely OT and
>> also full of flames?
> 
> Yes, there is private email. Unfortunately private email doesn't give the 
> culprits the audience that they desire.
> 
>> Or would you be willing to stop the bashing? I don't see that it helps
>> anyone, and could be very offputting to other newbies.
> 
> That's what I have been saying for a long time. I believe that whatever 
> negative effect Nikos the help-vampire is having, it is long ago 
> overwhelmed by the negative of the anti-Nikos vigilantes.

But the spoon feeders refuse to acknowledge their own role in this.

> Fortunately, Nikos appears to pay absolutely no attention to any thread 
> which isn't about him. So if you avoid threads started by him, you'll 
> miss the worst of it.
> 
> As a community, it is difficult to balance the conflicting needs here. If 
> we ignore Nikos completely, we appear unfriendly and indifferent to those 
> asking for help. If we answer his questions, we encourage him to post. It 
> is hard to find the right balance, if there even is a right balance, and 
> people can have differing ideas of what that right balance is.

This balance is less hard as you seem to think. Anyone who has been in
the care sector has probably been in contact with the difference between
helping someone and saving someone. The first is trying to empower
someone so that he can handle as many situations as posibible himself.
The second is that you make the problems of the other person your own
problems and you try to solve them for him.

The purpose is to help, not to save. And those that try to save
generally are not very popular because they effectively sabotage
the attempts to help and set the expectations of the client too
high.

> But it is clear from the last few months that abusive, aggressive posts 
> don't help anyone -- they don't set a good tone for the group, they put 
> off newcomers, and they do absolutely nothing to discourage Nikos. Please 
> consider this a request to the community, ignore Nikos if you like, 
> answer his questions if you must, but please keep the abusive posts off-
> list. They aren't helping.

If you care for the community and want to avoid frustrating others as
much as possible then don't spoon feed Nikos. It is equally clear from
the last few month they don't help anyone either. They frustrate a
significant number of members because it encourages Nikos in his
destructive behaviour. Continuing to spoon feed Nikos will only make
the frustration levels rise until they reach a level where someone
will feel the need to vent.

So if you can't resist wanting to help.

Don't answer or do his work for him. Give him the information he needs
to work it out himself, preferably refer him to the documentation.

-- 
Antoon Pardon
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: chroot to install packages

2013-11-14 Thread Himanshu Garg
I have done it but having a problem.

I have written a script

os.chroot("/lxc/test_container/rootfs")
subprocess.call(["apt-key", "add", "/root/package.key"])
subprocess.call(["apt-get", "update"])

os._exit(0)

Now, this script is working properly, entering the chroot jail and adding the 
apt key, but when the "apt-get update" command runs, it starts but throws me an 
error:
"E: Unable to change to (unreachable)/lxc/test_container/ - chdir (2: No such 
file or directory)"

However, when I manually chroot to "/lxc/test_container/rootfs" and run the 
update command, then it works perfectly with no errors. 

Why the apt-get update command require to go to my "/lxc/test_container" when 
run in script.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: chroot to install packages

2013-11-14 Thread Chris Angelico
On Thu, Nov 14, 2013 at 8:29 PM, Himanshu Garg  wrote:
> I have written a script
>
> os.chroot("/lxc/test_container/rootfs")
> subprocess.call(["apt-key", "add", "/root/package.key"])
> subprocess.call(["apt-get", "update"])
>
> os._exit(0)
>
> Now, this script is working properly, entering the chroot jail and adding the 
> apt key, but when the "apt-get update" command runs, it starts but throws me 
> an error:
> "E: Unable to change to (unreachable)/lxc/test_container/ - chdir (2: No such 
> file or directory)"

I'm not certain, but this might be due to chrooting without changing
directory. Unless os.chroot() does it for you, you'll want to
os.chdir("/") immediately afterwards. In any case, it's worth a try.

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


Re: chroot to install packages

2013-11-14 Thread Himanshu Garg
> os.chdir("/") immediately afterwards. In any case, it's worth a try.
> ChrisA

Very thanks. the trick worked.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyMyth: Global variables are evil... WRONG!

2013-11-14 Thread unknown
On Thu, 14 Nov 2013 14:29:41 +1100, Chris Angelico wrote:

> On Thu, Nov 14, 2013 at 2:22 PM, Rick Johnson
>  wrote:
>> Yeah, a "global" keyword that extends access ONLY as far as module
>> level scope -- hardly a *true* global.
> 
> I have yet to see any language that gives true globals. At very best,
> they're just process-wide! Honestly. How am I supposed to write code
> that accesses variables running on my New York server?
> 
> Now, of course, if I had a server on Mars, that would be completely
> different. They're only globals, after all.
> 
> ChrisA

+ networking computers on Mars is impossible (with TCP/IP at least)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Trying tcompile an use the Python 3.4a

2013-11-14 Thread Ferrous Cranus

Στις 14/11/2013 2:54 πμ, ο/η Johannes Findeisen έγραψε:

On Thu, 14 Nov 2013 00:00:04 +0200
Ferrous Cranus wrote:


Στις 13/11/2013 11:56 μμ, ο/η Mark Lawrence έγραψε:






But i have gone to the link and did what it said and it didn't proved
usefull thats why i re-ask.


Try looking for a package named "setuptools". I think that is the
package you are missing for installing pip. I don't know anything about
the current CentOS release so may it will not be available via yum.

Good luck!

Regards,
Johannes






i will but i must tell you that i had

'yum groupinstall "development tools"'

i did this before even installing Python 3.4a
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-14 Thread Ferrous Cranus

Στις 13/11/2013 11:46 μμ, ο/η Ferrous Cranus έγραψε:

root@secure:~/lib64# ls -al | grep libkey

lrwxrwxrwx 1 root root 20 Jun 22 2012 libkeyutils.so.1 ->
libkeyutils.so.1.3.0*
-rwxr-xr-x 1 root root 10192 Jun 22 2012 libkeyutils.so.1.3*
-rwxr-xr-x 1 root root 32920 Jun 22 2012 libkeyutils.so.1.3.0*

root@secure:~/lib64# rpm -qf libkeyutils.so.1.3.0
file /lib64/libkeyutils.so.1.3.0 is not owned by any package



It appears that my server has been compromised with a malicious payload
designed to sniff for and steal server passwords.

This must have happened when i was handling my root passwords out in the
open.

Served me well.




Can somebody explain to me why there is so many failed attempts to login 
into my linux server under various user accounts?


http://i.imgur.com/5PaZAWu.png

I mean is this some normal background radiation of the Internet or is 
something directed to me?


Does this happen on your servers at this extend too?
--
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-14 Thread Alister
On Thu, 14 Nov 2013 12:46:29 +0200, Ferrous Cranus wrote:
>> This must have happened when i was handling my root passwords out in
>> the open.
>>
>> Served me well.
> 
At least you seem to be learning this lesson
> 
> 
> Can somebody explain to me why there is so many failed attempts to login
> into my linux server under various user accounts?
> 
> http://i.imgur.com/5PaZAWu.png
> 
> I mean is this some normal background radiation of the Internet or is
> something directed to me?
> 
> Does this happen on your servers at this extend too?

any open ports on the internet are likely to attract attention of the 
'Black Hats'
this is why you have been advised to check your firewall settings
you should only expose the ports that are absolutely necessary

for a web server these would be 80 & 443

currently you have many other services also open that probably should not 
be.
if you check the logs for those services you will probably find even more 
login attempts (I hope they have failed)





-- 
Paranoid schizophrenics outnumber their enemies at least two to one.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: To whoever hacked into my Database

2013-11-14 Thread Ferrous Cranus

Στις 14/11/2013 2:32 μμ, ο/η Alister έγραψε:

On Thu, 14 Nov 2013 12:46:29 +0200, Ferrous Cranus wrote:

This must have happened when i was handling my root passwords out in
the open.

Served me well.



At least you seem to be learning this lesson



Can somebody explain to me why there is so many failed attempts to login
into my linux server under various user accounts?

http://i.imgur.com/5PaZAWu.png

I mean is this some normal background radiation of the Internet or is
something directed to me?

Does this happen on your servers at this extend too?


any open ports on the internet are likely to attract attention of the
'Black Hats'
this is why you have been advised to check your firewall settings
you should only expose the ports that are absolutely necessary

for a web server these would be 80 & 443

currently you have many other services also open that probably should not
be.
if you check the logs for those services you will probably find even more
login attempts (I hope they have failed)



Yes i have more ports open as 'nmap' reports but don't forget that i'm 
running cPanel for my customers, hence more ports need to be opened for 
cPanel and WHM use, let alone mail and sshd.


But the response wasn't clear to me.
Ia this randomly normal background Internet radiation or some personal 
directed attacks?



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


Re: To whoever hacked into my Database

2013-11-14 Thread Robert Kern

On 2013-11-14 13:24, Ferrous Cranus wrote:


But the response wasn't clear to me.
Ia this randomly normal background Internet radiation or some personal directed
attacks?


We don't know. This is not the appropriate forum for such questions. Please find 
a different forum for your server administration questions. Try this one:


  http://serverfault.com/

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Re: To whoever hacked into my Database

2013-11-14 Thread Chris Angelico
On Fri, Nov 15, 2013 at 12:24 AM, Ferrous Cranus  wrote:
> But the response wasn't clear to me.
> Ia this randomly normal background Internet radiation or some personal
> directed attacks?

This is not a Python question. You have to judge for yourself whether
the antagonism you've created here and elsewhere has merited a
directed attack, or if it's likely to be just drive-by attacks.
Computer security is a field on which we could discourse for hours...
but not on this list unless it's particularly Python-related.

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


Odd msg received from list

2013-11-14 Thread Verde Denim
I got an odd message this morning from the list telling me that my
account was de-activated due to excessive bounces. I've only sent a
handful of messages to this board, but do read an awful lot of the posts
in order to learn more about the language. The message also listed my
account password, which I found odd. Has anyone else received a message
like this?

-- 
Regards

Jack
Boston Tea Party, Coercive Acts, Powder Alarm, Revolution
Lessons (Mistakes) not learned are bound to be repeated.

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


Re: Trying tcompile an use the Python 3.4a

2013-11-14 Thread Nick the Gr33k

Will someone please tell me how to install 'pip'

My website is not working because modules are missing and the only way i 
can install them is by installing python's module manager 'pip'


but 'yum install python-pip' fails.

How would i install the damn thing?

These action should be done via package managers but i wasn't ven able 
to install python 3.4a like that, i had to compile it form source when 
the easy thing to do was "yum install python3"


what wrong with this 'yum' manager?
--
https://mail.python.org/mailman/listinfo/python-list


Re: Odd msg received from list

2013-11-14 Thread Joel Goldstick
On Thu, Nov 14, 2013 at 8:53 AM, Verde Denim  wrote:
> I got an odd message this morning from the list telling me that my
> account was de-activated due to excessive bounces. I've only sent a
> handful of messages to this board, but do read an awful lot of the posts
> in order to learn more about the language. The message also listed my
> account password, which I found odd. Has anyone else received a message
> like this?
>
> --
> Regards
>
> Jack
> Boston Tea Party, Coercive Acts, Powder Alarm, Revolution
> Lessons (Mistakes) not learned are bound to be repeated.
>
> --
> https://mail.python.org/mailman/listinfo/python-list

I got the same message.  It hasn't happened to me lately but I think
this also happened maybe a couple of years ago.

-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Odd msg received from list

2013-11-14 Thread Chris Angelico
On Fri, Nov 15, 2013 at 12:53 AM, Verde Denim  wrote:
> I got an odd message this morning from the list telling me that my
> account was de-activated due to excessive bounces. I've only sent a
> handful of messages to this board, but do read an awful lot of the posts
> in order to learn more about the language. The message also listed my
> account password, which I found odd. Has anyone else received a message
> like this?

Yes, I did too. I don't think it has anything to do with the number of
posts you make; it'll be to do with the number that get sent to you,
and it looks like it may be something to do with gmail. I tossed an
email to the list-owner address and it's being looked into; you'll
probably need to mark your address as active again. (In case you
haven't yet done that, I'm doing something I almost never do and
including the OP in the To: list. Please don't take this as a
precedent; normally, just reply to the list and let the sender get a
copy through that.)

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


Re: Trying tcompile an use the Python 3.4a

2013-11-14 Thread Chris Angelico
On Fri, Nov 15, 2013 at 12:50 AM, Nick the Gr33k  wrote:
> These action should be done via package managers but i wasn't ven able to
> install python 3.4a like that, i had to compile it form source when the easy
> thing to do was "yum install python3"
>
> what wrong with this 'yum' manager?

With yum you get whatever yum is carrying. If you build from source,
you're on your own. You chose to build from source. Now you're on your
own. Have fun. Get to know what it takes to run your own system,
without the package manager's help (or rather, without as much of the
package manager's help). These are Linux system administration
questions, NOT Python questions.

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


Re: To whoever hacked into my Database

2013-11-14 Thread Alister
On Thu, 14 Nov 2013 15:24:32 +0200, Ferrous Cranus wrote:

> Στις 14/11/2013 2:32 μμ, ο/η Alister έγραψε:
>> On Thu, 14 Nov 2013 12:46:29 +0200, Ferrous Cranus wrote:
 This must have happened when i was handling my root passwords out in
 the open.

 Served me well.
>>>
>> At least you seem to be learning this lesson
>>>
>>>
>>> Can somebody explain to me why there is so many failed attempts to
>>> login into my linux server under various user accounts?
>>>
>>> http://i.imgur.com/5PaZAWu.png
>>>
>>> I mean is this some normal background radiation of the Internet or is
>>> something directed to me?
>>>
>>> Does this happen on your servers at this extend too?
>>
>> any open ports on the internet are likely to attract attention of the
>> 'Black Hats'
>> this is why you have been advised to check your firewall settings you
>> should only expose the ports that are absolutely necessary
>>
>> for a web server these would be 80 & 443
>>
>> currently you have many other services also open that probably should
>> not be.
>> if you check the logs for those services you will probably find even
>> more login attempts (I hope they have failed)
> 
> 
> Yes i have more ports open as 'nmap' reports but don't forget that i'm
> running cPanel for my customers, hence more ports need to be opened for
> cPanel and WHM use, let alone mail and sshd.
> 
> But the response wasn't clear to me.
> Ia this randomly normal background Internet radiation or some personal
> directed attacks?

As others have said this is no longer python related & i am not going to 
answer any further.





-- 
The brain is a wonderful organ; it starts working the moment you get up
in the morning, and does not stop until you get to work.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Odd msg received from list

2013-11-14 Thread Roy Smith
In article ,
 Verde Denim  wrote:

> I got an odd message this morning from the list telling me that my
> account was de-activated due to excessive bounces. I've only sent a
> handful of messages to this board, but do read an awful lot of the posts
> in order to learn more about the language. The message also listed my
> account password, which I found odd. Has anyone else received a message
> like this?

This sounds like a variation of a classic phishing scam.  You get an 
email which looks official, telling you that some account you have has 
been suspended because you need to verify some information.  The wording 
of the message is always vague about exactly what account this is.

Don't click on any of the links.  At best, they're harvesting email 
addresses.  At worst, they're harvesting personal information which can 
be used for identity theft, credit card fraud, or all sorts of 
malfeasance.

Here's some recent examples from my junk mailbox:

> Attention User;
> Your email Quota is almost exceeded. We are currently doing a maintenance on 
> our server. Please, Visit page below to update your account and avoid losing 
> your inbox.
>  
> [link elided]
> 
> Thank you,
> Technical Team

and another:

> Dear Client,
> 
> 
> This is an automatic message by the system to let you know that you have to 
> confirm your account information within 48 hours.
> Your account has been frozen temporarily in order to protect it.
> The account will continue to be frozen until it is approved And Validate Your 
> Account Information.
> Once you have updated your account records, your information will be 
> confirmed and your account will start to work as normal once again.
>  This will help protect you in the future. The process does not take more 
> than 3 minutes.
> 
> To proceed to confirm your account information please click on the link below 
> and follow the instructions that will be required.
>  
> Click Here To Verfiy Your Account info
>  
> © 2013 All rights reserved.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: writing fortran equivalent binary file using python

2013-11-14 Thread Oscar Benjamin
On 14 November 2013 00:53, Sudheer Joseph  wrote:
> My trial code with Python (data is read from file here)
>
> from netCDF4 import Dataset as nc
> import numpy as np
> XFIN=0.0,YFIN=-90.0,NREC=1461,DXIN=0.5;DYIN=0.5
> TITLE="NCMRWF 6HOURLY FORCING MKS"
> nf=nc('ncmrwf_uv.nc')
> ncv=nf.variables.keys()
> IWI=len(nf.variables[ncv[0]])
> JWI=len(nf.variables[ncv[1]])
> WDAY=nf.varlables[ncv[2]][0:NREC]
> U=nf.variables[ncv[3]][0:NREC,:,:]
> V=nf.variables[ncv[4]][0:NREC,:,:]
> bf=open('ncmrwf_uv.bin',"wb")
> f.write(TITLE)
> f.write(IWI,JWI,XFIN,YFIN,DXIN,DYIN,NREC,WDAY)
> for i in np.arange(0,NREC):
> f.write(U[i,:,:],V[i,:,:])
> f.close()
>
> But the issue is that f.write do not allow multiple values( it allows one by 
> one so throws an error with above code ) on same write statement like in the 
> fortran code. experts may please advice if there a solution for this?

Can you just call write twice? e.g.:

f.write(U[i,:,:])
f.write(V[i,:,:])


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


Program Translation - Nov. 14, 2013

2013-11-14 Thread E.D.G.

Posted by E.D.G.  on November 14, 2013

  In view of the fact that I mentioned the following project in both 
Perl and Python Newsgroup notes and did not get any hostile responses I am 
going to take a chance and mention it again in all three of these 
Newsgroups.  People posting responses might want to do that in just one 
Newsgroup.  I will check all three for responses for a few weeks.



  This is the Web address for an interesting and apparently unique 
computer program written using FORTRAN 77.  As far as I am aware, it has 
never been translated to newer language.  There is a BASIC version that was 
apparently written around the same time as the FORTRAN version.


http://www.bfo.geophys.uni-stuttgart.de/etgtab.html

  What a number of us would like to do is obtain a copy of the program 
that is written in a newer language so that we can then merge it with the 
programs available through the following Web page.  The new programs would 
then be made available as freeware programs to researchers around the world. 
This indirect link is being used in an effort to keep Web site related spam 
to a minimum.  I don't collect credits by having people visit that 
(indirect) Web site.


http://www.freewebs.com/eq-forecasting/RH.html

  If there are any programmers who might be interested in such a 
translation effort then I would be interested in hearing from them.


  Etgtab generates Solid Earth Tide and ocean tide data for any 
location on or inside the planet.  I am not aware of any other freeware 
program that can do that.


  SunGP available at that second Web site is the only freeware program 
that I know about that generates what are sometimes referred to as subsolar 
and sublunar types of data.  The download code was written using True BASIC.


  If you draw a line between the centers of the sun and the Earth then 
the place where that line crosses the surface of the Earth is the subsolar 
location.  The sublunar location is the same type of thing.  The SunGP 
program code is also available in Perl code, but not through any Web sites.



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


Re: Odd msg received from list

2013-11-14 Thread MRAB

On 14/11/2013 13:53, Verde Denim wrote:

I got an odd message this morning from the list telling me that my
account was de-activated due to excessive bounces. I've only sent a
handful of messages to this board, but do read an awful lot of the posts
in order to learn more about the language. The message also listed my
account password, which I found odd. Has anyone else received a message
like this?


I'm wondering if it has anything to do with spam filtering.

If you're using a spam filter (it might be offered as a feature by your
ISP) that bounces instead of just deleting, and the spam looks like it
comes from or through the list, then the list would receive those
bounces without you being aware of it.

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


Re: Odd msg received from list

2013-11-14 Thread Tim Golden
On 14/11/2013 13:53, Verde Denim wrote:
> I got an odd message this morning from the list telling me that my
> account was de-activated due to excessive bounces. I've only sent a
> handful of messages to this board, but do read an awful lot of the posts
> in order to learn more about the language. The message also listed my
> account password, which I found odd. Has anyone else received a message
> like this?
> 

I can confirm that your account has been suspended because bounces. That
is: as a moderator, I can view your record in the interface and see that
it has been tagged as such. I can't tell you any more, I'm afraid; I've
just emailed the other list owners to see if someone has a handle on why
this has happened to a number of @gmail.com users today.

TJG
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Odd msg received from list

2013-11-14 Thread Chris Angelico
On Fri, Nov 15, 2013 at 1:11 AM, Roy Smith  wrote:
> In article ,
>  Verde Denim  wrote:
>
>> I got an odd message this morning from the list telling me that my
>> account was de-activated due to excessive bounces. I've only sent a
>> handful of messages to this board, but do read an awful lot of the posts
>> in order to learn more about the language. The message also listed my
>> account password, which I found odd. Has anyone else received a message
>> like this?
>
> This sounds like a variation of a classic phishing scam.  You get an
> email which looks official, telling you that some account you have has
> been suspended because you need to verify some information.  The wording
> of the message is always vague about exactly what account this is.
>
> Don't click on any of the links.  At best, they're harvesting email
> addresses.  At worst, they're harvesting personal information which can
> be used for identity theft, credit card fraud, or all sorts of
> malfeasance.
>

I agree in general, but I happen to be pretty familiar with Mailman
alerts, and this one was genuine. Also, it pointed to what does appear
to be the right address (mail.python.org). There's definitely
something going around that's causing problems for gmail users; maybe
spam is getting bounced/rejected instead of being dropped?

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


Re: Odd msg received from list

2013-11-14 Thread Chris Angelico
On Fri, Nov 15, 2013 at 1:24 AM, MRAB  wrote:
> I'm wondering if it has anything to do with spam filtering.
>
> If you're using a spam filter (it might be offered as a feature by your
> ISP) that bounces instead of just deleting, and the spam looks like it
> comes from or through the list, then the list would receive those
> bounces without you being aware of it.

I hadn't read your post when I typed up my own. You said everything I
was saying about spam, only better and sooner. :)

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


Re: Odd msg received from list

2013-11-14 Thread Joost Molenaar
On Thu, Nov 14, 2013 at 2:53 PM, Verde Denim  wrote:
> Has anyone else received a message like this?

I did too. It seems to me that Gmail's spam filter might have been overly
enthusiastic, but the only way to find out is to look at the bounces
that the list
software received.

Yesterday I also received a warning from the debian-laptop mailing list program.

Joost
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: writing fortran equivalent binary file using python

2013-11-14 Thread Sudheer Joseph
Thank you,
  But it wont allow to write it in unformatted way so
that the fortran code can read

with

open(11,file="input.bin")
read(11) IWI,JWI,XFIN,YFIN,DXIN,DYIN,NREC,WDAY

with best regards,
sudheer


On Thu, Nov 14, 2013 at 7:48 PM, Oscar Benjamin
wrote:

> On 14 November 2013 00:53, Sudheer Joseph  wrote:
> > My trial code with Python (data is read from file here)
> >
> > from netCDF4 import Dataset as nc
> > import numpy as np
> > XFIN=0.0,YFIN=-90.0,NREC=1461,DXIN=0.5;DYIN=0.5
> > TITLE="NCMRWF 6HOURLY FORCING MKS"
> > nf=nc('ncmrwf_uv.nc')
> > ncv=nf.variables.keys()
> > IWI=len(nf.variables[ncv[0]])
> > JWI=len(nf.variables[ncv[1]])
> > WDAY=nf.varlables[ncv[2]][0:NREC]
> > U=nf.variables[ncv[3]][0:NREC,:,:]
> > V=nf.variables[ncv[4]][0:NREC,:,:]
> > bf=open('ncmrwf_uv.bin',"wb")
> > f.write(TITLE)
> > f.write(IWI,JWI,XFIN,YFIN,DXIN,DYIN,NREC,WDAY)
> > for i in np.arange(0,NREC):
> > f.write(U[i,:,:],V[i,:,:])
> > f.close()
> >
> > But the issue is that f.write do not allow multiple values( it allows
> one by one so throws an error with above code ) on same write statement
> like in the fortran code. experts may please advice if there a solution for
> this?
>
> Can you just call write twice? e.g.:
>
> f.write(U[i,:,:])
> f.write(V[i,:,:])
>
>
> Oscar
>



-- 
with best regards

Sudheer

**
Dr. Sudheer Joseph

Scientist

INDIAN NATIONAL CENTRE FOR OCEAN INFORMATION SERVICES (INCOIS)
MINISTRY OF EARTH SCIENCES, GOVERNMENT OF INDIA
"OCEAN VALLEY" PRAGATHI NAGAR (BO)
OPP.JNTU, NIZAMPET SO
Andhra Pradesh, India. PIN- 500 090.
TEl:+91-40-23044600(R),Tel:+91-9440832534(Mobile)
Tel:+91-40-23886047(O),Fax:+91-40-23892910(O)
E-mail: [email protected];  [email protected].
Web- http://oppamthadathil.tripod.com
   --* ---
"The ultimate measure of a man is
not where he stands in moments of
comfort and convenience, but where
he stands at times of challenge and
controversy."
Martin Luther King, Jr.
"What we have done for ourselves alone dies with us.
What we have done for others and the world remains and is immortal."
- Albert Pines
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: writing fortran equivalent binary file using python

2013-11-14 Thread Antoon Pardon
Op 14-11-13 01:53, Sudheer Joseph schreef:
> Hi,
>  I need to write a binary file exactly as written by fortran code 
> below to be read by another code which is part of a model which is not 
> advisable to edit.I would like to use python for this purpose as python has 
> mode flexibility and easy coding methods.
>   
>   character(40) :: TITLE="122322242"
>   integer :: IWI,JWI
>   real :: XFIN,YFIN,DXIN=0.5,DYIN=0.5,WDAY(6000)
>   XFIN=0.0,YFIN=-90.0,NREC=1461,DXIN=0.5;DYIN=0.5;IWI=720;JWI=361 
>   real,allocatable,dimension(:,:,:) :: VAR1_VAL
>   real,allocatable,dimension(:,:,:) :: VAR2_VAL
> 
>   open(11,file=outf,form='UNFORMATTED')
>   WRITE(11) TITLE
>   WRITE(11) NX,NY,XFIN,YFIN,DXIN,DYIN,NREC,WDAY
>   write(*,'(A10,2f10.3)') "START=",VAR1_VAL(1,1,1),VAR2_VAL(1,1,1)
>   write(*,'(A10,2f10.3)') "END=",VAR1_VAL(nx,ny,nrec),VAR2_VAL(nx,ny,nrec)
>   do i=1,NREC
>   WRITE(11) VAR1_VAL(:,:,i),VAR2_VAL(:,:,i)
>   WRITE(*,'(2I10,f10.3)') NX,NY,WDAY(i)
>   enddo
> 
> My trial code with Python (data is read from file here)
> 
> from netCDF4 import Dataset as nc
> import numpy as np
> XFIN=0.0,YFIN=-90.0,NREC=1461,DXIN=0.5;DYIN=0.5
> TITLE="NCMRWF 6HOURLY FORCING MKS"
> nf=nc('ncmrwf_uv.nc')
> ncv=nf.variables.keys()
> IWI=len(nf.variables[ncv[0]])
> JWI=len(nf.variables[ncv[1]])
> WDAY=nf.varlables[ncv[2]][0:NREC]
> U=nf.variables[ncv[3]][0:NREC,:,:]
> V=nf.variables[ncv[4]][0:NREC,:,:]
> bf=open('ncmrwf_uv.bin',"wb")
> f.write(TITLE)
> f.write(IWI,JWI,XFIN,YFIN,DXIN,DYIN,NREC,WDAY)
> for i in np.arange(0,NREC):
> f.write(U[i,:,:],V[i,:,:])
> f.close()
> 
> But the issue is that f.write do not allow multiple values( it allows > one 
> by one so throws an error with above code ) on same write statement
> like in the fortran code. experts may please advice if there a solution for 
> this?

That is not the main issue. The python write only works with bytes or
strings, not with floats or ints. So you will have to convert your
numbers using struct. So the question is if you know the byte layout
fortran uses and if you can replicate it with the struct module.

-- 
Antoon Pardon
-- 
https://mail.python.org/mailman/listinfo/python-list


@gmail.com accounts put on hold

2013-11-14 Thread Tim Golden
Several people have reported Mailman messages notifying them of their
subscription being suspended because of bounces.

The notifications are pukka and appear to have resulted from a reaction
by Google's mail servers to messages via this list from an invalid
address at a valid domain.

The Mailman admins have implemented a workaround and have attempted to
reactivate all gmail accounts. Please check your susbcription per the
notification email. If you have any problems, drop a line to
[email protected].

(With thanks to Ralf Hildebrandt who's done all the legwork...)

TJG
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Invalid syntax with print "Hello World"

2013-11-14 Thread johannes . gunz97
Am Donnerstag, 12. März 2009 07:57:11 UTC+1 schrieb Henrik Bechmann:
> obviously total mewbiew:
> 
> My first program in Python Windows
> 
> print "Hello World"
> 
> I select Run/Run Module and get an error:
> 
> Syntax error, with the closing quote highlighted.
> 
> Tried with single quotes as well. Same problem.
> 
> Can someone explain my mistake?
> 
> Thanks,
> 
> - Henrik

thanx
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pypy and ctypes

2013-11-14 Thread Neil Cerutti
On 2013-11-14, Peter Chant  wrote:
> Or is it that - if I keep the code as simple as possible, PyPy
> is about as fast as you can get?

PyPy profiles your code as it runs and creates, using a
just-in-time compiler, highly optimized versions of frequently
run sections. You don't have to declare types or even think about
it; The scheme will work best with code that runs for a
significant amount of time.

cython allows you to declare types, and attempts to create more
efficient code *at compile time* using those type declaration.

Which approach will be better depends on how the code runs and
how clever you are at using cython.

PyPy isn't designed to speed up programs that run for a few
hundred milliseconds and then complete, though it might sometimes
work for that.

-- 
Neil Cerutti
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python 2.7.x on MacOSX: failed dlopen() on .so's

2013-11-14 Thread Paul Smith
On Wed, 2013-11-13 at 23:06 -0800, Ned Deily wrote:
> On Nov 13, 2013, at 17:24 , Paul Smith  wrote:
> > I'm discovering that this is tricky.  I don't want to bring OS wars into
> > it, but this kind of thing is so simple and just works on GNU/Linux.  I
> > guess I've been spoiled :-).
> 
> Well, if you are building from scratch, you would likely run into some
> of the same issues on Linux systems, too.  There are many variations
> in configurations that are mutually incompatible.

Possibly.  However as long as you're using basic system libraries and
not higher-level stuff like GTK etc., you can compile on an older
version of Linux (say, Red Hat EL 5 or so) and the result will run
without any problems on pretty much any distribution, even the newest
ones: Red Hat, Ubuntu, Debian, Suse, etc. etc.  We do this regularly,
for production code we ship to customers.  About the only "basic"
libraries that cause problems are libssl/libcrypto... the openssl folks
just don't seem to care much about this issue.

> > I'm somewhat dreading my next effort after MacOS: the same thing, on
> > Windows :-/.
> > 
> > And another task, which seems like it will be fun: building GDB on
> > MacOSX with Python support enabled...
> 
> Keep in mind that on newer OS X releases, Apple no longer ships gcc or
> gdb.  The standard compiler is clang and it has its own debuggers.

Yes, I'm aware.  Very frustrating.  We have a large set of specialized
macros, both in native GDB and in Python using GDB's extension, that are
invaluable for debugging our code.  I'm not thrilled about the idea of
trying to get all that working in lldb as well.  So we're going to stick
with GDB, building it ourselves, until it no longer works at all.  At
that point we'll decide how to proceed.

> > Hm, that's an idea.  I don't HAVE to build Python myself, actually, I
> > just need (a) it to be relocatable, and (b) to add these extra modules
> > to it so I can use it across systems without installing them
> > individually by hand.
> 
> I'm not sure I know what you mean by "relocatable".  Like the
> third-party package manager solutions, the python.org installers place
> the Pythons they install in fixed locations (under /Library/Frameworks
> with links from /usr/local/bin) but one that does not conflict with
> any system files, including the Apple-supplied system Pythons.

By relocatable I mean "runnable from any location"; i.e., not fixed.  I
have a wrapper around the Python executable that can compute the correct
root directory and set any environment variables or add flags or
whatever might be needed.

Basically I have a large number of test systems and a set of test suites
that are all written in Python, and I need to be able to distribute the
same version of Python plus a specific set of additional modules across
all those systems to be sure they all have the same environment.  Plus
the set of systems changes (new systems added/old ones removed)
regularly.  I'm handling this by checking in the Python distribution
plus modules into a "tools" Git repository, then cloning it on each
system.  However, I have no special privileges on these systems (so I
can't modify any system locations such as /usr/local) and I can't
control what user account will be running the tests (so the user's home
directory, where the tools repository is cloned, is not constant across
the systems).

I have this working on Linux with very little effort.  Now I'm trying to
get the same result on MacOSX.

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


Converting hex data to image

2013-11-14 Thread Shyam Parimal Katti
I am implementing an authentication system(in Django) using LDAP as the
backend(django-auth-ldap). When we fetch the data from the LDAP server for
a particular valid user, the data associated with the user contains the
thumbnail photo in hex representation. E.x.:

[('CN=XX,OU=Users,OU=Accounts,DC=test,DC=com', {'msExchBlockedSendersHash':
['\xce'], 'mailNickname': ['test_user'], 'primaryGroupID': ['513'],
'logonCount': ['1021'], *thumbnailPhoto:
['\xef\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00`\x00`\x00\x00\xff\xdb\x00C\x00\x08\x06\x06\x07\x06\x05\x08\x07\x07\x07\t\t\x08\n\x0c\x14\r\x0c.']*..
]

How do I convert the hex data for an image to the actual image?

Any help would be greatly appreciated.


Thanks,
Shyam
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Odd msg received from list

2013-11-14 Thread Gisle Vanem

"Chris Angelico"  wrote:


I agree in general, but I happen to be pretty familiar with Mailman
alerts, and this one was genuine. Also, it pointed to what does appear
to be the right address (mail.python.org). There's definitely
something going around that's causing problems for gmail users;


It happended to me too. And I'm a Yahoo user. I clicked the MailMan
confirmation link and all emails seems to be received now (comparing
to what's on the NNTP group).

--gv

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


Re: @gmail.com accounts put on hold

2013-11-14 Thread Matty Sarro
Whew, thank you for your hard work.
I was really worried I would stop getting emails about Islam, Hacking
Databases, and the Ruby Community ;)

Kidding, kidding. Great job with the fast workaround!


On Thu, Nov 14, 2013 at 10:05 AM, Tim Golden  wrote:

> Several people have reported Mailman messages notifying them of their
> subscription being suspended because of bounces.
>
> The notifications are pukka and appear to have resulted from a reaction
> by Google's mail servers to messages via this list from an invalid
> address at a valid domain.
>
> The Mailman admins have implemented a workaround and have attempted to
> reactivate all gmail accounts. Please check your susbcription per the
> notification email. If you have any problems, drop a line to
> [email protected].
>
> (With thanks to Ralf Hildebrandt who's done all the legwork...)
>
> TJG
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Converting hex data to image

2013-11-14 Thread Tim Golden
On 14/11/2013 15:32, Shyam Parimal Katti wrote:
> I am implementing an authentication system(in Django) using LDAP as the
> backend(django-auth-ldap). When we fetch the data from the LDAP server
> for a particular valid user, the data associated with the user contains
> the thumbnail photo in hex representation. E.x.:
> 
> [('CN=XX,OU=Users,OU=Accounts,DC=test,DC=com',
> {'msExchBlockedSendersHash': ['\xce'], 'mailNickname': ['test_user'],
> 'primaryGroupID': ['513'], 'logonCount': ['1021'], *thumbnailPhoto:
> ['\xef\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00`\x00`\x00\x00\xff\xdb\x00C\x00\x08\x06\x06\x07\x06\x05\x08\x07\x07\x07\t\t\x08\n\x0c\x14\r\x0c.']*
> .. ]
> 
> How do I convert the hex data for an image to the actual image?

Well, the first few bytes suggest that it's a JPEG, so save the bytes as
"something.jpg" and there you have it: an actual image.

Alternatively, you could load it into PIL [1] / Pillow [2] and
manipulate it as you see fit...

TJG

[1] http://www.pythonware.com/products/pil/
[2] https://pypi.python.org/pypi/Pillow/


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


Re: Most discussion on comp.lang.python is about developing with Python

2013-11-14 Thread Nobody
On Wed, 13 Nov 2013 15:35:56 -0500, bob gailer wrote:

> I joined a week or so ago.
> 
> The subject line was copied from the description of comp.lang.python aka 
> [email protected].
> 
> I am very disappointed to see so much energy and bandwidth going to 
> conversations that bash individuals.
> 
> Is there a moderator for this list?

"list"? As you have already noted, the mailing list is bi-directionally
gatewayed to a usenet group. The advantage of usenet is that anyone can
read or post without having to sign up. That's also its disadvantage.

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


Re: ogg2mp3 utility?

2013-11-14 Thread Tim Johnson
* Tim Johnson  [131113 17:06]:
> I've written an application that does some audio file conversions.
> 
> I use mutagen for some of the mp3 file manipulation, but to convert
> ogg files to mp3 format I've been using subprocess to run the
> ogg2mp3 perl utility.  (available from http://marginalhacks.com/) by
> David Madison.
> 
> It's a "spot on" great app, but I would like to be able to "keep it
> all one codebase".
> 
> Are there any python utility that anyone could recommend?

  I've downloaded ogg2mp3.py (http://emptybits.com/ogg2mp3/ogg2mp3)
  by Darren Stone http://bitmason.com, I've compared two
  conversions.

  Thus far, the perl utility produces a clearer playback, but I have
  not yet played with the options available from the python script.

  Both scripts rely on oggdec, ogginfo and lame.
  On the mac available through macports, available on other *nixes as
  well.

  If anyone is interested, I'd welcome feedback on the python script
  above and I will fiddle with it (not being an audio expert) to see
  if I can get the playback improved.

  I've looked at pymedia also. Have not tested it.

  FYI.cheers

-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com, http://www.tj49.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Program Translation - Nov. 14, 2013

2013-11-14 Thread mecej4

On 11/14/2013 8:18 AM, E.D.G. wrote:

Posted by E.D.G.  on November 14, 2013

   In view of the fact that I mentioned the following project in
both Perl and Python Newsgroup notes and did not get any hostile
responses I am going to take a chance and mention it again in all three
of these Newsgroups.  People posting responses might want to do that in
just one Newsgroup.  I will check all three for responses for a few weeks.


   This is the Web address for an interesting and apparently unique
computer program written using FORTRAN 77.  As far as I am aware, it has
never been translated to newer language.  There is a BASIC version that
was apparently written around the same time as the FORTRAN version.

http://www.bfo.geophys.uni-stuttgart.de/etgtab.html

   What a number of us would like to do is obtain a copy of the
program that is written in a newer language so that we can then merge it
with the programs available through the following Web page.  The new
programs would then be made available as freeware programs to
researchers around the world. This indirect link is being used in an
effort to keep Web site related spam to a minimum.  I don't collect
credits by having people visit that (indirect) Web site.

http://www.freewebs.com/eq-forecasting/RH.html

   If there are any programmers who might be interested in such a
translation effort then I would be interested in hearing from them.

   Etgtab generates Solid Earth Tide and ocean tide data for any
location on or inside the planet.  I am not aware of any other freeware
program that can do that.

   SunGP available at that second Web site is the only freeware
program that I know about that generates what are sometimes referred to
as subsolar and sublunar types of data.  The download code was written
using True BASIC.

   If you draw a line between the centers of the sun and the Earth
then the place where that line crosses the surface of the Earth is the
subsolar location.  The sublunar location is the same type of thing.
The SunGP program code is also available in Perl code, but not through
any Web sites.


If this old program is to be translated or reused, do use this 
opportunity to fix some bugs in the program.


The data file contains data for 1200 waves, but the program computes 
results for 1212 waves. For waves 1201 to 1212, the program ends up 
calculating results based on uninitialized data. Whether or not this 
affects the validity of the final output results is something that 
someone knowledgeable about the field of application has to judge.


-- mecej4
--
https://mail.python.org/mailman/listinfo/python-list


Re: Automation

2013-11-14 Thread Mark Lawrence

On 14/11/2013 03:56, [email protected] wrote:

I apologize again for my bad english and any inconvenience that I have 
generated.



I do wish that people would stop apologising for poor English, it's an 
extremely difficult language.  IIRC there are eight different ways of 
pronouncing the vowel combination au.  Whatever happened to "There 
should be one-- and preferably only one --obvious way to do it."? :)


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: PyMyth: Global variables are evil... WRONG!

2013-11-14 Thread Rick Johnson
On Wednesday, November 13, 2013 11:50:40 PM UTC-6, Steven D'Aprano wrote:
> On Wed, 13 Nov 2013 19:45:42 -0800, Rick Johnson wrote:
> > On Wednesday, November 13, 2013 8:45:16 PM UTC-6, Steven D'Aprano wrote:
> >>  A fully-auto machine gun with a hair-trigger and no
> >> safety is no  different from a single-barrel shotgun with a safety and
> >> a trigger lock!  You can blow your foot off with both!
> > Yes. But in the case of the shotgun you'd have to find the key, unlock
> > the trigger, unset the safety, and aim REALLY well... because your only
> > getting off one shot, and if you miss or only wound me, i've got that
> > full auto machine gun with hair trigger and no safety -- i won't need to
> > live very long to return the favor. >:)
> I think you're missing the point that we're talking about the coder 
> shooting themselves in the foot, not Gunfight At The OK Corral. There's 
> no "favour" to return. 

And you missed the point that i took your straw-man and
converted him into satire. You owe me gratitude for
*politely* ignoring your repeated logical fallacies.

> Yes, the point is that process-wide global variables are
> demonstrated by 50+ years of programming experience to be
> best avoided (in general -- there are caveats and
> exceptions of course). We're talking about probably
> millions of person-hours of experience leading to the
> conclusion that "globals are harmful".

But yet Python has globals, you just have to *import* them.
But that design is flawed

> It isn't that global variables will leap out of the
> computer and attack you while you sleep,

Funny, that sounds like my argument from earlier. Something
about "gremlins".

> of course, but that in general *its too damn hard* for
> human programmers to write good, reliable, maintainable,
> correct (i.e. bug-free) code using process-wide global
> variables.

Complete FUD. Maybe for you. Not for me.
 
> Global variables are the spaghetti code of namespacing --
> everything is mixed up together in one big tangled mess.

It's a tangled mess if you design it to be a tangled mess. 

> The more global variables you have, the worse the tangle. 

Complete illogic. 

What if all the globals are only accessed
and never mutated? You could have a million globals that never
change (of course they'd technically be constants) and never
suffer a single error from globals EVEN IF your an incompetent
software designer.

> One or two is not too bad. With good conventions for
> encapsulation to limit the amount of tangled, coupled code
> (e.g. naming conventions, or limiting globals to a single
> module at a time by default) the amount of harm can be
> reduced to manageable levels.

> SO now your agreeing that globals are not evil again. I
> positied an anaology in a passed thred that went something
> like this:

ManufacurerA claims his car is the safest on the road.

ManfacturerB drives ManfacturerA's car into a ditch and then
claims ManfacturerA is a liar.

Result: Who is wrong?

> Global variables increases coupling between distant parts
> of the code. I remember a nasty little bug in Windows
> where removing IE stopped copy-and- paste from working
> everywhere. That's a sign of excess coupling between code
> -- there's no logical reason why removing a web browser
> should cause copying text in Notepad to fail.

Do you have link describing this bug? I am not aware of such
bug ,but uh, i would not at all be surprised that windows
could break from removing that gawd awful IE.

Come to think of it, i'll bet it's not even a bug at all,
but a feature to prevent "wise users" from removing IE,
thereby maintaining IE's footprint in the wild. 

Steven, this sounds more like Fascism than "clumsy use of
globals" to me.

But even IF globals are to blame, by removing IE, you have
removed a large chunk of code from a code base that was not
designed for modularity. (We could argue whether or not
windows should allow removal of IE, but ultimately that is
M$ decision)

No developer could possibly forecast every possible "bad
thing" a user might decide to do. Especially when we're
talking about ripping components of the software out
completely.

Do i think IE should be a removal component? HECK YEAH, and
i would have designed it that way. But IS is not my baby, it
belongs to Mr. Gates, and he designs his software any way he
damn well pleases, and you and i can choose not to use it.

Image if someone downloaded Python and just started ripping
out source files willy-nilly because they did not like them
for whatever reason. Then, they came to this list and start
bitching because Python was blowing chunks. And don't give
examples of things that can be ripped out without breaking
Python, because that is germane either.

How would you respond to such complaints? 

Hmm...never thought you'd be agree with Mr. Gates did ya?

> We want to avoid unnecessary coupling: opening your fridge
> door shouldn't flush the toilet.

*KAH-BOOM* (Straw-bomb expodes)(AGAIN!)

> Since global variab

Re: PyMyth: Global variables are evil... WRONG!

2013-11-14 Thread Joel Goldstick
On Thu, Nov 14, 2013 at 12:26 PM, Rick Johnson
 wrote:
> On Wednesday, November 13, 2013 11:50:40 PM UTC-6, Steven D'Aprano wrote:
>> On Wed, 13 Nov 2013 19:45:42 -0800, Rick Johnson wrote:
>> > On Wednesday, November 13, 2013 8:45:16 PM UTC-6, Steven D'Aprano wrote:
>> >>  A fully-auto machine gun with a hair-trigger and no
>> >> safety is no  different from a single-barrel shotgun with a safety and
>> >> a trigger lock!  You can blow your foot off with both!
>> > Yes. But in the case of the shotgun you'd have to find the key, unlock
>> > the trigger, unset the safety, and aim REALLY well... because your only
>> > getting off one shot, and if you miss or only wound me, i've got that
>> > full auto machine gun with hair trigger and no safety -- i won't need to
>> > live very long to return the favor. >:)
>> I think you're missing the point that we're talking about the coder
>> shooting themselves in the foot, not Gunfight At The OK Corral. There's
>> no "favour" to return.
>
> And you missed the point that i took your straw-man and
> converted him into satire. You owe me gratitude for
> *politely* ignoring your repeated logical fallacies.
>
>> Yes, the point is that process-wide global variables are
>> demonstrated by 50+ years of programming experience to be
>> best avoided (in general -- there are caveats and
>> exceptions of course). We're talking about probably
>> millions of person-hours of experience leading to the
>> conclusion that "globals are harmful".
>
> But yet Python has globals, you just have to *import* them.
> But that design is flawed
>
>> It isn't that global variables will leap out of the
>> computer and attack you while you sleep,
>
> Funny, that sounds like my argument from earlier. Something
> about "gremlins".
>
>> of course, but that in general *its too damn hard* for
>> human programmers to write good, reliable, maintainable,
>> correct (i.e. bug-free) code using process-wide global
>> variables.
>
> Complete FUD. Maybe for you. Not for me.
>
>> Global variables are the spaghetti code of namespacing --
>> everything is mixed up together in one big tangled mess.
>
> It's a tangled mess if you design it to be a tangled mess.
>
>> The more global variables you have, the worse the tangle.
>
> Complete illogic.
>
> What if all the globals are only accessed
> and never mutated? You could have a million globals that never
> change (of course they'd technically be constants) and never
> suffer a single error from globals EVEN IF your an incompetent
> software designer.
>
>> One or two is not too bad. With good conventions for
>> encapsulation to limit the amount of tangled, coupled code
>> (e.g. naming conventions, or limiting globals to a single
>> module at a time by default) the amount of harm can be
>> reduced to manageable levels.
>
>> SO now your agreeing that globals are not evil again. I
>> positied an anaology in a passed thred that went something
>> like this:
>
> ManufacurerA claims his car is the safest on the road.
>
> ManfacturerB drives ManfacturerA's car into a ditch and then
> claims ManfacturerA is a liar.
>
> Result: Who is wrong?
>
>> Global variables increases coupling between distant parts
>> of the code. I remember a nasty little bug in Windows
>> where removing IE stopped copy-and- paste from working
>> everywhere. That's a sign of excess coupling between code
>> -- there's no logical reason why removing a web browser
>> should cause copying text in Notepad to fail.
>
> Do you have link describing this bug? I am not aware of such
> bug ,but uh, i would not at all be surprised that windows
> could break from removing that gawd awful IE.
>
> Come to think of it, i'll bet it's not even a bug at all,
> but a feature to prevent "wise users" from removing IE,
> thereby maintaining IE's footprint in the wild.
>
> Steven, this sounds more like Fascism than "clumsy use of
> globals" to me.
>
> But even IF globals are to blame, by removing IE, you have
> removed a large chunk of code from a code base that was not
> designed for modularity. (We could argue whether or not
> windows should allow removal of IE, but ultimately that is
> M$ decision)
>
> No developer could possibly forecast every possible "bad
> thing" a user might decide to do. Especially when we're
> talking about ripping components of the software out
> completely.
>
> Do i think IE should be a removal component? HECK YEAH, and
> i would have designed it that way. But IS is not my baby, it
> belongs to Mr. Gates, and he designs his software any way he
> damn well pleases, and you and i can choose not to use it.
>
> Image if someone downloaded Python and just started ripping
> out source files willy-nilly because they did not like them
> for whatever reason. Then, they came to this list and start
> bitching because Python was blowing chunks. And don't give
> examples of things that can be ripped out without breaking
> Python, because that is germane either.
>
> How would you respond to such complaints?
>
> Hmm..

Re: Program Translation - Nov. 14, 2013

2013-11-14 Thread Gordon Sande

On 2013-11-14 17:07:45 +, mecej4 said:


On 11/14/2013 8:18 AM, E.D.G. wrote:

Posted by E.D.G.  on November 14, 2013

In view of the fact that I mentioned the following project in
both Perl and Python Newsgroup notes and did not get any hostile
responses I am going to take a chance and mention it again in all three
of these Newsgroups.  People posting responses might want to do that in
just one Newsgroup.  I will check all three for responses for a few weeks.


This is the Web address for an interesting and apparently unique
computer program written using FORTRAN 77.  As far as I am aware, it has
never been translated to newer language.  There is a BASIC version that
was apparently written around the same time as the FORTRAN version.

http://www.bfo.geophys.uni-stuttgart.de/etgtab.html

What a number of us would like to do is obtain a copy of the
program that is written in a newer language so that we can then merge it
with the programs available through the following Web page.  The new
programs would then be made available as freeware programs to
researchers around the world. This indirect link is being used in an
effort to keep Web site related spam to a minimum.  I don't collect
credits by having people visit that (indirect) Web site.

http://www.freewebs.com/eq-forecasting/RH.html

If there are any programmers who might be interested in such a
translation effort then I would be interested in hearing from them.

Etgtab generates Solid Earth Tide and ocean tide data for any
location on or inside the planet.  I am not aware of any other freeware
program that can do that.

SunGP available at that second Web site is the only freeware
program that I know about that generates what are sometimes referred to
as subsolar and sublunar types of data.  The download code was written
using True BASIC.

If you draw a line between the centers of the sun and the Earth
then the place where that line crosses the surface of the Earth is the
subsolar location.  The sublunar location is the same type of thing.
The SunGP program code is also available in Perl code, but not through
any Web sites.


If this old program is to be translated or reused, do use this 
opportunity to fix some bugs in the program.


The data file contains data for 1200 waves, but the program computes 
results for 1212 waves. For waves 1201 to 1212, the program ends up 
calculating results based on uninitialized data. Whether or not this 
affects the validity of the final output results is something that 
someone knowledgeable about the field of application has to judge.


-- mecej4


Indeed! Under NAGWare Fortran it runs to completion with C=all but pulls an
undefined reference when C=undefined is added.

Lots of obsolete features and other warnings but no compiler error messages.

The obvious lessons are that 1. Fortran has very good historical continuity
and 2. the good debugging Fortran compilers do a good job.


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


The Spirit of Python

2013-11-14 Thread Roy Smith
https://twitter.com/dabeaz/status/400813245532876800/photo/1

"Now THIS is a Python book I should get.  I'm guessing it's about design 
patterns. Or maybe just the GIL. "

---
Roy Smith
[email protected]

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


Re: python 2.7.x on MacOSX: failed dlopen() on .so's

2013-11-14 Thread Ned Deily
In article <1384442536.3496.532.camel@pdsdesk>,
 Paul Smith  wrote:
[...]
> By relocatable I mean "runnable from any location"; i.e., not fixed.  I
> have a wrapper around the Python executable that can compute the correct
> root directory and set any environment variables or add flags or
> whatever might be needed.

In that case, the python.org installer may not be a good choice.  You should 
be to accomplish what you want by building your own Python.   You'll probably 
find you were getting tripped up by unnecessarily setting environment 
variables.  Good luck!

-- 
 Ned Deily,
 [email protected]

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


Re: PyMyth: Global variables are evil... WRONG!

2013-11-14 Thread Ethan Furman

On 11/14/2013 09:37 AM, Joel Goldstick wrote:


So, beyond that, what is the point of the thread?


You haven't met Ranting Rick yet?  He's a troll's troll, outdone only by one 
other whose name I don't remember.

His posts are, amazingly enough, rants.  Usually about his (mis)perceptions of 
the failures of:

  - Python
  - The Python Leaders
  - Good Coding Practices
  - Everyone but himself (and the "Silent Majority" he represents)

He has been on vacation for a few months, but, alas, he is back.  Interestingly, even though he is still in my kill file 
I could tell the thread was his just from the subject title.


--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


Re: PyMyth: Global variables are evil... WRONG!

2013-11-14 Thread Joel Goldstick
On Thu, Nov 14, 2013 at 12:56 PM, Ethan Furman  wrote:
> On 11/14/2013 09:37 AM, Joel Goldstick wrote:
>>
>>
>> So, beyond that, what is the point of the thread?
>
>
> You haven't met Ranting Rick yet?  He's a troll's troll, outdone only by one
> other whose name I don't remember.
>
> His posts are, amazingly enough, rants.  Usually about his (mis)perceptions
> of the failures of:
>
>   - Python
>   - The Python Leaders
>   - Good Coding Practices
>   - Everyone but himself (and the "Silent Majority" he represents)
>
> He has been on vacation for a few months, but, alas, he is back.
> Interestingly, even though he is still in my kill file I could tell the
> thread was his just from the subject title.
>
> --
> ~Ethan~
> --
> https://mail.python.org/mailman/listinfo/python-list

Ah, thanks.  A tag team .. oh my!

-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The Spirit of Python

2013-11-14 Thread jkn
On Thursday, November 14, 2013 6:11:08 PM UTC, Roy Smith wrote:
> https://twitter.com/dabeaz/status/400813245532876800/photo/1
> 
> 
> "Now THIS is a Python book I should get.  I'm guessing it's about design 
> patterns. Or maybe just the GIL. "
> 

Excellent, thanks fro the link. And is that a book by Ethan Furman next to it??

J^n

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


Re: PyMyth: Global variables are evil... WRONG!

2013-11-14 Thread Mark Lawrence

On 14/11/2013 17:56, Ethan Furman wrote:

On 11/14/2013 09:37 AM, Joel Goldstick wrote:


So, beyond that, what is the point of the thread?


You haven't met Ranting Rick yet?  He's a troll's troll, outdone only by
one other whose name I don't remember.

His posts are, amazingly enough, rants.  Usually about his
(mis)perceptions of the failures of:

   - Python
   - The Python Leaders
   - Good Coding Practices
   - Everyone but himself (and the "Silent Majority" he represents)

He has been on vacation for a few months, but, alas, he is back.
Interestingly, even though he is still in my kill file I could tell the
thread was his just from the subject title.

--
~Ethan~


But he's not 100% troll as he has published some useful stuff on 
IDLE/tkinter, that's why he's only on the subs bench for my Trolls Dream 
Team.  No guesses who the captain is now :)


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Running python's own unit tests?

2013-11-14 Thread Russell E. Owen
I'm building python from source and trying to figure out how to test the 
result. I must be overlooking something obvious, but I looked through 
the documentation and source and tried some google searches (which turn 
up plenty about writing unit tests in python, but nothing about testing 
a python distribution).

Any hints?

-- Russell

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


Re: Trying tcompile an use the Python 3.4a

2013-11-14 Thread Mark Lawrence

On 14/11/2013 02:55, Steven D'Aprano wrote:


Please Mark, and anyone else reading, I'm begging you on bended knee,
take your flaming off list. You can be a valued member of this community
when you put your mind to it, but your prideful refusal to stop attacking
Nikos is helping to wreck this community.



No need for the bended knee old chap, although if you want some kind of 
part I'm fairly sure that Chris Angelico could find you something in one 
of his Gilbert and Sullivan productions.


Talking of Chris, I see that he, Robert Kern and alister (possibly 
others?) have all pointed out to our illustrious Greek colleague that 
his latest question, which has been repeated three times to my 
knowledge, isn't Python related and would he please ask it elsewhere. 
Hopefully this pattern will continue, meaning the end of hostilities.


I'll give up mentioning the spoon feeders part in this rather unpleasant 
interlude.  Doh!!!


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: Running python's own unit tests?

2013-11-14 Thread Tim Golden


On 14/11/2013 19:12, Russell E. Owen wrote:

I'm building python from source and trying to figure out how to test the
result. I must be overlooking something obvious, but I looked through
the documentation and source and tried some google searches (which turn
up plenty about writing unit tests in python, but nothing about testing
a python distribution).

Any hints?

-- Russell


http://docs.python.org/devguide/

TJG
--
https://mail.python.org/mailman/listinfo/python-list


Re: Trying tcompile an use the Python 3.4a

2013-11-14 Thread Benjamin Kaplan
On Nov 14, 2013 5:55 AM, "Nick the Gr33k"  wrote:
>
> Will someone please tell me how to install 'pip'
>
> My website is not working because modules are missing and the only way i
can install them is by installing python's module manager 'pip'
>
> but 'yum install python-pip' fails.
>
> How would i install the damn thing?
>
> These action should be done via package managers but i wasn't ven able to
install python 3.4a like that, i had to compile it form source when the
easy thing to do was "yum install python3"
>
> what wrong with this 'yum' manager?
> --
> https://mail.python.org/mailman/listinfo/python-list

package managers assume that they are the only thing installing software on
your system. Any python related package you install through yum will only
be compiled for and installed to the versions of python that you can get
through yum. If you want to compile python outside they package manager,
you'll also have to install all the libraries outside of the package
manager.
-- 
https://mail.python.org/mailman/listinfo/python-list


Django Weekend Cardiff

2013-11-14 Thread D.M. Procida
(With apologies if you have already seen this on another email list or
newsgroup.)

The UK's first-ever Django conference will take place on the 7th-9th
February 2014 in Cardiff, Wales.



The programme for the event:

Friday: tutorials and demonstrations (also open to the public)
Saturday:   talks
Sunday: code sprints and clinics

The conference is Django-focused, but all of all aspects of Python fall
within its remit - particularly in the tutorials and workshops.

A venue has been booked at Cardiff University.

Registration and ticket sales will open soon, as well as a call for
papers.

To be a success, the conference needs the support of:

*   people in Wales, the UK and beyond who will participate as
attendees or volunteers
*   speakers who'd like to give talks or conduct tutorials
*   organisations locally and internationally willing to provide
sponsorship or other support

If you can offer support, please get in touch.

One of the aims of the conference is to establish it as an annual event
that will raise the profile in Wales of open-source software in general
and  Python in particular, and also bolster the local open-source
software community here. 

Above all, however, the intention is to establish the Django Weekend in
Cardiff as a meaningful and enjoyable date in the Django/Python
calendar.

We'll publish updates on our website, our Twitter account
 and elsewhere as appropriate.

Daniele
-- 
https://mail.python.org/mailman/listinfo/python-list


Plot a contour inside a contour

2013-11-14 Thread Isaac Won
I tried to plot one smaller contour inside of the other larger contour. I have 
two different 2D-arrays. One is with smaller grid spacing and smaller domain 
size and the other is with larger spacing and larger domain size. So, I tried 
to use fig.add_axes function as follows:
fig = plt.figure()
ax1 = fig.add_axes([0.1,0.1,0.8,0.8])
 .
 .
dx   = 450
NX   = SHFX_plt.shape[1]
NY   = SHFX_plt.shape[0]
xdist= (np.arange(NX)*dx+dx/2.)/1000. 
ydist= (np.arange(NY)*dx+dx/2.)/1000.
myPLT = plt.pcolor(xdist,ydist,SHFX_plt)
 .
 .
ax2 = fig.add_axes([8.,8.,18.,18.])
dx1  = 150
NX1   = SHFX_plt1.shape[1]
NY1   = SHFX_plt1.shape[0]
print 'NX1=',NX1,'NY1=',NY1
xdist1= (np.arange(NX1)*dx1+dx1/2.)/1000.
ydist1= (np.arange(NY1)*dx1+dx1/2.)/1000.
myPLT1 = plt.pcolor(xdist1,ydist1,SHFX_plt1)
plt.show()

My intention is to plot ax2 on the top of ax1 from xdist and ydist = 8 with 18 
by 18 size.

However, the result seems only showing ax1.

I will really appreciate any help or idea.

Thank you, Isaac
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Automation

2013-11-14 Thread Alister
On Thu, 14 Nov 2013 17:10:02 +, Mark Lawrence wrote:

> On 14/11/2013 03:56, [email protected] wrote:
>> I apologize again for my bad english and any inconvenience that I have
>> generated.
>>
>>
> I do wish that people would stop apologising for poor English, it's an
> extremely difficult language.  IIRC there are eight different ways of
> pronouncing the vowel combination au.  Whatever happened to "There
> should be one-- and preferably only one --obvious way to do it."? :)

As a native of England I have to agree
it is far to arrogant to expect everyone else to be able to speak good 
English when I can barley order a beer in any other language.
(even or especially in the USA)




-- 
Only through hard work and perseverance can one truly suffer.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Running python's own unit tests?

2013-11-14 Thread Zachary Ware
On Thu, Nov 14, 2013 at 1:12 PM, Russell E. Owen  wrote:
> I'm building python from source and trying to figure out how to test the
> result. I must be overlooking something obvious, but I looked through
> the documentation and source and tried some google searches (which turn
> up plenty about writing unit tests in python, but nothing about testing
> a python distribution).
>
> Any hints?

`python -m test -uall` will test everything (where 'python' invokes
the interpreter you built, which may be "python_d.exe" on Windows if
you built in Debug mode, or "python.exe" on OSX).  If you're testing
2.7, '-m test' needs to be '-m test.regrtest'.

For any further detail, check Tim's link to the devguide, specifically
the chapter on running tests.

-- 
Zach
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyMyth: Global variables are evil... WRONG!

2013-11-14 Thread Alister
On Thu, 14 Nov 2013 09:56:04 -0800, Ethan Furman wrote:

> On 11/14/2013 09:37 AM, Joel Goldstick wrote:
>>
>> So, beyond that, what is the point of the thread?
> 
> You haven't met Ranting Rick yet?  He's a troll's troll, outdone only by
> one other whose name I don't remember.
> 
> His posts are, amazingly enough, rants.  Usually about his
> (mis)perceptions of the failures of:
> 
>- Python - The Python Leaders - Good Coding Practices - Everyone but
>himself (and the "Silent Majority" he represents)
> 
> He has been on vacation for a few months, but, alas, he is back. 
> Interestingly, even though he is still in my kill file I could tell the
> thread was his just from the subject title.

I don't think there is any comparison.
Ricks trolls do at least promote intelligent discussion & cause the 
reader to re-asses preconceptions if only to confirm them.

Ricks non trolling posts do give him enough credibility to avoid 
dismissing his ideas out of hand





-- 
Go away! Stop bothering me with all your "compute this ... compute that"!
I'm taking a VAX-NAP.

logout
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Running python's own unit tests?

2013-11-14 Thread Tim Golden

On 14/11/2013 20:13, Zachary Ware wrote:

On Thu, Nov 14, 2013 at 1:12 PM, Russell E. Owen  wrote:

I'm building python from source and trying to figure out how to test the
result. I must be overlooking something obvious, but I looked through
the documentation and source and tried some google searches (which turn
up plenty about writing unit tests in python, but nothing about testing
a python distribution).

Any hints?


`python -m test -uall` will test everything (where 'python' invokes
the interpreter you built, which may be "python_d.exe" on Windows if
you built in Debug mode, or "python.exe" on OSX).  If you're testing
2.7, '-m test' needs to be '-m test.regrtest'.

For any further detail, check Tim's link to the devguide, specifically
the chapter on running tests.



Sorry if I seemed a bit terse; I was just on my way downstairs. But the 
front page his quite neat instructions for building and testing on most 
platforms.


TJG
--
https://mail.python.org/mailman/listinfo/python-list


Re: The Spirit of Python

2013-11-14 Thread Ethan Furman

On 11/14/2013 10:47 AM, jkn wrote:

On Thursday, November 14, 2013 6:11:08 PM UTC, Roy Smith wrote:

https://twitter.com/dabeaz/status/400813245532876800/photo/1


"Now THIS is a Python book I should get.  I'm guessing it's about design patterns. 
Or maybe just the GIL."



Excellent, thanks fro the link. And is that a book by Ethan Furman next to it??


Nope, 'fraid not.  If I actually write a book it will be on the One True 
Python, not a merely corporeal imposter!  ;)

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


Re: Getting globals of the caller, not the defining module

2013-11-14 Thread Rotwang

On 11/11/2013 12:02, [email protected] wrote:

(Sorry for posting through GG, I'm at work.)

On Monday, November 11, 2013 11:25:42 AM UTC, Steven D'Aprano wrote:

Suppose I have a function that needs access to globals:

# module A.py
def spam():
 g = globals()  # this gets globals from A
 introspect(g)

As written, spam() only sees its own globals, i.e. those of the module in
which spam is defined. But I want spam to see the globals of the caller.

# module B
import A
A.spam()  # I want spam to see globals from B

I can have the caller explicitly pass the globals itself:

def spam(globs=None):
 if globs is None:
 globs = globals()
 introspect(globs)

But since spam is supposed to introspect as much information as possible,
I don't really want to do that. What (if anything) are my other options?


How about this?

# module A.py
import inspect
def spam():
 return inspect.stack()[1][0].f_globals


Bump. Did this do what you wanted, or not?
--
https://mail.python.org/mailman/listinfo/python-list


Re: Converting hex data to image

2013-11-14 Thread Ben Finney
Shyam Parimal Katti  writes:

> When we fetch the data from the LDAP server for a particular valid
> user, the data associated with the user contains the thumbnail photo
> in hex representation. E.x.:
>
> [('CN=XX,OU=Users,OU=Accounts,DC=test,DC=com', {'msExchBlockedSendersHash':
> ['\xce'], 'mailNickname': ['test_user'], 'primaryGroupID': ['513'],
> 'logonCount': ['1021'], *thumbnailPhoto:
> ['\xef\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00`\x00`\x00\x00\xff\xdb\x00C\x00\x08\x06\x06\x07\x06\x05\x08\x07\x07\x07\t\t\x08\n\x0c\x14\r\x0c.']*..
> ]

So the image data appears to be a byte string, is that right? You can
use the Pillow library https://pypi.python.org/pypi/Pillow/> to
process graphic images to and from bytes.

To turn a byte string into a file-like object for use with PIL, extract
the byte string as ‘image_data’, use the standard library ‘io.StringIO’
class http://docs.python.org/3/library/io.html#io.StringIO>, then
create a new ‘PIL.Image’ object by reading from that pseudo-file::

import io

import PIL

photo_data = # … get the byte string from wherever it is …
photo_infile = io.StringIO(photo_data)
photo_image = PIL.Image.frombytes(photo_infile)

> How do I convert the hex data for an image to the actual image?

It depends on what you think “the actual image” is, if not the bytes
themselves. There's no native Python “graphic image” data type; if the
bytes are not the representation you want, you need to choose some other
representation of that image.

Using a ‘PIL.Image’ object as the representation, you can perform all
kinds of further manipulations of a graphic image
http://pillow.readthedocs.org/en/latest/reference/Image.html>.

-- 
 \  “It seems intuitively obvious to me, which means that it might |
  `\   be wrong.” —Chris Torek |
_o__)  |
Ben Finney

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


Re: Invalid syntax with print "Hello World"

2013-11-14 Thread bob gailer

On 11/14/2013 10:05 AM, [email protected] wrote:

Am Donnerstag, 12. März 2009 07:57:11 UTC+1 schrieb Henrik Bechmann:

obviously total mewbiew:

My first program in Python Windows

print "Hello World"

I assume you are running Python 3 in which case you need

print("Hello World")


--
Bob Gailer
919-636-4239
Chapel Hill NC

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


Re: Converting hex data to image

2013-11-14 Thread Ben Finney
Ben Finney  writes:

> To turn a byte string into a file-like object for use with PIL, extract
> the byte string as ‘image_data’, use the standard library ‘io.StringIO’
> class http://docs.python.org/3/library/io.html#io.StringIO>, then
> create a new ‘PIL.Image’ object by reading from that pseudo-file::

My apologies, I showed the wrong usage. This should work::

import io

import PIL

photo_data = # … get the byte string from wherever it is …
photo_infile = io.StringIO(photo_data)
photo_image = PIL.Image.open(photo_infile)

That is, ‘PIL.Image.frombytes’ allows you to read the bytes from a byte
string, but requires you to also specify metadata about the image data
(format, pixel mode, size), whereas ‘PIL.Image.open’ reads the data from
a file-like object and parses all the metadata. So you usually want to
use the latter, as shown here.

-- 
 \ “People's Front To Reunite Gondwanaland: Stop the Laurasian |
  `\  Separatist Movement!” —wiredog, http://kuro5hin.org/ |
_o__)  |
Ben Finney

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


Re: Most discussion on comp.lang.python is about developing with Python

2013-11-14 Thread Peter Pearson
On Wed, 13 Nov 2013 15:35:56 -0500, bob gailer  wrote:
> I joined a week or so ago.
>
> The subject line was copied from the description of comp.lang.python aka 
> [email protected].
>
> I am very disappointed to see so much energy and bandwidth going to 
> conversations that bash individuals.

I'm sorry your initial impression is so negative.  This Usenet
news group, comp.lang.python, is the most civil and helpful
news group I've followed in my long career of Usenet reading.
Losing that would be sad.

Perhaps the appearance of the group changes according to one's method
of access.  I read comp.lang.python using the slrn news-reading tool,
which allows me to skip an entire thread with a single keystroke.  Maybe
that's what has kept me from noticing so many unpleasant posts.

-- 
To email me, substitute nowhere->spamcop, invalid->net.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Invalid syntax with print "Hello World"

2013-11-14 Thread unknown
On Thu, 14 Nov 2013 07:05:08 -0800, johannes.gunz97 wrote:

> Am Donnerstag, 12. März 2009 07:57:11 UTC+1 schrieb Henrik Bechmann:
>> obviously total mewbiew:
>> 
>> My first program in Python Windows
>> 
>> print "Hello World"
>> 
>> I select Run/Run Module and get an error:
>> 
>> Syntax error, with the closing quote highlighted.
>> 
>> Tried with single quotes as well. Same problem.
>> 
>> Can someone explain my mistake?
>> 
>> Thanks,
>> 
>> - Henrik
> 
> thanx

which version of python?
if V3.X then you need print ('Hello World')
as print has changed from a statement to a function.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Plot a contour inside a contour

2013-11-14 Thread John Ladasky
On Thursday, November 14, 2013 11:39:37 AM UTC-8, Isaac Won wrote:
> I tried to plot one smaller contour inside of the other larger contour.

Using what software?  A plotting package is not part of the Python standard 
library.

You did not show the import statements in your code.  If I had to guess, I 
would say that you are using the Matplotlib package.  Questions which are 
specific to matplotlib should be asked in the matplotlib-users discussion group:

https://lists.sourceforge.net/lists/listinfo/matplotlib-users
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Converting hex data to image

2013-11-14 Thread Shyam Parimal Katti
Perfect. Thank you @Ben and @Tim


On Thu, Nov 14, 2013 at 4:29 PM, Ben Finney wrote:

> Ben Finney  writes:
>
> > To turn a byte string into a file-like object for use with PIL, extract
> > the byte string as ‘image_data’, use the standard library ‘io.StringIO’
> > class http://docs.python.org/3/library/io.html#io.StringIO>, then
> > create a new ‘PIL.Image’ object by reading from that pseudo-file::
>
> My apologies, I showed the wrong usage. This should work::
>
> import io
>
> import PIL
>
> photo_data = # … get the byte string from wherever it is …
> photo_infile = io.StringIO(photo_data)
> photo_image = PIL.Image.open(photo_infile)
>
> That is, ‘PIL.Image.frombytes’ allows you to read the bytes from a byte
> string, but requires you to also specify metadata about the image data
> (format, pixel mode, size), whereas ‘PIL.Image.open’ reads the data from
> a file-like object and parses all the metadata. So you usually want to
> use the latter, as shown here.
>
> --
>  \ “People's Front To Reunite Gondwanaland: Stop the Laurasian |
>   `\  Separatist Movement!” —wiredog, http://kuro5hin.org/ |
> _o__)  |
> Ben Finney
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PyMyth: Global variables are evil... WRONG!

2013-11-14 Thread Chris Angelico
On Fri, Nov 15, 2013 at 7:12 AM, Alister  wrote:
> Ricks non trolling posts do give him enough credibility to avoid
> dismissing his ideas out of hand

When he's talking about Tkinter, he knows his stuff, and is orders of
magnitude more helpful than I would be (as I don't know Tkinter). When
he's talking about warts in Python, he sometimes knows what he's
talking about, often ignores facts, and generally is more stirring the
pot than actually being productive. But hey, they can still be fun
threads.

Now, I'm just waiting for the thread in which Nikos has problems with
Tkinter not working with Greek characters as of Python 3.3, and a
singularity is formed that results in the destruction of the known
universe...

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


Re: Automation

2013-11-14 Thread Chris Angelico
On Fri, Nov 15, 2013 at 7:03 AM, Alister  wrote:
> On Thu, 14 Nov 2013 17:10:02 +, Mark Lawrence wrote:
>
>> On 14/11/2013 03:56, [email protected] wrote:
>>> I apologize again for my bad english and any inconvenience that I have
>>> generated.
>>>
>>>
>> I do wish that people would stop apologising for poor English, it's an
>> extremely difficult language.  IIRC there are eight different ways of
>> pronouncing the vowel combination au.  Whatever happened to "There
>> should be one-- and preferably only one --obvious way to do it."? :)
>
> As a native of England I have to agree
> it is far to arrogant to expect everyone else to be able to speak good
> English when I can barley order a beer in any other language.
> (even or especially in the USA)

http://tvtropes.org/pmwiki/pmwiki.php/Main/SeparatedByACommonLanguage

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


Re: Odd msg received from list

2013-11-14 Thread Terry Reedy

On 11/14/2013 9:26 AM, Tim Golden wrote:

On 14/11/2013 13:53, Verde Denim wrote:

I got an odd message this morning from the list telling me that my
account was de-activated due to excessive bounces. I've only sent a
handful of messages to this board, but do read an awful lot of the posts
in order to learn more about the language. The message also listed my
account password, which I found odd. Has anyone else received a message
like this?



I can confirm that your account has been suspended because bounces. That
is: as a moderator, I can view your record in the interface and see that
it has been tagged as such. I can't tell you any more, I'm afraid; I've
just emailed the other list owners to see if someone has a handle on why
this has happened to a number of @gmail.com users today.


It has since been discovered and announced elsewhere on this list that 
the problem was a post 'from' unknown.org which google rejected.


--
Terry Jan Reedy

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


Re: Running python's own unit tests?

2013-11-14 Thread Terry Reedy

On 11/14/2013 2:12 PM, Russell E. Owen wrote:

I'm building python from source and trying to figure out how to test the
result. I must be overlooking something obvious, but I looked through
the documentation and source and tried some google searches (which turn
up plenty about writing unit tests in python, but nothing about testing
a python distribution).

Any hints?


http://docs.python.org/3/library/test.html#running-tests-using-the-command-line-interface

Or 2.7 equivalent.

--
Terry Jan Reedy

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


Re: Plot a contour inside a contour

2013-11-14 Thread Isaac Won
On Thursday, November 14, 2013 2:01:39 PM UTC-8, John Ladasky wrote:
> On Thursday, November 14, 2013 11:39:37 AM UTC-8, Isaac Won wrote:
> 
> > I tried to plot one smaller contour inside of the other larger contour.
> 
>  
> 
> Using what software?  A plotting package is not part of the Python standard 
> library.
> Thanks John, I am using Matplotlib package. I will ask the question in the 
> matplotlib-users discussion group as you suggested.
Thank you again, Isaac
> 
> 
> You did not show the import statements in your code.  If I had to guess, I 
> would say that you are using the Matplotlib package.  Questions which are 
> specific to matplotlib should be asked in the matplotlib-users discussion 
> group:
> 
> 
> 
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

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


Re: Trying tcompile an use the Python 3.4a

2013-11-14 Thread Chris Angelico
On Fri, Nov 15, 2013 at 6:12 AM, Mark Lawrence  wrote:
> On 14/11/2013 02:55, Steven D'Aprano wrote:
>>
>>
>> Please Mark, and anyone else reading, I'm begging you on bended knee,
>> take your flaming off list. You can be a valued member of this community
>> when you put your mind to it, but your prideful refusal to stop attacking
>> Nikos is helping to wreck this community.
>>
>
> No need for the bended knee old chap, although if you want some kind of part
> I'm fairly sure that Chris Angelico could find you something in one of his
> Gilbert and Sullivan productions.

Oh, absolutely! Quite a few! Also, there are references in "The Grand
Duke" to, and I quote, "histrionic art". I think that adequately
describes some of what we've seen here :)

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


Re: pypy and ctypes

2013-11-14 Thread Peter Chant

On 11/14/2013 03:13 PM, Neil Cerutti wrote:

On 2013-11-14, Peter Chant  wrote:

Or is it that - if I keep the code as simple as possible, PyPy
is about as fast as you can get?


PyPy profiles your code as it runs and creates, using a
just-in-time compiler, highly optimized versions of frequently
run sections. You don't have to declare types or even think about
it; The scheme will work best with code that runs for a
significant amount of time.



That is the situation I'm in.  If it only ran for a second or two 
there'd be no point in worrying about speed. PyPy gave a massive speed 
up.  I was wonding if I could do a little more.



cython allows you to declare types, and attempts to create more
efficient code *at compile time* using those type declaration.

Which approach will be better depends on how the code runs and
how clever you are at using cython.


If it is marginal then I don't think the effort would be worth while.
I do wonder whether writing some specific functions in C using cffi
would benefit.  It is something I have no experience of.



PyPy isn't designed to speed up programs that run for a few
hundred milliseconds and then complete, though it might sometimes
work for that.



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


Re: Odd msg received from list

2013-11-14 Thread Gregory Ewing

Verde Denim wrote:

The message also listed my
account password, which I found odd.


You mean the message contained your actual password,
in plain text? That's not just odd, it's rather worrying
for at least two reasons. First, what business does a
message like that have carrying a password, and second,
it means the server must be keeping passwords in a
readable form somewhere, which is a really bad idea.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


How to np.vectorize __call__ method

2013-11-14 Thread Yaşar Arabacı
I am cross-posting from: http://stackoverflow.com/q/19990863/886669

I am following, [quant-econ](http://quant-econ.net/numpy.html)
tutorial. I am trying the exercise where I am supposed to implement a
[Empirical Cumulative Probability
Funcion](http://en.wikipedia.org/wiki/Empirical_distribution_function)
using vectorized numpy methods.

Here is the **correct** solution to problem:

class ecdf:

def __init__(self, observations):
self.observations = np.asarray(observations)

def __call__(self, x):
return np.mean(self.observations <= x)

def plot(self, a=None, b=None):

# === choose reasonable interval if [a, b] not specified === #
if not a:
a = self.observations.min() - self.observations.std()
if not b:
b = self.observations.max() + self.observations.std()

# === generate plot === #
x_vals = np.linspace(a, b, num=100)
f = np.vectorize(self.__call__)
plt.plot(x_vals, f(x_vals))
plt.show()

But I am **trying** to do it this way:

class ecdf(object):

def __init__(self, observations):
self.observations = np.asarray(observations)
self.__call__ = np.vectorize(self.__call__)

def __call__(self, x):
return np.mean(self.observations <= x)

So that, `__call__` method is vectorized and instance can be called
with an array and it returns an array of cumulative probabilities for
that array. However, when I try it like this:

p = ecdf(uniform(0,1,500))
p([0.2, 0.3])

I am getting this error:

Traceback (most recent call last):

  File "", line 1, in 
p([0.2, 0.3])

  File 
"D:/Users/y_arabaci-ug/Desktop/quant-econ/programs/numpy_exercises.py",
line 50, in __call__
return np.mean(self.observations <= x)

ValueError: operands could not be broadcast together with shapes (500) (2)

My question is, how come author could vectorize `self.__call__` and it
works, while my method gives an error?


-- 
http://ysar.net/
-- 
https://mail.python.org/mailman/listinfo/python-list


Implementing #define macros similar to C on python

2013-11-14 Thread JL
One of my favorite tools in C/C++ language is the preprocessor macros.

One example is switching certain print messages for debugging use only

#ifdef DEBUG_ENABLE
DEBUG_PRINT   print
#else
DEBUG_PRINT

Is it possible to implement something similar in python? Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to disable RTLD_NOW for Python 2.7.x dlopen() in Mac OS X Mavericks?

2013-11-14 Thread Tat-Chee Wan
On Thursday, November 14, 2013 11:44:44 AM UTC+8, Ned Deily wrote:
> 
> I'm not very familiar with ctypes internals but it looks like 
> 
> sys.setdlopenflags is not intended to have an influence on ctypes; rather, it 
> 
> conditions the Python interpreter's use of dlopen to load shared Python 
> 
> modules.  For ctypes itself, it looks like it unconditionally sets RTLD_NOW 
> 
> when calling dlopen and probably with good reason:
> 
> 
> 
> http://hg.python.org/cpython/file/2.7/Modules/_ctypes/callproc.c#l1432
> 
> 

Ah, thanks for the link. I couldn't figure out where the RTLD_NOW flag was set.

> 
> Sorry, I don't have a suggestion for you, assuming you want to just try to 
> 
> ignore the error, other than perhaps running an older version of OS X in a VM 
> 
> on 10.8.

That's not an option for me unfortunately. Guess I'll have to look into other 
alternatives to solve the missing symbol problem.

T. C.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The Spirit of Python

2013-11-14 Thread Dave Angel

On Thu, 14 Nov 2013 13:11:08 -0500, Roy Smith  wrote:

Intriguing subject line but an empty message body. Please post in 
text not html if you want everyone to see it.


Thanks

--
DaveA

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


Re: Implementing #define macros similar to C on python

2013-11-14 Thread Dave Angel
On Thu, 14 Nov 2013 18:29:48 -0800 (PST), JL  
wrote:
One of my favorite tools in C/C++ language is the preprocessor 

macros.


One example is switching certain print messages for debugging use 

only



#ifdef DEBUG_ENABLE
DEBUG_PRINT   print
#else
DEBUG_PRINT




Is it possible to implement something similar in python? Thank you.


Sure. A preprocessor can be written for nearly every language. Are 
you offering?


--
DaveA

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


Re: Implementing #define macros similar to C on python

2013-11-14 Thread Chris Angelico
On Fri, Nov 15, 2013 at 1:29 PM, JL  wrote:
> One of my favorite tools in C/C++ language is the preprocessor macros.
>
> One example is switching certain print messages for debugging use only
>
> #ifdef DEBUG_ENABLE
> DEBUG_PRINT   print
> #else
> DEBUG_PRINT
>
> Is it possible to implement something similar in python? Thank you.

There are usually other ways to do things. For instance, you can
define a function to either do something or do nothing:

if debug_mode:
debug_print = print
else:
debug_print = lambda: None

debug_print("This won't be shown unless we're in debug mode!")

But as Dave says, you could write a preprocessor if you need one.

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


Re: Implementing #define macros similar to C on python

2013-11-14 Thread Roy Smith
In article ,
 JL  wrote:

> One of my favorite tools in C/C++ language is the preprocessor macros.
> 
> One example is switching certain print messages for debugging use only
> 
> #ifdef DEBUG_ENABLE
> DEBUG_PRINT   print
> #else
> DEBUG_PRINT
> 
> Is it possible to implement something similar in python? Thank you.

Why would you want to?  One of the most horrible things about C/C++ is 
the preprocessor.  Python has much better mechanisms to implement just 
about anything you would do with the preprocessor.

For the example you gave, you would log things as info() or debug(), and 
then adjust the filter level in the logger.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The Spirit of Python

2013-11-14 Thread Ben Finney
Dave Angel  writes:

> On Thu, 14 Nov 2013 13:11:08 -0500, Roy Smith  wrote:
>
> Intriguing subject line but an empty message body. Please post in text
> not html if you want everyone to see it.

My message agent also discards HTML messages. Roy Smith's message
displayed fine, containing a URL to an amusing Twitter post about
Python.

-- 
 \ “True greatness is measured by how much freedom you give to |
  `\  others, not by how much you can coerce others to do what you |
_o__)   want.” —Larry Wall |
Ben Finney

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


Re: Implementing #define macros similar to C on python

2013-11-14 Thread Chris Angelico
On Fri, Nov 15, 2013 at 3:10 PM, Roy Smith  wrote:
> Why would you want to?  One of the most horrible things about C/C++ is
> the preprocessor.

Hey, that's not fair! Without the preprocessor, how would you be able
to do this:

//Hide this part away in a header file somewhere
struct b0rkb0rk
{
float value;
b0rkb0rk(float v):value(v) {}
operator float() {return value;}
float operator +(float other) {return value+other-0.1;}
};
//Behold the power of the preprocessor!
#define float b0rkb0rk

//Okay, now here's your application
#include 

int main()
{
std::cout << "Look how stupidly inaccurate float is!\n";
float x = 123.0f;
std::cout << "123.0 + 2.0 = " << x + 2.0f << "\n";
std::cout << "See? You should totally use double instead.\n";
}

(Anybody got a cheek de-tonguer handy? I think it's stuck.)

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


Re: The Spirit of Python

2013-11-14 Thread Dave Angel
On Fri, 15 Nov 2013 15:16:09 +1100, Ben Finney 
 wrote:

Dave Angel  writes:
> On Thu, 14 Nov 2013 13:11:08 -0500, Roy Smith  

wrote:




> Intriguing subject line but an empty message body. Please post in 

text

> not html if you want everyone to see it.






My message agent also discards HTML messages. Roy Smith's message
displayed fine, containing a URL to an amusing Twitter post about
Python.


Recently trying to use tablet newsreaders: groundhog and android 
newsreader. Both seem to throw out the whole message if any part is 
html. Or perhaps it just throws out the html and whatever precedes 
it, as I do see the boilerplate that`s tacked onto theend in the 
python-tutor.


Suggestions anyone?  Samsung Note runningAndroid.

--
DaveA

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


Re: Automation

2013-11-14 Thread Steven D'Aprano
On Thu, 14 Nov 2013 20:03:44 +, Alister wrote:

> As a native of England I have to agree it is far to arrogant to expect
> everyone else to be able to speak good English when I can barley order a
> beer in any other language. (even or especially in the USA)

Apparently you can "barley" write UK English either :-)

No offence intended, I just thought that was an amusing error to make. 
The word you're after is "barely", barley is a grain similar to wheat or 
oats. Also "far too arrogant".

But yes, English is a tricky language. Who would imagine that "ghoti" 
could legitimately be pronounced "fish"?

"gh" sounds like F, as in "enough" (enuf)

"o" sounds like I, as in "women" (wimmin)

"ti" sounds like SH, as in "station" (stayshun)



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


Re: Automation

2013-11-14 Thread Steven D'Aprano
On Thu, 14 Nov 2013 17:10:02 +, Mark Lawrence wrote:

> On 14/11/2013 03:56, [email protected] wrote:
>> I apologize again for my bad english and any inconvenience that I have
>> generated.
>>
>>
> I do wish that people would stop apologising for poor English, it's an
> extremely difficult language.  IIRC there are eight different ways of
> pronouncing the vowel combination au.  Whatever happened to "There
> should be one-- and preferably only one --obvious way to do it."? :)

Words like "sorry", "pardon me", etc. are the social grease to smooth out 
interactions between people. Instead, I read such apologies as a flag 
that we ought to make allowances for any grammatical or spelling errors 
they may make, rather than to interpret them as signs of laziness or 
stupidity.

I'm inclined to forgive nearly any language error from somebody who is 
trying their best to communicate, while people who merely cannot be 
bothered to use language which is at least an approximation to 
grammatically correct, syntactically valid, correctly-spelled sentences 
inspire similar apathy in me. If they can't be bothered to write as well 
as they are capable of, I can't be bothered to answer their questions.

A few minor errors is one thing, but when you see people whose posts are 
full of error after error and an apparent inability to get English syntax 
right, you have to wonder how on earth they expect to be a programmer? 
Compilers are even less forgiving of errors than is my wife, and she once 
kicked a man to death for using a colon where a semi-colon was required. 
(Only joking. He didn't actually die.)

This doesn't apply to people who gave some sort of sign that they're 
doing the best that they can, whether it is due to inexperience, 
dyslexia, being Foreign *wink*, or even broken keyboard. ("Nw kyboard is 
on ordr, pls xcus my lack of lttr aftr D and b4 F.")

But it does amuse me when non-native English speakers apologise, then 
write a post which is better written, more clear, and far more articulate 
than the native English speakers :-)


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


Re: Automation

2013-11-14 Thread Paul Rudin
Steven D'Aprano  writes:

> A few minor errors is one thing, but when you see people whose posts are 
> full of error after error and an apparent inability to get English syntax 
> right, you have to wonder how on earth they expect to be a programmer? 

The irritating thing is apparent lack of care. A post is written once
and will be seen (perhaps not read) by many people. People post with the
intention of others reading their words. If they can't be bothered to
take a little care in writing, why should we spend time reading?
-- 
https://mail.python.org/mailman/listinfo/python-list