REMINDER: OSCON Call for Proposals (deadline 1/12)

2012-01-02 Thread Aahz
DEADLINE Thursday January 12

Ring in the Gnu year with a proposal for OSCON!

OSCON (O'Reilly Open Source Convention), the premier Open Source
gathering, will be held in Portland, OR July 16-20.  We're looking for
people to deliver tutorials and shorter presentations.

http://www.oscon.com/oscon2012
http://www.oscon.com/oscon2012/public/cfp/197

Hope to see you there!
-- 
Aahz (a...@pythoncraft.com)   * http://www.pythoncraft.com/

Do not taunt happy fun for loops. Do not change lists you are looping over.
--Remco Gerlich
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Re: Generating sin/square waves sound

2012-01-02 Thread Peter Billam
On 2012-01-02, Paulo da Silva p_s_d_a_s_i_l_...@netcabo.pt wrote:
 Em 30-12-2011 11:23, mblume escreveu:
 Am Fri, 30 Dec 2011 07:17:13 + schrieb Paulo da Silva:
 Alternatively you might just generate (t,signal) samples, write
 them to a file and convert them using sox (under Linux, might
 also be available under Windows) to another format.

That's how I'd do it.
 
Sox can cope with raw samples, provided you tell it stuff like
the sample-rate, sample-size, channels etc.  E.g. from man sox
  sox -r 16k -e signed -b 8 -c 1 voice-memo.raw voice-memo.wav
(Once it's in wav form the wav header contains that information.)

 As much as I could understand at a 1st look you are
 writing to a wav file and then play the file.
 It would be nice if I could play directly the samples.

-d as an output-file means the default output,
which means it plays to your sound card. E.g.:

  sox -r 48k -e float -b 32 -c 2 input.raw -d

The input file can be - so you can pipe directly to it:

  sox -r 44100 -e float -b 32 -c 2 - -d

It should also run under windows and macos, and can generate lots
of formats, see man soxformat.  It also has a synth effect
which can generate simple waveforms easily. Sox is useful.

Regards,  Peter

-- 
Peter Billamwww.pjb.com.auwww.pjb.com.au/comp/contact.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: .format vs. %

2012-01-02 Thread Terry Reedy

On 1/1/2012 4:11 PM, Miki Tebeka wrote:

s = {0} {1} {2} {3}
s.format(1, 2, 3, 4)

'1 2 3 4'

Or even
 In [4]: fmt = '{0} {1} {2} {3}'.format
 In [5]: print(fmt(1, 2, 3, 4))
 1 2 3 4


I have done this, except for using a more informative name, like 'emsg' 
for error message.

  except XError as e:
print(emsg(a,b,c,e))
makes for pretty clear code.

--
Terry Jan Reedy

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


Re: Spamming PyPI with stupid packages

2012-01-02 Thread Felinx Lee
Hi guys,

I am the author of girlfriend module, a serious Python programmer.
This project is nothing about sexist or racism,
it is just a joke, a famous joke in China, please be cool down.

And now, I have removed money, car, house packages from PyPi,
and remove their dependences in girlfriend module, the website is also
updated.
The girlfriend module just depends on workhard module now.
I will remove girlfriend module forever if you still think it is a spam or
illegal.

I'm sorry for that I abused the PyPi, but I should say again that it is
nothing about sexist or racism as you assumption.

Felinx Lee


On 1/1/12 10:18 PM, Matt Chaput wrote:

 Someone seems to be spamming PyPI by uploading multiple stupid packages.
 Not sure if it's some form of advertising spam or just idiocy.

 Don't know if we should care though... maybe policing uploads is worse
 than cluttering PyPI's disk space and RSS feed with dumb 1 KB packages.

 girlfriend 1.0.110  A really simple module that allow everyone
 to do import girlfriend
 girlfriends 1.0 4   Girl Friends
 car 1.0 2   Car, a depended simple module that allow everyone to do
 import girlfriend
 house 1.0   2   House, a depended simple module that allow
 everyone to do import girlfriend
 money 1.0   2   Money, a depended simple module that allow
 everyone to do import girlfriend
 workhard 1.02   Keep working hard, a depended simple module that
 allow everyone to do import girlfriend


I'm betting on a joke, like antigravity only significantly less funny and
more sexist. The author is a legitimate Python programmer, and the links go
to his blog where he talks about Python stuff.

 https://bitbucket.org/felinx

You can tell him that you don't appreciate his abuse of PyPI here if you
like:

 
http://feilong.me/2012/01/**python-import-girlfriendhttp://feilong.me/2012/01/python-import-girlfriend

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

-- 
What can change the nature of a man?(Planescape Torment)

http://feilong.meFelinx Lee's Blog (Chinese Only)
http://www.zhimaq.com IT QA (Chinese Only)
http://poweredsites.org  What powered your sites? PHP, Ruby or Python?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can't write to a directory made w/ os.makedirs

2012-01-02 Thread Tim Golden

On 02/01/2012 03:14, David Goldsmith wrote:

Here's my script, in case that helps:


It certainly does. A few things occur to me.

First, you
shouldn't need to double-quote the path; the subprocess.call
should do that for you as long as you're using the list
version of the param -- which you are.

Second, you almost certainly don't want to be using the
env param, at least not in the way you are. Depending on
the way in which your app runs, either pass the appropriate
directory as the cwd= param, or copy and override the
current environ dict, ie either do this:

subprocess.call (
  ['c:/program files/somewhere/app.exe', 'blah1', 'blah2'],
  cwd=c:/somewhere/else
)

or this:

env = dict (os.environ)
env['PATH'] = c:/somewhere/else
# or env['PATH'] += ;c:/somewhere/else
subprocess.call (
  ['c:/program files/somewhere/app.exe', 'blah1', 'blah2'],
  env=env
)


See if any of that helps

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


Re: Spamming PyPI with stupid packages

2012-01-02 Thread Kai Diefenbach

Hi,

On 2012-01-02 11:03:25 +, Felinx Lee said:


I am the author of girlfriend module, a serious Python programmer.
This project is nothing about sexist or racism, 
it is just a joke, a famous joke in China, please be cool down.


Yeah, quite funny. Why not put this on an own web server?


And now, I have removed money, car, house packages from PyPi, 
and remove their dependences in girlfriend module, the website is also updated.
The girlfriend module just depends on workhard module now.
I will remove girlfriend module forever if you still think it is a spam 
or illegal.


I think it's fucking spam. Please remove this crap.

kthxbye
Kai


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


Re: Spamming PyPI with stupid packages

2012-01-02 Thread Chris Withers

On 02/01/2012 11:03, Felinx Lee wrote:

The girlfriend module just depends on workhard module now.
I will remove girlfriend module forever if you still think it is a spam
or illegal.


What is the point of these packages? Why do they exist?

Chris

--
Simplistix - Content Management, Batch Processing  Python Consulting
- http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list


Re: Spamming PyPI with stupid packages

2012-01-02 Thread Felinx Lee
I have removed those packages (girlfriend and others) from PyPI forever, I
apologize for that.

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


Re: Spamming PyPI with stupid packages

2012-01-02 Thread Peter Otten
Felinx Lee wrote:

 I have removed those packages (girlfriend and others) from PyPI forever, I
 apologize for that.

The thought police has won :(


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


Re: Spamming PyPI with stupid packages

2012-01-02 Thread Felinx Lee
Hi,

On 2012-01-02 11:03:25 +, Felinx Lee said:

 I am the author of girlfriend module, a serious Python programmer.
 This project is nothing about sexist or racism,
 it is just a joke, a famous joke in China, please be cool down.

Yeah, quite funny. Why not put this on an own web server?

 And now, I have removed money, car, house packages from PyPi,
 and remove their dependences in girlfriend module, the website is also
updated.
 The girlfriend module just depends on workhard module now.
 I will remove girlfriend module forever if you still think it is a spam
 or illegal.

I think it's fucking spam. Please remove this crap.

OK, Removed.
I apologize again.

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


Re: Spamming PyPI with stupid packages

2012-01-02 Thread David Monaghan
On Mon, 2 Jan 2012 02:52:06 -0500, Devin Jeanpierre jeanpierr...@gmail.com
wrote:

 Perhaps I'm just slow, but what is sexist about this package? Do you even
 know what the package does?

The dependencies are car, house, and money (and workhard, of
course). The joke being that women only care about how wealthy you
are.

That's not a joke, it's a stereotype - and a stereotype with a biological
truth in it.

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


Re: Spamming PyPI with stupid packages

2012-01-02 Thread Chris Angelico
On Mon, Jan 2, 2012 at 11:20 PM, Peter Otten __pete...@web.de wrote:
 Felinx Lee wrote:

 I have removed those packages (girlfriend and others) from PyPI forever, I
 apologize for that.

 The thought police has won :(

There's nothing wrong with cracking jokes, but sometimes a large
central repository is the wrong place for them. If I made a joke
package whose name happened to be very similar to some other package,
then no matter how funny and non-offensive the joke is, it would be a
poor submission to PyPI. But that's not thought police; there are
plenty of other avenues for publication. Felinx Lee still has the
freedom to think his joke, to write his joke in code, and to share his
joke with others - but other people have the freedom to get offended
when it's published in places that they think are racist, or whatever
it was. (I never did follow how sexism is somehow a subset of racism,
to be honest. Are women a different race from nerds?)

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


Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error

2012-01-02 Thread Νικόλαος Κούρας
On 23 Δεκ 2011, 19:14, Νικόλαος Κούρας nikos.kou...@gmail.com wrote:
 On 23 Äåê, 12:41, becky_lewis bex.le...@gmail.com wrote:

  Is there any possibility that you can tell us what the script actually
  is or provide a code listing (use pastebin if it's big)?

 The script is about retrieving and storing the visitros hostnames to
 mysql database creating a log file.

 I dont know why this line host =
 socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] fails sometimes
 and some other times works ok retrieving the hostnames correctly.

 What do you understand from the traceback?!

Please i need some help. My webpage doesn't work due to this error...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error

2012-01-02 Thread Heiko Wundram

Am 02.01.2012 14:25, schrieb Νικόλαος Κούρας:

On 23 Δεκ 2011, 19:14, Νικόλαος Κούραςnikos.kou...@gmail.com  wrote:

I dont know why this line host =
socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] fails sometimes
and some other times works ok retrieving the hostnames correctly.


Please i need some help. My webpage doesn't work due to this error...


The error herror: (1, ...) says it all: the DNS-name (i.e., the 
something.in-addr.arpa name) you're trying to resolve is unknown. Not 
all hosts (or rather, IPs) on the internet have reverse lookups: try the 
IP 81.14.209.35 from which I'm posting, and dig/nslookup will tell you 
that it has no reverse resolution, which would result in gethostbyaddr() 
throwing an herror-instance.


Basically: make the reverse lookup conditional by wrapping it in a 
try:/except herror: and assigning an appropriate default for host in 
case reverse lookup fails.


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


Re: Can't write to a directory made w/ os.makedirs

2012-01-02 Thread Dave Angel

On 01/01/2012 10:14 PM, David Goldsmith wrote:

On Jan 1, 7:05 am, Tim Goldenm...@timgolden.me.uk  wrote:

On 01/01/2012 12:05, David Goldsmith wrote:
ie can the Python process creating the directories,
  
Yes.
  
and a subprocess called from it create a simple file?
  
No.
  
Depending on where you are in the filesystem, it may indeed
be necessary to be running as administrator. But don't try
to crack every security nut with an elevated sledgehammer.
  
If you mean running as admin., those were my sentiments exactly.  So,
there isn't something specific I should be doing to assure that my
subproceses can write to directories?

In the general case, no. By default, a subprocess will have
the same security context as its parent. The exception is
where the parent (the Python processing invoking subprocess.call
in this example) is already impersonating a different user;
in that case, the subprocess will inherit its grandparent's
context.

But unless you're doing something very deliberate here then
I doubt if that's biting you.

Can I ask: are you absolutely certain that the processes
you're calling are doing what you think they are and failing
where you think they're failing?

TJG

I'm a mathematician: the only thing I'm absolutely certain of is
nothing.

Here's my script, in case that helps:

import os
import sys
import stat
import os.path as op
import subprocess as sub
from os import remove
from os import listdir as ls
from os import makedirs as mkdir

def doFlac2Mp3(arg, d, fl):
 if '.flac' in [f[-5:] for f in fl]:
 newD = d.replace('FLACS', 'MP3s')
 mkdir(newD)
 for f in fl:
 if f[-5:]=='.flac':
 root = f.replace('.flac', '')
 cmd = ['C:\\Program Files (x86)\\aTunes\\win_tools\
\flac.exe -d ' +
'--output-prefix=' + newD + '\\', f]
 res = sub.call(cmd)#, env={'PATH': os.defpath})
 if not res:
 cmd = ['C:\\Program Files (x86)\\aTunes\\win_tools
\\lame.exe -h',
 newD + root + '.wav',  newD + root +
'.mp3']
 res = sub.call(cmd)#, env={'PATH': os.defpath})
 if not res:
 rf = newD + root + '.wav'
 remove(rf)

top=sys.argv[1]
op.walk(top, doFlac2Mp3, None)
The line cmd= is bogus.  You're trying to run a program with a -h after 
the filename.  The reason you're passing a list to sub.call is to 
separate the parameters from the program name, not to mention with 
quotes in its name.  So the -h has to be  a separate list item.  
(Although Windows will probably handle it correctly if you combine the 
-h with the FOLLOWING argument, it's still bad practice]


cmd = [ c:\\program files  \\lame.exe, -h, newD + root + .



--

DaveA

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


Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error

2012-01-02 Thread Νικόλαος Κούρας
On 2 Ιαν, 16:00, Heiko Wundram modeln...@modelnine.org wrote:
 Am 02.01.2012 14:25, schrieb Νικόλαος Κούρας:

  On 23 Δεκ 2011, 19:14, Νικόλαος Κούραςnikos.kou...@gmail.com  wrote:
  I dont know why this line host =
  socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] fails sometimes
  and some other times works ok retrieving the hostnames correctly.

  Please i need some help. My webpage doesn't work due to this error...

 The error herror: (1, ...) says it all: the DNS-name (i.e., the
 something.in-addr.arpa name) you're trying to resolve is unknown. Not
 all hosts (or rather, IPs) on the internet have reverse lookups: try the
 IP 81.14.209.35 from which I'm posting, and dig/nslookup will tell you
 that it has no reverse resolution, which would result in gethostbyaddr()
 throwing an herror-instance.

I see

 Basically: make the reverse lookup conditional by wrapping it in a
 try:/except herror: and assigning an appropriate default for host in
 case reverse lookup fails.

Can tou show me how to write this please?

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


Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error

2012-01-02 Thread Roy Smith
In article 
6b787f23-5813-4831-a349-02883f564...@q7g2000yqn.googlegroups.com,
 ÉΪÉ«É»όλαος Κούρας nikos.kou...@gmail.com wrote:

 On 2 ÉßÉΩÉΥ, 16:00, Heiko Wundram modeln...@modelnine.org wrote:
  Am 02.01.2012 14:25, schrieb ÉΪÉ«É»όλαος Κούρας:
 
   On 23 Δεκ 2011, 19:14, Νικόλαος 
   Κούραςnikos.kou...@gmail.com  wrote:
   I dont know why this line host =
   socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] fails sometimes
   and some other times works ok retrieving the hostnames correctly.
 
   Please i need some help. My webpage doesn't work due to this error...
 
  The error herror: (1, ...) says it all: the DNS-name (i.e., the
  something.in-addr.arpa name) you're trying to resolve is unknown. Not
  all hosts (or rather, IPs) on the internet have reverse lookups: try the
  IP 81.14.209.35 from which I'm posting, and dig/nslookup will tell you
  that it has no reverse resolution, which would result in gethostbyaddr()
  throwing an herror-instance.
 
 I see
 
  Basically: make the reverse lookup conditional by wrapping it in a
  try:/except herror: and assigning an appropriate default for host in
  case reverse lookup fails.
 
 Can tou show me how to write this please?

try:
   host =  socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0]
except socket.herror:
   host = unknown host
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error

2012-01-02 Thread Thomas Rachel

Am 22.12.2011 15:40 schrieb Νικόλαος Κούρας:

Hello when i try to visit my webpage i get the error it displays. Iam
not posting it since you can see it by visiting my webpage at
http://superhost.gr

Please if you can tell me what might be wrong.


What is wrong on this site? Mainly the unwanted sound.

Are you trying to sell something? Then you should try not to scare your 
potential customers away.

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


Re: Python education survey

2012-01-02 Thread Grant Edwards
On 2012-01-01, Alexander Kapps alex.ka...@web.de wrote:
 On 01.01.2012 03:36, Grant Edwards wrote:
 On 2011-12-31, Alexander Kappsalex.ka...@web.de  wrote:
 On 31.12.2011 19:23, Roy Smith wrote:

 Why do I waste my time reading your pretentious self-important nonsense?

 http://xkcd.com/386/

 ;)

 Why ROFLMAO when double-plus funny works just as well?

 xkcd/386 has been the excuse for replying to RR for ages and I still
 don't understand why he gets that much advertence. Charity? Sympathy
 for the lone and broken?

 Sadly, RR's post are often (in the supposed words of Wolfgang Pauli)
 not even wrong.

 I'm sure, RR is now jumping up high in rapture for being compared to 
 high-profile scientist geniuses.

I'm not comparing RR to Pauli.  I'm quoting somethin Pauli said when
criticising something that was so confusing and ill conceived that it
wasn't even wrong.

-- 
Grant

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


Re: Generating sin/square waves sound

2012-01-02 Thread Dave Angel

On 01/02/2012 02:24 AM, Paulo da Silva wrote:

Em 30-12-2011 10:05, Dave Angel escreveu:

On 12/30/2011 02:17 AM, Paulo da Silva wrote:

Hi,
Sorry if this is a FAQ, but I have googled and didn't find any
satisfatory answer.

Is there a simple way, preferably multiplataform (or linux), of
generating sinusoidal/square waves sound in python?

Thanks for any answers/suggestions.

If you're willing to be Linux-only, then I believe you can do it without
any extra libraries.

You build up a string (8 bit char, on Python 2.x)  of samples, and write
it to  /dev/audio.  When i experimented, I was only interested in a
few seconds, so a single write was all I needed.

Note that the samples are 8 bits, and they are offset by 128.  So a zero
signal would be a string of 128 values.  A very quiet square wave might
be a bunch of 126, followed by a bunch of 130.  and so on.  And the
loudest might be a bunch of 2's followed by a bunch of 253's.

You'll have to experiment with data rate;   The data is sent out at a
constant rate from your string, but I don't know what that rate is.



This sounds nice, but then is 8 bits the limit for /dev/audio? What
about stereo? I don't need this one ... just for curiosity.
Thanks.
I don't even remember where I got the information, but it sufficed for 
my needs.  I wanted to be able to generate arbitrary tones at a high 
volume, bypassing any volume control system settings.  I assume there's 
some way (ioctl ?) to tell the device to interpret differently.  It's 
even possible that it's already stereo (left/right samples stored in 
adjacent 16bit locations -- it wouldn't change the effect I hear, except 
for the frequency being cut in half.


Interesting link from1991, it's from Guido, but doesn't mention Python
http://wiretap.area.com/Gopher/Library/Techdoc/Misc/audiofor.faq
Also, a lot has changed since then.

Now I wonder whether I should be sending u-law values, rather than 
linear ones.  I'm generating sine waves, and they don't really sound 
flutelike.


This link probably has all our answers.
http://www.faqs.org/docs/Linux-HOWTO/Sound-HOWTO.html

I suspect that my approach will simply use the latest setup values (eg. 
sampling rate) and thus runs the risk of sometimes not working.  That 
hasn't been my experience,  The only problem I see is that sometimes the 
device is busy.  When that happens, other programs don't seem to work 
either.  I need to find the rogue process which is hogging the device, 
using fuser.


--

DaveA

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


Re: Spamming PyPI with stupid packages

2012-01-02 Thread Lie Ryan

On 01/02/2012 11:20 PM, Peter Otten wrote:

Felinx Lee wrote:


I have removed those packages (girlfriend and others) from PyPI forever, I
apologize for that.


The thought police has won :(


I think the community has a right to defend themselves against trolls. 
If it's just bad naming, we can probably just laugh it off; but when a 
failed joke spans a half dozen module and just opens a browser to his 
website, there is no value for it to stay at PyPI. Additionally, it may 
fuel copycats: http://pypi.python.org/pypi/kimwoohyeon1/1.3.0 (do anyone 
have any idea who submitted that one?)


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


Re: Generating sin/square waves sound

2012-01-02 Thread Paulo da Silva
Em 30-12-2011 07:17, Paulo da Silva escreveu:
 Hi,
 Sorry if this is a FAQ, but I have googled and didn't find any
 satisfatory answer.
 
 Is there a simple way, preferably multiplataform (or linux), of
 generating sinusoidal/square waves sound in python?
 
 Thanks for any answers/suggestions.

Thank you very much to all who responded.
There is enough material here to spend some time searching for the best
solution for me.
In the meanwhile I also found http://www.speech.kth.se/snack.
May be it could also be useful.

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


Re: InvalidResponseError: headers must be str

2012-01-02 Thread Waldek M.
On Sat, 31 Dec 2011 17:40:15 -0800 (PST), Niklas Rosencrantz wrote:
 Thanks for the replies here. I will have patience but this bug
 is blocking my integration efforts. I tried logging the TCP
 packets with tcpdump and nothing special appeared.

Well, it's free software, isn't it?
You may either wait a little, fix it yourself or pay someone 
to fix it for you, if you're in a hurry. Or stay with 2.5 / try upgrading
to 3.x.

The Python community is usually very helpful and friendly, but
by *demanding a fix ASAP you may accidentily step on people's toes :-)

Best regards,
Waldek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error

2012-01-02 Thread Νικόλαος Κούρας
On 2 Ιαν, 17:49, Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-
a470-7603bd3aa...@spamschutz.glglgl.de wrote:
 Am 22.12.2011 15:40 schrieb Νικόλαος Κούρας:

  Hello when i try to visit my webpage i get the error it displays. Iam
  not posting it since you can see it by visiting my webpage at
 http://superhost.gr

  Please if you can tell me what might be wrong.

 What is wrong on this site? Mainly the unwanted sound.

 Are you trying to sell something? Then you should try not to scare your
 potential customers away.

I'am trying to present myself through my webpage as computer tech.
Is the background music so bad?! :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error

2012-01-02 Thread Νικόλαος Κούρας
On 2 Ιαν, 17:47, Roy Smith r...@panix.com wrote:
 In article
 6b787f23-5813-4831-a349-02883f564...@q7g2000yqn.googlegroups.com,
  ÉΪÉ«É»όλαος Κούρας nikos.kou...@gmail.com wrote:









  On 2 ÉßÉΩÉΥ, 16:00, Heiko Wundram modeln...@modelnine.org wrote:
   Am 02.01.2012 14:25, schrieb ÉΪÉ«É»όλαος Κούρας:

On 23 Δεκ 2011, 19:14, Νικόλαος Κούραςnikos.kou...@gmail.com  wrote:
I dont know why this line host =
socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] fails sometimes
and some other times works ok retrieving the hostnames correctly.

