RE: Myth Busters: % this old style of formatting will eventually be removed from the language

2013-05-22 Thread Carlos Nepomuceno
Ok. Thanks!

bugs.python.org/issue18031


 Date: Tue, 21 May 2013 23:26:58 -0400
 From: n...@nedbatchelder.com
 To: carlosnepomuc...@outlook.com
 CC: python-list@python.org
 Subject: Re: Myth Busters: % this old style of formatting will eventually be 
 removed from the language

 On 5/21/2013 10:26 PM, Carlos Nepomuceno wrote:
 I was looking for something else and just found what I think is the place 
 where I was first exposed to the myth[1]:

 Since str.format() is quite new, a lot of Python code still uses the % 
 operator. However, because this old style of formatting will eventually be 
 removed from the language, str.format() should generally be used.

 Is this tutorial outdated or this still an issue?

 [1] http://docs.python.org/2/tutorial/inputoutput.html#old-string-formatting

 That tutorial is out of date. %-formatting isn't being removed.

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


Newbie question about evaluating raw_input() responses

2013-05-22 Thread C. N. Desrosiers
Hi,

I'm just starting out with Python and to practice I am trying to write a script 
that can have a simple conversation with the user.

When I run the below code, it always ends up printing response to if age  
18: -- even if I enter a value below 18.

Can anyone point me to what I am doing wrong?  Many thanks in advance.

age=raw_input('Enter your age: ')
if age  18:
print ('Wow, %s. You can buy cigarettes.' % age)
else:
print ('You are a young grasshopper.')
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about evaluating raw_input() responses

2013-05-22 Thread Fábio Santos
You have to convert `age` to an integer. Use int() to do it. Then you can
compare it to other numbers and obtain the expected results.
On 22 May 2013 07:29, C. N. Desrosiers cndesrosi...@gmail.com wrote:

 Hi,

 I'm just starting out with Python and to practice I am trying to write a
 script that can have a simple conversation with the user.

 When I run the below code, it always ends up printing response to if age
  18: -- even if I enter a value below 18.

 Can anyone point me to what I am doing wrong?  Many thanks in advance.

 age=raw_input('Enter your age: ')
 if age  18:
 print ('Wow, %s. You can buy cigarettes.' % age)
 else:
 print ('You are a young grasshopper.')
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: A computer programmer, web developer and network admin resume

2013-05-22 Thread Chris Angelico
On Wed, May 22, 2013 at 12:32 PM, Tim Chase
python.l...@tim.thechases.com wrote:
 On 2013-05-22 01:15, i...@databaseprograms.biz wrote:
 A computer programmer, web developer and network administrator

 ...walk into a bar...

 So what's the punchline?

;steps up to the mike

So yeah, as I was saying, a programmer, a web dev, and a BOFH walk
into a bar. The other two buy the BOFH a drink, because they're not
stupid, and anyway, so this luser walks up to them with a resume in
his hand.

, says the luser.

So what's the punchline? says the computer programmer.

The stand-up comic steps up to the mike, and he says, So yeah, as I
was saying, a programmer, a web dev, and a BOFH walk into a stable
time loop...

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


Re: Newbie question about evaluating raw_input() responses

2013-05-22 Thread Kevin Xi
On Wednesday, May 22, 2013 2:23:15 PM UTC+8, C. N. Desrosiers wrote:
 Hi,
 
Hi,
 
 I'm just starting out with Python and to practice I am trying to write a 
 script that can have a simple conversation with the user.
 
So you may want to search the doc before you ask: http://docs.python.org
 
 When I run the below code, it always ends up printing response to if age  
 18: -- even if I enter a value below 18.
 
 
 
 Can anyone point me to what I am doing wrong?  Many thanks in advance.
 
 
 
 age=raw_input('Enter your age: ')
 
 if age  18:
 
 print ('Wow, %s. You can buy cigarettes.' % age)
 
 else:
 
 print ('You are a young grasshopper.')

You can either use `raw_input` to read data and convert it to right type, or 
use `input` to get an integer directly. Read this: 
http://docs.python.org/2/library/functions.html#raw_input
http://docs.python.org/2/library/functions.html#input

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


Re: Newbie question about evaluating raw_input() responses

2013-05-22 Thread C. N. Desrosiers
Muchas gracias!

On Wednesday, May 22, 2013 2:35:18 AM UTC-4, Fábio Santos wrote:
 You have to convert `age` to an integer. Use int() to do it. Then you can 
 compare it to other numbers and obtain the expected results.
 
 On 22 May 2013 07:29, C. N. Desrosiers cndesr...@gmail.com wrote:
 
 Hi,
 
 
 
 I'm just starting out with Python and to practice I am trying to write a 
 script that can have a simple conversation with the user.
 
 
 
 When I run the below code, it always ends up printing response to if age  
 18: -- even if I enter a value below 18.
 
 
 
 Can anyone point me to what I am doing wrong?  Many thanks in advance.
 
 
 
 age=raw_input('Enter your age: ')
 
 if age  18:
 
     print ('Wow, %s. You can buy cigarettes.' % age)
 
 else:
 
     print ('You are a young grasshopper.')
 
 --
 
 http://mail.python.org/mailman/listinfo/python-list


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


Re: PEP 378: Format Specifier for Thousands Separator

2013-05-22 Thread 88888 Dihedral
Carlos Nepomuceno於 2013年5月22日星期三UTC+8上午11時38分45秒寫道:
 
  From: steve+comp.lang.pyt...@pearwood.info
  Subject: Re: PEP 378: Format Specifier for Thousands Separator
  Date: Wed, 22 May 2013 03:08:54 +
  To: python-list@python.org
 [...]
  So, the only alternative to have '%,d' % x rendering the thousands
  separator output would a C source code modification?
 
  That's one alternative. But the language you would be then running will
  no longer be Python.
 
  Another alternative would be to write a pre-processor that parses your
  Python source code, extracts any reference to the above, and replaces it
  with a call to the appropriate format call. But not only is that a lot of
  work for very little gain, but it's also more or less impossible to do in
  full generality. And again, what you are running will be something
  different than Python, it will be Python plus a pre-processor.
 
 
  Don't fight the language. You will lose.
 
 Not fighting the language. In fact it's not even a language issue.
 All I need is a standard library[1] improvement: %,d! That's all!
 
 Just to put in perspective the performance difference of str.__mod__() and 
 str.format():
 
 C:\Python27python -m timeit -cv -n1000 '%d'%12345
 raw times: 0.386 0.38 0.373
 1000 loops, best of 3: 0.0373 usec per loop
 
 C:\Python27python -m timeit -cv -n1000 '{:d}'.format(12345)
 raw times: 7.91 7.89 7.98
 1000 loops, best of 3: 0.789 usec per loop
 
 C:\Python27python -m timeit -cv -n1000 '{:,d}'.format(12345)
 raw times: 8.7 8.67 8.78
 1000 loops, best of 3: 0.867 usec per loop
 
 That shows str.format() is 20 times slower than str.__mod__() for a simple 
 decimal integer literal formatting.
 And it's additionally 10% slower if the thousands separator format specifier 
 (',') is used.
 
 [1] I think that translates to Python source code in 'Objects/stringobject.c' 
 and maybe 'Objects/unicodeobject.c'
 
 
 
  --
  Steven
  --
  http://mail.python.org/mailman/listinfo/python-list

The conversions of the  32 bit integers and 64 bit floats
 to the strings of the  base 10 digits require an 
efficint div and mod normally in the low level.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about evaluating raw_input() responses

2013-05-22 Thread Chris Angelico
On Wed, May 22, 2013 at 4:52 PM, Kevin Xi kevin@gmail.com wrote:
 On Wednesday, May 22, 2013 2:23:15 PM UTC+8, C. N. Desrosiers wrote:
 age=raw_input('Enter your age: ')
 if age  18:

 You can either use `raw_input` to read data and convert it to right type, or 
 use `input` to get an integer directly. Read this: 
 http://docs.python.org/2/library/functions.html#raw_input
 http://docs.python.org/2/library/functions.html#input

No! No, please do NOT use input()! It does not return an integer; it
*evaluates* (that is, executes) the input.

 input('Enter your age: ')
Enter your age: 18
18
 input('Enter your age: ')
Enter your age: 1+2+4+5+6
18
 input('Enter your age: ')
Enter your age: sys.stdout.write(Hello, world!\n) or 18
Hello, world!
18
 input('Enter your age: ')
Enter your age: sys.exit(0)

This is almost certainly NOT what you want to have in your script. If
you want an integer, just pass it through int() as Fabio suggested.

Please do not use, or advocate using, this steam-powered Izzet goblin
hammer for cracking walnuts.

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


Diagnosing socket Connection reset by peer

2013-05-22 Thread loial
I have a sockets client that is connecting to a printer and occassionally 
getting the error 104 Connection reset by peer

I have not been able to diagnose what is causing this. Is there any additional 
traceing I can do(either within my python code or on the network) to establish 
what is causing this error?

Currently I am simply trapping socket.erruor 

Python version is 2.6






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


Re: More general way of generating PyODBC queries as a dict?

2013-05-22 Thread stackoverflowuser95
On Wednesday, May 22, 2013 9:33:18 AM UTC+10, Dennis Lee Bieber wrote:
 On Tue, 21 May 2013 10:27:07 -0700 (PDT), stackoverflowuse...@gmail.com
 
 declaimed the following in gmane.comp.python.general:
 
 
 
  
 
  For example, when multiple tables are queried; some hackish lambdas are 
  required to generate the resulting dictionary.
 
  
 
  Can you think of some more general methods?
 
 
 
   What about using the information from 
 
 
 
   cursor.description
 
 
 
 You did state PyODBC, did you not?
 
 
 
 
 
 description
 
 
 
 This read-only attribute is a list of 7-item tuples, each containing
 
 (name, type_code, display_size, internal_size, precision, scale,
 
 null_ok). pyodbc only provides values for name, type_code,
 
 internal_size, and null_ok. The other values are set to None.  
 
 
 
 -- 
 
   Wulfraed Dennis Lee Bieber AF6VN
 
 wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/

YAY: `[{c[0]: v for (c, v) in zip(row.cursor_description, row)} for row in 
self.cursor.fetchall()]`
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Myth Busters: % this old style of formatting will eventually be removed from the language

2013-05-22 Thread Skip Montanaro
 Is this tutorial outdated or this still an issue?

 [1]
 http://docs.python.org/2/tutorial/inputoutput.html#old-string-formatting


 That tutorial is out of date.  %-formatting isn't being removed.

OTOH, PEP 3101 also mentions deprecation, at the very end: ... both
systems can co-exist until it comes time to deprecate the older
system.

I have been operating under the assumption since the days of that PEP
that %-style formatting would eventually disappear, dreading the day
when I'd have to learn the str.format language.  I apologize for
(inadvertently) spreading FUD.

It does seem like the documentation should be updated in a few places.
 If the decision has been made to not remove the older system, it
might be worthwhile to mention that somewhere.  Clearly the tutorial
and PEP 3101 should be updated.

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


Re: PEP 378: Format Specifier for Thousands Separator

2013-05-22 Thread Skip Montanaro
 Please stop perpetuating this myth, see
 http://mail.python.org/pipermail/python-dev/2012-February/116789.html
 and http://bugs.python.org/issue14123

 What myth?

 The myth that % string formatting is deprecated. It is not deprecated.
 Skip didn't say that it was deprecated.

I didn't mean to create a tempest in a teapot.  I was away from
comp.lang.python, python-bugs, and python-dev for a few years.  In
particular, I didn't ever see the aforementioned thread from Feb 2012.
 Had I known of that thread I would have worded the sentence which
shall not be repeated differently.

My apologies...

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


Re: Static Maps from Lat Long data in XLS file

