Re: Python usage numbers

2012-02-14 Thread jmfauth
On 13 fév, 04:09, Terry Reedy tjre...@udel.edu wrote:


 * The new internal unicode scheme for 3.3 is pretty much a mixture of
 the 3 storage formats (I am of course, skipping some details) by using
 the widest one needed for each string. The advantage is avoiding
 problems with each of the three. The disadvantage is greater internal
 complexity, but that should be hidden from users. They will not need to
 care about the internals. They will be able to forget about 'narrow'
 versus 'wide' builds and the possible requirement to code differently
 for each. There will only be one scheme that works the same on all
 platforms. Most apps should require less space and about the same time.

 --


Python 2 was built for ascii users. Now, Python 3(.3) is
*optimized* for the ascii users.

And the rest of the crowd? Not so sure, French users
(among others) who can not write their texts will
iso-8859-1/latin1 will be very happy.

No doubts, it will work. Is this however the correct
approach?

jmf

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


Override the interpreter used by multiprocessing subprocesses?

2012-02-14 Thread Logan Pugh
Hello,

I am using a product that has a built-in Python interpreter (ESRI ArcGIS
Desktop 10.0 SP3) and have implemented multiprocessing in script that can
be run by a tool within the application using the built-in interpreter.

The way the built-in interpreter works is incompatible with multiprocessing
as it appears to want to start multiple instances of the host application
when the subprocesses are created.

I am using multiprocessing.Pool with the apply_async function. It works
great in a standalone script and I'd rather not rewrite what I've done so
far if I can help it, but if there is a way to simply force the standard
interpreter to be used for the subprocesses that would be ideal.

Thinking about it I realize that this might not be possible due to whatever
messaging, pickling, and queueing that the main processes has to handle for
the subprocesses, but thought I would ask anyways if only for my own
enlightenment.

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


Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-14 Thread John O'Hagan
On Mon, 13 Feb 2012 13:01:05 -0800 (PST)
Rick Johnson rantingrickjohn...@gmail.com wrote:

 On Feb 13, 12:38 pm, Ian Kelly ian.g.ke...@gmail.com wrote:
  I hate being suckered in by trolls, but this paragraph demands a response.

Ditto...

  On Mon, Feb 13, 2012 at 9:01 AM, Rick Johnson
 
  rantingrickjohn...@gmail.com wrote:
   You are born with rights. Life, Liberty, and the pursuit of happiness.
   Healthcare care is NOT a right, healthcare is a privileged.
[...]
 HOWEVER, healthcare is not a concern of the greater society, but only
 the individual -- with the exception of contagious disease of course,

[...snip half-baked, social-Darwinist, there-is-no-such-thing-as-society, 
naive U.S.-capitalist-libertarian drivel...]

   Procreation should be a
   privilege, however sadly for our collective evolution, it's seems to
   be a right :(
 
  There is a word for the philosophy that procreation should be a
  privilege reserved for those with good genes: eugenics.
 
 No, the word is evolution; which means: survival of the fittest.


Don't try to hijack real science to bolster a repugnant ideology.
Neither Herbert Spencer nor Darwin meant that phrase the way you do.
 
[...snip egregious, self-serving display of ignorance on the subjects of
evolution and genetics...] 

 
  Welcome to fascism, Rick.
 
 Don't try to append me onto a specific ideology structure just because
 that group happens to support ONE of my beliefs. I carry no political
[...blah blah...]

It's called duck-typing.

I somewhat optimistically implore you, Rick, to do some basic research on your
chosen subjects. Failing that (almost certainly), here are three simple points
which debunk your agenda (and that of the U.S. Republican Right):

1. Publicly-funded healthcare is both cheaper and more effective than
privatised systems. It's also the right thing to do (i.e. you don't have
to stand by while someone dies because their illness is their fault).
Which makes it a win-win-win.

2. The recent economic problems were not triggered by degenerates (are you
actually talking about homosexuals here, or just in the more general,
McCathyist sense?), but in fact by the operations of the same unregulated
markets you are advocating.

3. The central fallacy of social Darwinism is the misapprehension that because
natural selection occurs in nature, human society _should_ also work this
way. This is a failure to acknowledge the is/ought problem, and is usually
compounded (Rick is no exception) by the equally mistaken view that there exist
superior individuals whose possession of a quality gene-pool entitles them
to survival - an entitlement that is encroached upon by inferior sorts who take
up space by insisting on not dying. Can you guess in which group those who hold
this view place themselves?

In fact, a gene pool is held by a species, not an individual, and the
maintenance of its diversity is essential for long term-survival. And to the
great disappointment of those looking for a justification of dog-eat-dog, one
of the main drivers of evolution is not competition, but adapting to new
environments to _avoid_ competition. I'm told the Spanish have a saying
which translates as dogs don't eat dogs.

Genetics is complicated. Switching one gene on switches others off in
unpredictable ways, people choose mates by unfathomable processes, good-looking
geniuses have dumb, ugly children and vice-versa. This is why eugenics projects
are doomed to failure. They are also morally wrong, which is another win-win.

If some featureless fungus, toxic to all other living things, engulfed the
globe, would that make it superior? Of course, not, it merely survived.

Considerations of what _should_ happen, of superiority and quality, are human,
social concerns. We are humans, so they are important to us. But they have
nothing to do with genetics or evolution. 

Social Darwinism is merely a psuedo-scientific attempt to justify inequity and
class divides. Furthermore, it is completely dead outside the U.S. - ironically
the only developed nation where real Darwinism is still seriously questioned.

[...]

 Go on believing that humans will be inhabiting this rock in
 the next 1000 years, or this universe in the next 10,000 -- because
 the enlightened few will have transcended into the mind hive and your @
 $$ will be glued to Terra firma forever!


Now that is some crazy shit! Maybe L. Ron _is_ still alive...


Regards,

John

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


Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-14 Thread Tim Wintle
(Sorry for top-posting this bit, but I think it's required before the
rest of my response)

At the risk of wading into this from a UK citizen's perspective:

You're imagining a public healthcare system as if it were private.

Imagine you go to a doctor and say I've got the flu, can you give me
antibiotics.

In a Private healthcare system:

 * The doctor gets paid for retaining a client.
 * He is incentivised to do what you request.
... so he gives you the antibiotics.

In a Public healthcare system:
 * The doctor is paid no matter what.
 * His job is to stop the population becoming ill.
 * By reducing illnesses he reduces his workload, without reducing his
wage

... so he'll only give you antibiotics if he feels you are at serious
risk, and giving you antibiotics carries less risk for the population
than the risk of the population getting immunities.

Same goes for surgery etc.

On Mon, 2012-02-13 at 08:01 -0800, Rick Johnson wrote:
 And just how much healthcare dollars are you entitled to exactly? Can
 you put your entitlement into some form of monetary value?
 
 And how can we ever make a system like this fair? If someone works for
 30 years and pays a 30% tax rate and another works for 2 years and
 pays 15%, then how do we delegate the fair share?

If your children are educated privately then should you still be paying
taxes for education?

If you work for/bank with a company that doesn't need to be bailed out,
then should you still pay tax for that?

If you never need benefits (welfare) then should your taxes be paying
for that?

you can use that same argument for everything that taxes pay for - the
only logical conclusion of that argument is anarchy (i.e. no taxes, and
no government).