Please i need some help. My webpage doesn't work due to this error...

   The error herror: (1, ...) says it all: the DNS-name (i.e., the
   something.in-addr.arpa name) you're trying to resolve is unknown. Not
   all hosts (or rather, IPs) on the internet have reverse lookups: try the
   IP 81.14.209.35 from which I'm posting, and dig/nslookup will tell you
   that it has no reverse resolution, which would result in gethostbyaddr()
   throwing an herror-instance.

  I see

   Basically: make the reverse lookup conditional by wrapping it in a
   try:/except herror: and assigning an appropriate default for host in
   case reverse lookup fails.

  Can tou show me how to write this please?

 try:
    host =  socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0]
 except socket.herror:
    host = unknown host

Thank you very much.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error

2012-01-02 Thread Roy Smith
In article 
bacea15d-fae0-4b1f-8a8e-a8b06b561...@t30g2000vbx.googlegroups.com,
 ÉΪÉ«É»όλαος Κούρας nikos.kou...@gmail.com wrote:

 I'am trying to present myself through my webpage as computer tech.
 Is the background music so bad?! :-)

Yes.  Background music on web sites is evil.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: readline for mac python? (really, reproducing mac python packages)

2012-01-02 Thread K Richard Pixley

On 1/1/12 19:04 , K Richard Pixley wrote:

On 1/1/12 16:49 , K Richard Pixley wrote:

I'm having trouble finding a reasonable python environment on mac.

The supplied binaries, (2.7.2, 3.2.2), are built with old versions of
macosx and are not capable of building any third party packages that
require gcc.

The source builds easily enough out of the box, (./configure
--enable-framework  make  sudo make install), but when I do that, I
end up with a python interpreter that lacks readline.

How do I get readline involved?

Or better... is there an instruction sheet somewhere on how to reproduce
the python.org binary packages?

--rich


Bah. I just needed to dig a little deeper into the source. All the doc I
wanted is in there.


Well, partial victory.  2.7.2 builds.  3.2 doesn't.

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


Python3 on MacOsX Lion?

2012-01-02 Thread K Richard Pixley
Where would I look to find the current expected status of python3 on 
MacOsX Lion?


The distributed binaries aren't capable of allowing extensions that use gcc.

I can build the source naked, but then it lacks some libraries, notably, 
readline.


Attempting to build the full Mac packages fails, even with the few tiny 
patches I used for 2.7.2.


Is anyone working on this?  Are there pre-release patches available?

Should I be asking elsewhere?

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


Re: Spamming PyPI with stupid packages

2012-01-02 Thread Ben Finney
Peter Otten __pete...@web.de writes:

 Felinx Lee wrote:

  I have removed those packages (girlfriend and others) from PyPI
  forever, I apologize for that.

 The thought police has won :(

Nonsense. Felinx is free to make sexist jokes, and others are free to
howl him down when he does so. PyPI has no obligation to be a platform
to amplify anyone's prejudice.

-- 
 \ “I have never imputed to Nature a purpose or a goal, or |
  `\anything that could be understood as anthropomorphic.” —Albert |
_o__)Einstein, unsent letter, 1955 |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error

2012-01-02 Thread Νικόλαος Κούρας
On 2 Ιαν, 20:42, Roy Smith r...@panix.com wrote:
 In article
 bacea15d-fae0-4b1f-8a8e-a8b06b561...@t30g2000vbx.googlegroups.com,
  ÉΪÉ«É»όλαος Κούρας nikos.kou...@gmail.com wrote:

  I'am trying to present myself through my webpage as computer tech.
  Is the background music so bad?! :-)

 Yes.  Background music on web sites is evil.

Evil?!?! How come? :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error

2012-01-02 Thread Νικόλαος Κούρας
On 2 Ιαν, 20:42, Roy Smith r...@panix.com wrote:
 In article
 bacea15d-fae0-4b1f-8a8e-a8b06b561...@t30g2000vbx.googlegroups.com,
  ÉΪÉ«É»όλαος Κούρας nikos.kou...@gmail.com wrote:

  I'am trying to present myself through my webpage as computer tech.
  Is the background music so bad?! :-)

 Yes.  Background music on web sites is evil.

Evil?!?! How come? :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error

2012-01-02 Thread Roy Smith
In article 
24123dfe-b2fc-4f4c-8dfe-23bfef19b...@m10g2000vbc.googlegroups.com,
 ÉΪÉ«É»όλαος Κούρας nikos.kou...@gmail.com wrote:

 On 2 ÉßÉΩÉΥ, 20:42, Roy Smith r...@panix.com wrote:
  In article
  bacea15d-fae0-4b1f-8a8e-a8b06b561...@t30g2000vbx.googlegroups.com,
  †ÉΪÉ«É»όλαος Κούρας nikos.kou...@gmail.com wrote:
 
   I'am trying to present myself through my webpage as computer tech.
   Is the background music so bad?! :-)
 
  Yes.  Background music on web sites is evil.
 
 Evil?!?! How come? :)

Because people hate going to web sites and having background music start 
to play.  But, there are better fora than here for discussions of web 
site best practices.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spamming PyPI with stupid packages

2012-01-02 Thread Devin Jeanpierre
 Nonsense. Felinx is free to make sexist jokes, and others are free to
 howl him down when he does so. PyPI has no obligation to be a platform
 to amplify anyone's prejudice.

A module named girlfriend won't amplify anyone's prejudice. It is,
at that point, just a joke. The punchline is import girlfriend, and
the joke makes fun of geeky losers, not women.

But, hey, inertia. As long as we're trying to make this dude get rid
of the offensive part, might as well get rid of the rest too. Why not
make him get rid of everything he's written, too? Woo, party time!

-- Devin

On Mon, Jan 2, 2012 at 2:45 PM, Ben Finney ben+pyt...@benfinney.id.au wrote:
 Peter Otten __pete...@web.de writes:

 Felinx Lee wrote:

  I have removed those packages (girlfriend and others) from PyPI
  forever, I apologize for that.

 The thought police has won :(

 Nonsense. Felinx is free to make sexist jokes, and others are free to
 howl him down when he does so. PyPI has no obligation to be a platform
 to amplify anyone's prejudice.

 --
  \             “I have never imputed to Nature a purpose or a goal, or |
  `\    anything that could be understood as anthropomorphic.” —Albert |
 _o__)                                    Einstein, unsent letter, 1955 |
 Ben Finney
 --
 http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python3 on MacOsX Lion?

2012-01-02 Thread Benjamin Kaplan
On Mon, Jan 2, 2012 at 2:32 PM, K Richard Pixley r...@noir.com wrote:
 Where would I look to find the current expected status of python3 on MacOsX
 Lion?

 The distributed binaries aren't capable of allowing extensions that use gcc.

 I can build the source naked, but then it lacks some libraries, notably,
 readline.

 Attempting to build the full Mac packages fails, even with the few tiny
 patches I used for 2.7.2.

 Is anyone working on this?  Are there pre-release patches available?

 Should I be asking elsewhere?

 --rich
 --

Have you tried building through Macports?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python3 on MacOsX Lion?

2012-01-02 Thread K Richard Pixley

On 1/2/12 13:03 , Benjamin Kaplan wrote:

On Mon, Jan 2, 2012 at 2:32 PM, K Richard Pixleyr...@noir.com  wrote:

Where would I look to find the current expected status of python3 on MacOsX
Lion?

The distributed binaries aren't capable of allowing extensions that use gcc.

I can build the source naked, but then it lacks some libraries, notably,
readline.

Attempting to build the full Mac packages fails, even with the few tiny
patches I used for 2.7.2.

Is anyone working on this?  Are there pre-release patches available?

Should I be asking elsewhere?

--rich
--


Have you tried building through Macports?


No, I haven't.  Macports scares me.  When I tried them, or fink, in the 
past, they rapidly polluted my boot disk and I didn't have any way to 
unpollute it other than reloading from scratch.


In freebsd, netbsd, or any of the linux distributions, I can trivially 
create a virtual machine in about 20 minutes, screw with it as I like, 
and toss it in seconds.  In modern linux, I can create a root file 
system with btrfs, snapshot, chroot to the snapshot and munge away. 
When I'm done, I can just toss the snapshot.  (Can do snapshots in 
vmware too).


If I screw up my boot drive in MacOsX, I'm in for hours of recovery time 
reloading from Time Machine.  While that's a lot better than it used to 
be now that Time Machine is available, (reloading can now be done 
largely unattended), it's not a price I'm willing to pay in order to 
attempt to use Macports.


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


Re: Spamming PyPI with stupid packages

2012-01-02 Thread Ben Finney
Devin Jeanpierre jeanpierr...@gmail.com writes:

  Nonsense. Felinx is free to make sexist jokes, and others are free
  to howl him down when he does so. PyPI has no obligation to be a
  platform to amplify anyone's prejudice.

 A module named girlfriend won't amplify anyone's prejudice. It is,
 at that point, just a joke.

I agree that it's a joke. It is a joke at the expense of women:
promoting the view that, like a car or a house (the other modules that
were part of the joke), a girlfriend is a possession to be acquired.

 The punchline is import girlfriend

Yes, exactly.

The next time someone asks why the ratio of women becoming programmers
is disproportionately low, please recall episodes where men here give
defenses of jokes that objectify women.

Instead, the more we marginalise sexism and reject normalising it
through sexist jokes, the safer this community can become for anyone of
any sex.