2013-05-22 Thread kobewka
On Tuesday, May 21, 2013 11:27:42 AM UTC-4, Tim Daneliuk wrote:
 On 05/21/2013 08:12 AM, @gmail.com wrote:
 
  Hello,
 
 
 
  I'm new to Python, but I think it can solve my problem and I am looking for 
  a someone to point me to tutorial or give me some tips here.
 
 
 
  I have an xls file that has about 1,000 latitude and longitude points. I 
  want to do one of two things: 1) Save a static maps and street view image 
  from the coordinates, or 2) create an html file with the map and street 
  view image side by side.
 
 
 
  I need the urls to look like this:
 
 
 
  Map with a pin in the centre:
 
  http://maps.googleapis.com/maps/api/staticmap?center=43.65162,-79.40571zoom=16size=600x600markers=color:blue%7Clabel:S%7C43.65162,-79.40571sensor=false
 
 
 
  Image:
 
  http://maps.googleapis.com/maps/api/streetview?location=43.65162,%20-79.40571size=600x600sensor=false
 
 
 
  I am not sure if option 1 will work because the url doesn't actually lead 
  to an image, but rather Google returns an image when that url is used.
 
 
 
  Any tips or pointers are much appreciated!
 
 
 
 
 
 
 
 https://pypi.python.org/pypi/xlrd
 
 
 
 
 
 
 
 -- 
 
 ---
 
 Tim Daneliuk

Thanks Tim.

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


Re: Static Maps from Lat Long data in XLS file

2013-05-22 Thread kobewka
Thanks Ken. I'll have a closer look at those links. I also found Motionless, 
which creates a static map HTML file. Combined with what you said, I should be 
able to get what I need.

https://github.com/ryancox/motionless

Scott



On Tuesday, May 21, 2013 9:58:25 AM UTC-4, Ken Bolton wrote:
 On Tue, May 21, 2013 at 9:12 AM,  kob...@gmail.com wrote:
 
 
 Hello,
 
 
 
 I'm new to Python, but I think it can solve my problem and I am looking for a 
 someone to point me to tutorial or give me some tips here.
 
  
 Hi! I am a first-time poster to python-list, but I think I can help you.
 
 
  
 I have an xls file that has about 1,000 latitude and longitude points. I want 
 to do one of two things: 1) Save a static maps and street view image from the 
 coordinates, or 2) create an html file with the map and street view image 
 side by side.
 
 
 
 
 If you save your xls file as a csv (comma-separated values), you can use 
 python's built-in csv module, documented here - 
 http://docs.python.org/2/library/csv.html, to read the file line by line. 
 Store the values and substitute the strings into a new list of URLs.
 
 
  
 I need the urls to look like this:
 
 
 
 Map with a pin in the centre:
 
 http://maps.googleapis.com/maps/api/staticmap?center=43.65162,-79.40571zoom=16size=600x600markers=color:blue%7Clabel:S%7C43.65162,-79.40571sensor=false
 
 
 
 
 
 Image:
 
 http://maps.googleapis.com/maps/api/streetview?location=43.65162,%20-79.40571size=600x600sensor=false
 
 
 
 
 I was able to use curl to grab the images you linked. I believe you can use 
 urllib (or, better, requests - http://docs.python-requests.org/en/latest/) to 
 get and save the images.
 
 
 
 
 hth.
 
 
 best,
 ken
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP 378: Format Specifier for Thousands Separator

2013-05-22 Thread Ned Batchelder


On 5/21/2013 11:38 PM, Carlos Nepomuceno wrote:

From:steve+comp.lang.pyt...@pearwood.info
Subject: Re: PEP 378: Format Specifier for Thousands Separator
Date: Wed, 22 May 2013 03:08:54 +
To:python-list@python.org

[...]

So, the only alternative to have '%,d' % x rendering the thousands
separator output would a C source code modification?


That's one alternative. But the language you would be then running will
no longer be Python.

Another alternative would be to write a pre-processor that parses your
Python source code, extracts any reference to the above, and replaces it
with a call to the appropriate format call. But not only is that a lot of
work for very little gain, but it's also more or less impossible to do in
full generality. And again, what you are running will be something
different than Python, it will be Python plus a pre-processor.


Don't fight the language. You will lose.

Not fighting the language. In fact it's not even a language issue.
All I need is a standard library[1] improvement: %,d! That's all!


You have to keep in mind that 2.7 is not getting any new features, no 
matter how small they seem.  If you create a patch that implements the 
comma flag in %-formatting, it *might* go into 3.x, but it will not go 
into 2.7.


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


Re: Diagnosing socket Connection reset by peer

2013-05-22 Thread Matt Jones
This typically indicates that the peer at the other end of the tcp
connection severed the session without the typical FIN packet.  If you're
treating the printer as a blackbox then there really isn't anything you
can do here except catch the exception and attempt to reconnect.

*Matt Jones*


On Wed, May 22, 2013 at 3:46 AM, loial jldunn2...@gmail.com wrote:

 I have a sockets client that is connecting to a printer and occassionally
 getting the error 104 Connection reset by peer

 I have not been able to diagnose what is causing this. Is there any
 additional traceing I can do(either within my python code or on the
 network) to establish what is causing this error?

 Currently I am simply trapping socket.erruor

 Python version is 2.6






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

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


RE: PEP 378: Format Specifier for Thousands Separator

2013-05-22 Thread Carlos Nepomuceno

 Date: Wed, 22 May 2013 07:25:13 -0400
 From: n...@nedbatchelder.com
[...]
 You have to keep in mind that 2.7 is not getting any new features, no
 matter how small they seem. If you create a patch that implements the
 comma flag in %-formatting, it *might* go into 3.x, but it will not go
 into 2.7.

 --Ned.

No problem. I have just discovered i was measuring the wrong thing.

My test case is been optimized at compile time by CPython that treats '%d' % 
12345 as a constant.
My use case is different because I almost have no literals been used with % 
operator.

So my gain isn't that great. In fact it's faster with str.format() than %, and 
it's even faster if I use the default format specifier.

C:\Python27python -m timeit -cv -n1000 -sv=12345 '%d'%v
raw times: 10.5 10.7 10.7
1000 loops, best of 3: 1.05 usec per loop

C:\Python27python -m timeit -cv -n1000 -sv=12345 '{:d}'.format(v)
raw times: 8.11 8.09 8.02
1000 loops, best of 3: 0.802 usec per loop

C:\Users\Josue\Documents\Pythonpython -m timeit -cv -n1000 -sv=12345 
'{}'.format(v)
raw times: 5.3 5.5 5.62
1000 loops, best of 3: 0.53 usec per loop

Using variables (100% of cases) makes str.format() 50% faster than %.   
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Python Windows release and encoding

2013-05-22 Thread Absalom K.
Hi, I am working on Linux; a friend of mine sends to me python files from
his Windows release. He uses the editor coming with the release; he runs
his code from the editor by using a menu (or some F5 key I think).

He doesn't declare any encoding in his source file; when I want to try
his code, I have an error since he obviously uses non-ascii characters.
As far as I can see, he uses utf8 without knowing it. I add the UTF8
declaration, run the code, and everything is fine.

Then I tell him to add the utf-8 declaration; but now he has an error
when running his file from the Windows editor.

Finally, he told me he could run the file by declaring the latin-1
encoding.

But I want to understand exactly:
  a) what is the encoding used by the editor coming in the Windows release?
  b) why doesn't he need to declare the encoding (I need it on Linux for
 the very same files)?

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


Re: Python Windows release and encoding

2013-05-22 Thread Peter Otten
Absalom K. wrote:

 Hi, I am working on Linux; a friend of mine sends to me python files from
 his Windows release. He uses the editor coming with the release; he runs
 his code from the editor by using a menu (or some F5 key I think).
 
 He doesn't declare any encoding in his source file; when I want to try
 his code, I have an error since he obviously uses non-ascii characters.
 As far as I can see, he uses utf8 without knowing it. I add the UTF8
 declaration, run the code, and everything is fine.
 
 Then I tell him to add the utf-8 declaration; but now he has an error
 when running his file from the Windows editor.
 
 Finally, he told me he could run the file by declaring the latin-1
 encoding.
 
 But I want to understand exactly:
   a) what is the encoding used by the editor coming in the Windows
   release? b) why doesn't he need to declare the encoding (I need it on
   Linux for
  the very same files)?
 
 Best regards, ak.

Your friend may be using an old version of Python. Quoting

http://www.python.org/dev/peps/pep-0263/


For backwards-compatibility with existing code which currently
uses non-ASCII in string literals without declaring an encoding,
the implementation will be introduced in two phases:

1. Allow non-ASCII in string literals and comments, by internally
   treating a missing encoding declaration as a declaration of
   iso-8859-1. This will cause arbitrary byte strings to
   correctly round-trip between step 2 and step 5 of the
   processing, and provide compatibility with Python 2.2 for
   Unicode literals that contain non-ASCII bytes.

   A warning will be issued if non-ASCII bytes are found in the
   input, once per improperly encoded input file.

2. Remove the warning, and change the default encoding to ascii.

[...]

Implementation of steps 1 and 2 above were completed in 2.3,
except for changing the default encoding to ascii.

The default encoding was set to ascii in version 2.5.
 

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


Re: Diagnosing socket Connection reset by peer

2013-05-22 Thread Dave Angel

On 05/22/2013 04:46 AM, loial wrote:

   SNIP

 Is there any additional traceing I can do(either within my python code or 
on the network) to establish what is causing this error?




Try using Wireshark.  It can do a remarkable job of filtering, 
capturing, and analyzing packets.  It can also read and write pcap 
files, which you could either save for later analysis, or send to 
someone who might help.  (Note - unfiltered pcap files can be very large 
on a busy network, but if you can quiet other traffic, you may not need 
to filter at all.)



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


Re: A computer programmer, web developer and network admin resume

2013-05-22 Thread Tim Chase
On 2013-05-22 16:39, Chris Angelico wrote:
 On Wed, May 22, 2013 at 12:32 PM, Tim Chase
 python.l...@tim.thechases.com wrote:
  On 2013-05-22 01:15, i...@databaseprograms.biz wrote:
  A computer programmer, web developer and network administrator
 
  ...walk into a bar...
 
  So what's the punchline?
 
 ;steps up to the mike
 
 So yeah, as I was saying, a programmer, a web dev, and a BOFH walk
 into a bar. The other two buy the BOFH a drink, because they're not
 stupid, and anyway, so this luser walks up to them with a resume in
 his hand.
 
 , says the luser.
 
 So what's the punchline? says the computer programmer.
 
 The stand-up comic steps up to the mike, and he says, So yeah, as I
 was saying, a programmer, a web dev, and a BOFH walk into a stable
 time loop...

So a pirate programmer walks into a bar with a bird on his shoulder.
The bird repeatedly squawks pieces of nine! pieces of nine!.  The
bartender looks at him and asks what's up with the bird? to which
the pirate says Arrr, he's got a parroty error.  The bartender
replies, Ah, I thought he was a bit off.

-tkc



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


Re: What was the project that made you feel skilled in Python?

2013-05-22 Thread Ben Finney
Ned Batchelder n...@nedbatchelder.com writes:

 as you moved from exercises like those in Learn Python the Hard Way,
 up to your own self-guided work on small projects, what project were
 you working on that made you feel independent and skilled?  What
 program first felt like your own work rather than an exercise the
 teacher had assigned?

I wanted to simulate a particular board game, and had others in mind
with some common mechanics.

This resulted in a library for rolling dice in different combinations,
and looking up result tables URL:https://pypi.python.org/pypi/alea.

Eventually I wanted to extend it to know about custom decks of cards,
and the different ways those are handled in board games.