If you are an anarchist then that's a different argument all together
(not saying it doesn't have intellectual validity).

snip

 Healthcare is expensive. Do you want a minimum wage doctor curing your
 ills? And the frivolous lawsuits are not bringing the costs down
 either.

It's so expensive because of the marketing, and because of all the
middle-men.

A public health system doesn't need to do that marketing.

They also don't need to put up with people who aren't seriously ill - I
don't know how long your private appointments are, but here in the UK a
standard doctor's appointment is 5-10 minutes. If they decide you're
actually ill they may extend that.

  - bosses win, because they have reduced absenteeism, lower training costs
  to replace workers who die, and fewer epidemics that threaten their own
  families
 
 BS! With free healthcare, those who would have allowed their immune
 system fight off the flu, now take off from work, visit a local
 clinic, and get pumped full of antibiotics so they can create a new
 strain of antibiotic resistant flu virus! Thanks free healthcare!

See my comments at the top.


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


Re: how to tell a method is classmethod or static method or instance method

2012-02-14 Thread Cameron Simpson
On 14Feb2012 13:13, Zheng Li dllizh...@gmail.com wrote:
|  On 13Feb2012 15:59, Zheng Li dllizh...@gmail.com wrote:
|  | how to tell a method is class method or static method or instance method?
|  
|  Maybe a better question is:
|   under what circumstances do you need to figure this out? 
|
| I can get method1 of class Test by
| a = getattr(Test, method1)
| 
| and I also want know how to invoke it
| a()   or  a(Test())

Normally:

  a(T)

where T is an object of type/class Test. So your second approach is
notionally correct (aside from making a throwaway object that is then
discarded).

| BTW:
| I don't see what the problem is if I ask a question just because I am curious 
about it.

There's nothing wrong with it at all.

But often, questions arise from some other circumstances and this one is
of such a flavour that if you wanted this code in a real application it
would _often_ be the wrong solution to seek, because normally you know
how to call something - it is not normally useful to introspect it to
decide what to do.

So I was wondering what the outer context might be, because there may
well have been a better solution to the situation that brought up the
specific question.

Simple curiosity is sufficient reason, of course.
-- 
Cameron Simpson c...@zip.com.au DoD#743
http://www.cskk.ezoshosting.com/cs/

Too young to rest on the weekend, too old to rest during the week.
- Mark Randol ryv...@email.sps.mot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-14 Thread Duncan Booth
Rick Johnson rantingrickjohn...@gmail.com wrote:

 BS! With free healthcare, those who would have allowed their immune
 system fight off the flu, now take off from work, visit a local
 clinic, and get pumped full of antibiotics so they can create a new
 strain of antibiotic resistant flu virus! Thanks free healthcare!

Anyone who can write 'antibiotic resistant flu virus' as though they 
believe it really needs to read some elementary books about disease.

Here's a clue: No flu viruses are treatable with antibiotics. In some cases 
antibiotics may be useful for flu patients to treat secondary bacterial 
infections, but they are not effective against viruses.

-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-14 Thread Devin Jeanpierre
On Tue, Feb 14, 2012 at 6:31 AM, Duncan Booth
duncan.booth@invalid.invalid wrote:
 Here's a clue: No flu viruses are treatable with antibiotics.

Oh my god we're too late! Now they're ALL resistant!

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


Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-14 Thread rusi
On Feb 13, 9:01 pm, Rick Johnson rantingrickjohn...@gmail.com wrote:

 And just how much healthcare dollars are you entitled to exactly? Can
 you put your entitlement into some form of monetary value?

Rick hats off to you man -- you are damn good! Did you study at a top-
troll-school?
eg. http://www.youtube.com/watch?v=FMEe7JqBgvg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ?

2012-02-14 Thread Vinay Sajip
On Feb 14, 4:38 am, Devin Jeanpierre jeanpierr...@gmail.com wrote:
 Hey Pythonistas,

 Consider the regular expression $*. Compilation fails with the
 exception, sre_constants.error: nothing to repeat.

 Consider the regular expression (?=$)*. As far as I know it is
 equivalent. It does not fail to compile.

 Why the inconsistency? What's going on here?

 -- Devin

$ is a meta character for regular expressions. Use '\$*', which does
compile.

Regards,

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


Re: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ?

2012-02-14 Thread Devin Jeanpierre
On Tue, Feb 14, 2012 at 8:20 AM, Vinay Sajip vinay_sa...@yahoo.co.uk wrote:
 $ is a meta character for regular expressions. Use '\$*', which does
 compile.

I mean for it to be a meta-character.

I'm wondering why it's OK for to repeat a zero-width match if it is a
zero-width assertion.

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


name of a sorting algorithm

2012-02-14 Thread Jabba Laci
Hi,

Could someone please tell me what the following sorting algorithm is called?

Let an array contain the elements a_1, a_2, ..., a_N. Then:

for i = 1 to N-1:
for j = i+1 to N:
if a_j  a_i then swap(a_j, a_i)

It's so simple that it's not mentioned anywhere. I guess it's called
selection sort but I'm not sure. The minimum selection sort is an
improvement of this one.

Thanks,

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


Re: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ?

2012-02-14 Thread Vlastimil Brom
2012/2/14 Devin Jeanpierre jeanpierr...@gmail.com:
 Hey Pythonistas,

 Consider the regular expression $*. Compilation fails with the
 exception, sre_constants.error: nothing to repeat.

 Consider the regular expression (?=$)*. As far as I know it is
 equivalent. It does not fail to compile.

 Why the inconsistency? What's going on here?

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

Hi,
I don't know the reason for the  observed differences either (I can
think of some optimisation issues etc.), but just wanted to mention
some other  similar patterns to your lookahaed:
It seems, that groups (capturing or not capturing) also work ok:

 re.findall(($)*, abc)
['', '', '', '']
 re.findall((?:$)*, abc)
['', '', '', '']

However, is there any realistic usecase for repeated zero-width anchors?

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


Re: Automatic Type Conversion to String

2012-02-14 Thread Ulrich Eckhardt

Am 14.02.2012 00:18, schrieb Bruce Eckel:

I'm willing to subclass str, but when I tried it before it became a
little confusing -- I think mostly because anytime I assigned to self
it seemed like it converted the whole object to a str rather than a
Path. I suspect I don't know the proper idiom for doing this -- any
hints? Thanks ...


Could it be that you missed the fact that strings are immutable? That 
means that you can't change the content of the object once it is 
initialized. In particular, it means that you e.g. have to override 
__new__ instead of __init__, because the content is already fixed when 
the latter is called.


Python strings rather behave like Java strings than C++ strings.

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


Re: name of a sorting algorithm

2012-02-14 Thread Mel Wilson
Jabba Laci wrote:
 Could someone please tell me what the following sorting algorithm is
 called?
 
 Let an array contain the elements a_1, a_2, ..., a_N. Then:
 
for i in xrange (N-1):
for j in xrange (i, N):
if a[j]  a[i]:
a[i], a[j] = a[j], a[i]
 
 It's so simple that it's not mentioned anywhere. I guess it's called
 selection sort but I'm not sure. The minimum selection sort is an
 improvement of this one.

It's what Wikipedia says a selection sort is: put the least element in [0], 
the least of the remaining elements in [1], etc.

Mel.

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


Re: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ?

2012-02-14 Thread Devin Jeanpierre
On Tue, Feb 14, 2012 at 10:05 AM, Vlastimil Brom
vlastimil.b...@gmail.com wrote:
 However, is there any realistic usecase for repeated zero-width anchors?

Maybe. There is a repeated zero-width anchor is used in the Python re
test suite, which is what made me notice this. I assume that came from
some actual use-case. (see:
http://hg.python.org/cpython/file/096e856a01aa/Lib/test/test_re.py#l599
)

And yeah, even something as crazy as ()* works, but as soon as it
becomes (a*)* it doesn't work. Weird.

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


RE: name of a sorting algorithm

2012-02-14 Thread Prasad, Ramit
 
for i in xrange (N-1):
for j in xrange (i, N):
if a[j]  a[i]:
a[i], a[j] = a[j], a[i]
 It's what Wikipedia says a selection sort is: put the least element in [0], 
 the least of the remaining elements in [1], etc.

If your only requirement to match to selection sort is the end result, then 
every sort would be selection sort. If you meant put the least element in [0] 
in the first pass then that would indeed be selection sort, but that is not 
what the above code does. The above code is bubble sort.

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: name of a sorting algorithm

2012-02-14 Thread Ulrich Eckhardt

Am 14.02.2012 16:01, schrieb Jabba Laci:

Could someone please tell me what the following sorting algorithm is called?

Let an array contain the elements a_1, a_2, ..., a_N. Then:

for i = 1 to N-1:
 for j = i+1 to N:
 if a_j  a_i then swap(a_j, a_i)

It's so simple that it's not mentioned anywhere.


Please do your own homework. This code isn't even Python!



I guess it's called selection sort but I'm not sure.


You guessed right.


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


Re: name of a sorting algorithm

2012-02-14 Thread Arnaud Delobelle
On 14 February 2012 15:31, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:
 On Tue, 14 Feb 2012 16:01:05 +0100, Jabba Laci jabba.l...@gmail.com
 wrote:

Could someone please tell me what the following sorting algorithm is called?

Let an array contain the elements a_1, a_2, ..., a_N. Then:

for i = 1 to N-1:
    for j = i+1 to N:
        if a_j  a_i then swap(a_j, a_i)

        Off hand... The ancient Bubble-Sort...

 http://en.wikipedia.org/wiki/Bubble_sort

Ahem...

No, it's not Bubble Sort.  Bubble sort only swaps adjacent terms.

I don't know what this sort is called, if it even has a name.  It's a
kind of Selection Sort, as each pass it looks for the minimum of the
remaining unsorted items.  But it ruffles the unsorted list each pass,
seemingly to save using an extra register to store the current minumum
(there was a time when registers were at a premium).

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


RE: name of a sorting algorithm

2012-02-14 Thread Mel Wilson
Prasad, Ramit wrote:

 
 for i in xrange (N-1):
 for j in xrange (i, N):
 if a[j]  a[i]:
 a[i], a[j] = a[j], a[i]
 It's what Wikipedia says a selection sort is: put the least element in
 [0], the least of the remaining elements in [1], etc.
 
 If your only requirement to match to selection sort is the end result,
 then every sort would be selection sort. If you meant put the least
 element in [0] in the first pass then that would indeed be selection
 sort, but that is not what the above code does. The above code is bubble
 sort.

Well, the classic bubble sort swaps adjacent elements until the extreme one 
gets all the way to the end.  This sort continually swaps with the end 
element during one pass until the end element holds the extreme.  Then it 
shrinks the range and swaps then next less extreme into the new end element.  
It does extra swaps because it combines the swap operation with recording 
the temporary extreme while it searches the subrange.

Mel.

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


Re: name of a sorting algorithm

2012-02-14 Thread Den
On Feb 14, 8:22 am, Arnaud Delobelle arno...@gmail.com wrote:
 On 14 February 2012 15:31, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:

  On Tue, 14 Feb 2012 16:01:05 +0100, Jabba Laci jabba.l...@gmail.com
  wrote:

 Could someone please tell me what the following sorting algorithm is called?

 Let an array contain the elements a_1, a_2, ..., a_N. Then:

 for i = 1 to N-1:
     for j = i+1 to N:
         if a_j  a_i then swap(a_j, a_i)

         Off hand... The ancient Bubble-Sort...

 http://en.wikipedia.org/wiki/Bubble_sort

 Ahem...

 No, it's not Bubble Sort.  Bubble sort only swaps adjacent terms.

 I don't know what this sort is called, if it even has a name.  It's a
 kind of Selection Sort, as each pass it looks for the minimum of the
 remaining unsorted items.  But it ruffles the unsorted list each pass,
 seemingly to save using an extra register to store the current minumum
 (there was a time when registers were at a premium).

 --
 Arnaud

I disagree.  In a bubble sort, one pointer points to the top element,
while another descents through all the other elements, swapping the
elements at the pointers when necessary.  Then the one pointer moved
down to the next element and the process repeats.  This looks like the
bubble sort to me.  It was one of the first algorithms I had to
program in my first programming class in 1969.

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


Re: name of a sorting algorithm

2012-02-14 Thread Mel Wilson
Den wrote:

 I disagree.  In a bubble sort, one pointer points to the top element,
 while another descents through all the other elements, swapping the
 elements at the pointers when necessary.

'When I use a word,' Humpty Dumpty said, in rather a scornful tone, 'it 
means just what I choose it to mean — neither more nor less.' (_Through the 
Looking Glass, Lewis Caroll).  And you, too, have that ability.  
Contrariwise see Knuth, _The Art of Computer Programming_ Section 5.2.2, 
Algorithm B.