-- 
 \   “If trees could scream, would we be so cavalier about cutting |
  `\   them down? We might, if they screamed all the time, for no good |
_o__)reason.” —Jack Handey |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Spamming PyPI with stupid packages

2012-01-02 Thread Robert Kern

On 1/2/12 8:56 PM, Devin Jeanpierre wrote:


But, hey, inertia. As long as we're trying to make this dude get rid
of the offensive part, might as well get rid of the rest too. Why not
make him get rid of everything he's written, too?


Because that's something that no one desires, nor is it the logical conclusion 
of anything that anyone has expressed here. Please don't invent strawmen.


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

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


Re: .format vs. %

2012-01-02 Thread Ethan Furman

Andrew Berg wrote:

On 12/31/2011 12:19 PM, davidfx wrote:

Should we always be using .format() for formatting strings or %?



%-style formatting will eventually go away, but
probably not for a long time.


%-style formatting isn't going away.

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


Re: Python3 on MacOsX Lion?

2012-01-02 Thread Tamer Higazi

Hi Rich!
Why don't you ask the maintainer who built the macport?!
Why don't you try to to figure out with WHAT kind of tools they have 
built the mac port and WHERE to get them either. And ask him also how 
to set the flags to build the 64bit edition.


Then you don't have to be afraid of any prebuild mac port editions. This 
is how I would do it.


Tamer


Am 02.01.2012 22:23, schrieb K Richard Pixley:

On 1/2/12 13:03 , Benjamin Kaplan wrote:

On Mon, Jan 2, 2012 at 2:32 PM, K Richard Pixleyr...@noir.com  wrote:
Where would I look to find the current expected status of python3 on 
MacOsX

Lion?

The distributed binaries aren't capable of allowing extensions that 
use gcc.


I can build the source naked, but then it lacks some libraries, 
notably,

readline.

Attempting to build the full Mac packages fails, even with the few tiny
patches I used for 2.7.2.

Is anyone working on this?  Are there pre-release patches available?

Should I be asking elsewhere?

--rich
--


Have you tried building through Macports?


No, I haven't.  Macports scares me.  When I tried them, or fink, in 
the past, they rapidly polluted my boot disk and I didn't have any way 
to unpollute it other than reloading from scratch.


In freebsd, netbsd, or any of the linux distributions, I can trivially 
create a virtual machine in about 20 minutes, screw with it as I like, 
and toss it in seconds.  In modern linux, I can create a root file 
system with btrfs, snapshot, chroot to the snapshot and munge away. 
When I'm done, I can just toss the snapshot.  (Can do snapshots in 
vmware too).


If I screw up my boot drive in MacOsX, I'm in for hours of recovery 
time reloading from Time Machine.  While that's a lot better than it 
used to be now that Time Machine is available, (reloading can now be 
done largely unattended), it's not a price I'm willing to pay in order 
to attempt to use Macports.


--rich


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


Avoid race condition with Popen.send_signal

2012-01-02 Thread Jérôme
Hi all.

When a subprocess is running, it can be sent a signal with the send_signal
method :

process = Popen( args)
process.send_signal(signal.SIGINT)

If the SIGINT is sent while the process has already finished, an error is
raised : 

  File /usr/lib/python2.7/subprocess.py, line 1457, in send_signal
os.kill(self.pid, sig)
OSError: [Errno 3] Aucun processus de ce type

To avoid this, I can check that the process is still alive :

process = Popen( args)
process.poll()
if (None == process.returncode):
process.send_signal(signal.SIGINT)

It makes safer, but there is still an issue if the process ends between
poll() and send_signal().

What is the clean way to avoid this race condition ?

Should I use try/except to catch the error or is there a more elegant way to
go ?

Thanks.

-- 
Jérôme
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Avoid race condition with Popen.send_signal

2012-01-02 Thread MRAB

On 02/01/2012 23:09, Jérôme wrote:

Hi all.

When a subprocess is running, it can be sent a signal with the send_signal
method :

process = Popen( args)
process.send_signal(signal.SIGINT)

If the SIGINT is sent while the process has already finished, an error is
raised :

   File /usr/lib/python2.7/subprocess.py, line 1457, in send_signal
 os.kill(self.pid, sig)
OSError: [Errno 3] Aucun processus de ce type

To avoid this, I can check that the process is still alive :

process = Popen( args)
process.poll()
if (None == process.returncode):
 process.send_signal(signal.SIGINT)

It makes safer, but there is still an issue if the process ends between
poll() and send_signal().

What is the clean way to avoid this race condition ?

Should I use try/except to catch the error or is there a more elegant way to
go ?


I think that catching the exception is probably the most Pythonic way.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Spamming PyPI with stupid packages

2012-01-02 Thread Devin Jeanpierre
 Because that's something that no one desires, nor is it the logical
 conclusion of anything that anyone has expressed here. Please don't invent
 strawmen.

You're right, sorry. I let myself say something dumb. I'll try not to
do it again.

-- Devin

On Mon, Jan 2, 2012 at 5:43 PM, Robert Kern robert.k...@gmail.com wrote:
 On 1/2/12 8:56 PM, Devin Jeanpierre wrote:

 But, hey, inertia. As long as we're trying to make this dude get rid
 of the offensive part, might as well get rid of the rest too. Why not
 make him get rid of everything he's written, too?


 Because that's something that no one desires, nor is it the logical
 conclusion of anything that anyone has expressed here. Please don't invent
 strawmen.


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

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


Re: Avoid race condition with Popen.send_signal

2012-01-02 Thread Adam Skutt
On Jan 2, 6:09 pm, Jérôme jer...@jolimont.fr wrote:
 Hi all.

 When a subprocess is running, it can be sent a signal with the send_signal
 method :

 process = Popen( args)
 process.send_signal(signal.SIGINT)

 If the SIGINT is sent while the process has already finished, an error is
 raised :

   File /usr/lib/python2.7/subprocess.py, line 1457, in send_signal
     os.kill(self.pid, sig)
 OSError: [Errno 3] Aucun processus de ce type

 To avoid this, I can check that the process is still alive :

 process = Popen( args)
 process.poll()
 if (None == process.returncode):
     process.send_signal(signal.SIGINT)

 It makes safer, but there is still an issue if the process ends between
 poll() and send_signal().

 What is the clean way to avoid this race condition ?

The fundamental race condition cannot be removed nor avoided. Ideally,
avoid the need to send the subprocess a signal in the first place.  If
it cannot be avoided, then trap the exception.

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


Re: Avoid race condition with Popen.send_signal

2012-01-02 Thread Devin Jeanpierre
 I think that catching the exception is probably the most Pythonic way.

It's the only correct way.

-- Devin

On Mon, Jan 2, 2012 at 6:51 PM, MRAB pyt...@mrabarnett.plus.com wrote:
 On 02/01/2012 23:09, Jérôme wrote:

 Hi all.

 When a subprocess is running, it can be sent a signal with the send_signal
 method :

 process = Popen( args)
 process.send_signal(signal.SIGINT)

 If the SIGINT is sent while the process has already finished, an error is
 raised :

   File /usr/lib/python2.7/subprocess.py, line 1457, in send_signal
     os.kill(self.pid, sig)
 OSError: [Errno 3] Aucun processus de ce type

 To avoid this, I can check that the process is still alive :

 process = Popen( args)
 process.poll()
 if (None == process.returncode):
     process.send_signal(signal.SIGINT)

 It makes safer, but there is still an issue if the process ends between
 poll() and send_signal().

 What is the clean way to avoid this race condition ?

 Should I use try/except to catch the error or is there a more elegant way
 to
 go ?

 I think that catching the exception is probably the most Pythonic way.
 --
 http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Idiot-proof installs for python+pygame+pyopenal+app

2012-01-02 Thread alex23
On Jan 2, 1:58 pm, Tim Chase python.l...@tim.thechases.com wrote:
 I'm looking at developing some tools that involve pygame+pyopenal
 and would like to make cross-platform distribution as painless as
 possible.

Hey Tim,

I don't have an answer, sorry, just two suggestions:

1. Maybe PyInstaller could be useful: http://www.pyinstaller.org/
2. Also ask on the Pygame mailing list: http://pygame.org/wiki/info

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


Re: Avoid race condition with Popen.send_signal

2012-01-02 Thread Cameron Simpson
On 02Jan2012 20:31, Devin Jeanpierre jeanpierr...@gmail.com wrote:
|  I think that catching the exception is probably the most Pythonic way.
| 
| It's the only correct way.

Indeed, but be precise - chek that it _is_ error 3, or more portably,
errno.ESRCH. POSIX probably mandates that that is a 3, but the symbol
should track the local system if it differs. Example:

  import errno
  ...
  try:
...signal...
  except OSError, e:
if e.errno == errno.ESRCH:
  pass  # or maybe an info log message
else:
  raise # something else wrong - raise exception anyway

Cheers,
-- 
Cameron Simpson c...@zip.com.au DoD#743
http://www.cskk.ezoshosting.com/cs/

WHATS A K3WL D00D AND WH3R3 CAN 1 G3T S0M3!!!
- Darren Embry
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: .format vs. %

2012-01-02 Thread Rick Johnson
On Jan 2, 4:00 pm, Ethan Furman et...@stoneleaf.us wrote:
 %-style formatting isn't going away.

You may want to freshen up on the definition of deprecation. If it
was NOT going away, why the need to deprecate it? hmm? It would be
more beneficial if you DO NOT encourage continued usage of this end-
of-life feature.

   http://en.wikipedia.org/wiki/Deprecation
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: .format vs. %

2012-01-02 Thread Rick Johnson
On Dec 31 2011, 12:19 pm, davidfx dgeorge2...@gmail.com wrote:
 Hello everyone,
 I just have a quick question about .format and %r %s %d.

 Should we always be using .format() for formatting strings or %?

ALWAYS use the format method over the old and dumpy string
interpolation. Why? Well because the format method is so much more
powerful, elegant, and the way of the future. Some might argue that
format is slower than interpolation (and i can't comment in favor of
either) HOWEVER, if speed is your concern than interpolation is NOT
the answer.

 If I wanted to put .format into a variable, how would I do that.

That question has been answered many times in this thread already.

You may find the format spec to be cryptic at first. Well, most find
regexes cryptic also -- but would anyone recommend NOT using regexes
just because of crypti-ness? I think not. It's a non-starter.

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


Re: Python3 on MacOsX Lion?

2012-01-02 Thread Benjamin Kaplan
On Mon, Jan 2, 2012 at 6:03 PM, Tamer Higazi th9...@googlemail.com wrote:
 Hi Rich!
 Why don't you ask the maintainer who built the macport?!
 Why don't you try to to figure out with WHAT kind of tools they have built
 the mac port and WHERE to get them either. And ask him also how to set the
 flags to build the 64bit edition.

 Then you don't have to be afraid of any prebuild mac port editions. This is
 how I would do it.

 Tamer


That's not quite how Macports works. Macports is a package manager.
Each package has a port file with (among other things)
1) A location to download the source tarball
2) A list of patches to apply
3) A list of dependencies
4) Sets of config arguments and build scripts for different variants

Richard, if something goes wrong with Macports, nuking /opt/local does
a pretty good job of cleaning it up. And even if you don't want to use
Macports, you can still grab their patches. They're all here:
http://trac.macports.org/browser/trunk/dports/lang/python32. You can
dig through the portfile to see what patches and config flags they're
using to build it.

 Am 02.01.2012 22:23, schrieb K Richard Pixley:

 On 1/2/12 13:03 , Benjamin Kaplan wrote:

 On Mon, Jan 2, 2012 at 2:32 PM, K Richard Pixleyr...@noir.com  wrote:

 Where would I look to find the current expected status of python3 on
 MacOsX
 Lion?

 The distributed binaries aren't capable of allowing extensions that use
 gcc.

 I can build the source naked, but then it lacks some libraries, notably,
 readline.

 Attempting to build the full Mac packages fails, even with the few tiny
 patches I used for 2.7.2.

 Is anyone working on this?  Are there pre-release patches available?

 Should I be asking elsewhere?

 --rich
 --


 Have you tried building through Macports?


 No, I haven't.  Macports scares me.  When I tried them, or fink, in the
 past, they rapidly polluted my boot disk and I didn't have any way to
 unpollute it other than reloading from scratch.

 In freebsd, netbsd, or any of the linux distributions, I can trivially
 create a virtual machine in about 20 minutes, screw with it as I like, and
 toss it in seconds.  In modern linux, I can create a root file system with
 btrfs, snapshot, chroot to the snapshot and munge away. When I'm done, I can
 just toss the snapshot.  (Can do snapshots in vmware too).

 If I screw up my boot drive in MacOsX, I'm in for hours of recovery time
 reloading from Time Machine.  While that's a lot better than it used to be
 now that Time Machine is available, (reloading can now be done largely
 unattended), it's not a price I'm willing to pay in order to attempt to use
 Macports.

 --rich


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


Re: Can't write to a directory made w/ os.makedirs

2012-01-02 Thread David Goldsmith
On Jan 2, 6:09 am, Dave Angel d...@davea.name wrote:
 On 01/01/2012 10:14 PM, David Goldsmith wrote:







  On Jan 1, 7:05 am, Tim Goldenm...@timgolden.me.uk  wrote:
  On 01/01/2012 12:05, David Goldsmith wrote:
      ie can the Python process creating the directories,

      Yes.

      and a subprocess called from it create a simple file?

      No.

      Depending on where you are in the filesystem, it may indeed
      be necessary to be running as administrator. But don't try
      to crack every security nut with an elevated sledgehammer.

      If you mean running as admin., those were my sentiments exactly.  So,
      there isn't something specific I should be doing to assure that my
      subproceses can write to directories?

  In the general case, no. By default, a subprocess will have
  the same security context as its parent. The exception is
  where the parent (the Python processing invoking subprocess.call
  in this example) is already impersonating a different user;
  in that case, the subprocess will inherit its grandparent's
  context.

  But unless you're doing something very deliberate here then
  I doubt if that's biting you.

  Can I ask: are you absolutely certain that the processes
  you're calling are doing what you think they are and failing
  where you think they're failing?

  TJG
  I'm a mathematician: the only thing I'm absolutely certain of is
  nothing.

  Here's my script, in case that helps:

  import os
  import sys
  import stat
  import os.path as op
  import subprocess as sub
  from os import remove
  from os import listdir as ls
  from os import makedirs as mkdir

  def doFlac2Mp3(arg, d, fl):
       if '.flac' in [f[-5:] for f in fl]:
           newD = d.replace('FLACS', 'MP3s')
           mkdir(newD)
           for f in fl:
               if f[-5:]=='.flac':
                   root = f.replace('.flac', '')
                   cmd = ['C:\\Program Files (x86)\\aTunes\\win_tools\
  \flac.exe -d ' +
                          '--output-prefix=' + newD + '\\', f]
                   res = sub.call(cmd)#, env={'PATH': os.defpath})
                   if not res:
                       cmd = ['C:\\Program Files (x86)\\aTunes\\win_tools
  \\lame.exe -h',
                               newD + root + '.wav',  newD + root +
  '.mp3']
                       res = sub.call(cmd)#, env={'PATH': os.defpath})
                       if not res:
                           rf = newD + root + '.wav'
                           remove(rf)

  top=sys.argv[1]
  op.walk(top, doFlac2Mp3, None)

 The line cmd= is bogus.  You're trying to run a program with a -h after
 the filename.  The reason you're passing a list to sub.call is to
 separate the parameters from the program name, not to mention with
 quotes in its name.  So the -h has to be  a separate list item.
 (Although Windows will probably handle it correctly if you combine the
 -h with the FOLLOWING argument, it's still bad practice]

 cmd = [ c:\\program files  \\lame.exe, -h, newD + root + .

 --

 DaveA

Thanks, this is the kind of feedback I was hoping for--the
documentation for subprocess.call is notably sparing to put it
politely.  However, having not yet tried it, I'm skeptical, as what
doc there is says:

subprocess.call(args, *, stdin=None, stdout=None, stderr=None,
shell=False)

Run the command described by args. Wait for command to complete,
then return the returncode attribute.

The arguments shown above are merely the most common ones,
described below in Frequently Used Arguments (hence the slightly odd
notation in the abbreviated signature). The full function signature is
the same as that of the Popen constructor - this functions passes all
supplied arguments directly through to that interface.
:
:
class subprocess.Popen(args, bufsize=0, executable=None, stdin=None,
stdout=None, stderr=None, preexec_fn=None, close_fds=False,
shell=False, cwd=None, env=None, universal_newlines=False,
startupinfo=None, creationflags=0)

Arguments are:

args should be a string, or a sequence of program arguments...On
Windows: the Popen class uses CreateProcess() to execute the child
child program, which operates on strings. If args is a sequence, it
will be converted to a string in a manner described in Converting an
argument sequence to a string on Windows.  Thus I didn't really see
the point of separating out the -h string--which tells lame to use
high quality encoding--into another sequence element, but as per your
advice, I'll try it (along with Tim's and MRAB's suggestions; I'll
report back what works).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2012-01-02 Thread alex23
On Dec 27 2011, 8:01 pm, Eelco hoogendoorn.ee...@gmail.com wrote:
 But I consider it a reasonable change for a
 'python 4', or whatever the next major version change will be called.

You do realise there were 8 years between 2  3? You might be waiting
for quite some time.

Conversely, you could pitch in behind Rick Johnson's Python 4000 fork,
I sure it's progressing nicely given how long Rick has been talking it
up.

 Writing a code-conversion tool to convert from *args to args::tuple
 would be quite easy indeed.

You might want to ask people maintaining libraries in both 2.x  3.x
via 2to3 just how well that's working out for them. If the impact of
changes was trivially obvious, the programming landscape would look
very different indeed.

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


Re: Avoid race condition with Popen.send_signal

2012-01-02 Thread Adam Skutt
On Jan 2, 8:44 pm, Cameron Simpson c...@zip.com.au wrote:
 On 02Jan2012 20:31, Devin Jeanpierre jeanpierr...@gmail.com wrote:
 |  I think that catching the exception is probably the most Pythonic way.
 |
 | It's the only correct way.

 Indeed, but be precise - chek that it _is_ error 3, or more portably,
 errno.ESRCH. POSIX probably mandates that that is a 3, but the symbol
 should track the local system if it differs. Example:


No. It is possible (however unlikely) for EPERM to be legitimately
returned in this case.  Anything other than EINVAL should be
interpreted as The child process is dead.  Hence why you should
avoid sending the signal in the first place: the situations where you
don't run the risk of possibly killing an innocent bystander are
pretty narrow.  While unlikely on modern UNiX and Linux, IMO it's best
to avoid the issue altogether whenever possible.

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


Re: .format vs. %

2012-01-02 Thread Steven D'Aprano
On Mon, 02 Jan 2012 17:51:48 -0800, Rick Johnson wrote:

 You may find the format spec to be cryptic at first. Well, most find
 regexes cryptic also -- but would anyone recommend NOT using regexes
 just because of crypti-ness? I think not. It's a non-starter.

I would.

If you have a task that doesn't *need* a regular expression solution, 
don't use a regular expression.


For what it's worth, I like the syntax of % formatting. It's nice and 
simple and compact while still being readable. format() is more powerful, 
but when I don't need that power, I stick to % formatting.


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


Re: .format vs. %

2012-01-02 Thread Steven D'Aprano
On Mon, 02 Jan 2012 17:59:43 -0800, Rick Johnson wrote:

 On Jan 2, 4:00 pm, Ethan Furman et...@stoneleaf.us wrote:
 %-style formatting isn't going away.
 
 You may want to freshen up on the definition of deprecation.

I'm sure Ethan knows the definition of deprecation. I'm sure he also 
knows that % formatting is NOT deprecated. Please stop spreading FUD 
about Python features.



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


Re: Avoid race condition with Popen.send_signal

2012-01-02 Thread Cameron Simpson
On 02Jan2012 19:16, Adam Skutt ask...@gmail.com wrote:
| On Jan 2, 8:44 pm, Cameron Simpson c...@zip.com.au wrote:
|  On 02Jan2012 20:31, Devin Jeanpierre jeanpierr...@gmail.com wrote:
|  |  I think that catching the exception is probably the most Pythonic way.
|  |
|  | It's the only correct way.
| 
|  Indeed, but be precise - chek that it _is_ error 3, or more portably,
|  errno.ESRCH. POSIX probably mandates that that is a 3, but the symbol
|  should track the local system if it differs. Example:
| 
| No. It is possible (however unlikely) for EPERM to be legitimately
| returned in this case.  Anything other than EINVAL should be
| interpreted as The child process is dead.

Sure. I was more taking the line: catch and accept only the specific
errors you understand. Of course he can catch EPERM also. But any other
variant should at the least generate a warning to stderr or a log -
it is _unexpected_.

I take your point that reraising the exception may be overkill for
failed signal delivery (if that was your point). But I am arguing for
being very careful about what you silently pass as an ok thing.

| Hence why you should
| avoid sending the signal in the first place: the situations where you
| don't run the risk of possibly killing an innocent bystander are
| pretty narrow.  While unlikely on modern UNiX and Linux, IMO it's best
| to avoid the issue altogether whenever possible.

Fair enough too. But sometimes you need to nail a rogue child.

Cheers,
-- 
Cameron Simpson c...@zip.com.au DoD#743
http://www.cskk.ezoshosting.com/cs/

Death is life's way of telling you you've been fired.   - R. Geis
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python3 on MacOsX Lion?

2012-01-02 Thread Ned Deily
In article eDnMq.3172$ik5.2...@newsfe03.iad,
 K Richard Pixley r...@noir.com wrote:
 Where would I look to find the current expected status of python3 on 
 MacOsX Lion?
 
 The distributed binaries aren't capable of allowing extensions that use gcc.
 
 I can build the source naked, but then it lacks some libraries, notably, 
 readline.
 
 Attempting to build the full Mac packages fails, even with the few tiny 
 patches I used for 2.7.2.
 
 Is anyone working on this?  Are there pre-release patches available?

The short answer is: yes, it is being worked on but it has been taking 
longer than it should.

The 64-bit/32-bit installers from python.org for Python 2.7.x and Python 
3.2.x have been being built on 10.6 with gcc-4.2.  OSX 10.7 (Lion) was 
initially released with Xcode 4.1 which still included a version of 
gcc-4.2 similar to what has been available all along in 10.6 (Snow 
Leopard).  However, more recently, Apple has released Xcode 4.2 which 
finally removed gcc-4.2 and now only includes updated versions of 
llvm-gcc-4.2 (gcc front-end with an llvm code generator backend) and 
clang (clang front-end with an llvm backend).  Apple has made it clear 
that they want developers and other users to move eventually to clang 
and that llvm-gcc is an interim step towards the migration to clang. 
While there are other reasons for that move (like the change in gcc 
licensing), I believe Apple believes that clang will provide an 
all-around better build experience (better code, better checking, better 
diagnostics, more flexibility).  But, as with any major change to a 
build compiler and environment, lots of nitty and often knotty problems 
are to be expected.  (For an idea of the breadth of them, peruse the 
MacPorts project mailing lists for all the issues they've been 
discovering in the many open source packages they support since they've 
moved to using clang by default.)  Python is no exception.   There are 
already a couple of fixes that have been applied for upcoming Python 
releases to deal with either llvm-gcc or clang issues.

To further complicate things, prior to the release of Lion, Apple made a 
preliminary version of Xcode 4 available for Snow Leopard through the 
Mac App Store but appears to have removed it for new purchases after 
Lion was released although it seems that previous purchasers and paying 
members of the Mac Developer program can get updates for it.  So, now 
some 10.6 users also no longer have gcc-4.2, although they do have the 
supported option of reverting to the most recent Xcode 3 release for 
10.6 which is free and still available through the Apple Developer 
Connection website.

The PSF (via python.org) also supplies 32-bit-only installer variants 
for OS X 10.3+ which were great for building applications to run on 
multiple versions of OS X.  But since Xcode 4 doesn't ship the necessary 
SDK (10.4u) and gcc-4.0, that installer version is also problematic on 
10.7.  We need to be careful in developing any fixes that we don't 
inadvertently break anything for older OS X releases like 10.5.  So, 
it's all a bit of mess at the moment with *a lot* of variables.

I had hoped to complete a comprehensive set of tests of the most 
important combinations of build environments with the three current 
active branches of python development (2.7.x, 3.2.x, and the future 3.3) 
for 10.7, 10.6, as well as baselines on 10.5 and 10.4 several weeks ago 
but, unfortunately, other events intervened.  Such is the downside of 
all-volunteer projects.  But I will be working on completing this over 
the next couple of weeks and, after review by the other core developers, 
will summarize the known issues and suggested fixes on the python.org 
website (with pointers posted here).  I expect that we will then need to 
push maintenance releases of 2.7.x and 3.2.x.  In the meantime, the 
safest approach is to continue to build on OS X 10.6 with Xcode 3 
installed.

-- 
 Ned Deily,
 n...@acm.org

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


Re: Python education survey

2012-01-02 Thread Rick Johnson
On Dec 31 2011, 11:12 pm, Dominic Binks dbi...@codeaurora.org wrote:

 I doubt you could validate or invalidate a word.  A word is, there is no
 validation necessary.  You could potentially try to validate it's use
 but again that's not in your power.

Usage begets validation. By using words in a manner that is improper
we validate the continued existence of stupidity.

 I think you need to go back to school to understand what a dictionary
 is. (FYI, a dictionary codifies usage, not the other way around.)

So there are no standards by which a dictionary must meet? The sheeple
should just read and accept any garage that the dictionary writers
dictate? Sadly, a dictionary has the power to give legitimacy to a
word. When we expand the definitions of words like pretty and reduce
those definitions to the absurd AND then include those absurd
definitions in a dictionary NOW we have just given lunacy the
justification it so desires.

 Perhaps you mean, because more precise words or phrases for these uses
 exist?  By your token 'work' should refer to physical activity which is
 not appropriate in this context and probably 'fine' should refer to a
 payment that is made having broken some rule or regulation thus leading
 to monetary reparation.

Yes, i used the word work improperly here. Just another example of
the corrupting influence of garage verbiage. Thanks for bring this to
my attention!


  Why would you use a word like hard (which describes the physical
  properties of a tangible object),

 Because many words have more than one meaning and their context
 describes the meaning.  For example 'Time flies like an arrow, fruit
 flies like a banana'.  I know you can parse and understand that but the
 sentences are precisely alike, yet completely different.

And that is just my point: by adopting so many meanings of a word that
are dependent on context, we obfuscate our communication.

 rr said: Supposed to -  required|expected

 probably 'intended' would be better here since 'supposed to' indicates
 that you should do this, but it is not required (pretty much the
 opposite for your given translation).

Actually, no. Consider this sentence: We are supposed to--[required
to|expected] follow the law, but sometimes i just cannot get used to
it!

 rr said:  Use to -  accustomed|acquainted

 Sorry to be picky, but use to refers to application as in When I say
 'idiot', in this context 'idiot' I use to mean 'person who cannot speak
 English as it is commonly used'.

Completely wrong! Consider this: I USED TO wear a tutu however i just
never could get USE TO the ridicule from others

 rr said:  Right (OOC) -  Correct

 While I agree 'right' can be annoying it's usage as in 'you are correct'
 can be traced back to 1588, I think we're going to have to allow for
 it's usage in 2011

So just because people have been using a word out of context we should
just continue? Why?

 rr said: Hard (OOC) -  Difficult

 Phrases to mean 'difficult' or 'tough' come from at least 1886 so again,
 it's use in this context is hardly new.

New or not, it's wrong!

 rr said: Pretty (OOC) -  very

 Pretty on it's own doesn't mean very at all.  (God knows where you got
 that idea from.) When combined with another adjective, such as hard,
 pretty does enhance the adjective.  However, pretty difficult is not the
 same as very difficult.  Pretty, in this context would probably be
 better defined as 'somewhat' or 'quite'.  (Oh and it's use in this
 context can be traced back to 1565.)

Pretty is by far the most ubiquitous use of a word in a manner that is
out of context. If you don't believe me, grep this group for all the
occurrences of the word pretty, and see if ANY instances of this
word are used to describe the pleasurable physical attributes of a
tangible object. I would safely say that 99% are used out of
context. :-(

Why do people use pretty when we already have words that carry more
specific meaning? Because they are lazy! And laziness begets
stupidity.

Do any of you remember the Unicode thread from way back? If so, you
will remember all the well known trolls who ranted about how the
words you use shape the way your brain processes information.
Choosing the easy way out is detrimental to your future evolution.
Stop propagating your stupidity memes and use your F'in brain for
once!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: readline for mac python? (really, reproducing mac python packages)

2012-01-02 Thread Ned Deily
In article cxnMq.50333$dr1.19...@newsfe08.iad,
 K Richard Pixley r...@noir.com wrote:
 On 1/1/12 19:04 , K Richard Pixley wrote:
  On 1/1/12 16:49 , K Richard Pixley wrote:
  I'm having trouble finding a reasonable python environment on mac.
 
  The supplied binaries, (2.7.2, 3.2.2), are built with old versions of
  macosx and are not capable of building any third party packages that
  require gcc.
 
  The source builds easily enough out of the box, (./configure
  --enable-framework  make  sudo make install), but when I do that, I
  end up with a python interpreter that lacks readline.
 
  How do I get readline involved?
 
  Or better... is there an instruction sheet somewhere on how to reproduce
  the python.org binary packages?
 
  --rich
 
  Bah. I just needed to dig a little deeper into the source. All the doc I
  wanted is in there.
 
 Well, partial victory.  2.7.2 builds.  3.2 doesn't.

As you may have discovered, by default the python.org Python 2.7.x and 
3.2.x on OS X 10.6 and above will link with the readline compatibility 
layer supplied with BSD editline (libedit) shipped by Apple.  The 
Apple-suppled system Pythons also link with editline.  While it is 
possible to link with your own version of GNU readline, there is also a 
readline project listed on PyPI that supplies pre-compiled versions of 
the Python readline module linked with GNU readline.  I believe they are 
intended primarily for the system Pythons; I have not tried them myself 
with the python.org versions.

http://pypi.python.org/pypi/readline

-- 
 Ned Deily,
 n...@acm.org

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


Re: Python3 on MacOsX Lion?

2012-01-02 Thread Ned Deily
In article WepMq.67154$u16.54...@newsfe15.iad,
 K Richard Pixley r...@noir.com wrote:
 On 1/2/12 13:03 , Benjamin Kaplan wrote:
[...]
  Have you tried building through Macports?
 No, I haven't.  Macports scares me.  When I tried them, or fink, in the 
 past, they rapidly polluted my boot disk and I didn't have any way to 
 unpollute it other than reloading from scratch.
 
 In freebsd, netbsd, or any of the linux distributions, I can trivially 
 create a virtual machine in about 20 minutes, screw with it as I like, 
 and toss it in seconds.  In modern linux, I can create a root file 
 system with btrfs, snapshot, chroot to the snapshot and munge away. 
 When I'm done, I can just toss the snapshot.  (Can do snapshots in 
 vmware too).
 
 If I screw up my boot drive in MacOsX, I'm in for hours of recovery time 
 reloading from Time Machine.  While that's a lot better than it used to 
 be now that Time Machine is available, (reloading can now be done 
 largely unattended), it's not a price I'm willing to pay in order to 
 attempt to use Macports.

Whether you use a third-party package manager like MacPorts or Fink is a 
personal decision, of course, and there pros or cons for using either.  
But both MacPorts and Fink are specifically designed *not* to pollute 
your existing system.  They both go to great lengths to install 
everything under their own unique directory subtrees, by default, 
/opt/local for MacPorts and /sw for Fink.  I don't have much recent 
experience with Fink but I do with MacPorts.  Other than a very few and 
documented exceptions, *everything* that MacPorts installs is under that 
/opt/local prefix and there are no conflicts with any Apple-installed 
files so it is really quite trivial to install and remove without fear 
of corrupting your base system.  The whole process is documented here:

http://guide.macports.org/chunked/installing.macports.uninstalling.html

-- 
 Ned Deily,
 n...@acm.org

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


Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2012-01-02 Thread Rick Johnson
On Jan 2, 8:38 pm, alex23 wuwe...@gmail.com wrote:

 Conversely, you could pitch in behind Rick Johnson's Python 4000 fork,
 I sure it's progressing nicely given how long Rick has been talking it
 up.

It's NOT a fork Alex. It IS in fact the next logical step in Python's
future evolution.
-- 
http://mail.python.org/mailman/listinfo/python-list


Setting an environment variable.

2012-01-02 Thread Ashton Fagg

Hi list.

A bit new to Python so please forgive my potential ignorance.

I'm working with an embedded machine, which is using a Python script to 
oversee the acquisition of some data. The supervisor script, which is 
run by crontab every 5 minutes, relies on an environment variable to be 
set. I've tried to set the environment variable inside crontab, however 
this doesn't work when the script runs.


Is there a nice way to do this inside the supervisor script itself? 
Would an os.system(export foo=/bar/foo/bar) at the very beginning of 
the script do what I want? I would just like to check before I make 
changes, as being an embedded machine it's a bit of a pain to update 
things like this...(read only file system)


Note: This is for Python 2.4. I have no ability to update to anything 
newer as this is what our codebase relies upon.


Thanks and regards,
Ashton.

--
Ashton Fagg (ash...@fagg.id.au)
Web: http://www.fagg.id.au/~ashton/

Keep calm and call Batman.
--
http://mail.python.org/mailman/listinfo/python-list


Re: .format vs. %

2012-01-02 Thread Ian Kelly
On Mon, Jan 2, 2012 at 8:52 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Mon, 02 Jan 2012 17:59:43 -0800, Rick Johnson wrote:

 On Jan 2, 4:00 pm, Ethan Furman et...@stoneleaf.us wrote:
 %-style formatting isn't going away.

 You may want to freshen up on the definition of deprecation.

 I'm sure Ethan knows the definition of deprecation. I'm sure he also
 knows that % formatting is NOT deprecated. Please stop spreading FUD
 about Python features.

I can't believe I'm taking Rick's side here, but the docs do say:

Note: The formatting operations described here are obsolete and may
go away in future versions of Python. Use the new String Formatting in
new code.

http://docs.python.org/py3k/library/stdtypes.html#old-string-formatting-operations

I consider that a statement of deprecation, even if it doesn't use the
term explicitly or describe a definite timeline for removal.

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


Re: Python education survey

2012-01-02 Thread Dominic Binks

On 1/2/2012 9:27 PM, Rick Johnson wrote:

On Dec 31 2011, 11:12 pm, Dominic Binksdbi...@codeaurora.org  wrote:


I doubt you could validate or invalidate a word.  A word is, there is no


... taken off list


--
Dominic Binks: dbi...@codeaurora.org
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
--
http://mail.python.org/mailman/listinfo/python-list


Re: .format vs. %

2012-01-02 Thread Steven D'Aprano
On Mon, 02 Jan 2012 22:58:23 -0700, Ian Kelly wrote:

 On Mon, Jan 2, 2012 at 8:52 PM, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
 On Mon, 02 Jan 2012 17:59:43 -0800, Rick Johnson wrote:

 On Jan 2, 4:00 pm, Ethan Furman et...@stoneleaf.us wrote:
 %-style formatting isn't going away.

 You may want to freshen up on the definition of deprecation.

 I'm sure Ethan knows the definition of deprecation. I'm sure he also
 knows that % formatting is NOT deprecated. Please stop spreading FUD
 about Python features.
 
 I can't believe I'm taking Rick's side here, but the docs do say:
 
 Note: The formatting operations described here are obsolete and may go
 away in future versions of Python. Use the new String Formatting in new
 code.
 
 http://docs.python.org/py3k/library/stdtypes.html#old-string-formatting-
operations
 
 I consider that a statement of deprecation, even if it doesn't use the
 term explicitly or describe a definite timeline for removal.

Which is exactly why it is not deprecated: it doesn't say it is 
deprecated and has no timeline for removal. It may not even be removed: 
may go away is not will go away.

Going around saying that features are deprecated just because they may 
(or may not) some day in the distant future become deprecated is FUD. It 
simply isn't true that % formatting is deprecated: Python Dev has a 
formal process for deprecating code, and that process has not been 
applied to % and there are no plans to do so in the foreseeable future.

There is a huge code base using this feature, including the standard 
library, and Python does not arbitrarily deprecate features used by real 
code without good reason. Just because a number of Python devs want to 
encourage people to use format doesn't imply that % will go away any time 
before Python 4000.



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


Re: Python education survey

2012-01-02 Thread Evan Driscoll
On 1/3/2012 0:27, Rick Johnson wrote:
 Yes, i used the word work improperly here. Just another example of
 the corrupting influence of garage verbiage. Thanks for bring this to
 my attention! 

Diction would be a far better word than verbiage there.

Evan



signature.asc
Description: OpenPGP digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2012-01-02 Thread alex23
On Jan 3, 3:39 pm, Rick Johnson rantingrickjohn...@gmail.com wrote:
 It's NOT a fork Alex. It IS in fact the next logical step in Python's
 future evolution.

Link to the repo please, or STFU.
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue2698] Extension module build fails for MinGW: missing vcvarsall.bat

2012-01-02 Thread Piotr Dobrogost

Piotr Dobrogost p...@python.dobrogost.net added the comment:

@Lehmann

You have to have either Visual Studio 2008 or Visual C++ Express 2008 
installed. The folder where vcvarsall.bat file is being looked for is read from 
the registry. It's either 
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\Setup\VC 
(for Visual Studio) or 
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\9.0\Setup\VC (for 
Visual C++ Express).

--
nosy: +piotr.dobrogost

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



[issue13565] test_multiprocessing.test_notify_all() hangs on AMD64 Snow Leopard 02 03.x

2012-01-02 Thread Charles-François Natali

Charles-François Natali neolo...@free.fr added the comment:

Alright, it seems to be fixed.
We can still reopen if this happens again.

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

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



[issue13694] asynchronous connect in asyncore.dispatcher does not set addr

2012-01-02 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +giampaolo.rodola, josiahcarlson, stutzbach
stage:  - patch review
versions:  -Python 2.6, Python 3.1

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



[issue13609] Add os.get_terminal_size() function

2012-01-02 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Thanks for the updated patch.
I think I would like other people's opinions about the dual-function approach.

--
nosy: +loewis, neologix, rosslagerwall

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



[issue13694] asynchronous connect in asyncore.dispatcher does not set addr

2012-01-02 Thread Giampaolo Rodola'

Giampaolo Rodola' g.rod...@gmail.com added the comment:

I'm not sure how useful this is as addr will be set later, when connection is 
established.

--

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



[issue13609] Add os.get_terminal_size() function

2012-01-02 Thread Giampaolo Rodola'

Giampaolo Rodola' g.rod...@gmail.com added the comment:

What I would do:

- build the namedtuple in Python rather than in C
- I don't particularly like CamelCased names for nametuples (I would use size 
instead of TerminalSize)
- on UNIX, the ioctl() stuff can be done in python rather than in C
- use C only on Windows to deal with GetStdHandle/GetConsoleScreenBufferInfo; 
function name should be accessed as nt._get_terminal_size similarly to what we 
did for shutil.disk_usage in issue12442.
- do not raise NotImplementedError; if the required underlying functions are 
not available os.get_terminal_size should not exists in the first place (same 
as we did for shutil.disk_usage / issue12442)


Also, I'm not sure I like fallback=(80, 25) as default, followed by:

try:
size = query_terminal_size(sys.__stdout__.fileno())
except OSError:
size = TerminalSize(fallback)

That means we're never going to get an exception.
Instead I would:
- provide fallback as None
- let OSError propate unless fallback is not None

--

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



[issue9975] Incorrect use of flowinfo and scope_id in IPv6 sockaddr tuple

2012-01-02 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 0c10061df711 by Charles-François Natali in branch '2.7':
Issue #9975: socket: Fix incorrect use of flowinfo and scope_id. Patch by
http://hg.python.org/cpython/rev/0c10061df711

New changeset cc346a672091 by Charles-François Natali in branch '3.2':
Issue #9975: socket: Fix incorrect use of flowinfo and scope_id. Patch by
http://hg.python.org/cpython/rev/cc346a672091

New changeset 9222b8e7a7bc by Charles-François Natali in branch 'default':
Issue #9975: socket: Fix incorrect use of flowinfo and scope_id. Patch by
http://hg.python.org/cpython/rev/9222b8e7a7bc

--
nosy: +python-dev

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



[issue13684] httplib tunnel infinite loop

2012-01-02 Thread Ross Lagerwall

Changes by Ross Lagerwall rosslagerw...@gmail.com:


--
nosy: +rosslagerwall

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



[issue13694] asynchronous connect in asyncore.dispatcher does not set addr

2012-01-02 Thread Ross Lagerwall

Changes by Ross Lagerwall rosslagerw...@gmail.com:


--
nosy: +rosslagerwall

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



[issue13690] Add DEBUG flag to documentation of re.compile

2012-01-02 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

 Display debug information about compiled expression.

IMO it would be helpful to define “display” more precisely (e.g. “Print 
debugging information on stdout during pattern compilation”).

--
nosy: +eric.araujo

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



[issue1467619] Header.decode_header eats up spaces

2012-01-02 Thread Ralf Schlatterbeck

Ralf Schlatterbeck r...@runtux.com added the comment:

I've been bitten by this too (in python up to 2.7 in roundup the bug-tracker). 
We're currently using a workaround that re-inserts spaces, see git on 
roundup.sourceforge.net file mailgw.py method _decode_header_to_utf8

RFC2047 even has a test-case at the end, it specifies:

encoded formdisplayed as
(=?ISO-8859-1?Q?a?= b)  (a b)

note the space between 'a' and 'b' above. Spaces between non-encoded and 
encoded parts should be preserved. And it's probably a good idea to put the 
examples from the RFC into the regression test.

--
nosy: +runtux

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



[issue13402] Document absoluteness of sys.executable

2012-01-02 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

This discussion seems relevant: 
http://mail.python.org/pipermail/python-dev/2006-March/062453.html (it talks 
about the meaning of sys.executable, special cases such as embedded Python and 
functions that implement it (so we can have a look at that code)).

--

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



[issue1467619] Header.decode_header eats up spaces

2012-01-02 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
versions: +Python 2.7, Python 3.2

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



[issue1079] decode_header does not follow RFC 2047

2012-01-02 Thread Ralf Schlatterbeck

Ralf Schlatterbeck r...@runtux.com added the comment:

maybe it would be a good start to include the examples at the end of RFC2047 
into the regression tests? These examples at least support the case that a '?' 
may immediately follow an encoded string:

encoded formdisplayed as
(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=) (ab)

when trying this in python 2.7:

 decode_header ('(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)')
[('(', None), ('a', 'iso-8859-1'), ('=?ISO-8859-1?Q?b?=)', None)]

this fails. So I consider this a bug.

Note that although RFC2047 is vague concerning the interpretation if two 
encoded strings could follow each other without a whitespace, these *are* seen 
in the wild and *are* interpreted correctly by the mailers I've tested: mutt, 
thunderbird, exchange in various versions, even lotus notes seems to get this 
right. So I guess python should be liberal in what you accept and parse 
something like 
'(=?ISO-8859-1?Q?a?==?ISO-8859-1?Q?b?=)'
into
[ ('(', None)
, ('a', 'iso-8859-1')
, ('b', 'iso-8859-1')
, (')', None)
]

--
nosy: +runtux

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



[issue13609] Add os.get_terminal_size() function

2012-01-02 Thread Ross Lagerwall

Ross Lagerwall rosslagerw...@gmail.com added the comment:

Nice patch :-)

I think the two function approach works well.

Since you have already checked that termsize is not NULL, Py_DECREF can be used 
instead of Py_CLEAR.

Would it not be better to use sys.__stdout__ instead of 1 in the documentation 
and to use STDOUT_FILENO instead of 1 in the code?

A brief google suggested that Solaris requires sys/termios.h for TIOCGWINSZ. 
Perhaps also only define TERMSIZE_USE_IOCTL if TIOCGWINSZ is defined.
Like so:
#if defined(HAVE_SYS_IOCTL_H)
#include sys/ioctl.h
#if defined(TIOCGWINSZ)
#define TERMSIZE_USE_IOCTL
#else
#define TERMSIZE_USE_NOTIMPLEMENTED
#endif
#elif defined(HAVE_CONIO_H)
#include windows.h
#include conio.h
#define TERMSIZE_USE_CONIO
#else
#define TERMSIZE_USE_NOTIMPLEMENTED
#endif

(didn't check the windows parts)

--

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



[issue12394] packaging: generate scripts from callable (dotted paths)

2012-01-02 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

I’ll get back to this issue later, but now I just wanted to add a link about 
building the binary exe files: 
http://mail.python.org/pipermail/python-dev/2006-April/063846.html (it comes 
from the time where setuptools was supposed to be added to the stdlib)

--

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



[issue13511] Specifying multiple lib and include directories on linux

2012-01-02 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

 Whether or not includedir and libdir are supposed to allow multiple packages 
 is beyond me at this
 point so I'll change the topic to more reflect the problem I am having.  More 
 importantly (and
 possibly related to includedir and libdir) is the fact that python 2.7 does 
 not allow specifying
 multiple lib and include directories in linux.  Is there one way to do this 
 that I overlooked? I
 included the bit about includedir, libdir, CFLAGS, and LDFLAGS in my original 
 post to show what I
 tried.

At present I know less than you about these.  Maybe Martin can chime in?

If it’s not possible to use multiple directories to configure Python, then it’s 
a limitation, and changing it would qualify as a new feature given our policy, 
and as such be inappropriate for 2.7.

--
nosy: +loewis
versions:  -Python 2.7

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



[issue6983] Add specific get_platform() for freebsd

2012-01-02 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Thanks for the reply.  distutils2 won’t support eggs, and I don’t think 
setuptools or distribute will be reworked to work on distutils2, so if your 
problem is only with eggs there is nothing that we can do to solve it in 
distutils2.  (As I said, distutils is frozen and can’t be changed to address 
this either.)  Currently distutils2 build sdists and bdists of the dumb, msi 
and wininst varieties.  If these formats have the same issue that you describe, 
then we can change them.

--

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



[issue13561] os.listdir documentation should mention surrogateescape

2012-01-02 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Patch looks good, apart from a missing “the”, but I think it should be 
expanded: Right now it tells that surrogateescape is used, but IMO it would be 
more useful if it also mentioned practical implications, i.e. what Michael “The 
Beard” Foord says in the first message.

--

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



[issue9993] shutil.move fails on symlink source

2012-01-02 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Antoine, would you mind taking this one?

--

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



[issue13663] pootle.python.org is outdated.

2012-01-02 Thread Ezio Melotti

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


--
nosy: +ezio.melotti

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



[issue13665] TypeError: string or integer address expected instead of str instance

2012-01-02 Thread Ezio Melotti

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


--
nosy: +ezio.melotti
stage:  - needs patch
type:  - enhancement

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



[issue13693] email.Header.Header incorrect/non-smart on international charset address fields

2012-01-02 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

Actually, no, the local part cannot be in anything other than ascii (see RFC 
5335, which desires to address this problem among others).  Also, an encoded 
word cannot occur inside quotation marks.  If you correct those two bugs, you 
can generate an RFC-valid address using Header.append.

There is a project underway to make all of this header parsing and formatting 
stuff work better: see the http://pypi.python.org/pypi/email.

By the way, this is easier already in python 3.2.  There you can do:

formataddr(('Nameß', 'weofij@fjeio'))
   '=?utf-8?b?TmFtZcOf?= weofij@fjeio'

--
nosy: +r.david.murray
resolution:  - invalid
status: open - closed

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



[issue10839] email module should not allow some header field repetitions

2012-01-02 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

Regardless of what anybody thinks about the design, it is what it is and can't 
be changed for backward compatibility reasons.  The best we can do is reject 
creating duplicate headers for headers that may only appear once.  That feature 
has already been coded in the new version of the email package (see 
http://pypi.python.org/pypi/email), but has not yet been committed to the 
trunk, which is why this issue is still open.

--

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



[issue1467619] Header.decode_header eats up spaces

2012-01-02 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

Antoine, I marked this for Python 3.3 only because there is no good way to fix 
it in 2.7/3.2.  (If someone comes up with a way I'll be happy to review it, 
though!)

--
versions:  -Python 2.7, Python 3.2

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



[issue1079] decode_header does not follow RFC 2047

2012-01-02 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

The RFC isn't at all vague about encoded words not separated by white space.  
That isn't allowed by the BNF.  As you say, though, they occur in the wild and 
should be parsed correctly.

In your other point I think you mean immediately followed by a ), right?  
Yes, that is allowed and no, we don't currently parse that correctly.

Adding the RFC tests would be great (patches gladly accepted).  Fixes for ones 
we fail would be great, too, but at the very least we can mark them as expected 
failures.  I don't usually like adding tests that we expect to fail, but in the 
case of externally defined tests such as the RFC examples I think it is 
worthwhile, so that we can check in a complete test set.

--

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



[issue9993] shutil.move fails on symlink source

2012-01-02 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Ow, I'm sorry for overlooking this. I thought you would take it.
Unfortunately the patch is now broken because of 5b61334bb776.
(technically it applies, but the tests don't run anymore because the other 
filesystem now uses a mocking approach)

By the way, I think this shouldn't be applied to bugfix branches, since it's a 
behaviour change.

--
versions:  -Python 2.7, Python 3.2

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



[issue13696] [urllib.request.HTTPRedirectHandler.http_error_302] Relative Redirect issue

2012-01-02 Thread CRicky

New submission from CRicky cricky@gmx.fr:

I had an HTTP redirection that worked perfectly on version 3.1.

On version 3.2, I get a HTTP error 302. In this redirection, I actually have 2 
redirections. The last one does not work because it is a relative redirection, 
so urlparts.scheme is empty.

Some lines have been added in version 3.2 for security reason, but it also 
blocks relative links in 302 return.

To correct, I have added empty scheme in check:
if not urlparts.scheme in ('http', 'https', 'ftp', ''):

With that, it works correctly.
I don't make you any for 3 new chars. ;)

Best regards,
CRicky

--
components: Library (Lib)
messages: 150473
nosy: CRicky
priority: normal
severity: normal
status: open
title: [urllib.request.HTTPRedirectHandler.http_error_302] Relative Redirect 
issue
type: behavior
versions: Python 3.2

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



[issue13609] Add os.get_terminal_size() function

2012-01-02 Thread Zbyszek Szmek

Zbyszek Szmek zbys...@in.waw.pl added the comment:

Thanks for the reviews!

 - build the namedtuple in Python rather than in C
I started this way, but if two functions are used, it is nicer to have them both
return the same type. If it was defined in the Python part, there would be
loop in the sense that os would import the function from _posixmodule, and
_posixmodule would import the namedtuple from os. The code for the tuple is 
fairly simple,
mostly docs, and saving a few lines just doesn't seem to be worth the 
complication of doing
it other way around.

 - I don't particularly like CamelCased names for nametuples (I would use 
 size instead of TerminalSize)
I was following the style in _posixmodule: there is WaitidResultType and 
SchedParamType.
size seems to generic, maybe something like terminal_size would be better 
(SchedParamType
is exported as sched_param).

Will change to terminal_size.

- on UNIX, the ioctl() stuff can be done in python rather than in C
It can, but it requires extracting the bytes by hand, doing it in C is cleaner.
The C implementation is only 5 lines (in addition to the code necessary for 
windows)
and again it seems simpler this way. Also the configuration is kept in one
place in the #ifdefs at the top, not in two different files.

 - use C only on Windows to deal with GetStdHandle/GetConsoleScreenBufferInfo; 
 function name should be
 accessed as nt._get_terminal_size similarly to what we did for 
 shutil.disk_usage in issue12442.
 - do not raise NotImplementedError; if the required underlying functions are 
 not available 
 os.get_terminal_size should not exists in the first place (same as we did for 
 shutil.disk_usage / issue12442)

I think that there is a difference in importance -- shutil.disk_usage cannot 
be
faked, or ignored, and if it is unavailable, then some work-around must be 
implemented.
OTOH, the terminal size is an embellishment, and if a wrong terminal size is 
used, the output
might wrap around or be a bit narrow (the common case), but like in 
argparse.FancyFormatter,
just continuing is probably reasonable. So to save the users of the function 
the trouble
to wrap it in some try..except, let's cater for the common case.

This same argument goes for defining the function only if an implementation is 
available:
argparse would need something like:
try:
  os.get_terminal_size
except NameError:
  def get_terminal_size():
return (80, 25)
which just doesn't seem to _gain_ anything.

 Also, I'm not sure I like fallback=(80, 25) as default, followed by:
 [...]
 That means we're never going to get an exception.
 Instead I would:
 - provide fallback as None
 - let OSError propate unless fallback is not None
Again, if the user forgets to add the fallback, and only tests in a terminal, 
she 
would get an unnecessary surprise when running the thing in a pipe. So the 
fallback
would have to be almost always provided... and it will almost always be (80, 
25).
So let's just provide it upfront, and let the user call the low-level function 
if
they want full control.

---

 I think the two function approach works well.
:)

 Since you have already checked that termsize is not NULL, Py_DECREF can be 
 used instead of Py_CLEAR.
OK.

 Would it not be better to use sys.__stdout__ instead of 1 in the 
 documentation and to use STDOUT_FILENO 
 instead of 1 in the code?
OK.

 A brief google suggested that Solaris requires sys/termios.h for TIOCGWINSZ. 
 Perhaps also only define
 TERMSIZE_USE_IOCTL if TIOCGWINSZ is defined.
Hm, I don't have solaris available, so I won't be able to check easily, but
maybe sys/termios.h should be imported if TIOCGWINSZ is not available. Would 
be nice to provide the implementation if possible.

 Like so:
Something like:

 #if defined(HAVE_SYS_IOCTL_H)
 #include sys/ioctl.h
 #if defined(TIOCGWINSZ)
 #define TERMSIZE_USE_IOCTL
 #else

#if defined(HAVE_SYS_TERMIOS_H)
#include sys/termios.h
#if defined(TIOCGWINSZ)
#define TERMSIZE_USE_IOCTL
#else
#define TERMSIZE_USE_NOTIMPLEMENTED

 #endif
 #elif defined(HAVE_CONIO_H)
 #include windows.h
 #include conio.h
 #define TERMSIZE_USE_CONIO
 #else
 #define TERMSIZE_USE_NOTIMPLEMENTED
 #endif

--

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



[issue13609] Add os.get_terminal_size() function

2012-01-02 Thread Ross Lagerwall

Ross Lagerwall rosslagerw...@gmail.com added the comment:

I'll try  investigate Solaris a bit...

Also, what should be the default terminal size?

Gnome-terminal and xterm seem to default to 80x24, not 80x25.

--

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



[issue2698] Extension module build fails for MinGW: missing vcvarsall.bat

2012-01-02 Thread Bill Janssen

Bill Janssen bill.jans...@gmail.com added the comment:

Actually, when using setup.py with MinGW, you just need to say the right thing:

  % python setup.py build --compiler=mingw32 install

That removes the check for vcvarsall.bat.

Bill

On Mon, Jan 2, 2012 at 6:19 AM, Piotr Dobrogost rep...@bugs.python.org wrote:

 Piotr Dobrogost p...@python.dobrogost.net added the comment:

 @Lehmann

 You have to have either Visual Studio 2008 or Visual C++ Express 2008 
 installed. The folder where vcvarsall.bat file is being looked for is read 
 from the registry. It's either 
 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\Setup\VC 
 (for Visual Studio) or 
 HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VCExpress\9.0\Setup\VC (for 
 Visual C++ Express).

 --
 nosy: +piotr.dobrogost

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue2698
 ___

--

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



[issue13697] python RLock implementation unsafe with signals

2012-01-02 Thread Robert Collins

New submission from Robert Collins robe...@robertcollins.net:

This affects the python implementation of RLock only.

If a signal occurs during RLock.acquire() or release() and then operates on the 
same lock to acquire() or release() it, process hangs or assertions can be 
triggered.

The attached test script demonstrates the issue on Python 2.6 and 3.2, and code 
inspection suggests this is still valid for 2.7 and 3.4.

To use it, run the script and then 'kill -SIGUSR2' the process id it prints 
out. Keep sending SIGUSR2 until you get bored or:
 - a traceback occurs
 - the process stops printing out '.'s

We found this debugging application server hangs during log rotation 
(https://bugs.launchpad.net/launchpad/+bug/861742) where if the thread that the 
signal is received in was about to log a message the deadlock case would crop 
up from time to time. Of course, this wasn't ever safe code, and we're changing 
it (to have the signal handler merely set a integer flag that the logging 
handler can consult without locking).

However, I wanted to raise this upstream, and I note per issue #3618 that the 
3.x IO module apparently includes a minimal version of the Python RLock 
implementation (or just uses RLock itself). Either way this bug probably exists 
for applications simply doing IO, either when there is no C RLock 
implementation available, or all the time (depending on exactly what the IO 
module is doing nowadays).

--
components: Library (Lib)
files: hang.py
messages: 150477
nosy: rbcollins
priority: normal
severity: normal
status: open
title: python RLock implementation unsafe with signals
versions: Python 2.7, Python 3.4
Added file: http://bugs.python.org/file24126/hang.py

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



[issue13698] Should not use mboxo format

2012-01-02 Thread endolith

New submission from endolith endol...@gmail.com:

The documentation states:

Several variations of the mbox format exist to address perceived shortcomings 
in the original. In the interest of compatibility, mbox implements the original 
format, which is sometimes referred to as mboxo.

http://docs.python.org/dev/library/mailbox.html#mailbox.mbox

But this format is fundamentally broken, corrupting lines that start with 
From , and I can't find any justification for using it in Python.  In fact, 
all four links included in that section argue against this format.

If only one mbox format is used, it should be mboxrd.  Otherwise, include 
support for all the variants, with mboxrd as the default.

--
components: Library (Lib)
messages: 150478
nosy: endolith
priority: normal
severity: normal
status: open
title: Should not use mboxo format
type: behavior
versions: Python 2.7, Python 3.3

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



[issue13698] Mailbox module should not use mboxo format

2012-01-02 Thread endolith

Changes by endolith endol...@gmail.com:


--
title: Should not use mboxo format - Mailbox module should not use mboxo format

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



  1   2   >