The unifying theme was a library of routines for simulating the random
elements (dice, cards, tables, spinners, etc.) in any board game.

A little over-engineered, I'll freely admit. But it did give me a sense
of being at home in Python and knowing that this is a good language for
getting things done the right way.

-- 
 \ “Creativity can be a social contribution, but only in so far as |
  `\society is free to use the results.” —Richard Stallman |
_o__)  |
Ben Finney

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


Re: A computer programmer, web developer and network admin resume

2013-05-22 Thread Harry Percival
oh wow.  great one, thanks for that tim :)


On 22 May 2013 14:03, Tim Chase python.l...@tim.thechases.com wrote:

 On 2013-05-22 16:39, Chris Angelico wrote:
  On Wed, May 22, 2013 at 12:32 PM, Tim Chase
  python.l...@tim.thechases.com wrote:
   On 2013-05-22 01:15, i...@databaseprograms.biz wrote:
   A computer programmer, web developer and network administrator
  
   ...walk into a bar...
  
   So what's the punchline?
 
  ;steps up to the mike
 
  So yeah, as I was saying, a programmer, a web dev, and a BOFH walk
  into a bar. The other two buy the BOFH a drink, because they're not
  stupid, and anyway, so this luser walks up to them with a resume in
  his hand.
 
  , says the luser.
 
  So what's the punchline? says the computer programmer.
 
  The stand-up comic steps up to the mike, and he says, So yeah, as I
  was saying, a programmer, a web dev, and a BOFH walk into a stable
  time loop...

 So a pirate programmer walks into a bar with a bird on his shoulder.
 The bird repeatedly squawks pieces of nine! pieces of nine!.  The
 bartender looks at him and asks what's up with the bird? to which
 the pirate says Arrr, he's got a parroty error.  The bartender
 replies, Ah, I thought he was a bit off.

 -tkc



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




-- 
--
Harry J.W. Percival
--
Twitter: @hjwp
Mobile:  +44 (0) 78877 02511
Skype: harry.percival
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Future standard GUI library

2013-05-22 Thread Wolfgang Keller
  Do you think tkinter is going to be the standard python built-in
  gui solution as long as python exists?
 
  AT the moment, there is nothing really comparable that is a
  realistic candidate to replace tkinter.
 
  FLTK? (http://www.fltk.org/index.php)
 
  tkinter is the Python wrapper of the tk library, just as wxpython
  is the python wrapper of the wx library. I do not see a py-fltk
  wrapper.
 
 It exists, but it's really old.
 
 http://pyfltk.sourceforge.net/

And it's imho definitely not native (in terms of look and feel) on
*any* operating system, not even on Linux.

In fact it's SGI's Irix Forms re-implemented, afaik.

Sincerely,

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


Re: Future standard GUI library

2013-05-22 Thread Wolfgang Keller
 I know this may sound a silly question because no one can see the
 future. But ...
 Do you think tkinter is going to be the standard python built-in gui
 solution as long as python exists?

Standard built-in maybe, but by far most people who need a GUI for an
actual application will keep using something else.
 
 I couldn't help but wonder if wx or PySide receives better py2 and py3
 support, or anything else that prevent
 them from getting into the standard python distributions, whether or
 not this scene could start to shift ...

Didn't Pyside have serious trouble recently, requiring a reanimation of
the project?
 
 I believe this which one of tkinter, wx, qt, is the best gui toolkit
 for python flame war has been going on
 for ages. 

If (Py)Qt wasn't so freaking fat, it might be the best.
If wxPython had a more pythonic (and stable?) API, it might be the best.
If PyGTK was more native on Windows and native at all on MacOS X, it
might be the best.
If PyGUI was more extensive, it might be the best.

 This worries me very much about whether I should start a gui app
 using python.

What other open-source cross-platform programming language choices do yo
have.

Java? For GUIs? Excuse me while I vomit.

C++? As a language for human beings? Oops, I have to throw up again.

Sincerely,

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


Re: Future standard GUI library

2013-05-22 Thread Chris Angelico
On Wed, May 22, 2013 at 11:42 PM, Wolfgang Keller felip...@gmx.net wrote:
 What other open-source cross-platform programming language choices do yo
 have.

 Java? For GUIs? Excuse me while I vomit.

 C++? As a language for human beings? Oops, I have to throw up again.

I personally like using Pike and GTK, so if I were to try a
cross-platform Python GUI project, I'd probably give PyGTK a shot. But
there's another option that is available to every platform and
(practially) every high level language: the web browser. Make your app
serve HTTP and do up your UI in HTML5/CSS3 - your facilities are
pretty extensive. Plus you get networking support for free! Obviously
this option isn't for everyone, but don't discount it out of hand.

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


Re: Translation API in Python

2013-05-22 Thread Chris Angelico
On Wed, May 22, 2013 at 8:16 AM, Hala Gamal halagamal2...@gmail.com wrote:
 ok MR,
 I have searched before asking here,but i didn't find thing

Your post doesn't demonstrate that. When you ask a question like this,
it's helpful to give at least some indication of what you've tried and
what you haven't. Also, I strongly suspect that #4 is going to turn
something up; though of course people who read this post now have no
idea what I'm talking about, because you're responding to last week's
post without a shred of context.

Here are some tips that might help you:

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

ChrisA
PS. I say might only because they can't help if they're not followed.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Myth Busters: % this old style of formatting will eventually be removed from the language

2013-05-22 Thread Denis McMahon
On Tue, 21 May 2013 23:26:58 -0400, Ned Batchelder wrote:

 On 5/21/2013 10:26 PM, Carlos Nepomuceno wrote:

 Since str.format() is quite new, a lot of Python code still uses the %
 operator. However, because this old style of formatting will eventually
 be removed from the language, str.format() should generally be used.

 Is this tutorial outdated or this still an issue?

 That tutorial is out of date.  %-formatting isn't being removed.

Indeed, removing %-formatting could break a substantial amount of live 
code, with potentially significant maintenance effort in the user 
community simply to make existing code work with the new interpreter. The 
effect of this on corporations using python code translates into 
business risk, and the next step is we can avoid the business risk by 
migrating our python scripts to some other language.

For the designers and maintainers of any language to arbitrarily[1] (in 
the eyes of the user base) remove a widely used feature that would have a 
major effect on the user base could kill off a language, simply because 
many users will not want to take the risk of it happening again, even if 
they can easily automate the upgrade from removed obsolete language 
feature to new shiny language feature.

[1] Some portion of the user base will always consider any such change 
that causes them headaches and additional effort as having been 
arbitrary, no matter how well the language designers and maintainers 
explain the need to break the old scripts.

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


Re: What was the project that made you feel skilled in Python?

2013-05-22 Thread Chris Angelico
On Wed, May 22, 2013 at 11:05 PM, Ben Finney ben+pyt...@benfinney.id.au wrote:
 I wanted to simulate a particular board game, and had others in mind
 with some common mechanics.

 This resulted in a library for rolling dice in different combinations,
 and looking up result tables URL:https://pypi.python.org/pypi/alea.

Fun fun! Of course, when I hear rolling dice in different
combinations, my mind immediately turns to Dungeons and Dragons,
where it's plausible to roll d20+7, then roll 2d8+d6+12 to figure out
how much damage you did...

But the hard part of board games is usually the board. I used to spend
ages trying to draw up a half-decent board, and ended up giving up. By
simulate, I'm guessing you mean that you didn't actually draw
anything of the sort?

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


Re: PEP 378: Format Specifier for Thousands Separator

2013-05-22 Thread Steven D'Aprano
On Wed, 22 May 2013 05:45:12 -0500, Skip Montanaro wrote:

 I didn't mean to create a tempest in a teapot.  I was away from
 comp.lang.python, python-bugs, and python-dev for a few years.  In
 particular, I didn't ever see the aforementioned thread from Feb 2012.
  Had I known of that thread I would have worded the sentence which
 shall not be repeated differently.
 
 My apologies...

No problem, it's not about you specifically, it's just that some of us 
fans of % formatting can be a tad sensitive about it, especially since 
the idea that it has been deprecated (or soon will be deprecated, or one 
day will be deprecated, and therefore code using it is bad) is relatively 
widespread on the Internet.

Glad to have you back here!



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


subclassing from unittest

2013-05-22 Thread Charles Smith
Hi,

I'd like to subclass from unittest.TestCase.  I observed something
interesting and wonder if anyone can explain what's going on... some
subclasses create  null tests.

I can create this subclass and the test works:

  class StdTestCase (unittest.TestCase):
  blahblah

and I can create this subsubclass and the test works:

  class aaaTestCase (StdTestCase):
  moreblahblah

but if I create this subsubclass (or any where the first letter is
capital):

  class AaaTestCase (StdTestCase):
  differentblahblah

the test completes immediately without any work being done.

I suspect that the answer is in the prefix printed out by the test.  I
have diffed both the long output (tests works, on the left) and the
short output (null test, on the right):

test
(TC_02.TestCase_F__ULLA05__AM_Tx) ...  
test suite has  unittest.TestSuite tests=[unittest.TestSuite
tests=[],   test suite has  unittest.TestSuite
tests=[unittest.TestSuite tests=[],
 
unittest.TestSuite tests=[],
 unittest.TestSuite
tests=[TC_02.TestCase_F__ULLA05__AM
unittest.TestSuite tests=[TC_02.TestCase_F__ULLA05__AM
 unittest.TestSuite
tests=[TC_02.TestCase_F_0001_ULLA10__AM
unittest.TestSuite tests=[TC_02.TestCase_F_0001_ULLA10__AM
 unittest.TestSuite
tests=[TC_02.TestCase_F_0002_ULLA20__AM
unittest.TestSuite tests=[TC_02.TestCase_F_0002_ULLA20__AM
 unittest.TestSuite
tests=[TC_02.TestCase_F_0003_ULLA05__UM
unittest.TestSuite tests=[TC_02.TestCase_F_0003_ULLA05__UM
 unittest.TestSuite
tests=[TC_02.TestCase_F_0005_ULLA10__UM
unittest.TestSuite tests=[TC_02.TestCase_F_0005_ULLA10__UM
 unittest.TestSuite
tests=[TC_02.TestCase_F_0006_ULLA20__UM   |
unittest.TestSuite tests=[TC_02.TestCase_F_0006_ULLA20__UM
 unittest.TestSuite
tests=[]]
 
   --  test_api_socket:the address specified is:  127.0.0.1
 

 

 

 

--
 
   Ran 0 tests in 0.000s
 

 
   OK


I see an empty test somehow gets sorted to the beginning of the list.
How could that be a result of whether the first letter of the class is
capitalized or not?

Thanks in advance...
cts


http://www.creative-telcom-solutions.de
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: subclassing from unittest

2013-05-22 Thread Charles Smith
On 22 Mai, 17:32, Charles Smith cts.private.ya...@gmail.com wrote:
 Hi,

 I'd like to subclass from unittest.TestCase.  I observed something
 interesting and wonder if anyone can explain what's going on... some
 subclasses create  null tests.

 I can create this subclass and the test works:

   class StdTestCase (unittest.TestCase):
       blahblah

 and I can create this subsubclass and the test works:

   class aaaTestCase (StdTestCase):
       moreblahblah

 but if I create this subsubclass (or any where the first letter is
 capital):

   class AaaTestCase (StdTestCase):
       differentblahblah

 the test completes immediately without any work being done.

 I suspect that the answer is in the prefix printed out by the test.  I
 have diffed both the long output (tests works, on the left) and the
 short output (null test, on the right):

 test
 (TC_02.TestCase_F__ULLA05__AM_Tx) ...                  
 test suite has  unittest.TestSuite tests=[unittest.TestSuite
 tests=[],       test suite has  unittest.TestSuite
 tests=[unittest.TestSuite tests=[],

     unittest.TestSuite tests=[],

  unittest.TestSuite
 tests=[TC_02.TestCase_F__ULLA05__AM
 unittest.TestSuite tests=[TC_02.TestCase_F__ULLA05__AM
  unittest.TestSuite
 tests=[TC_02.TestCase_F_0001_ULLA10__AM
 unittest.TestSuite tests=[TC_02.TestCase_F_0001_ULLA10__AM
  unittest.TestSuite
 tests=[TC_02.TestCase_F_0002_ULLA20__AM
 unittest.TestSuite tests=[TC_02.TestCase_F_0002_ULLA20__AM
  unittest.TestSuite
 tests=[TC_02.TestCase_F_0003_ULLA05__UM
 unittest.TestSuite tests=[TC_02.TestCase_F_0003_ULLA05__UM
  unittest.TestSuite
 tests=[TC_02.TestCase_F_0005_ULLA10__UM
 unittest.TestSuite tests=[TC_02.TestCase_F_0005_ULLA10__UM
  unittest.TestSuite
 tests=[TC_02.TestCase_F_0006_ULLA20__UM   |
 unittest.TestSuite tests=[TC_02.TestCase_F_0006_ULLA20__UM
  unittest.TestSuite
 tests=[]]                                        

    --  test_api_socket:the address specified is:  127.0.0.1

 --

    Ran 0 tests in 0.000s

    OK

 I see an empty test somehow gets sorted to the beginning of the list.
 How could that be a result of whether the first letter of the class is
 capitalized or not?

 Thanks in advance...
 cts

 http://www.creative-telcom-solutions.de


Unfortunately, the side-by-side diff didn't come out so well  ...

---
http://www.creative-telcom-solutions.de
-- 
http://mail.python.org/mailman/listinfo/python-list


file I/O and arithmetic calculation

2013-05-22 Thread Keira Wilson
Dear all,

I would appreciate if someone could write a simple python code for the
purpose below:

I have five text files each of 10 columns by 10 rows as follows:

file_one = 'C:/test/1.txt'
file_two = 'C:/test/2.txt' . . .
file_five = 'C:/test/5.txt'

 I want to calculate the mean of first row (10 elements) for each file (5
files), if mean of first column (10 elements) of each file (5 files) is 50.

Thank you in advance.

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


Re: file I/O and arithmetic calculation

2013-05-22 Thread Mark Lawrence

On 22/05/2013 17:13, Keira Wilson wrote:

Dear all,

I would appreciate if someone could write a simple python code for the
purpose below:

I have five text files each of 10 columns by 10 rows as follows:


|file_one=  'C:/test/1.txt'
file_two=  'C:/test/2.txt'
.  .  .
file_five=  'C:/test/5.txt'|

I want to calculate the mean of first row (10 elements) for each file (5
files), if mean of first column (10 elements) of each file (5 files) is 50.

Thank you in advance.

Keira



Sorry but we don't do homework.

--
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.


Mark Lawrence

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


Re: PEP 378: Format Specifier for Thousands Separator

2013-05-22 Thread Ned Batchelder


On 5/22/2013 10:58 AM, Steven D'Aprano wrote:

On Wed, 22 May 2013 05:45:12 -0500, Skip Montanaro wrote:


I didn't mean to create a tempest in a teapot.  I was away from
comp.lang.python, python-bugs, and python-dev for a few years.  In
particular, I didn't ever see the aforementioned thread from Feb 2012.
  Had I known of that thread I would have worded the sentence which
shall not be repeated differently.

My apologies...

No problem, it's not about you specifically, it's just that some of us
fans of % formatting can be a tad sensitive about it, especially since
the idea that it has been deprecated (or soon will be deprecated, or one
day will be deprecated, and therefore code using it is bad) is relatively
widespread on the Internet.


Seems like maybe this should become a question in the Python FAQ.

--Ned.



Glad to have you back here!





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


Re: Myth Busters: % this old style of formatting will eventually be removed from the language

2013-05-22 Thread Terry Jan Reedy

On 5/22/2013 10:24 AM, Denis McMahon wrote:


Indeed, removing %-formatting could break a substantial amount of live
code, with potentially significant maintenance effort in the user


While I would like to see % formatting go away everntually*, other 
developers would not. In any case, I agree that it should not disappear 
until there is a foolproof conversion tool, probably custom written. I 
am working on other things.


* perhaps in 10 years?, when all 2.x code that is going to be converted 
has been converted


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


Re: Diagnosing socket Connection reset by peer

2013-05-22 Thread Jorgen Grahn
On Wed, 2013-05-22, Dave Angel wrote:
 On 05/22/2013 04:46 AM, loial wrote:
SNIP

  Is there any additional traceing I can do(either within my
 python code or on the network) to establish what is causing this
 error?

 Try using Wireshark.  It can do a remarkable job of filtering, 
 capturing, and analyzing packets.  It can also read and write pcap 
 files, which you could either save for later analysis, or send to 
 someone who might help.

Or use tcpdump, which has a text interface so you can show the problem
in a text medium like Usenet.

 (Note - unfiltered pcap files can be very large 
 on a busy network, but if you can quiet other traffic, you may not need 
 to filter at all.)

Or simply filter.  It's not hard -- the capture filter
host my-printer-hostname-or-address is enough.

/Jorgen

-- 
  // Jorgen Grahn grahn@  Oo  o.   . .
\X/ snipabacken.se   O  o   .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Myth Busters: % this old style of formatting will eventually be removed from the language

2013-05-22 Thread nn
On May 22, 6:35 am, Skip Montanaro s...@pobox.com wrote:
  Is this tutorial outdated or this still an issue?

  [1]
 http://docs.python.org/2/tutorial/inputoutput.html#old-string-formatting

  That tutorial is out of date.  %-formatting isn't being removed.

 OTOH, PEP 3101 also mentions deprecation, at the very end: ... both
 systems can co-exist until it comes time to deprecate the older
 system.

 I have been operating under the assumption since the days of that PEP
 that %-style formatting would eventually disappear, dreading the day
 when I'd have to learn the str.format language.  I apologize for
 (inadvertently) spreading FUD.

 It does seem like the documentation should be updated in a few places.
  If the decision has been made to not remove the older system, it
 might be worthwhile to mention that somewhere.  Clearly the tutorial
 and PEP 3101 should be updated.

 Skip

I was of the impression that deprecating % was still planned for Py4k,
whenever that is. I personally believe that eliminating % formatting
would reduce bugs and generally make code clearer, but I realize that
breaking backward compatibility has a high price.

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


Re: What was the project that made you feel skilled in Python?

2013-05-22 Thread Terry Jan Reedy

On 5/22/2013 9:05 AM, Ben Finney wrote:


I wanted to simulate a particular board game, and had others in mind
with some common mechanics.

This resulted in a library for rolling dice in different combinations,
and looking up result tables URL:https://pypi.python.org/pypi/alea.


Have you cosidered adding a description so it can be found be a search?
A 3.3 version?

Simulate game randomizers and lookup: dice rolls, card drawing, 
spinners, ...



Eventually I wanted to extend it to know about custom decks of cards,
and the different ways those are handled in board games.

The unifying theme was a library of routines for simulating the random
elements (dice, cards, tables, spinners, etc.) in any board game.

A little over-engineered, I'll freely admit. But it did give me a sense
of being at home in Python and knowing that this is a good language for
getting things done the right way.




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


Re: Diagnosing socket Connection reset by peer

2013-05-22 Thread Jorgen Grahn
On Wed, 2013-05-22, Matt Jones wrote:
 On Wed, May 22, 2013 at 3:46 AM, loial jldunn2...@gmail.com wrote:

 I have a sockets client that is connecting to a printer and occassionally
 getting the error 104 Connection reset by peer

 I have not been able to diagnose what is causing this. Is there any
 additional traceing I can do(either within my python code or on the
 network) to establish what is causing this error?

 Currently I am simply trapping socket.erruor

 Python version is 2.6

 This typically indicates that the peer at the other end of the tcp
 connection severed the session without the typical FIN packet.

I.e. by sending a RST (reset) instead.  Yes, that's what Connection
reset by peer means.  I don't think there are any other causes for
this signal.

A server application can cause a reset explicitly, or if it crashes
the OS will send one for it, as part of the resource cleanup.

Also, if you're behind a cheap NATing gateway, I think it may send
fake RSTs if it has lost track of the TCP session.

 If you're
 treating the printer as a blackbox then there really isn't anything you
 can do here except catch the exception and attempt to reconnect.

Yes.  Note that there *may* be some uncertainty re: did the printer
process the last request before the reset or not? E.g. I wouldn't
endlessly retry printing a 100-page document in that case.

/Jorgen

-- 
  // Jorgen Grahn grahn@  Oo  o.   . .
\X/ snipabacken.se   O  o   .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Diagnosing socket Connection reset by peer

2013-05-22 Thread Grant Edwards
On 2013-05-22, Jorgen Grahn grahn+n...@snipabacken.se wrote:
 On Wed, 2013-05-22, Dave Angel wrote:
 On 05/22/2013 04:46 AM, loial wrote:
SNIP

  Is there any additional traceing I can do(either within my
 python code or on the network) to establish what is causing this
 error?

 Try using Wireshark.  It can do a remarkable job of filtering, 
 capturing, and analyzing packets.  It can also read and write pcap 
 files, which you could either save for later analysis, or send to 
 someone who might help.

 Or use tcpdump, which has a text interface so you can show the problem
 in a text medium like Usenet.

There's also tshark, which is sort of a command-line version of
wireshark.

http://www.wireshark.org/docs/man-pages/tshark.html

 (Note - unfiltered pcap files can be very large on a busy network,
 but if you can quiet other traffic, you may not need to filter at
 all.)

 Or simply filter.  It's not hard -- the capture filter host
 my-printer-hostname-or-address is enough.

Indeed.  Even a simple filter can make life several orders of
magnitude easier.  If filtering by IP address isn't enough, the next
step is usually to add a port number filter...

-- 
Grant Edwards   grant.b.edwardsYow! Of course, you
  at   UNDERSTAND about the PLAIDS
  gmail.comin the SPIN CYCLE --
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP 378: Format Specifier for Thousands Separator

2013-05-22 Thread nn
On May 22, 2:30 pm, Ned Batchelder n...@nedbatchelder.com wrote:
 On 5/22/2013 10:58 AM, Steven D'Aprano wrote:

  On Wed, 22 May 2013 05:45:12 -0500, Skip Montanaro wrote:

  I didn't mean to create a tempest in a teapot.  I was away from
  comp.lang.python, python-bugs, and python-dev for a few years.  In
  particular, I didn't ever see the aforementioned thread from Feb 2012.
    Had I known of that thread I would have worded the sentence which
  shall not be repeated differently.

  My apologies...
  No problem, it's not about you specifically, it's just that some of us
  fans of % formatting can be a tad sensitive about it, especially since
  the idea that it has been deprecated (or soon will be deprecated, or one
  day will be deprecated, and therefore code using it is bad) is relatively
  widespread on the Internet.

 Seems like maybe this should become a question in the Python FAQ.

 --Ned.









  Glad to have you back here!

Maybe a cformat(formatstring, variables)  function should be created
in the string module so people who prefer that can use it. I don't
mind the C formatting syntax but I don't like the fact that the %
operator does something totally different when the first variable is
an integer and the fact that it misbehaves if the second variable is a
tuple.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: file I/O and arithmetic calculation

2013-05-22 Thread Carlos Nepomuceno
Funny! I made a lot of assumptions regarding your requirements specification. 
Let me know if it isn't what you need:

### 1strow_average.py ###
#Assuming you have CSV (comma separated values) files such as:
#1.txt = '0,1,2,3,4,5,6,7,8,9\n' \
#    '10,11,12,13,14,15,16,17,18,19\n' \
#    '20,21,22,23,24,25,26,27,28,29\n' ...
#
# Usage: contents[file][row][column]
# contents[0]   : file '1.txt'
# contents[1][2]    : 3rd row of file '2.txt'
# contents[3][4][5] : 6th column of 5th row of file '4.txt'
# len(contents) : quantity of files
# len(contents[4])  : quantity of lines in file '5.txt'
# len(contents[4][0]: quantity of values in the 1st line of file '5.txt'

filenames = ['1.txt', '2.txt', '3.txt', '4.txt', '5.txt']
contents  = [[[int(z) for z in y.split(',')] for y in open(x).read().split()] 
for x in filenames]
s1c  = [sum([r[0] for r in f]) for f in contents]
a1r  = [sum(f[0])/float(len(f[0])) for f in contents]
print '\n'.join([x for x in ['File {} has 1st row average = 
{:.2f}'.format(n,a1r[i]) if s1c[i]==50 else '' for i,n in enumerate(filenames)] 
if x])



 From: wilke...@gmail.com 
 Date: Thu, 23 May 2013 01:13:19 +0900 
 Subject: file I/O and arithmetic calculation 
 To: python-list@python.org 
  
  
 Dear all, 
  
 I would appreciate if someone could write a simple python code for the  
 purpose below: 
  
 I have five text files each of 10 columns by 10 rows as follows: 
  
  
  
 file_one = 'C:/test/1.txt' 
 file_two = 'C:/test/2.txt' 
 . . . 
 file_five = 'C:/test/5.txt' 
  
 I want to calculate the mean of first row (10 elements) for each file  
 (5 files), if mean of first column (10 elements) of each file (5  
 files) is 50. 
  
 Thank you in advance. 
  
 Keira 
  
  
 -- http://mail.python.org/mailman/listinfo/python-list
   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: subclassing from unittest

2013-05-22 Thread Terry Jan Reedy

On 5/22/2013 11:32 AM, Charles Smith wrote:

Have you red this? I will suggest some specifics.
http://www.catb.org/esr/faqs/smart-questions.html


I'd like to subclass from unittest.TestCase.


What version of Python.

 I observed something interesting and wonder if anyone can explain 
what's going on... some

subclasses create  null tests.

I can create this subclass and the test works:


What does 'works' mean?


   class StdTestCase (unittest.TestCase):
   blahblah


I bet that this (and the rest of your 'code' is not what you actually 
ran. Unless blahblah is bound (to what?), this fails with NameError.

Give us what you ran so we can run it too, and modify it.


and I can create this subsubclass and the test works:

   class aaaTestCase (StdTestCase):
   moreblahblah

but if I create this subsubclass (or any where the first letter is
capital):

   class AaaTestCase (StdTestCase):
   differentblahblah

the test completes immediately without any work being done.


What does this mean? I see no difference with the following

import unittest
class StdTestCase (unittest.TestCase): pass
class lowerSub(StdTestCase): pass
class UpperSub(StdTestCase): pass

unittest.main(verbosity=2, exit=False)

# prints (3.3)
--
Ran 0 tests in 0.000s

OK

Same as before the subclasses were added.

--
Terry Jan Reedy


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


RE: PEP 378: Format Specifier for Thousands Separator

2013-05-22 Thread Carlos Nepomuceno

 Date: Wed, 22 May 2013 13:26:23 -0700
 Subject: Re: PEP 378: Format Specifier for Thousands Separator
 From: prueba...@latinmail.com
 To: python-list@python.org
[...]

 Maybe a cformat(formatstring, variables) function should be created
 in the string module so people who prefer that can use it. I don't
 mind the C formatting syntax but I don't like the fact that the %
 operator does something totally different when the first variable is
 an integer and the fact that it misbehaves if the second variable is a
 tuple.
 --
 http://mail.python.org/mailman/listinfo/python-list

I still don't understand why % benefits from literals optimization 
('%d'%12345) while '{:d}'.format(12345) doesn't.

What totally different you talking about? Please give me an example.  
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about evaluating raw_input() responses

2013-05-22 Thread Alister
On Tue, 21 May 2013 23:52:30 -0700, Kevin Xi wrote:

 On Wednesday, May 22, 2013 2:23:15 PM UTC+8, C. N. Desrosiers wrote:
 Hi,
 
 Hi,
 
 I'm just starting out with Python and to practice I am trying to write
 a script that can have a simple conversation with the user.
 
 So you may want to search the doc before you ask: http://docs.python.org
 
 When I run the below code, it always ends up printing response to if
 age  18: -- even if I enter a value below 18.
 
 
 
 Can anyone point me to what I am doing wrong?  Many thanks in advance.
 
 
 
 age=raw_input('Enter your age: ')
 
 if age  18:
 
 print ('Wow, %s. You can buy cigarettes.' % age)
 
 else:
 
 print ('You are a young grasshopper.')
 
 You can either use `raw_input` to read data and convert it to right
 type, or use `input` to get an integer directly. Read this:
 http://docs.python.org/2/library/functions.html#raw_input
 http://docs.python.org/2/library/functions.html#input
 
  
Kevin

Please write out 1000 time (without using any form of loop)

NEVER use input in python 3.0 it is EVIL*

as Chris A point out it executes user input an can cause major damage 
(reformatting the hard disk is not impossible!)


-- 
Quality Control, n.:
The process of testing one out of every 1,000 units coming off
a production line to make sure that at least one out of 100 works.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Newbie question about evaluating raw_input() responses

2013-05-22 Thread Carlos Nepomuceno

 From: alister.w...@ntlworld.com
[...]
 Kevin

 Please write out 1000 time (without using any form of loop)

 NEVER use input in python 3.0 it is EVIL*

 as Chris A point out it executes user input an can cause major damage
 (reformatting the hard disk is not impossible!)


Indeed! input is eval(raw_input())! lol 
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A computer programmer, web developer and network admin resume

2013-05-22 Thread Gregory Ewing

Tim Chase wrote:

So a pirate programmer walks into a bar with a bird on his shoulder.
The bird repeatedly squawks pieces of nine! pieces of nine!.  The
bartender looks at him and asks what's up with the bird? to which
the pirate says Arrr, he's got a parroty error.


No, he's just using half-open ranges.

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


Re: file I/O and arithmetic calculation

2013-05-22 Thread Oscar Benjamin
On 22 May 2013 22:05, Carlos Nepomuceno carlosnepomuc...@outlook.com wrote:

 filenames = ['1.txt', '2.txt', '3.txt', '4.txt', '5.txt']
 contents  = [[[int(z) for z in y.split(',')] for y in open(x).read().split()] 
 for x in filenames]
 s1c  = [sum([r[0] for r in f]) for f in contents]
 a1r  = [sum(f[0])/float(len(f[0])) for f in contents]
 print '\n'.join([x for x in ['File {} has 1st row average = 
 {:.2f}'.format(n,a1r[i]) if s1c[i]==50 else '' for i,n in 
 enumerate(filenames)] if x])

Do you find this code easy to read? I wouldn't write something like
this and I certainly wouldn't use it when explaining something to a
beginner.

Rather than repeated list comprehensions you should consider using a
single loop e.g.:

for filename in filenames:
# process each file

This will make the code a lot simpler.


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


RE: file I/O and arithmetic calculation

2013-05-22 Thread Carlos Nepomuceno

 From: oscar.j.benja...@gmail.com
[...]

 Do you find this code easy to read? I wouldn't write something like
 this and I certainly wouldn't use it when explaining something to a
 beginner.

 Rather than repeated list comprehensions you should consider using a
 single loop e.g.:

 for filename in filenames:
 # process each file

 This will make the code a lot simpler.


 Oscar

Indeed, but for that you can use Pascal.

List comprehensions it's what Python does best!

The code is pretty obvious to me, I mean there's no obfuscation at all. 
  
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: file I/O and arithmetic calculation

2013-05-22 Thread Carlos Nepomuceno
# contents[3][4][5] : 6th column of 5th row of file '4.txt'

BTW, it should read

# contents[3][4][5] : 6th value of 5th row of file '4.txt'  
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: file I/O and arithmetic calculation

2013-05-22 Thread Denis McMahon
On Thu, 23 May 2013 01:13:19 +0900, Keira Wilson wrote:

 I would appreciate if someone could write a simple python code for the
 purpose below:

Didn't have your data, so couldn't verify it completely, but try this:

import re
def v(s):
 l=len(s)
 t=0.
 for i in range(l):
  t=t+(abs(ord(s[i]))*1.)
 return t/(l*1.)
for n in range(5):
 m=c:/test/+str(n+1)+.txt
 f=open(m,r)
 d=[]
 t=0.
 for l in range(10):
  d=d+[re.findall(r[0-9.eE+-]+,f.readline())]
  t=t+v(d[l][0])
 f.close()
 c=t/10.
 if c==50.:
  t=0.
  for u in range(10):
   t=t+v(d[0][u])
  r=t/10.
  print %s C1: %f R1: %f%(m,c,r)

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


RE: file I/O and arithmetic calculation

2013-05-22 Thread Carlos Nepomuceno

 From: denismfmcma...@gmail.com
[...]

 import re
 def v(s):
 l=len(s)
 t=0.
 for i in range(l):
 t=t+(abs(ord(s[i]))*1.)
 return t/(l*1.)
 for n in range(5):
 m=c:/test/+str(n+1)+.txt
 f=open(m,r)
 d=[]
 t=0.
 for l in range(10):
 d=d+[re.findall(r[0-9.eE+-]+,f.readline())]
 t=t+v(d[l][0])
 f.close()
 c=t/10.
 if c==50.:
 t=0.
 for u in range(10):
 t=t+v(d[0][u])
 r=t/10.
 print %s C1: %f R1: %f%(m,c,r)

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

Can you send it again without tabs?   
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PEP 378: Format Specifier for Thousands Separator

2013-05-22 Thread Oscar Benjamin
On 22 May 2013 23:31, Carlos Nepomuceno carlosnepomuc...@outlook.com wrote:

 I still don't understand why % benefits from literals optimization 
 ('%d'%12345) while '{:d}'.format(12345) doesn't.

There's no reason why that optimisation can't happen in principle.
However no one has written a patch for it. Why don't you look into
what it would take to make it happen?


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


Re: file I/O and arithmetic calculation

2013-05-22 Thread Oscar Benjamin
On 23 May 2013 00:49, Carlos Nepomuceno carlosnepomuc...@outlook.com wrote:

 The code is pretty obvious to me, I mean there's no obfuscation at all.

I honestly can't tell if you're joking.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: file I/O and arithmetic calculation

2013-05-22 Thread Carlos Nepomuceno

 From: oscar.j.benja...@gmail.com
 Date: Thu, 23 May 2013 01:34:37 +0100
 Subject: Re: file I/O and arithmetic calculation
 To: carlosnepomuc...@outlook.com
 CC: python-list@python.org

 On 23 May 2013 00:49, Carlos Nepomuceno carlosnepomuc...@outlook.com wrote:

 The code is pretty obvious to me, I mean there's no obfuscation at all.

 I honestly can't tell if you're joking.

I'm not! lol  
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: PEP 378: Format Specifier for Thousands Separator

2013-05-22 Thread Carlos Nepomuceno

 From: oscar.j.benja...@gmail.com
 Date: Thu, 23 May 2013 01:30:53 +0100
 Subject: Re: PEP 378: Format Specifier for Thousands Separator
 To: carlosnepomuc...@outlook.com
 CC: prueba...@latinmail.com; python-list@python.org

 On 22 May 2013 23:31, Carlos Nepomuceno carlosnepomuc...@outlook.com wrote:

 I still don't understand why % benefits from literals optimization 
 ('%d'%12345) while '{:d}'.format(12345) doesn't.

 There's no reason why that optimisation can't happen in principle.
 However no one has written a patch for it. Why don't you look into
 what it would take to make it happen?


 Oscar

Maybe I'll look into that later, but I couldn't even find how the hell they 
made _Py_InsertThousandsGrouping() been called.

That's what I got when analysing % formating:

Thousands separator format specifier for str.__mod__()
==

@Objects/stringobject.c: implements formatint() for '%' processing
-Looking for code used in str.format()

@Objects/stringlib/formatter.h: implements str.format()
-It uses STRINGLIB_GROUPING() to do the job.

@Objects/stringlib/stringdefs.h: #define STRINGLIB_GROUPING   
_PyString_InsertThousandsGrouping
@Objects/stringlib/unicodedefs.h: #define STRINGLIB_GROUPING   
_PyUnicode_InsertThousandsGrouping
@Objects/stringobject.c: #define _Py_InsertThousandsGrouping 
_PyString_InsertThousandsGrouping
@Objects/stringobject.h: declares _PyString_InsertThousandsGrouping()
@???: ??? _PyString_InsertThousandsGrouping ??? _Py_InsertThousandsGrouping
@Objects/stringlib/localeutil.h: implements _Py_InsertThousandsGrouping()


Let me explain what that means. I found no relating declarations/definitions 
that turn _PyString_InsertThousandsGrouping into _Py_InsertThousandsGrouping.

So, I don't even know how that source code compiles without error.

:/ really strange...


Not to mention the lots of code inside header definition files! Weird   
  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A computer programmer, web developer and network admin resume

2013-05-22 Thread Ken Bolton
On Wed, May 22, 2013 at 7:25 PM, Gregory Ewing
greg.ew...@canterbury.ac.nzwrote:

 Tim Chase wrote:

 So a pirate programmer walks into a bar with a bird on his shoulder.
 The bird repeatedly squawks pieces of nine! pieces of nine!.  The
 bartender looks at him and asks what's up with the bird? to which
 the pirate says Arrr, he's got a parroty error.


 No, he's just using half-open ranges.


That is the punchline for the one about the cowboy programmer.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about evaluating raw_input() responses

2013-05-22 Thread Kevin Xi
Oh yes, you guys are right. Thank you very much for warning me that.

On Thursday, May 23, 2013 6:31:04 AM UTC+8, Alister wrote:

 
 as Chris A point out it executes user input an can cause major damage 
 
 (reformatting the hard disk is not impossible!)
 

It definitely can cause major damage! I try to input `os.system('rm -rf *')` 
and it really delete all stuff under the directory:(, I have never realized it 
can do that harm. Sorry for misleading you C. N. Desrosiers.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Future standard GUI library

2013-05-22 Thread llanitedave
On Wednesday, May 22, 2013 7:24:15 AM UTC-7, Chris Angelico wrote:
 On Wed, May 22, 2013 at 11:42 PM, Wolfgang Keller felip...@gmx.net wrote:
 
  What other open-source cross-platform programming language choices do yo
 
  have.
 
 
 
  Java? For GUIs? Excuse me while I vomit.
 
 
 
  C++? As a language for human beings? Oops, I have to throw up again.
 
 
 
 I personally like using Pike and GTK, so if I were to try a
 
 cross-platform Python GUI project, I'd probably give PyGTK a shot. But
 
 there's another option that is available to every platform and
 
 (practially) every high level language: the web browser. Make your app
 
 serve HTTP and do up your UI in HTML5/CSS3 - your facilities are
 
 pretty extensive. Plus you get networking support for free! Obviously
 
 this option isn't for everyone, but don't discount it out of hand.
 
 
 
 ChrisA

I've been thinking about that myself for some future app ideas.  If you have a 
stand-alone app working from your web browser, don't you need an embedded web 
server to utilize the file system?  Is a system like Django for an app 
overkill?  Or is its embedded development server underkill for a single-user 
browser-based application?
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: file I/O and arithmetic calculation

2013-05-22 Thread Carlos Nepomuceno
The last line of my noob piece can be improved. So this is it:

### 1strow_average.py ###
#Assuming you have CSV (comma separated values) files such as:
#1.txt = '0,1,2,3,4,5,6,7,8,9\n' \
#    '10,11,12,13,14,15,16,17,18,19\n' \
#    '20,21,22,23,24,25,26,27,28,29\n' ...
#
# Usage: contents[file][row][column]
# contents[0]   : file '1.txt'
# contents[1][2]    : 3rd row of file '2.txt'
# contents[3][4][5] : value on the 6th column of 5th row of file '4.txt'
# len(contents) : quantity of files
# len(contents[4])  : quantity of lines in file '5.txt'
# len(contents[4][0]: quantity of values in the 1st line of file '5.txt'

filenames = ['1.txt', '2.txt', '3.txt', '4.txt', '5.txt']
contents  = [[[int(z) for z in y.split(',')] for y in open(x).read().split()] 
for x in filenames]
s1c  = [sum([r[0] for r in f]) for f in contents]
a1r  = [sum(f[0])/float(len(f[0])) for f in contents]
print '\n'.join(['File {} has 1st row average = {:.2f}'.format(n,a1r[i]) for 
i,n in enumerate(filenames) if s1c[i]==50]) 
   
-- 
http://mail.python.org/mailman/listinfo/python-list


Ordered dictionaries compared

2013-05-22 Thread Dan Stromberg
What kind of ordered dictionaries?  Sorted by key.

I've redone the previous comparison, this time with a better red-black tree
implementation courtesy of Duncan G. Smith.

The comparison is at
http://stromberg.dnsalias.org/~strombrg/python-tree-and-heap-comparison/just-trees/

The Red-Black tree gave a much better showing this time, but it gave just
one 2nd place on one workload-interpreter - still kinda lackluster.  It
took 1st place 0 times.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Modules list-tool

2013-05-22 Thread Dan Stromberg
On Tue, May 21, 2013 at 12:35 PM, Gisle Vanem gva...@broadpark.no wrote:

 Are anyone aware of a tool that can show me at run-time
 which modules (pyd/dll) are loaded into a Python program at a specific
 time (or over time)?

 To clarify, e.g. when running a sample from PyQt4
 (examples\tutorials\**addressbook\part1.pyw) and using Process Explorer
 [1],
 I can launch WinDbg from it and get this list of modules:
 

 ModLoad: 1d00 1d00a000   G:\ProgramFiler\Python27\**python.EXE
 ModLoad: 7c90 7c9b1000   F:\WINDOWS\system32\ntdll.dll
 ModLoad: 7c80 7c8f7000   F:\WINDOWS\system32\kernel32.**dll
 ModLoad: 1e00 1e261000   f:\windows\system32\python27.**dll
 ModLoad: 7e41 7e4a1000   F:\WINDOWS\system32\USER32.dll
 ModLoad: 77f1 77f59000   F:\WINDOWS\system32\GDI32.dll
 ModLoad: 77dc 77e6a000   F:\WINDOWS\system32\ADVAPI32.**dll
 ModLoad: 77e7 77f03000   F:\WINDOWS\system32\RPCRT4.dll
 ModLoad: 77fe 77ff1000   F:\WINDOWS\system32\Secur32.**dll
 ModLoad: 7c9c 7d1d8000   F:\WINDOWS\system32\SHELL32.**dll
 ModLoad: 77c0 77c58000   F:\WINDOWS\system32\msvcrt.dll
 ModLoad: 77f6 77fd6000   F:\WINDOWS\system32\SHLWAPI.**dll
 ModLoad: 7852 785c3000   f:\windows\WinSxS\x86_**Microsoft.VC90.CRT_**
 1fc8b3b9a1e18e3b_9.0.30729.**6161_x-ww_31a54e43\MSVCR90.dll
 ModLoad: 7637 7638d000   f:\windows\system32\IMM32.DLL
 ModLoad: 62f2 62f29000   f:\windows\system32\LPK.DLL
 ModLoad: 7542 7548b000   f:\windows\system32\USP10.dll
 ModLoad: 773c 774c3000 f:\windows\WinSxS\x86_**
 Microsoft.Windows.Common-**Controls_6595b64144ccf1df_6.0.2600.6028_x-**
 ww_61e65202\comctl32.dll
 ModLoad: 5d5d 5d66a000   F:\WINDOWS\system32\comctl32.**dll
 ModLoad: 78aa 78b5f000   f:\windows\system32\MSVCR100.**dll
 ModLoad: 00d9 00f29000   g:\ProgramFiler\Python27\lib\**
 site-packages\PyQt4\QtCore.pyd
 ModLoad: 6700 6726   g:\ProgramFiler\Python27\lib\**
 site-packages\PyQt4\QtCore4.**dll
 ModLoad: 774d 7760e000   F:\WINDOWS\system32\ole32.dll
 ModLoad: 71aa 71ab7000   f:\windows\system32\WS2_32.dll
 ModLoad: 71a9 71a98000   f:\windows\system32\WS2HELP.**dll
 ModLoad: 7848 7850e000   f:\windows\WinSxS\x86_**Microsoft.VC90.CRT_**
 1fc8b3b9a1e18e3b_9.0.30729.**6161_x-ww_31a54e43\MSVCP90.dll
 ModLoad: 00a6 00a73000   g:\ProgramFiler\Python27\lib\**
 site-packages\sip.pyd
 ModLoad: 011f 0177f000   g:\ProgramFiler\Python27\lib\**
 site-packages\PyQt4\QtGui.pyd
 ModLoad: 6500 657c4000   g:\ProgramFiler\Python27\lib\**
 site-packages\PyQt4\QtGui4.dll
 ...

 -

 My example may be mooth since part1.pyw above (when I enter
 the debugger) is just waiting for events. The stack of pythonw.exe as
 shown in Process Explorer:
 ...
 ntdll.dll!**ZwWaitForMultipleObjects+0xc
 kernel32.dll!**WaitForMultipleObjectsEx+0x12c
 USER32.dll!**RealMsgWaitForMultipleObjectsE**x+0x13e
 QtCore4.dll!**QEventDispatcherWin32::**processEvents+0x3c3
 ntdll.dll!RtlAcquirePebLock+**0x28

 Is there a tool that can do something similar? (written in Python maybe?).
 But a bit simpler to use than my current method. Just launch it from the
 command-line; something like pyXX part1.pyw more args

 [1] 
 http://technet.microsoft.com/**en-gb/sysinternals/bb896653http://technet.microsoft.com/en-gb/sysinternals/bb896653

 --gv
 --
 http://mail.python.org/**mailman/listinfo/python-listhttp://mail.python.org/mailman/listinfo/python-list


Python -v reports on modules.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about evaluating raw_input() responses

2013-05-22 Thread Steven D'Aprano
On Wed, 22 May 2013 22:31:04 +, Alister wrote:

 Please write out 1000 time (without using any form of loop)
 
 NEVER use input in python 3.0 it is EVIL*
 
 as Chris A point out it executes user input an can cause major damage
 (reformatting the hard disk is not impossible!)

Is he allowed to use eval instead of a loop?

print (eval(NEVER use input in python 3.0 it is EVIL\n*1000))

*wink*


But all joking aside, eval is dangerous, yes, but it is not evil. It 
needs to be handled with caution, but there are good uses for it. In 
fact, there are a few -- a very few -- things which can *only* be done 
with eval or exec. That's why it is part of the language! 

(I just wish that eval and exec where in a module, rather than built-in, 
to help discourage casual usage by beginners who don't know what they're 
doing.)

For example, collections.namedtuple uses eval to dynamically generate new 
classes on the fly from arguments given. But it is safe to use, because 
it has been designed by experts to be safe and tested in great detail.

So while it is right and proper to treat eval with great respect as a 
powerful (and therefore dangerous) tool, and avoid it whenever you don't 
*need* it, there is no reason to be irrational about it :-)



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


RE: Modules list-tool

2013-05-22 Thread Carlos Nepomuceno
Have you tried Inspect Shell[1]?

All you have to do to monitor your script is include import inspect_shell in 
the 1st line of you source code and then run:

python inspect_shell.py

When you get the prompt you can enter the following to show the list of modules:

localhost:1234 '\n'.join(['{}={}'.format(k,v) for k,v in sys.modules.items()])


[1] https://github.com/amoffat/Inspect-Shell



 Date: Wed, 22 May 2013 21:39:52 -0700 
 Subject: Re: Modules list-tool 
 From: drsali...@gmail.com 
 To: gva...@broadpark.no 
 CC: python-list@python.org 
  
 On Tue, May 21, 2013 at 12:35 PM, Gisle Vanem  
 gva...@broadpark.nomailto:gva...@broadpark.no wrote: 
 Are anyone aware of a tool that can show me at run-time 
 which modules (pyd/dll) are loaded into a Python program at a specific  
 time (or over time)? 
  
 To clarify, e.g. when running a sample from PyQt4 
 (examples\tutorials\addressbook\part1.pyw) and using Process Explorer [1], 
 I can launch WinDbg from it and get this list of modules: 
  
  
 ModLoad: 1d00 1d00a000   G:\ProgramFiler\Python27\python.EXE 
 ModLoad: 7c90 7c9b1000   F:\WINDOWS\system32\ntdll.dll 
 ModLoad: 7c80 7c8f7000   F:\WINDOWS\system32\kernel32.dll 
 ModLoad: 1e00 1e261000   f:\windows\system32\python27.dll 
 ModLoad: 7e41 7e4a1000   F:\WINDOWS\system32\USER32.dll 
 ModLoad: 77f1 77f59000   F:\WINDOWS\system32\GDI32.dll 
 ModLoad: 77dc 77e6a000   F:\WINDOWS\system32\ADVAPI32.dll 
 ModLoad: 77e7 77f03000   F:\WINDOWS\system32\RPCRT4.dll 
 ModLoad: 77fe 77ff1000   F:\WINDOWS\system32\Secur32.dll 
 ModLoad: 7c9c 7d1d8000   F:\WINDOWS\system32\SHELL32.dll 
 ModLoad: 77c0 77c58000   F:\WINDOWS\system32\msvcrt.dll 
 ModLoad: 77f6 77fd6000   F:\WINDOWS\system32\SHLWAPI.dll 
 ModLoad: 7852 785c3000
 f:\windows\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.6161_x-ww_31a54e43\MSVCR90.dll
  
 ModLoad: 7637 7638d000   f:\windows\system32\IMM32.DLL 
 ModLoad: 62f2 62f29000   f:\windows\system32\LPK.DLL 
 ModLoad: 7542 7548b000   f:\windows\system32\USP10.dll 
 ModLoad: 773c 774c3000  
 f:\windows\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202\comctl32.dll
  
 ModLoad: 5d5d 5d66a000   F:\WINDOWS\system32\comctl32.dll 
 ModLoad: 78aa 78b5f000   f:\windows\system32\MSVCR100.dll 
 ModLoad: 00d9 00f29000
 g:\ProgramFiler\Python27\lib\site-packages\PyQt4\QtCore.pyd 
 ModLoad: 6700 6726
 g:\ProgramFiler\Python27\lib\site-packages\PyQt4\QtCore4.dll 
 ModLoad: 774d 7760e000   F:\WINDOWS\system32\ole32.dll 
 ModLoad: 71aa 71ab7000   f:\windows\system32\WS2_32.dll 
 ModLoad: 71a9 71a98000   f:\windows\system32\WS2HELP.dll 
 ModLoad: 7848 7850e000
 f:\windows\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729.6161_x-ww_31a54e43\MSVCP90.dll
  
 ModLoad: 00a6 00a73000
 g:\ProgramFiler\Python27\lib\site-packages\sip.pyd 
 ModLoad: 011f 0177f000
 g:\ProgramFiler\Python27\lib\site-packages\PyQt4\QtGui.pyd 
 ModLoad: 6500 657c4000
 g:\ProgramFiler\Python27\lib\site-packages\PyQt4\QtGui4.dll 
 ... 
  
 - 
  
 My example may be mooth since part1.pyw above (when I enter 
 the debugger) is just waiting for events. The stack of pythonw.exe as  
 shown in Process Explorer: 
 ... 
 ntdll.dll!ZwWaitForMultipleObjects+0xc 
 kernel32.dll!WaitForMultipleObjectsEx+0x12c 
 USER32.dll!RealMsgWaitForMultipleObjectsEx+0x13e 
 QtCore4.dll!QEventDispatcherWin32::processEvents+0x3c3 
 ntdll.dll!RtlAcquirePebLock+0x28 
  
 Is there a tool that can do something similar? (written in Python  
 maybe?). But a bit simpler to use than my current method. Just launch  
 it from the command-line; something like pyXX part1.pyw more args 
  
 [1] http://technet.microsoft.com/en-gb/sysinternals/bb896653 
  
 --gv 
 --  
 http://mail.python.org/mailman/listinfo/python-list 
  
 Python -v reports on modules. 
  
 -- http://mail.python.org/mailman/listinfo/python-list
   
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue18007] CookieJar expects request objects with origin_req_host attribute instead of method

2013-05-22 Thread Senthil Kumaran

Senthil Kumaran added the comment:

Hello Simon,

Thanks for bringing this to attention. Since get_origin_req_host has been under 
deprecation was a release, I thought it was safe to remove that. Agree that 
documentation of cookiejar methods, which had a dependency on the change 
should have been fixed.

Here is patch attempting to do that. If this is okay, I shall go with 
committing this change in 3.3 and 3.4.

--
assignee: docs@python - orsenthil
keywords: +patch
stage:  - patch review
versions: +Python 3.4
Added file: http://bugs.python.org/file30336/18007.patch

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



[issue18031] The Python Tutorial says % string formatting will be removed

2013-05-22 Thread Ezio Melotti

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


--
nosy: +ezio.melotti
type:  - enhancement
versions: +Python 3.3, Python 3.4

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



[issue17839] base64 module should use memoryview

2013-05-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you Ezio and Nick for your comments.

 I suggest renaming _bytes_from_decode_data to _bytes_for_decoding and 
 adding _bytes_for_encoding.

I rather think a TypeError exception raised by `memoryview(s).tobytes()` is 
good enough and we don't need a special wrapper.

--
Added file: http://bugs.python.org/file30337/base64_buffer_input_2.patch

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



[issue18030] IDLE shell crashes when reporting errors in Windows 7

2013-05-22 Thread Serhiy Storchaka

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


--
components: +Windows
nosy: +brian.curtin, kbk, roger.serwy, terry.reedy, tim.golden

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



[issue18030] IDLE shell crashes when reporting errors in Windows 7

2013-05-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This is a duplicate of issue13582.

--
nosy: +serhiy.storchaka
resolution:  - duplicate
stage:  - committed/rejected
status: open - closed
superseder:  - IDLE and pythonw.exe stderr problem

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



[issue18031] The Python Tutorial says % string formatting will be removed

2013-05-22 Thread Martin v . Löwis

Martin v. Löwis added the comment:

Can you please provide some context for this report?

On the abstract, I agree that there is an error in the tutorial: it is not 
decided whether the % formatting will be eventually removed, and I would also 
personally disagree with the recommendation to prefer .format.

--
nosy: +loewis

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



[issue13612] xml.etree.ElementTree says unknown encoding of a regular encoding

2013-05-22 Thread Serhiy Storchaka

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


--
dependencies: +ElementTree incorrectly parses strings with declared encoding 
not UTF-8

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



[issue13612] xml.etree.ElementTree says unknown encoding of a regular encoding

2013-05-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

For unit tests we first should fix issue16986.

--

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



[issue17844] Add link to alternatives for bytes-to-bytes codecs

2013-05-22 Thread Nick Coghlan

Nick Coghlan added the comment:

Thanks Serhiy, that version looks great.

--

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



[issue17140] Provide a more obvious public ThreadPool API

2013-05-22 Thread Nick Coghlan

Nick Coghlan added the comment:

Actors are just as vulnerable to the new threads/processes are expensive 
issue as anything else, and by using a dynamic pool appropriately you can 
amortise those costs across multiple instances.

The point is to expose a less opinionated threading model in a more readily 
accessible way. Executors and futures are *very* opinionated about the 
communication channels you're expected to use (the ones the executor provides), 
while pools are just a resource management tool.

--

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



[issue17716] From ... import fails when parent package failed but child module succeeded, yet works in std import case

2013-05-22 Thread Nick Coghlan

Nick Coghlan added the comment:

import-sig is probably a better place to start

--

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



[issue17140] Provide a more obvious public ThreadPool API

2013-05-22 Thread Richard Oudkerk

Richard Oudkerk added the comment:

I understand that a thread pool (in the general sense) might be used to 
amortise the cost.  But I think you would probably have to write this from 
scratch rather than use the ThreadPool API.

The ThreadPool API does not really expose anything that the ThreadPoolExceutor 
API does not -- the differences are just a matter of taste.

--

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



[issue7727] xmlrpc library returns string which contain null ( \x00 )

2013-05-22 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I don't really understand the issue. If you want to pass binary data (rather 
than unicode text), you should use a Binary object as explained in the docs:
http://docs.python.org/2/library/xmlrpclib.html#binary-objects

--
nosy: +pitrou

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



[issue18031] The Python Tutorial says % string formatting will be removed

2013-05-22 Thread Carlos Nepomuceno

Carlos Nepomuceno added the comment:

According to what I have been told at python-l...@python.org str.__mod__() is 
not going to be deprecated and that seems to be a myth created by Python's own 
documentation.

I do remember to have read previously in another page that it would be 
deprecated but that seems to be already corrected. Today I just found it in the 
tutorial.

--

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



[issue18031] The Python Tutorial says % string formatting will be removed

2013-05-22 Thread Ned Batchelder

Changes by Ned Batchelder n...@nedbatchelder.com:


--
nosy: +nedbat

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



[issue7727] xmlrpc library returns string which contain null ( \x00 )

2013-05-22 Thread Martin v . Löwis

Martin v. Löwis added the comment:

The original report really includes two parts:
a) when a string containing \0 is marshalled, ill-formed XML is produced
b) the expected behavior is that base64 is used

IMO: While a) is correct, b) is not. Antoine is correct that xmlrpclib.Binary 
should be used if you want to transmit binary data. Consequently, an Error 
should be reported if an attempt is made to produce ill-formed XML.

OTOH, ill-formed XML can also be produced when sending a byte string that does 
not match the encoding declaration. Because of that, I propose to close this by 
documentating the limitations, rather than changing the code.

--

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



[issue18015] python 2.7.5 fails to unpickle namedtuple pickled by 2.7.3 or 2.7.4

2013-05-22 Thread Anselm Kruis

Anselm Kruis added the comment:

I created a small *.pth to monkey patch collections.py until 2.7.6 gets 
released. Maybe this is useful for someone else. Therefore I attach it here.

The pth file runs the following code during Python startup:

import collections
def _fix_issue_18015(collections):
try:
template = collections._class_template
except AttributeError:
# prior to 2.7.4 _class_template didn't exists
return
if not isinstance(template, basestring):
return  # strange
if __dict__ in template or __getstate__ in template:
return  # already patched
lines = template.splitlines()
indent = -1
for i,l in enumerate(lines):
if indent  0:
indent = l.find('def _asdict')
continue
if l.startswith(' '*indent + 'def '):
lines.insert(i, ' '*indent + 'def __getstate__(self): pass')
lines.insert(i, ' '*indent + '__dict__ = _property(_asdict)')
break
collections._class_template = '''\n'''.join(lines)
_fix_issue_18015(collections)

--
Added file: http://bugs.python.org/file30338/fix_python_275_issue18015.pth

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



[issue12641] Remove -mno-cygwin from distutils

2013-05-22 Thread Martin v . Löwis

Martin v. Löwis added the comment:

Am 21.05.13 23:14, schrieb Oscar Benjamin:
 More generally I think that compiling non-cygwin extensions with
 cygwin gcc should be altogether deprecated (for Python 3.4 at least).
 It should be discouraged in the docs and unsupported in the future. 

I agree with that, although I find it sad that the Cygwin project
apparently abandoned support for building Mingw binaries.

 It can only work with -mno-cygwin 

This is factually incorrect. It also works with the i686-pc-mingw32-gcc
executable, which (IIUC) is still available for Cygwin.

--

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



[issue18032] set methods should specify whether they consume iterators lazily

2013-05-22 Thread Abafei

New submission from Abafei:

It says here 
(http://docs.python.org/2/library/stdtypes.html#set-types-set-frozenset) that 
some of the set methods take iterables as a parameter.

Usually, the expected behavior is for a iterator consumer to consume only as 
much data as it needs. For example, for the code `any(itertools.repeat(True))`, 
the code will complete speedily, in contrast to when all() is used instead of 
any(), in which case the code will go forever.

A least some of the set methods have semantics such that they can consume only 
some of the input; for example, issubset only needs to make sure that all of 
the items in the set are in the iterable, and once this is the case, it can 
return True.

However in such a case, the methods will *still* go forever.

The docs should specify that this is the case, to disambiguate the semantics.

(Tested on Python 3.2.3 and 2.7.3).

--
assignee: docs@python
components: Documentation
messages: 189806
nosy: Abafei, docs@python
priority: normal
severity: normal
status: open
title: set methods should specify whether they consume iterators lazily
type: behavior
versions: Python 2.7, Python 3.2

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



[issue7760] use_errno=True does not work

2013-05-22 Thread Matt Jones

Matt Jones added the comment:

Is this really a documentation issue?  Is it not generally understood that 
using absolute paths to libraries is a bad idea due to the amount of 
PATH/symlink spaghetti that the average file system contains?

--
nosy: +Matt.Jones

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



[issue7727] xmlrpc library returns string which contain null ( \x00 )

2013-05-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The limitations is already documented:

However, it’s the caller’s responsibility to ensure that the string is free 
of characters that aren’t allowed in XML, such as the control characters with 
ASCII values between 0 and 31 (except, of course, tab, newline and carriage 
return); failing to do this will result in an XML-RPC request that isn’t 
well-formed XML. If you have to pass arbitrary bytes via XML-RPC, use the bytes 
class or the class:Binary wrapper class described below.

Here is a patch which forbids creating ill-formed XML.

--
nosy: +serhiy.storchaka
stage: test needed - patch review
versions: +Python 2.7, Python 3.3, Python 3.4 -Python 2.6
Added file: http://bugs.python.org/file30339/xmlrpc_dump_invalid_string.patch

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



[issue13612] xml.etree.ElementTree says unknown encoding of a regular encoding

2013-05-22 Thread Eli Bendersky

Eli Bendersky added the comment:

 For unit tests we first should fix issue16986.

I did another round of code review on issue 16986 now.

--

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



[issue13612] xml.etree.ElementTree says unknown encoding of a regular encoding

2013-05-22 Thread Eli Bendersky

Eli Bendersky added the comment:

Looked at Serhiy's patch here too: LGTM with a unit test :)

--

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



[issue17844] Add link to alternatives for bytes-to-bytes codecs

2013-05-22 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 85c04fdaa404 by Serhiy Storchaka in branch '2.7':
Issue #17844: Refactor a documentation of Python specific encodings.
http://hg.python.org/cpython/rev/85c04fdaa404

New changeset 039dc6dd2bc0 by Serhiy Storchaka in branch '3.3':
Issue #17844: Add links to encoders and decoders for bytes-to-bytes codecs.
http://hg.python.org/cpython/rev/039dc6dd2bc0

New changeset 9afdd88fe33a by Serhiy Storchaka in branch 'default':
Issue #17844: Add links to encoders and decoders for bytes-to-bytes codecs.
http://hg.python.org/cpython/rev/9afdd88fe33a

--
nosy: +python-dev

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



[issue17844] Add link to alternatives for bytes-to-bytes codecs

2013-05-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you Nick. It's mainly your patch.

Do you want to foreport your changes (a Python Specific Encodings subheading 
and followed paragraph) to 3.x?

--

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



[issue12641] Remove -mno-cygwin from distutils

2013-05-22 Thread Oscar Benjamin

Oscar Benjamin added the comment:

On 22 May 2013 12:43, Martin v. Löwis rep...@bugs.python.org wrote:
 Am 21.05.13 23:14, schrieb Oscar Benjamin:
 More generally I think that compiling non-cygwin extensions with
 cygwin gcc should be altogether deprecated (for Python 3.4 at least).
 It should be discouraged in the docs and unsupported in the future.

 I agree with that,

Excellent.

 although I find it sad that the Cygwin project
 apparently abandoned support for building Mingw binaries.

I don't understand their reasoning but given the scorn poured on to
-mno-cygwin from at least some people I trust that they had some good
reason :)

Also they have replaced it with something that they consider more
appropriate (the cross-compilers).

 It can only work with -mno-cygwin

 This is factually incorrect. It also works with the i686-pc-mingw32-gcc
 executable, which (IIUC) is still available for Cygwin.

I should have been slightly clearer. It can only currently work in
distutils with -mno-cygwin. The executable you refer to is part of
cygwin gcc's cross-compiler toolchain. This is their recommended
replacement for -mno-cygwin (if not mingw) but is AFAICT unsupported
by distutils.

I think there's a case for saying that distutils should support these
but it should only be done with a new UnixCCompiler subclass and a new
--compiler entry point. It should also perhaps provide a way to
specify the --host since I think that facility is part of the purpose
of the new toolchain.

In any case cygwin cross-compiler support should not be conflated in
the codebase with distutils' mingw support and if it is to be added
that should be discussed in a separate issue. I personally don't think
I would use it and would not push for the support to be added.

Going back to the group C users: I think that it should be possible to
create an is_cygwingcc() function that would parse the output of 'gcc
--version'. Then Mingw32CCompiler.__init__ could do:

if is_cygwingcc() and self.gcc_version = '4':
raise RuntimeError('No cygwin mode only works with gcc-3. Use
gcc-3 or mingw')

The is_cygwingcc() function can be conservative since false positives
or more of a problem than false negatives. I think this should address
your concern.

However on further reflection I'm a little reluctant to force an error
if I can't *prove* that the setup is broken. I'm no stranger to
monkey-patching distutils and it's possible that someone has already
monkey-patched it to make some bizarre setup just about work. I would
be a little peeved if my setup broke in a bugfix release simply
because someone else who didn't understand it decided that it wasn't
viable. (The same monkey-patching concerns apply to the other changes
but I think that fixing the non-monkey-patched setup for mingw trumps
in that case.) So perhaps the best place to deal with the
gcc-4/no-cygwin issue is in the distutils docs.

My updated proposal is (I'll write patches if this is acceptable):

Python 3.4:
Remove '-mno-cygwin'. This breaks the no-cygwin mode and fixes the
mingw mode. The distutils docs are updated with something like:
'''
Note: Previous Python versions supported another 'no-cygwin' mode that
could use cygwin gcc to build extensions without a dependency on
cygwin.dll. This is no longer supported.

New in Python 3.4: No-cygwin mode is no longer supported.
'''

Python 2.7, 3.2 and 3.3:
Only use '-mno-cygwin' if self.gcc_version  '4'. This should not
break any currently functioning setups (barring serious
monkey-patching). The distutils docs are updated with something like:
'''
Note: The no-cygwin mode only works with cygwin's gcc-3. For gcc-4 it
may produce .pyd files with dependencies on cygwin.dll that are not
fully redistributable. The use of no-cygwin mode is deprecated by
cygwin and support for it is removed in Python 3.4.
'''

If you would rather have the is_cygwingcc() check I'm happy to put
that in also if it gets this issue moving but I'm personally cautious
about it.

Thanks,
Oscar

--

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



[issue12641] Remove -mno-cygwin from distutils

2013-05-22 Thread Oscar Benjamin

Oscar Benjamin added the comment:

On 22 May 2013 13:40, Oscar Benjamin rep...@bugs.python.org wrote:

 However on further reflection I'm a little reluctant to force an error
 if I can't *prove* that the setup is broken.

After a little more reflection I realise that we could just do:

if self.gcc_version  '4' or is_cygwingcc():
# use -mno-cygwin

This way the cygwin/gcc-4 error is still emitted only if gcc emits it.
If the is_cygwingcc() function is conservative then there could be
cases where it mistakenly does not use -mno-cygwin but that would have
to be a broken cygwin/gcc-4 setup anyway.

--

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



[issue17272] request.full_url: unexpected results on assignment

2013-05-22 Thread Senthil Kumaran

Senthil Kumaran added the comment:

Here is patch with tests and docs. I see no changes to opener is required and 
the selector which is sent to HTTP request is the correct one. I have added 
tests for redirect url with #fragment too (For testing scenario reported in 
Issue 8280).

I shall close this issue once I commit this patch. In a separate report/ 
commit, get_full_url should be deprecated. Also, I like to see splittag being 
replaced with urlparse itself, so that our test and expectation with fragment 
will be consistent.

--
Added file: http://bugs.python.org/file30340/17272-3.patch

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



[issue16986] ElementTree incorrectly parses strings with declared encoding not UTF-8

2013-05-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is an updated patch.

--
Added file: http://bugs.python.org/file30341/etree_parse_str_2.patch

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



[issue16986] ElementTree incorrectly parses strings with declared encoding not UTF-8

2013-05-22 Thread Eli Bendersky

Eli Bendersky added the comment:

LGTM

--

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



[issue13612] xml.etree.ElementTree says unknown encoding of a regular encoding

2013-05-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is an updated patch. PyUnknownEncodingHandler() and 
expat_unknown_encoding_handler() are synchronized. Added tests.

--
Added file: 
http://bugs.python.org/file30342/expat_unknown_encoding_handler_2.patch

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



[issue13612] xml.etree.ElementTree says unknown encoding of a regular encoding

2013-05-22 Thread Serhiy Storchaka

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


--
dependencies:  -ElementTree incorrectly parses strings with declared encoding 
not UTF-8

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



[issue16986] ElementTree incorrectly parses strings with declared encoding not UTF-8

2013-05-22 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 7781ccae7b9a by Serhiy Storchaka in branch '3.3':
Issue #16986: ElementTree now correctly parses a string input not only when
http://hg.python.org/cpython/rev/7781ccae7b9a

New changeset 659c1ce8ed2f by Serhiy Storchaka in branch 'default':
Issue #16986: ElementTree now correctly parses a string input not only when
http://hg.python.org/cpython/rev/659c1ce8ed2f

--
nosy: +python-dev

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



[issue16986] ElementTree incorrectly parses strings with declared encoding not UTF-8

2013-05-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Oh, 2.7 still uses old doctests. It's a challenge to backport tests for this 
issue.

--
versions:  -Python 3.2

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



[issue17844] Add link to alternatives for bytes-to-bytes codecs

2013-05-22 Thread Nick Coghlan

Nick Coghlan added the comment:

That sounds like a good idea. Yay for not needing those arcane footnotes, 
though :)

--

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



  1   2   >