Mel.


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


Re: name of a sorting algorithm

2012-02-14 Thread Ian Kelly
On Tue, Feb 14, 2012 at 9:55 AM, Den patents...@gmail.com wrote:
 On Feb 14, 8:22 am, Arnaud Delobelle arno...@gmail.com wrote:
 On 14 February 2012 15:31, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:

  On Tue, 14 Feb 2012 16:01:05 +0100, Jabba Laci jabba.l...@gmail.com
  wrote:

 Could someone please tell me what the following sorting algorithm is 
 called?

 Let an array contain the elements a_1, a_2, ..., a_N. Then:

 for i = 1 to N-1:
     for j = i+1 to N:
         if a_j  a_i then swap(a_j, a_i)

         Off hand... The ancient Bubble-Sort...

 http://en.wikipedia.org/wiki/Bubble_sort

 Ahem...

 No, it's not Bubble Sort.  Bubble sort only swaps adjacent terms.

 I don't know what this sort is called, if it even has a name.  It's a
 kind of Selection Sort, as each pass it looks for the minimum of the
 remaining unsorted items.  But it ruffles the unsorted list each pass,
 seemingly to save using an extra register to store the current minumum
 (there was a time when registers were at a premium).

 --
 Arnaud

 I disagree.  In a bubble sort, one pointer points to the top element,
 while another descents through all the other elements, swapping the
 elements at the pointers when necessary.  Then the one pointer moved
 down to the next element and the process repeats.  This looks like the
 bubble sort to me.  It was one of the first algorithms I had to
 program in my first programming class in 1969.

Either you're misremembering, or the algorithm you programmed 43 years
ago was not actually bubble sort.  Quoting from Wikipedia:


Bubble sort, also known as sinking sort, is a simple sorting algorithm
that works by repeatedly stepping through the list to be sorted,
comparing each pair of adjacent items and swapping them if they are in
the wrong order. The pass through the list is repeated until no swaps
are needed, which indicates that the list is sorted. The algorithm
gets its name from the way smaller elements bubble to the top of the
list.


In the present algorithm, you'll note that elements in the unsorted
part of the list do not bubble up as they would in bubble sort.
Rather, they jump around somewhat randomly until they are finally
selected for the current sort index.  I agree with Arnaud -- this is a
selection sort variant that saves a local variable (the index of the
minimum element) by placing it at the current sort index instead -- at
the cost of doing additional swaps.  Probably not a good trade-off in
Python (but then again, no pure Python sort algorithm is likely to
perform better than the built-in).

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


Re: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ?

2012-02-14 Thread MRAB

On 14/02/2012 15:53, Devin Jeanpierre wrote:

On Tue, Feb 14, 2012 at 10:05 AM, Vlastimil Brom
vlastimil.b...@gmail.com  wrote:

 However, is there any realistic usecase for repeated zero-width anchors?


Maybe. There is a repeated zero-width anchor is used in the Python re
test suite, which is what made me notice this. I assume that came from
some actual use-case. (see:
http://hg.python.org/cpython/file/096e856a01aa/Lib/test/test_re.py#l599
)

And yeah, even something as crazy as ()* works, but as soon as it
becomes (a*)* it doesn't work. Weird.

I think it's a combination of warning the user about something that's 
pointless,
as in the case of $*, and producing a pattern which could cause the 
internal

regex engine to get stuck in an infinite loop.

It is inconsistent in that it warns about $* but not (?=$)* even
though they are basically equivalent.
--
http://mail.python.org/mailman/listinfo/python-list


Re: name of a sorting algorithm

2012-02-14 Thread Jabba Laci
Hi,

 Either you're misremembering, or the algorithm you programmed 43 years
 ago was not actually bubble sort.  Quoting from Wikipedia:

 
 Bubble sort, also known as sinking sort, is a simple sorting algorithm
 that works by repeatedly stepping through the list to be sorted,
 comparing each pair of adjacent items and swapping them if they are in
 the wrong order. The pass through the list is repeated until no swaps
 are needed, which indicates that the list is sorted. The algorithm
 gets its name from the way smaller elements bubble to the top of the
 list.
 

I don't agree with the last sentence. During bubble sort, in the 1st
pass the largest element is moved to the top (for me top means the
right side (end) of an array). Thus the end of the array is sorted. In
the 2nd pass, the largest element of the unsorted left part is moved
to the end, etc. That is, it's the _larger_ elements that bubble to
the top. At http://en.wikipedia.org/wiki/Bubble_sort you can find an
animated gif that shows how the algorithm works.

 In the present algorithm, you'll note that elements in the unsorted
 part of the list do not bubble up as they would in bubble sort.
 Rather, they jump around somewhat randomly until they are finally
 selected for the current sort index.  I agree with Arnaud -- this is a
 selection sort variant that saves a local variable (the index of the
 minimum element) by placing it at the current sort index instead -- at
 the cost of doing additional swaps.  Probably not a good trade-off in
 Python (but then again, no pure Python sort algorithm is likely to
 perform better than the built-in).

The minimum selection sort is an improvement of this noname
algorithm. I give it in pseudo-code. Let A be an array with N
elements. Indexing starts with 1.

for i := 1 to N-1:
minindex := i
for j := i+1 to N:
if A[j]  A[minindex] then minindex := j
end for
if i != minindex then swap(A[i], A[minindex])
end for

The two loops are the same as in the naive version. It will also sort
the array from the left side. It does much less swaps than the naive
version.

If the noname algorithm is called selection sort, then its name
can be misleading. One may ask OK, but which one? Minimum or maximum
selection sort?. Well, neither...

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


Re: Komodo 7 release (Python development tools)

2012-02-14 Thread Todd Whiteman

On 12-02-08 01:52 PM, Terry Reedy wrote:

On 2/8/2012 3:14 PM, Todd Whiteman wrote:


My name is Todd. I'm the lead developer for Komodo IDE (Interactive
Development Environment) and Komodo Edit (a free, open-source editor) at
ActiveState. I wanted to announce that the newest version, Komodo 7, has
been released:
http://www.activestate.com/komodo-ide/python-editor


It would seem that the Professional Python Editor is the same as Komodo
Edit, but it is unclear why only Python editing would be featured for
Komodo IDE.

http://www.activestate.com/komodo-edit

is the page with the link people need to download just the editor.


The above page covers features from both Edit and IDE - some will only 
apply to the IDE version. For a full comparison of features you can 
check out:

http://www.activestate.com/komodo-edit/compare-with-komodo-ide



Does K.Edit let me run a program with one key, like F5 in IDLE?
If so, does it leave me in interactive mode (python -i) as IDLE does?



Komodo Edit does not offer a quick run (F5) command by default, you 
could create your own Python command [1] in the Komodo toolbox and 
assign it the F5 key binding to serve such a purpose.


[1] The short command for running a Python script is: %(python) %F, 
which uses Komodo's interpolation shortcuts:

http://docs.activestate.com/komodo/7.0/shortcuts.html#shortcuts_top

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


RE: name of a sorting algorithm

2012-02-14 Thread Prasad, Ramit
Prasad, Ramit wrote:
 My apologies, you are correct. It is a selection sort, just an inefficient 
 one.
Hmm, I think I should say it is neither since it reminds me of a hybrid of 
both (bubble/selection).

The swapping seems very bubble sort, but the looking for the min / max 
case seems selection sort-ish. Whatever it is, it is certainly 
inefficient. :)

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: name of a sorting algorithm

2012-02-14 Thread Prasad, Ramit
Wilson, Mel wrote:
Well, the classic bubble sort swaps adjacent elements until the extreme one 
gets all the way to the end.  This sort continually swaps with the end 
element during one pass until the end element holds the extreme.  Then it 
shrinks the range and swaps then next less extreme into the new end element.  
It does extra swaps because it combines the swap operation with recording 
the temporary extreme while it searches the subrange.

My apologies, you are correct. It is a selection sort, just an 
inefficient one. 

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--
This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: name of a sorting algorithm

2012-02-14 Thread Ian Kelly
On Tue, Feb 14, 2012 at 11:10 AM, Jabba Laci jabba.l...@gmail.com wrote:
 Hi,

 Either you're misremembering, or the algorithm you programmed 43 years
 ago was not actually bubble sort.  Quoting from Wikipedia:

 
 Bubble sort, also known as sinking sort, is a simple sorting algorithm
 that works by repeatedly stepping through the list to be sorted,
 comparing each pair of adjacent items and swapping them if they are in
 the wrong order. The pass through the list is repeated until no swaps
 are needed, which indicates that the list is sorted. The algorithm
 gets its name from the way smaller elements bubble to the top of the
 list.
 

 I don't agree with the last sentence. During bubble sort, in the 1st
 pass the largest element is moved to the top (for me top means the
 right side (end) of an array). Thus the end of the array is sorted. In
 the 2nd pass, the largest element of the unsorted left part is moved
 to the end, etc. That is, it's the _larger_ elements that bubble to
 the top. At http://en.wikipedia.org/wiki/Bubble_sort you can find an
 animated gif that shows how the algorithm works.

I think that by top they mean front.  Each largest element in turn
gets moved to the end in a single pass.  It is the smaller elements
gradually moving toward the front over many passes that I believe is
described as bubbling, as can be seen in that gif.

 If the noname algorithm is called selection sort, then its name
 can be misleading. One may ask OK, but which one? Minimum or maximum
 selection sort?. Well, neither...

It is a minimum selection sort, because it selects the minimum element
on each pass.  It just stores the minimum element so far in-place in
the array, rather than in a separate variable.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-14 Thread Rick Johnson
On Feb 14, 2:41 am, John O'Hagan resea...@johnohagan.com wrote:

 1. Publicly-funded healthcare is both cheaper and more effective than
 privatised systems. It's also the right thing to do (i.e. you don't have
 to stand by while someone dies because their illness is their fault).

So you have no problem paying the medical bills of people who overeat
sugar, salt, and fat; refuse to put down the ho-ho's; and get a little
exercise? If so, then give to charity. Why do you need to FORCE me
(and others) to pay for your experiment of degenerate eugenics?

 2. The recent economic problems were not triggered by degenerates (are you
 actually talking about homosexuals here, or just in the more general,
 McCathyist sense?)

WTF does homosexuality have to do with this conversation? I am talking
about lazy/slothful, drug/alcohol abusing, junk food eating, self-
induced illiterates, techno-phobic Luddite loving lemmings. Look, i
don't care how you want to live YOUR life, just leave me and my money
the hell out of it!

, but in fact by the operations of the same unregulated
 markets you are advocating.

I am well aware of the sins of wall street and the ruling corporate
class (Greed.inc). That is half the problem, yes. However, you cannot
ignore the fact that we are spending trillions around the globe
supporting degenerates.

Look at Detroit MI. People like to blame GM for the state of the city
but GM is only a very small part of the problem. The REAL problem is
sleazy politicians and infections entitlements/welfare. When you crush
the tax payers with more and more tyrannical taxation to pay for your
entitlement programs, the taxpayers leave town; but the welfare
recipients stay! Why the heck would they quit a good thing? However,
now you find yourself in a major pickle. With the taxpayers gone,
who's going to fund the entitlement programs? NOBODY! The whole house
of cards comes crumbling down!

Of course i'm probably just wasting my time trying to educate you.
You'll just blab on and on about how evil i am for not paying other
people's bills so they can watch there hero degenerates on Jersey
Shore.

 3. The central fallacy of social Darwinism is the misapprehension that because
 natural selection occurs in nature, human society _should_ also work this
 way.

I NEVER said we should adopt such a society. That is anarchy. And
anarchy will NEVER move us forward as a species.

 This is a failure to acknowledge the is/ought problem, and is usually
 compounded (Rick is no exception) by the equally mistaken view that there 
 exist
 superior individuals whose possession of a quality gene-pool entitles them
 to survival - an entitlement that is encroached upon by inferior sorts who 
 take
 up space by insisting on not dying. Can you guess in which group those who 
 hold
 this view place themselves?

You'd be surprised which group i reside in. I know my place; but do
you know yours?

 Genetics is complicated. Switching one gene on switches others off in
 unpredictable ways, people choose mates by unfathomable processes, 
 good-looking
 geniuses have dumb, ugly children and vice-versa. This is why eugenics 
 projects
 are doomed to failure. They are also morally wrong, which is another win-win.

There is nothing wrong with denying degenerates the right to
reproduce. Would you allow a crack head to reproduce? How about
someone who carries a virus/illness/deadly defect for which there is
no cure and the virus/illness/deadly defect will be passed on to the
child? What if you knew without a doubt the baby would be born with
two heads, or mentally incapacitated, or brain dead, or etc...? Would
you allow the procreation anyway simply because people have a right to
be selfish?

What if the couple was healthy but had poor parenting skills, or
cannot feed the child, or cannot cloth the child, or etc...? Would you
allow the procreation anyway simply because people have a right to be
selfish?

What abut people who go around making babies but refuse to care for
them at all? I mean, birth control has been around for some time, but
we can't force degenerates to use it! Would you allow the procreation
anyway simply because people have a right to be selfish?

 If some featureless fungus, toxic to all other living things, engulfed the
 globe, would that make it superior? Of course, not, it merely survived.

I love when people contradict themselves in the same sentence -- makes
my job much easier!

 Considerations of what _should_ happen, of superiority and quality, are human,
 social concerns. We are humans, so they are important to us. But they have
 nothing to do with genetics or evolution.

Really??? I think you need to spend more time ruminating on the
subject. You can stick your head in the sand if you like, but
technology will advance with or without you. Humans will be cloned.
Humans will be genetically engineered. Humans will employ eugenics to
sculpt the gene pool. It is our destiny to use our intelligence to
drive our own evolution at an 

Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-14 Thread Chris Angelico
On Wed, Feb 15, 2012 at 11:21 AM, Rick Johnson
rantingrickjohn...@gmail.com wrote:
 On Feb 14, 2:41 am, John O'Hagan resea...@johnohagan.com wrote:
 This is a failure to acknowledge the is/ought problem, and is usually
 compounded (Rick is no exception) by the equally mistaken view that there 
 exist
 superior individuals whose possession of a quality gene-pool entitles 
 them
 to survival - an entitlement that is encroached upon by inferior sorts who 
 take
 up space by insisting on not dying. Can you guess in which group those who 
 hold
 this view place themselves?

 You'd be surprised which group i reside in. I know my place; but do
 you know yours?

If you truly believe that only the best should be allowed to survive
and that you are not of the best, then the logical thing to do is to
immediately destroy yourself. Oddly enough, though, I don't see many
eugenics proponents committing mass suicide for the benefit of the
gene pool.

 There is nothing wrong with denying degenerates the right to
 reproduce.

Actually there is; I'm fairly sure that I wouldn't have been born if
such policies had been in place, and I strongly suspect that you
wouldn't have either. There was a country in the 20th century that
adopted a lot of the sorts of policies you're talking about, and it's
such a sensitive topic with MANY people that I'm not going to touch
it. Suffice it to say that the world does not appreciate such things.

 If some featureless fungus, toxic to all other living things, engulfed the
 globe, would that make it superior? Of course, not, it merely survived.

 I love when people contradict themselves in the same sentence -- makes
 my job much easier!

No, he did not contradict himself - he drew a distinction between
superior and survived. You might argue that your definition of
superior *is* the ability to survive, but that's a matter for
logical argument, not for pointing and laughing.

 It is our destiny to use our intelligence to
 drive our own evolution at an ever accelerating rate. To NOT use that
 power would be to spit in the face of evolution itself!

Evolution is driven by the survival of the fittest, not by us using
our intelligence to influence it.

It's high time I stood up for who I am. I *do* spit in the face of
evolution. I do not believe that we came here because we evolved from
some lesser life-form, and I do not believe that the world is best
served by such philosophies.

God created us, roughly 6000-1 years ago, and since then, many
things have happened (both good and bad), but never has there been the
emergence of any form of next-species human. Look at history (just
recent history if you like - the last few hundred years) and find the
times when one group of people deemed themselves more evolved than
another group. Why were Negros treated as slaves in the US? Why were
Australian Aboriginals treated like animals? And the one I hinted at
above. If you truly believe that evolution is the way forward, then go
find some of the lobbyists for these groups, and say to their faces
that you believe that some humans are lesser than others.

If you come out of that alive, report back. Preferably with video. It
should be interesting.

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


Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-14 Thread Rick Johnson
On Feb 13, 10:41 am, Tim Wintle tim.win...@teamrubber.com wrote:

 Imagine you go to a doctor and say I've got the flu, can you give me
 antibiotics.

 In a Private healthcare system:

  * The doctor gets paid for retaining a client.
  * He is incentivised to do what you request.
 ... so he gives you the antibiotics.

 In a Public healthcare system:
  * The doctor is paid no matter what.
  * His job is to stop the population becoming ill.
  * By reducing illnesses he reduces his workload, without reducing his
 wage

 ... so he'll only give you antibiotics if he feels you are at serious
 risk, and giving you antibiotics carries less risk for the population
 than the risk of the population getting immunities.

Of all the great arguments i have presented you choose the minor
antibiotic comment and run with it? But you take NO position on
supporting the degenerates of society? Would you mind making your
position known?

You see, you can have all the healthcare and healthcare dollars in the
world. But if your patient keeps eating greasy hamburgers, salty/oily
french fries, and blood-sugar spiking soda-pops, he is going to die a
nasty death! Sadly however, he will live for many years in a state of
poor heath before finally kicking the bucket. All the while draining
the system of resources and money.

 [...]
 you can use that same argument for everything that taxes pay for - the
 only logical conclusion of that argument is anarchy (i.e. no taxes, and
 no government).

 If you are an anarchist then that's a different argument all together
 (not saying it doesn't have intellectual validity).

I am not an anarchist. Stop trying to label me.

  Healthcare is expensive. Do you want a minimum wage doctor curing your
  ills? And the frivolous lawsuits are not bringing the costs down
  either.

 It's so expensive because of the marketing, and because of all the
 middle-men.

You're thinking of pharmaceuticals NOT healthcare. And while marketing
is a large expense for pharmaceutical companies; RD, lawsuits, and
brown-nosing are the main cost of doing buisness.

 They also don't need to put up with people who aren't seriously ill - I
 don't know how long your private appointments are, but here in the UK a
 standard doctor's appointment is 5-10 minutes. If they decide you're
 actually ill they may extend that.

Five to ten minutes? Is the doctor an a-hole or a machine? Can a
doctor REALLY diagnose an illness in five to ten minutes? Are you
joking? And if not, do you ACTUALLY want the experience to be
synonymous with an assembly line? You don't fear misdiagnosis? I envy
your bravery!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-14 Thread Rick Johnson
On Feb 14, 5:31 am, Duncan Booth duncan.bo...@invalid.invalid wrote:
 Rick Johnson rantingrickjohn...@gmail.com wrote:
  BS! With free healthcare, those who would have allowed their immune
  system fight off the flu, now take off from work, visit a local
  clinic, and get pumped full of antibiotics so they can create a new
  strain of antibiotic resistant flu virus! Thanks free healthcare!

 Anyone who can write 'antibiotic resistant flu virus' as though they
 believe it really needs to read some elementary books about disease.

 Here's a clue: No flu viruses are treatable with antibiotics. In some cases
 antibiotics may be useful for flu patients to treat secondary bacterial
 infections, but they are not effective against viruses.

Duncan, your reading and comprehension skills are atrocious. Please re-
read the paragraph you quoted, then spend some time comprehending
it, then show me where i stated that antibiotics cure viral
infections. psst: i NEVER said any such thing!

My point is: these quacks are prescribing antibiotics when people
don't even need them! Such disregard for immunity is frightening.
Penicillin was a gift from the gods, and we have squandered it! Thanks
free healthcare!


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


Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-14 Thread Chris Angelico
On Wed, Feb 15, 2012 at 11:48 AM, Rick Johnson
rantingrickjohn...@gmail.com wrote:
 Duncan, your reading and comprehension skills are atrocious. Please re-
 read the paragraph you quoted, then spend some time comprehending
 it, then show me where i stated that antibiotics cure viral
 infections. psst: i NEVER said any such thing!

I'm not sure how you'd go about creating a new strain of a virus
that's resistant to antibiotics, unless the previous strain was NOT
resistant. Viruses are _immune_ to antibiotics, and as we know from
Angband, immunity equals resistance times ten.

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


Re: OT: Entitlements [was Re: Python usage numbers]

2012-02-14 Thread Rick Johnson
On Feb 14, 6:44 pm, Chris Angelico ros...@gmail.com wrote:

 If you truly believe that only the best should be allowed to survive
 and that you are not of the best, then the logical thing to do is to
 immediately destroy yourself. Oddly enough, though, I don't see many
 eugenics proponents committing mass suicide for the benefit of the
 gene pool.

I don't need to destroy myself Chris. Likewise i don't need to destroy
anyone else. You are trying to cast me as an evil blood thirsty
person, and i can assure you, i am not.

All i need to do is NOT reproduce and i've done my part. Likewise all
WE need to do is keep the rest of us from reproducing.

I am not a degenerate, but my genes are flawed. All i can hope to do
is make an intellectual contribution to our evolution as a species.
Just because you're flawed in one area, does not mean you cannot make
contributions in other areas. You can still be part of the whole -- AS
LONG AS YOU UNDERSTAND YOUR PLACE!

  There is nothing wrong with denying degenerates the right to
  reproduce.

 Actually there is; I'm fairly sure that I wouldn't have been born if
 such policies had been in place, and I strongly suspect that you
 wouldn't have either.

So what's the problem with that?

 There was a country in the 20th century that
 adopted a lot of the sorts of policies you're talking about, and it's
 such a sensitive topic with MANY people that I'm not going to touch
 it. Suffice it to say that the world does not appreciate such things.

Of course people don't want to admit that they don't belong, or that
they are flawed, or that they are inferior. We are wired with egos
so that we don't purposely destroy ourselves; which is vital to our
collective evolution, but NOT our individual evolution.

However, like all software, the definitions don't always cover the
corner cases. Only WE, as intelligent beings, can compensate for the
missing code in our own software. Evolution is just a system. A very
dumb system. We are the only hope for evolution beyond what this base
system can create. We must take the reigns and drive our own
evolution.

  If some featureless fungus, toxic to all other living things, engulfed the
  globe, would that make it superior? Of course, not, it merely survived.

  I love when people contradict themselves in the same sentence -- makes
  my job much easier!

 No, he did not contradict himself - he drew a distinction between
 superior and survived. You might argue that your definition of
 superior *is* the ability to survive, but that's a matter for
 logical argument, not for pointing and laughing.

If a fungus did in fact engulf the earth, THEN it MUST be
superior!

  It is our destiny to use our intelligence to
  drive our own evolution at an ever accelerating rate. To NOT use that
  power would be to spit in the face of evolution itself!

 Evolution is driven by the survival of the fittest, not by us using
 our intelligence to influence it.

But WE are the fittest! Because we are INTELLIGENT!

 God created us, roughly 6000-1 years ago, and since then, many
 things have happened (both good and bad), but never has there been the
 emergence of any form of next-species human. Look at history (just
 recent history if you like - the last few hundred years) and find the
 times when one group of people deemed themselves more evolved than
 another group. Why were Negros treated as slaves in the US?

Because they allowed themselves to be subjected. Sad, but true.

 Why were
 Australian Aboriginals treated like animals?

Because they allowed them selves to be subjected. Sad, but true.

 And the one I hinted at
 above.

Because the Jews allowed themselves to be subjected. Sad, but true.

Slaves only exist because they allow themselves to exist. When people
fight back against tyranny, tyranny fails. When people subject
themselves to tyranny, tyranny prospers. There have been many
instances in history where people did not allow themselves to be
subjected; William Wallace comes to mind.

Freedmmm!
Live free, or die!
From my cold dead hand!
Over my dead body!
Freedom is never voluntarily given by the oppressor; it must be
demanded by the oppressed.
Those who deny freedom to others deserve it not for themselves.
Man is free at the moment he wishes to be.
Those who desire to give up freedom in order to gain security, will
not have, nor do they deserve, either one.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ?

2012-02-14 Thread Devin Jeanpierre
On Tue, Feb 14, 2012 at 1:05 PM, MRAB pyt...@mrabarnett.plus.com wrote:
 And yeah, even something as crazy as ()* works, but as soon as it
 becomes (a*)* it doesn't work. Weird.

 I think it's a combination of warning the user about something that's
 pointless,
 as in the case of $*, and producing a pattern which could cause the
 internal
 regex engine to get stuck in an infinite loop.

Considering that ()* works fine, I can't imagine it ever gets stuck in
infinite loops. But I admit I am too lazy to check against the
interpreter.

Also, complete failure is an exceptionally (heh) poor way of warning
people about stuff. I hope that's not really it.

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


Re: how to tell a method is classmethod or static method or instance method

2012-02-14 Thread Zheng Li
thank you.

I know the second way works.

but in my case, i need method1 to be a class method, because I use it to 
create an object.

I have a lot of classes that have __init__ with 2 arguments -- self, and user 
id.
usually, SomeClass(user_id) is used to create an object of SomeClass, 
but if SomeClass has a class method named method1, method1 will be used 
to finish the job.

and i get it. the context is useful.


On 2012/02/14, at 18:52, Cameron Simpson wrote:

 On 14Feb2012 13:13, Zheng Li dllizh...@gmail.com wrote:
 |  On 13Feb2012 15:59, Zheng Li dllizh...@gmail.com wrote:
 |  | how to tell a method is class method or static method or instance 
 method?
 |  
 |  Maybe a better question is:
 |   under what circumstances do you need to figure this out? 
 |
 | I can get method1 of class Test by
 | a = getattr(Test, method1)
 | 
 | and I also want know how to invoke it
 | a() or  a(Test())
 
 Normally:
 
  a(T)
 
 where T is an object of type/class Test. So your second approach is
 notionally correct (aside from making a throwaway object that is then
 discarded).
 
 | BTW:
 | I don't see what the problem is if I ask a question just because I am 
 curious about it.
 
 There's nothing wrong with it at all.
 
 But often, questions arise from some other circumstances and this one is
 of such a flavour that if you wanted this code in a real application it
 would _often_ be the wrong solution to seek, because normally you know
 how to call something - it is not normally useful to introspect it to
 decide what to do.
 
 So I was wondering what the outer context might be, because there may
 well have been a better solution to the situation that brought up the
 specific question.
 
 Simple curiosity is sufficient reason, of course.
 -- 
 Cameron Simpson c...@zip.com.au DoD#743
 http://www.cskk.ezoshosting.com/cs/
 
 Too young to rest on the weekend, too old to rest during the week.
- Mark Randol ryv...@email.sps.mot.com

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


Re: re module: Nothing to repeat, but no sre_constants.error: nothing to repeat ?

2012-02-14 Thread MRAB

On 15/02/2012 01:43, Devin Jeanpierre wrote:

On Tue, Feb 14, 2012 at 1:05 PM, MRABpyt...@mrabarnett.plus.com
wrote:

And yeah, even something as crazy as ()* works, but as soon as
it becomes (a*)* it doesn't work. Weird.


I think it's a combination of warning the user about something
that's pointless, as in the case of $*, and producing a pattern
which could cause the internal regex engine to get stuck in an
infinite loop.


Considering that ()* works fine, I can't imagine it ever gets stuck
in infinite loops. But I admit I am too lazy to check against the
interpreter.

Also, complete failure is an exceptionally (heh) poor way of warning
people about stuff. I hope that's not really it.


There is one place in the re engine where it tries to avoid getting
stuck in an infinite loop because of a zero-width match, but the fix
inadvertently causes another bug. It's described in issue #1647489.
--
http://mail.python.org/mailman/listinfo/python-list


TEST AN EXECUTABLE PYTHON SCRIPT SPEED UNDER A PYTHON SHELL

2012-02-14 Thread 88888 Dihedral
After my testing of JAVA, PYTHON, VB,  C-sharp and Erlang like 
script languages, I noticed that script languages should be 
timed after the shell interpreter completed loaded.

The start up loading time of script interpreters should be excluded in the 
measure of executing a byte code script.

This also explains why C-executables  are fast in manny testing
programs of various languages to out beat all interpreter loading
languages.  

But I computed the Euler'of s number for tens of thousands of digitsunder 
different  shells , then I was able to check the speed
issues of various computer languages.

My question is whether  a lot speed testings  of computer languages are done in 
a  biased way toward script languages 
to be slow?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python vs. C++11

2012-02-14 Thread Tim Roberts
sturlamolden sturlamol...@yahoo.no wrote:

There are bigsimilarities between Python and the new C++ standard. Now
we can actually use our experience as Python programmers to write
fantastic C++ :-)

This is more true than you might think.  For quite a few years now, I've
been able to do an almost line-for-line translation of my Python programs
to C++ programs.  (Microsoft has had a for each extension for a while
that made this easier.)
-- 
Tim Roberts, t...@probo.com
Providenza  Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue13706] non-ascii fill characters no longer work in formatting

2012-02-14 Thread Stefan Krah

Stefan Krah stefan-use...@bytereef.org added the comment:

I'm using ps_AF for testing:

$ ./localeconv_wchar ps_AF
size of wchar_t: 32 bits
decimal_point byte string: \xd9\xab (2 bytes)
decimal_point wide string: L\u066b (1 characters)
thousands_sep byte string: \xd9\xac (2 bytes)
thousands_sep wide string: L\u066c (1 characters)
currency_symbol byte string: \xd8\xa7\xd9\x81\xd8\xba\xd8\xa7\xd9\x86\xdb\x8d 
(12 bytes)
currency_symbol wide string: L\u0627\u0641\u063a\u0627\u0646\u06cd (6 
characters)

--

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



[issue14006] Improve the documentation of xml.etree.ElementTree

2012-02-14 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

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



[issue14007] xml.etree.ElementTree - XMLParser and TreeBuilder's doctype() method missing

2012-02-14 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

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



[issue13248] deprecated in 3.2, should be removed in 3.3

2012-02-14 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

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



[issue9856] Change object.__format__(s) where s is non-empty to a TypeError

2012-02-14 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

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



[issue14006] Improve the documentation of xml.etree.ElementTree

2012-02-14 Thread Stefan Behnel

Stefan Behnel sco...@users.sourceforge.net added the comment:

Both lxml and ElementTree have tutorials:

http://effbot.org/zone/element.htm

http://lxml.de/tutorial.html

Here is another tutorial that may server as a source for an intro:

http://infohost.nmt.edu/tcc/help/pubs/pylxml/web/index.html

And the general ET documentation is here:

http://effbot.org/zone/element-index.htm#documentation

In terms of licensing, I can't speak for any of the other sources, but as for 
the lxml documentation, feel free to copy any ET related parts of it that you 
see fit.

I think the lxml tutorial is gentle enough even for beginners to follow. Note, 
however, that it uses lxml specific APIs in some places. In the specific case 
of XPath, the examples should be easily replaced with ElementPath, though.

--

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



[issue14006] Improve the documentation of xml.etree.ElementTree

2012-02-14 Thread Stefan Behnel

Stefan Behnel sco...@users.sourceforge.net added the comment:

Oh, and here are the ReST sources of the lxml docs:

https://github.com/lxml/lxml/tree/master/doc/

Specifically the tutorial:

https://raw.github.com/lxml/lxml/master/doc/tutorial.txt

and the parsing part:

https://raw.github.com/lxml/lxml/master/doc/parsing.txt

--

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



[issue8739] Update to smtpd.py to RFC 5321

2012-02-14 Thread Geoffrey Spear

Changes by Geoffrey Spear geoffsp...@gmail.com:


--
nosy: +wooble

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



[issue14001] CVE-2012-0845 Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-14 Thread Jan Lieskovsky

Jan Lieskovsky ian...@seznam.cz added the comment:

The CVE identifier of CVE-2012-0845 has been assigned to this issue:
[3] http://www.openwall.com/lists/oss-security/2012/02/13/4

--
title: Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) 
by processing malformed XMLRPC / HTTP POST request - CVE-2012-0845 Python 
v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing 
malformed XMLRPC / HTTP POST request

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



[issue14008] Python uses the new source when reporting an old exception

2012-02-14 Thread Yuval Greenfield

New submission from Yuval Greenfield ubershme...@gmail.com:

I ran the following code:

import time
time.sleep(10)
print 1 / 0


And then modified the source before it hit the exception, python prints out the 
wrong lines from the new source file.


e:\Dropbox\dev\python\metricbotc:\python32\python test.py
Traceback (most recent call last):
  File test.py, line 3, in module
alkdf;alsdkf;l
ZeroDivisionError: division by zero


What should have been printed out:

e:\Dropbox\dev\python\metricbottest.py
Traceback (most recent call last):
  File E:\Dropbox\dev\python\metricbot\test.py, line 3, in module
print 1 / 0
ZeroDivisionError: integer division or modulo by zero


Although this is a toy example, I did run in to the problem when working on a 
long running script that I was upgrading.

Tested it and got the same results on python 2.7 and 3.2.

--
components: Interpreter Core
messages: 153337
nosy: ubershmekel
priority: normal
severity: normal
status: open
title: Python uses the new source when reporting an old exception
type: behavior
versions: Python 3.3

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



[issue14001] CVE-2012-0845 Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-14 Thread Senthil Kumaran

Changes by Senthil Kumaran sent...@uthcode.com:


--
nosy: +orsenthil

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



[issue14008] Python uses the new source when reporting an old exception

2012-02-14 Thread Florent Xicluna

Changes by Florent Xicluna florent.xicl...@gmail.com:


--
resolution:  - duplicate
status: open - closed
superseder:  - Unupdated source file in traceback

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



[issue8087] Unupdated source file in traceback

2012-02-14 Thread Yuval Greenfield

Changes by Yuval Greenfield ubershme...@gmail.com:


--
nosy: +ubershmekel

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



[issue14001] CVE-2012-0845 Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-14 Thread Antoine Pitrou

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


--
stage: needs patch - patch review

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



[issue14009] Clearer documentation for cElementTree

2012-02-14 Thread Éric Araujo

New submission from Éric Araujo mer...@netwok.org:

This patch should clarify how to use cElementTree usage, as well as improving 
indexing.

--
assignee: docs@python
components: Documentation
messages: 153338
nosy: docs@python, eli.bendersky, eric.araujo
priority: normal
severity: normal
stage: commit review
status: open
title: Clearer documentation for cElementTree
versions: Python 2.7, Python 3.2

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



[issue14009] Clearer documentation for cElementTree

2012-02-14 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
keywords: +patch
Added file: http://bugs.python.org/file24519/doc-cET.diff

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



[issue13953] Get rid of doctests in packaging.tests.test_version

2012-02-14 Thread Éric Araujo

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

 Does a doc test test the output literally?
Yes, that’s the problem.  See doctest documentation for more info about how it 
works and what problems it has.

--

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



[issue13198] Remove duplicate definition of write_record_file

2012-02-14 Thread Éric Araujo

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

Damn, bitten by the use of universal newlines!  I guess I should split on a 
literal '\n' instead of calling splitlines.  Could you make that change in your 
clone and tell me if it does the trick?

--

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



[issue14004] Distutils filelist selects too many files on Windows

2012-02-14 Thread Éric Araujo

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

This code just got changed (#13193) to use '/' instead of os.path.join, as it 
is documented that paths in MANIFEST.in must use only '/'.  Can you build an 
up-to-date Python 2.7 from Mercurial and check again?

Your report comes timely, as there was some doubt about what the correct fix 
was.  Even if your bug is now gone, I’ll want to add a regression test for it.

--
assignee: tarek - eric.araujo
keywords: +easy
stage:  - test needed
versions: +Python 3.2, Python 3.3

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



[issue13491] Fixes for sqlite3 doc

2012-02-14 Thread Éric Araujo

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

I think you can commit your patch, with our without merging execute_[12].py, as 
you think best.  Then you can do other patches (with or without pre-commit 
review) to fix or clean up the examples.

--

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



[issue14002] distutils2 fails to install a package from PyPI on Python 2.7.2

2012-02-14 Thread Éric Araujo

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

 The initial errors look like complaints about existing packages I have 
 installed by other means
They’re logging messages, not errors.  They appear because distutils2 scans 
sys.path for egg-info and egg files/dirs and reports invalid versions (per PEP 
386).  Can you report a bug about them?  We do want a warning or an error when 
someone puts an invalid version in their setup.cfg, but when we’re scanning 
installed distributions it’s useless to warn.

 The final one looks like a bug in distutils2
I can reproduce it on Debian.  A test should not be hard to add, adding the 
“easy” keyword.

--
assignee: tarek - eric.araujo
keywords: +easy
stage:  - test needed
versions: +3rd party, Python 3.3 -Python 2.7

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



[issue14010] deeply nested filter segfaults

2012-02-14 Thread Alex Gaynor

New submission from Alex Gaynor alex.gay...@gmail.com:

http://paste.pocoo.org/show/550884/ will reliably segfault Python3 on all 
platforms (similar versions for Python2 using itertools work)

--
components: Interpreter Core
messages: 153344
nosy: alex, benjamin.peterson
priority: normal
severity: normal
status: open
title: deeply nested filter segfaults
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4

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



[issue8087] Unupdated source file in traceback

2012-02-14 Thread Jim Jewett

Jim Jewett jimjjew...@gmail.com added the comment:

Martin v. Löwis (loewis) wrote:

 Displaying a warning whenever the code has changed on disk is
 clearly unacceptable

As clarified, the request is only for when a traceback is being created (or 
perhaps even only for when one is being printed).  

I agree that we don't want to watch every file every time any code is run, but 
by the time a traceback is being displayed, any tight loops are ending.

Nick Coghlan (ncoghlan) wrote:

 There are a few different cases: ...
 2. Source has been changed, but module has not been reloaded ...
 3. Source has been changed, module has been reloaded, but object ...

Given that a traceback is being displayed, I think it is reasonable to rerun 
the find-module portion of import, and verify that there is not stale 
byte-code.  

Frankly, I think it would be worth storing a file timestamp on modules, and 
verifying that whatever-would-be-imported-if-imported-now matches that 
timestamp.  This would also catch case (3).

I also think that -- on traceback display -- it might be worth verifying that 
the code's __globals__ is the __globals__ associated with the module of that 
name in sys.modules.  This would warn about some intentional manipulations, but 
would catch case (3) even more accurately.

--
nosy: +Jim.Jewett

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



[issue14011] packaging should use shutil archiving functions transparently

2012-02-14 Thread Éric Araujo

New submission from Éric Araujo mer...@netwok.org:

The packaging commands sdist and bdist can create various kinds of archives.  
The function used to create them is thankfully just a thin wrapper around 
shutil.make_archive (extracted from distutils), and sdist also uses 
shutil.get_archive_formats to validate its --formats option.  bdist however 
maintains its own registry.

The docstrings, help texts and reST documentation also contain out-of-sync 
duplicate lists of allowed formats.

I’m working on a patch to fix this duplication.

--
assignee: eric.araujo
components: Distutils2
messages: 153346
nosy: alexis, eric.araujo
priority: normal
severity: normal
status: open
title: packaging should use shutil archiving functions transparently
type: enhancement
versions: 3rd party, Python 3.3

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



[issue14005] IDLE Crash when running/saving a file

2012-02-14 Thread Roger Serwy

Roger Serwy roger.se...@gmail.com added the comment:

Try running IDLE from a command prompt and report the error message you see. 
Start a python shell session and run:

import idlelib.idle

--
nosy: +serwy

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



[issue14012] Misc tarfile fixes

2012-02-14 Thread Éric Araujo

New submission from Éric Araujo mer...@netwok.org:

I found a few possible bugs in tarfile:

- “mode in 'raw'” can give false positives for '' or 'ra'.  Most of the code 
also checks for “len(mode)  1”, but I find clearer and safer to just use “mode 
in ('r', 'a', 'w')”.

- To use the shadowed builtin “open”, tarfile uses both “import as” and a local 
alias “bltin_open = open”.  However, the second idiom would break if tarfile 
were reloaded.

- Error messages don’t say what the invalid mode was.  (Error messages are not 
part of the language, but nonetheless maybe it’s best not to commit that to 
stable branches.)

--
components: Library (Lib)
files: tarfile-misc-bugs-3.2.diff
keywords: patch
messages: 153348
nosy: eric.araujo, lars.gustaebel
priority: normal
severity: normal
stage: commit review
status: open
title: Misc tarfile fixes
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3
Added file: http://bugs.python.org/file24520/tarfile-misc-bugs-3.2.diff

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



[issue14011] packaging should use shutil archiving functions transparently

2012-02-14 Thread Ramchandra Apte

Changes by Ramchandra Apte maniandra...@gmail.com:


--
components: +Documentation

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



[issue6715] xz compressor support

2012-02-14 Thread Éric Araujo

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

BTW, any plans on a PyPI backport for fun and profit?

--

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



[issue14010] deeply nested filter segfaults

2012-02-14 Thread Ezio Melotti

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


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

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



[issue14013] tarfile should expose supported formats

2012-02-14 Thread Éric Araujo

New submission from Éric Araujo mer...@netwok.org:

shutil contains high-level functions to create a zipfile or a tarball.  When a 
new format is added to the tarfile module, then shutil needs to be updated 
manually.  If tarfile exposed the names of the compressors it supports, then 
shutil could just automatically support everything that tarfile supports 
instead of having to re-do import dances for optional modules (bz2, lzma, zlib) 
and also duplicate formats in its doc.

This may also be useful for other code wanting to do some introspection.

Attached patch implements tarfile.formats, a list of strings (I thought about 
using a frozenset but then followed the precedent set by the 3.3 crypt module). 
 Tests and docs not updated, I wanted to get Lars’ approval on the principle 
first.

One could argue that this is not needed: compression modules are not added 
often; updating shutil after updating tarfile is not hard; it is not that 
useful to have access to the list of supported formats.

--
assignee: docs@python
components: Documentation, Library (Lib)
messages: 153350
nosy: docs@python, eric.araujo, lars.gustaebel, nadeem.vawda
priority: normal
severity: normal
stage: patch review
status: open
title: tarfile should expose supported formats
type: enhancement
versions: Python 3.3

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



[issue14013] tarfile should expose supported formats

2012-02-14 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
keywords: +patch
Added file: http://bugs.python.org/file24521/add-tarfile.formats.diff

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



[issue5411] add xz compression support to shutil

2012-02-14 Thread Éric Araujo

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

a) is #14013; b) is #14011.

If Lars agrees to #14013, I will withdraw this patch in favor of another one 
that would make shutil automatically support all compressors that tarfile 
supports (my b) point).

Note that this is not going to be pain-free, as for example bzip2 compression 
is obtained with the strings “bz2”, “bzip2”, “bzip” or “bztar” depending on the 
modules; I think it’s worth it nonetheless, even if I have to add an ugly 
conversion in shutil for compat.

--
dependencies: +tarfile should expose supported formats

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



[issue6715] xz compressor support

2012-02-14 Thread Nadeem Vawda

Nadeem Vawda nadeem.va...@gmail.com added the comment:

 BTW, any plans on a PyPI backport for fun and profit?

At present, no. I'll look into it later in the year, but at the moment
I don't have the time to work on it - I suspect the parts written in C
will require substantial changes to work under 2.x.

--

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



[issue14010] deeply nested filter segfaults

2012-02-14 Thread Armin Rigo

Armin Rigo ar...@users.sourceforge.net added the comment:

The issue is a stack exhaustion.  Examples can be trivially made for any 
iterator that takes another iterator as argument: itertools.takewhile(), zip() 
in Python3, etc. etc.

It's just one of many places where CPython does a recursion without checking 
the recursion depth.  CPython still works, based on the resonable assumption 
that doing such a recursion here is obscure.

Someone seriously bored could start with some C-based callgraph builder; or 
alternatively use PyPy, which finds such recursions automatically in its own 
source, and compare all places where a recursion check is inserted with the 
corresponding place in CPython.  There are a large number of them (761, not 
counting the JIT), so be patient :-(

--
nosy: +arigo

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



[issue14014] codecs.StreamWriter.reset contract not fulfilled

2012-02-14 Thread Jim Jewett

New submission from Jim Jewett jimjjew...@gmail.com:

def reset(self):

 Flushes and resets the codec buffers used for keeping state.

Calling this method should ensure that the data on the
output is put into a clean state, that allows appending
of new fresh data without having to rescan the whole
stream to recover state.


pass

This does not ensure that the stream is flushed, as the docstring promises.  I 
believe the following would work better.


def reset(self):
 Flushes and resets the codec buffers used for keeping state.

Calling this method should ensure that the data on the
output is put into a clean state, that allows appending
of new fresh data without having to rescan the whole
stream to recover state.


if hasattr(self.stream, flush): self.stream.flush()

--
components: Unicode
messages: 153354
nosy: Jim.Jewett, ezio.melotti
priority: normal
severity: normal
status: open
title: codecs.StreamWriter.reset contract not fulfilled
type: behavior
versions: Python 3.2

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



[issue13992] Segfault in PyTrash_destroy_chain

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

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

I'm running out of ideas to debug this, maybe Antoine or Amaury can help :-)

One last idea (not sure it will work though):
If Channel's finalizer gets called twice, inside Channel.__del__, you
could save a string representation of the current backtrace as an
attribute, and print the previous and current backtrace is there is
already one such attribute (i.e. print the backtrace if __del__ is
called twice).
There may be false positives (for example a finalizer resurecting the
object would end up in __del__ being called twice), but it might yield
useful info.
You might also want to save the thread ID and time.

But this is really strange...

--

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



[issue14001] CVE-2012-0845 Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

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

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

With test.
test_xmlrpc has a timeout detection code which is simply broken (and it's 
actually documented): I just removed it, so if the server loops, the test will 
block. I think it's acceptable since other tests behave in the same way, and 
those days we have faulthandler that can be used to pinpoint such 
deadlocks/loops easily. Also, I've noticed that people are more inclined to fix 
tests that block than mere failing tests :-)

--
Added file: http://bugs.python.org/file24522/xmlrpc_loop-1.diff

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



[issue13878] test_sched failures on Windows buildbot

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

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

Well, it's not really needed, as long as scheduler deals correctly
with expired deadlines.

--

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



[issue13881] Stream encoder for zlib_codec doesn't use the incremental encoder

2012-02-14 Thread Andrew McNabb

Andrew McNabb amcn...@mcnabbs.org added the comment:

It looks like encodings/zlib_codec.py defines a custom IncrementalEncoder and 
IncrementalDecoder, but its StreamWriter and StreamReader rely on the standard 
implementation of codecs.StreamWriter and codecs.StreamReader.

One solution might be to have zlib_codec.StreamWriter inherit from 
zlib_codec.IncrementalEncoder instead of from zlib_encoder.Codec. I'm not 
familiar enough with the codecs library to know whether this is the best 
approach.

Unfortunately, there are 120 codec files in the encodings directory, and it's 
unclear how many of them would need to be modified. Based on the number of them 
that implement StreamWriter as class StreamWriter(Codec,codecs.StreamWriter), 
it looks like it might be a lot of them. Was each of these 120 files 
hand-written?

--

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



[issue13881] Stream encoder for zlib_codec doesn't use the incremental encoder

2012-02-14 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
nosy: +haypo

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



[issue14015] surrogateescape largely missing from documentation

2012-02-14 Thread Jim Jewett

New submission from Jim Jewett jimjjew...@gmail.com:

Recent discussion on the mailing lists and in http://bugs.python.org/issue13997 
make it clear that the best way to get python2 results for 
ASCII-in-the-parts-I-might-process-or-change is to replace 

f = open(fname)
with
f = open(fname, encoding=ascii, errors=surrogateescape)

Unfortunately, surrogateescape (let alone this recipe) is not easily 
discoverable.  

http://docs.python.org/dev/library/functions.html#open lists 5 error-handlers 
-- but not this one.  It says that other error handlers are possible if they 
are registered with 
http://docs.python.org/dev/library/codecs.html#codecs.register_error but I 
haven't found a way to determine which error handlers are already registered.

The codecs.register (as opposed to register_error) documentation does list it 
as a possible value, but that is the only reference.

The other 5 error handlers are also available as module-level functions within 
the codecs module, and have their own documenation sections within 
http://docs.python.org/dev/library/codecs.html

Neither help(open) nor import codecs; help(codecs) provides any hints of the 
existence of surrogateescape.  Both explicitly suggest that it does not exist, 
by enumerating other values.

--
assignee: docs@python
components: Documentation, Unicode
messages: 153359
nosy: Jim.Jewett, docs@python, ezio.melotti
priority: normal
severity: normal
status: open
title: surrogateescape largely missing from documentation
versions: Python 3.1, Python 3.2, Python 3.3

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



[issue13997] Clearly explain the bare minimum Python 3 users should know about Unicode

2012-02-14 Thread Jim Jewett

Jim Jewett jimjjew...@gmail.com added the comment:

See bugs/python.org/issue14015 for one reason that surrogateescape isn't better 
known.

--
nosy: +Jim.Jewett

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



[issue14016] Usage of socket.sendall() in multiple threads

2012-02-14 Thread Srikantha Kadur

New submission from Srikantha Kadur srikanthka...@gmail.com:

Here is my code.

Func1():
.
.
CliSock, addr = ServSocket.accept()
print 'DataPortServ:Connected by', addr
data.DataSendSock = CliSock

for cnt in range(data.ThreadCnt):
SessionId = startSessionId + SessionIdCnt* cnt  

thread.start_new_thread(ThreadHandleDataPort,((Thead+str(cnt)),data,EventCnt[cnt],EventCnt[cnt+1],UECntPerThread,ip,SessionId))
time.sleep(0.005)

ThreadHandleDataPort(args):
#here i use socket.sendall
 while True:
if ( 3 != data.bRunFlag): 
   if (len(data.AddedEvents) != 0) | (len(data.AddedReasons) != 0):
   #time.sleep(5)
   for EventCnt in range(StartEvent,StopEvent):
   .
   .
   .
   data.DataSendSock.sendall(SendEvent)
   .
   .

My application is a server and it accepts connection from the client on a port 
and start sending some messages to the client. While sending messages i use 
multiple threads for the same socket based on required traffic. 

I do not modify any global variables but i read only global variables.But at 
high Loads my messages are being corrupted, here is the snippet of the 
corruption

actual message should have been 
ABS1,1328577019.57,181138955,

instead im getting
ABS1,1329218634.91,181ABS1

so here is my Q:
Do i need to lock the socket before sending inside the threads or Python 
modules will take care of it? Please suggest.

--
components: 2to3 (2.x to 3.x conversion tool)
messages: 153361
nosy: srikadur
priority: normal
severity: normal
status: open
title: Usage of socket.sendall() in multiple threads
type: behavior

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



[issue14016] Usage of socket.sendall() in multiple threads

2012-02-14 Thread R. David Murray

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

This isn't really the place to get help on using python, but no, python doesn't 
do any implicit locking for you.

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

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



[issue13198] Remove duplicate definition of write_record_file

2012-02-14 Thread Paul Moore

Paul Moore p.f.mo...@gmail.com added the comment:

 Damn, bitten by the use of universal newlines!  I guess I should split on a 
 literal '\n' instead of calling splitlines.  Could you make that change in 
 your clone and tell me if it does the trick?

Not for a few days, but I'll check when I'm back home

--

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



[issue14016] Usage of socket.sendall() in multiple threads

2012-02-14 Thread Srikantha Kadur

Srikantha Kadur srikanthka...@gmail.com added the comment:

Thanks David,
  as the last available option i used this tool.

--

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



[issue14002] distutils2 fails to install a package from PyPI on Python 2.7.2

2012-02-14 Thread Paul Moore

Paul Moore p.f.mo...@gmail.com added the comment:

On 14 February 2012 15:48, Éric Araujo rep...@bugs.python.org wrote:

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

 The initial errors look like complaints about existing packages I have 
 installed by other means
 They’re logging messages, not errors.  They appear because distutils2 scans 
 sys.path for egg-info and egg files/dirs and reports invalid versions
 (per PEP 386).  Can you report a bug about them?  We do want a warning or an 
 error when someone puts an invalid version in their setup.cfg,
 but when we’re scanning installed distributions it’s useless to warn.

To what? The individual packages? Maybe, but I'm not sure how useful
that would be. For example, pywin32 has been using 3-digit versions
like this forever, and I don't see them changing just on the basis of
this (but I may be wrong). PyPI seems to handle pywin32's version
fine...

I'd rather say that it's a bug in distutils2 that it complains about
perfectly valid distributions. I'd be OK with a verify flag/action
that checked existing installed distributions, but I see no reason for
any message (informational, warning, or whatever) when you're just
asking for a new distribution to be installed.

--

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



[issue13878] test_sched failures on Windows buildbot

2012-02-14 Thread Nadeem Vawda

Nadeem Vawda nadeem.va...@gmail.com added the comment:

Ah, I suppose that makes sense.

--

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



[issue1326113] Letting build_ext --libraries take more than one lib

2012-02-14 Thread Eric Snow

Eric Snow ericsnowcurren...@gmail.com added the comment:

Ran into this bug today in 2.7 (building python-sybase with freetds).  The fix 
in msg121260 took care of it (didn't try the patch).  Thanks, Éric.  

Is this something that could get patched in the upcoming micro releases?  It's 
not so important for me at this point, and I'm not sure how often it will come 
up, but it's also a very simple fix.

--
nosy: +eric.snow

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



[issue9127] subprocess.Popen.communicate() and SIGCHLD handlers

2012-02-14 Thread Gregory P. Smith

Gregory P. Smith g...@krypto.org added the comment:

fixed via http://hg.python.org/cpython/rev/767420808a62

--
dependencies: +race condition in subprocess module
nosy: +gregory.p.smith

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



[issue13703] Hash collision security issue

2012-02-14 Thread Jim Jewett

Jim Jewett jimjjew...@gmail.com added the comment:

On Mon, Feb 13, 2012 at 3:37 PM,  Dave Malcolm
dmalc...@redhat.com added the comment:

  * added comments about the specialcasing of length 0:
    /*
      We make the hash of the empty string be 0, rather than using
      (prefix ^ suffix), since this slightly obfuscates the hash secret
    */

Frankly, other short strings may give away even more, because you can
put several into the same dict.

I would prefer that the randomization not kick in until strings are at
least 8 characters, but I think excluding length 1 is a pretty obvious
win.

--

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



[issue10287] NNTP authentication should check capabilities

2012-02-14 Thread Antoine Pitrou

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

I think the patch is fine. Will apply soon (thanks!)
.

--
status: closed - open

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



[issue14004] Distutils filelist selects too many files on Windows

2012-02-14 Thread Nadeem Vawda

Nadeem Vawda nadeem.va...@gmail.com added the comment:

I've been able to reproduce this on current builds of 2.7, 3.2 and 3.3.

The problem seems to be that distutils.filelist pathnames using the OS
directory separator, but the regexps used for matching paths are written
to always assume /-based paths.

I've been able to get the correct behaviour in this case by making the
module build paths using / regardless of the OS directory separator:

--- a/Lib/distutils/filelist.py
+++ b/Lib/distutils/filelist.py
@@ -55,10 +55,10 @@

 def sort(self):
 # Not a strict lexical sort!
-sortable_files = sorted(map(os.path.split, self.files))
+sortable_files = sorted(f.split(/) for f in self.files)
 self.files = []
 for sort_tuple in sortable_files:
-self.files.append(os.path.join(*sort_tuple))
+self.files.append(/.join(sort_tuple))


 # -- Other miscellaneous utility methods ---
@@ -258,7 +258,7 @@

 for name in names:
 if dir != os.curdir:# avoid the dreaded ./ syndrome
-fullname = os.path.join(dir, name)
+fullname = dir + / + name
 else:
 fullname = name

I'm not entirely comfortable with this fix, though - it seems like it
would be better to produce paths using the OS directory separator at the
end of the process. Maybe it's possible to add a translation step after
the file list is built and de-duplicated? I don't know much about how
the rest of distutils uses this module.

(Random aside: do we support any platforms that don't support / as a
directory separator (even if it isn't the preferred one)? Hmm...)

--

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



[issue6784] byte/unicode pickle incompatibilities between python2 and python3

2012-02-14 Thread Merlijn van Deen

Changes by Merlijn van Deen valhall...@gmail.com:


--
nosy: +valhallasw

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



[issue13881] Stream encoder for zlib_codec doesn't use the incremental encoder

2012-02-14 Thread STINNER Victor

STINNER Victor victor.stin...@gmail.com added the comment:

See also issue #7475.

--

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



[issue10287] NNTP authentication should check capabilities

2012-02-14 Thread Antoine Pitrou

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

This issue can now be closed for good.

--
status: open - closed

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



[issue10287] NNTP authentication should check capabilities

2012-02-14 Thread Roundup Robot

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

New changeset a7f1ffd741d6 by Antoine Pitrou in branch '3.2':
Issue #10287: nntplib now queries the server's CAPABILITIES first before 
sending MODE READER, and only sends it if not already in READER mode.
http://hg.python.org/cpython/rev/a7f1ffd741d6

New changeset 03019bb62d83 by Antoine Pitrou in branch 'default':
Issue #10287: nntplib now queries the server's CAPABILITIES first before 
sending MODE READER, and only sends it if not already in READER mode.
http://hg.python.org/cpython/rev/03019bb62d83

--

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



[issue14001] CVE-2012-0845 Python v2.7.2 / v3.2.2 (SimpleXMLRPCServer): DoS (excessive CPU usage) by processing malformed XMLRPC / HTTP POST request

2012-02-14 Thread Antoine Pitrou

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

The patch looks ok to me.

--
nosy: +pitrou

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



[issue14015] surrogateescape largely missing from documentation

2012-02-14 Thread Chris Rebert

Changes by Chris Rebert pyb...@rebertia.com:


--
nosy: +cvrebert

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



[issue14017] io.TextIOWrapper should expose a documented write_through attribute

2012-02-14 Thread Nick Coghlan

New submission from Nick Coghlan ncogh...@gmail.com:

io.TextIOWrapper acquired a new write_through argument for 3.3, but that is 
not exposed as a documented attribute.

This is needed so that a text wrapper can be replaced with an equivalent that 
only alters selected settings (such as the Unicode error handler).

--
components: Library (Lib)
messages: 153376
nosy: ncoghlan
priority: normal
severity: normal
status: open
title: io.TextIOWrapper should expose a documented write_through attribute
versions: Python 3.3

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



[issue14017] Make it easy to create a new TextIOWrapper based on an existing

2012-02-14 Thread Nick Coghlan

Nick Coghlan ncogh...@gmail.com added the comment:

Updating issue title, since I realised this doesn't work in 3.2 either (the 
newline argument also isn't available for introspection - newlines is not 
the same thing)

Possible API signature:

_missing = object()
def rewrap(self, encoding=_missing, errors=_missing, newline=_missing, 
line_buffering=_missing, write_through=_missing):
pass

That is, accept the same arguments as __init__ (excluding the buffer argument), 
with any arguments not explicitly supplied replaced with the values from the 
current instance.

--
title: io.TextIOWrapper should expose a documented write_through attribute - 
Make it easy to create a new TextIOWrapper based on an existing

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



  1   2   >