Re: Implicit initialization is EXCELLENT

2011-07-07 Thread Ulrich Eckhardt
Ian Kelly wrote:
 On Wed, Jul 6, 2011 at 12:49 AM, Ulrich Eckhardt
 ulrich.eckha...@dominolaser.com wrote:
 Mel wrote:
 In wx, many of the window classes have Create methods, for filling in
 various attributes in two-step construction. [...]

 Just guessing, is it legacy, C-with-classes code rather than C++ code
 perhaps? Haven't looked at wx for a while. Such code typically lacks
 understanding of exceptions, which are the only way to signal failure
 from e.g. constructors.
 
 No, wx is C++ through and through.

No namespaces. No templates but macros. No exceptions. No C++.

Sorry, I beg to differ. BTW, they say themselves that they tolerate but not 
use exceptions, so they actually need two-stage construction if construction 
can fail, and for exactly the guessed legacy reasons.


 http://wiki.wxpython.org/TwoStageCreation

A C++ object is not a window, it is rather a proxy for managing the window. 
As such, it can be attached or detached from the underlying window, just 
like a std::fstream, so in this light it makes sense actually. Thanks for 
the link!

Uli


-- 
Domino Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

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


Re: web browsing short cut

2011-07-07 Thread Cousin Stanley

Chris Angelico wrote:

 frameset rows=50%,50%
   frameset cols=50%,50%
 frame src=http://blah/blah;
 frame src=http://another/blah;
   /frameset
   frameset cols=50%,50%
 frame src=http://third/blah;
 frame src=http://final/blah;
   /frameset
 /frameset

 That should divide your screen four ways 
 ( if I haven't botched my HTML
   - ages since I've used frames ).

  html !botched  :-)

  An example of your frameset code 

http://csphx.net/fourpy.htm


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


TypeError: unbound method DefaultTracer() must be called with MyClass instance as first argument (got str instance instead)

2011-07-07 Thread Kannan Varadhan
Hi Folks,

Here is something I don't fully understand.

  1 def DefaultTracer(fmt, *args):
  2   fmt = 'in DefaultTracer ' + fmt
  3   print(fmt % args)
  4   pass
  5 def myTracer(fmt, *args):
  6   fmt = 'in myTracer ' + fmt
  7   print(fmt % args)
  8
  9 class MyClass:
 10   ClassDefaultTracer = DefaultTracer
 11   def __init__(self):
 12 self.InstanceTracer = MyClass.ClassDefaultTracer
 13   def trace(self, fmt, *args):
 14 self.InstanceTracer(fmt, *args)
 15
 16
 17 DefaultTracer(Testing %s, 'at first')
 18 myTracer(Testing %s, 'at first')
 19
 20 MyClass().trace('Using ClassDefaultTracer')
 21
 22 # override ClassDefaultTracer for all new instances
 23 MyClass.ClassDefaultTracer = myTracer
 24 MyClass().trace('Using Overridden ClassDefaultTracer')

I want ClassDefaultTracer to store a reference to DefaultTracer and be
used by instances of MyClass.  Why does line20 give me the following
error:

$ python foo.py
in DefaultTracer Testing at first
in myTracer Testing at first
Traceback (most recent call last):
  File foo.py, line 20, in module
MyClass().trace('Using ClassDefaultTracer')
  File foo.py, line 14, in trace
self.InstanceTracer(fmt, *args)
TypeError: unbound method DefaultTracer() must be called with MyClass
instance as first argument (got str instance instead)

Alternately, how can I achieve what I want, i.e. a class-wide default
used by all instances created off it, but
itself be changeable, so that once changed, the changed default would
be used by subsequent newer instances of that class.

Thanks,

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


Re: wx MenuItem - icon is missing

2011-07-07 Thread Laszlo Nagy



I can understand why it's frustrating but a menu items with icons on them 
aren't exactly common, so you're wandering into territory that's probably not 
so throughly explored (nor standard across platforms). Now that I think about 
it, I don't know that I've ever seen one under OSX, and I don't even know if 
it's supported at all.
Maybe you are right, I'm not familiar with OS X. But they are common in 
GTK, Qt and Windows.

Me, I would start by addressing the error in the traceback. wx doesn't seem 
happy with an orphan menu item; why not create a wx.Menu and assign the menu 
item to that? It might solve your icon problem; you never know.

I did create it:

menu = wx.Menu() # wx.Menu created here.
item = wx.MenuItem(None,-1,uTest)
item.SetBitmap(img.GetBitmap())
menu.AppendItem(item) # Item added to menu here.


In defense of wxPython, we have three wx apps in our project and they contain 
very little platform-specific code. To be fair, we've had to rewrite some code 
after we found that it worked on one platform but not another, but generally 
we're able to find code that works on all platforms. We have only a couple of 
places where we were forced to resort to this kind of thing:

if wx.Platform == __WXGTK__:
   do X
elif wx.Platform == __WXMAC__:
   do Y
etc.

Hmmm then probably I'll have to install other OS too. :-)

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


more advanced learning resources (code structure, fundamentals)

2011-07-07 Thread John [H2O]

Hello,

I've been programming in Python for a few years now. I have read most the
typical learning resources, such as 'Dive Into Python', 'A Byte of Python',
etc. In general I feel I have a good overview of the language. However, as I
advanced toward trying to create more OO styled programs, I feel I am
lacking some background on basic concepts.

I have read 'Coding' and 'Beautiful Code', and while these provide good
information on how to style and think about code, they haven't help me
design classes, think about where and when to use inheritance, decorators,
etc. The point is, most examples stop at demonstrating a single class, or
show a trivial decorator example. What I am after is something that will
help me design a program from scratch.

What are the key points to the classes? Is it okay to reference or pass
classes to instantiate a class? When would I want to use a decorator? How to
decide which should be a static method, and if I need them at all?

I know a lot of this would come from experience of working in a team, but
unfortunately, I'm mostly running solo. I am starting to look more and more
at source code too, which I find helpful, but the styles of programming vary
significantly. Perhaps someone could say which modules have nice 'exemplary'
code worth learning from?

So, if someone has a good book or online reference, please point me to it.
Other ideas too are most certainly welcome!

Best,
john


-- 
View this message in context: 
http://old.nabble.com/more-advanced-learning-resources-%28code-structure%2C-fundamentals%29-tp32011481p32011481.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Re: TypeError: unbound method DefaultTracer() must be called with MyClass instance as first argument (got str instance instead)

2011-07-07 Thread Peter Otten
Kannan Varadhan wrote:

 Here is something I don't fully understand.
 
   1 def DefaultTracer(fmt, *args):
   2   fmt = 'in DefaultTracer ' + fmt
   3   print(fmt % args)
   4   pass
   5 def myTracer(fmt, *args):
   6   fmt = 'in myTracer ' + fmt
   7   print(fmt % args)
   8
   9 class MyClass:
  10   ClassDefaultTracer = DefaultTracer
  11   def __init__(self):
  12 self.InstanceTracer = MyClass.ClassDefaultTracer
  13   def trace(self, fmt, *args):
  14 self.InstanceTracer(fmt, *args)
  15
  16
  17 DefaultTracer(Testing %s, 'at first')
  18 myTracer(Testing %s, 'at first')
  19
  20 MyClass().trace('Using ClassDefaultTracer')
  21
  22 # override ClassDefaultTracer for all new instances
  23 MyClass.ClassDefaultTracer = myTracer
  24 MyClass().trace('Using Overridden ClassDefaultTracer')
 
 I want ClassDefaultTracer to store a reference to DefaultTracer and be
 used by instances of MyClass.  Why does line20 give me the following
 error:
 
 $ python foo.py
 in DefaultTracer Testing at first
 in myTracer Testing at first
 Traceback (most recent call last):
   File foo.py, line 20, in module
 MyClass().trace('Using ClassDefaultTracer')
   File foo.py, line 14, in trace
 self.InstanceTracer(fmt, *args)
 TypeError: unbound method DefaultTracer() must be called with MyClass
 instance as first argument (got str instance instead)

Functions written in Python are also descriptors, they have a __get__() 
method. The seemingly harmless

whatever = MyClass.ClassDefaultTracer

therefore results in something like

whatever = MyClass.__dict__[ClassDefaultTracer].__get__(None, MyClass)

internally, and whatever becomes an unbound method, essentially the 
DefaultTracer function wrapped in a check that its first argument is a 
MyClass instance.

The simplest workaround is probably to spell out the dictionary access

whatever = MyClass.__dict__[ClassDefaultTracer]

If you want inheritance to work properly you need something more invoved, 
perhaps (untested)

f = self.ClassDefaultTracer
try: 
f = f.im_func
except AttributeError: 
pass
self.InstanceTracer = f

or you wrap the callable in a descriptor:

 def DefaultTracer(*args): print args
...
 class D(object):
... def __init__(self, f):
... self.f = f
... def __get__(self, *args):
... return self.f
...
 class MyClass(object):
... old = DefaultTracer
... new = D(DefaultTracer)
...
 MyClass.old
unbound method MyClass.DefaultTracer
 MyClass.new
function DefaultTracer at 0x7f0f1c0c45f0
 m = MyClass()
 m.old
bound method MyClass.DefaultTracer of __main__.MyClass object at 
0x7f0f1cda6fd0
 m.new
function DefaultTracer at 0x7f0f1c0c45f0

Not pretty, but in Python 3 the problem is gone...

 Alternately, how can I achieve what I want, i.e. a class-wide default
 used by all instances created off it, but
 itself be changeable, so that once changed, the changed default would
 be used by subsequent newer instances of that class.


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


Re: Large number multiplication

2011-07-07 Thread Ulrich Eckhardt
Billy Mays wrote:
 On 07/06/2011 04:02 PM, Ian Kelly wrote:
 According to Wikipedia:

 
 In practice the Schönhage–Strassen algorithm starts to outperform
 older methods such as Karatsuba and Toom–Cook multiplication for
 numbers beyond 2**2**15 to 2**2**17 (10,000 to 40,000 decimal digits).
 

 I think most Python users are probably not working with numbers that
 large, and if they are, they are probably using specialized numerical
 libraries anyway, so there would be little benefit in implementing it
 in core.
 
 You are right that not many people would gain significant use of it.

Even worse, most people would actually pay for its use, because they don't 
use numbers large enough to merit the Schönhage–Strassen algorithm.


 The reason I ask is because convolution has a better (best ?) complexity
 class than the current multiplication algorithm.

The asymptotic complexity of algorithms (I guess that's what you mean) is 
concerned with large up to infinite n elements in operations. The claim 
there always excludes any number of elements below n_0, where the complexity 
might be different, even though that is usually not repeatedly mentioned. In 
other words, lower complexity does not mean that something runs faster, only 
that for large enough n it runs faster. If you never realistically reach 
that limit, you can't reap those benefits.

That said, I'm sure that the developers would accept a patch that switches 
to a different algorithm if the numbers get large enough. I believe it 
already doesn't use Karatsuba for small numbers that fit into registers, 
too.


 I was more interested in finding previous discussion (if any) on why
 Karatsuba was chosen, not so much as trying to alter the current
 multiplication implementation.

I would hope that such design decisions are documented in code or at least 
referenced from there. Otherwise the code is impossible to understand and 
argue about.


Cheers!

Uli

-- 
Domino Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

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


find max and min values from a column of a csv file

2011-07-07 Thread prakash jp
Hi All ,

Could any one help to get max and min values from a specified column of a
csv file. The* csv file is large* and hence the below code did go bad.
*Alternate
methods would be highly appreciated
**
minimum.py*:
import csv
filename = testLog_4.csv
f = open(filename)
def col_min(mincname):
with open(filename, 'rb') as f:
reader = csv.reader(f, delimiter=,)
#print reader
#print mincname
col_index = next(reader).index(mincname)
#print col_index
least = min(rec[col_index] for rec in reader)
print least

col_min(str(Server Latency))
col_min(str(Client Latency))
f.close()

*maximum.py:*
import csv
filename = testLog_4.csv
f = open(filename)
def col_max(maxcname):
with open(filename, 'rb') as f:
reader = csv.reader(f, delimiter=,)
#print reader
#print cname
col_index = next(reader).index(maxcname)
#print col_index
highest = max(rec[col_index] for rec in reader)
print highest

col_max(str(Server Latency))
col_max(str(Client Latency))
f.close()


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


Re: bash: testing whether anyone is or has recently been logged in?

2011-07-07 Thread Adam Funk
On 2011-04-20, Bill Marcum wrote:

 On 2011-04-20, Adam Funk a24...@ducksburg.com wrote:
 I'd appreciate any suggestions for testing (preferably from a bash
 script, although perl or python would be OK too) whether anyone is
 currently logged in, and whether anyone has been logged in during the
 past $N minutes.  

 (The idea is to use this in a cron script that only does its job when
 the machine is not in live use.)

 A script could parse the output of who, w or last, and the stored
 output from previous commands. 

[adding comp.lang.python]

Here's what I came up with in python.  If you call it with no
arguments or with 0 as the argument, it gives a 0 exit code if no-one
is logged in.  If you call it with a non-zero argument N, it gives a 0
exit code if no-one has been logged in in the past N minutes.

I welcome suggestions, corrections, c.



#v+
#!/usr/bin/python
# -*- coding: utf-8 -*-

import subprocess, re
from   dateutil.parser import *
from   sys  import stdout, stderr, argv
from   datetime import datetime, timedelta
from   optparseimport OptionParser


oparser = OptionParser(usage=usage: %prog [options] [N])

oparser.add_option(-v, dest=verbose, default=False, action=store_true,
   help=Verbose output)

(options, args) = oparser.parse_args()



query = 0

try:
if len(args)  0:
query = int(args[0])
except ValueError:
stderr.write('Invalid argument %s\n' % argv[1])
exit(-1)

if (options.verbose):
stdout.write('query %i\n' % query)


last_proc = subprocess.Popen(args=['last'], stdout=subprocess.PIPE)
last_out = last_proc.stdout.read().split('\n')

still_logged = re.compile(r'still logged in')
line_pattern = re.compile(r'^\S+\s+\S+\s+\S+\s+(\S+\s+\S+\s+\S+) ..:.. - 
(..:..)\s+.*$')
timestamps = [];
minutes = 1


for line in last_out:
if line.startswith('reboot'):
pass

elif still_logged.search(line):
minutes = 0
if (options.verbose):
stdout.write('still logged in\n')
break

else:
matcher = line_pattern.match(line)
# user term host Tue Apr 26 13:49 - 14:52  (01:02)

if matcher:
date_string = matcher.group(1) + ' ' + matcher.group(2)
timestamp = parse(date_string)
stdout.write('d ' + date_string + '  --  ' + str(timestamp) + 
'\n')
timestamps.append(timestamp)

if len(timestamps)  0:
latest = max(timestamps)
stderr.write(str(latest) + '\n')
now = datetime.now()
delta = now - latest
minutes = delta.days * 24 * 60 + delta.seconds / 60



diff_value = query + 1 - minutes
exit_value = max (0, diff_value)

if (options.verbose):
stdout.write('min   %i\n' % minutes)
stdout.write('diff  %i\n' % diff_value)
stdout.write('exit  %i\n' % exit_value)

exit(exit_value)
#v-


-- 
I worry that 10 or 15 years from now, [my daughter] will come to me
and say 'Daddy, where were you when they took freedom of the press
away from the Internet?'  [Mike Godwin]
http://www.eff.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: find max and min values from a column of a csv file

2011-07-07 Thread John [H2O]

I think you would benefit from reading the data into a numpy array first,
then using numpy min, max functions.



prakash jp wrote:
 
 Hi All ,
 
 Could any one help to get max and min values from a specified column of a
 csv file. The* csv file is large* and hence the below code did go bad.
 *Alternate
 methods would be highly appreciated
 **
 minimum.py*:
 import csv
 filename = testLog_4.csv
 f = open(filename)
 def col_min(mincname):
 with open(filename, 'rb') as f:
 reader = csv.reader(f, delimiter=,)
 #print reader
 #print mincname
 col_index = next(reader).index(mincname)
 #print col_index
 least = min(rec[col_index] for rec in reader)
 print least
 
 col_min(str(Server Latency))
 col_min(str(Client Latency))
 f.close()
 
 *maximum.py:*
 import csv
 filename = testLog_4.csv
 f = open(filename)
 def col_max(maxcname):
 with open(filename, 'rb') as f:
 reader = csv.reader(f, delimiter=,)
 #print reader
 #print cname
 col_index = next(reader).index(maxcname)
 #print col_index
 highest = max(rec[col_index] for rec in reader)
 print highest
 
 col_max(str(Server Latency))
 col_max(str(Client Latency))
 f.close()
 
 
 Thanks
 
 -- 
 http://mail.python.org/mailman/listinfo/python-list
 
 

-- 
View this message in context: 
http://old.nabble.com/find-max-and-min-values-from-a-column-of-a-csv-file-tp32011861p32012126.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Re: more advanced learning resources (code structure, fundamentals)

2011-07-07 Thread Mel
John [H2O] wrote:
[ ... ]
 What are the key points to the classes? Is it okay to reference or pass
 classes to instantiate a class? 

Yes.  The standard library does this in BaseHTTPServer (via its parent 
SocketServer.)  Maybe looks abstruse at the outset, but it's the natural way 
to assign a fresh message handler to a new input message.  Docs are via the 
Python Global Module Index, source is in some directory like
/usr/lib/python2.6/SocketServer.py , .../BaseHTTPServer.py , etc.

Mel.

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


Re: Does hashlib support a file mode?

2011-07-07 Thread Anssi Saari
Mel mwil...@the-wire.com writes:

 def file_to_hash(path, m = hashlib.md5()):

 hashlib.md5 *is* called once; that is when the def statement is executed.

Very interesting, I certainly wasn't clear on this. So after that def,
the created hashlib object is in the module's scope and can be
accessed via file_to_hash.__defaults__[0].
-- 
http://mail.python.org/mailman/listinfo/python-list


blist question

2011-07-07 Thread dmitrey
hi all,
I feel lack of native Python lists operations (e.g. taking N greatest
elements with the involved key function and O(n) speed) and
occasionally found blist
http://pypi.python.org/pypi/blist/
Its entry says it is better than Python list. Did anyone ensure?
Will it ever be merged into Python source code?
D.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does hashlib support a file mode?

2011-07-07 Thread Paul Rudin
Anssi Saari a...@sci.fi writes:

 Mel mwil...@the-wire.com writes:

 def file_to_hash(path, m = hashlib.md5()):

 hashlib.md5 *is* called once; that is when the def statement is executed.

 Very interesting, I certainly wasn't clear on this. So after that def,
 the created hashlib object is in the module's scope and can be
 accessed via file_to_hash.__defaults__[0].

This also why you have to be a bit careful if you use e.g. [] or {} as a
default argument - if you then modify these things within the function
you might not end up with what you expect - it's the same list or
dictionary each time the function is called.  So to avoid that kind of
thing you end up with code like:

def foo(bar=None):
   if bar is None:
   bar = []
   ...

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


Re: find max and min values from a column of a csv file

2011-07-07 Thread Peter Otten
prakash jp wrote:

 Could any one help to get max and min values from a specified column of a
 csv file. The* csv file is large* and hence the below code did go bad.
 *Alternate
 methods would be highly appreciated
 **
 minimum.py*:
 import csv
 filename = testLog_4.csv
 f = open(filename)
 def col_min(mincname):
 with open(filename, 'rb') as f:
 reader = csv.reader(f, delimiter=,)
 #print reader
 #print mincname
 col_index = next(reader).index(mincname)
 #print col_index
 least = min(rec[col_index] for rec in reader)
 print least
 
 col_min(str(Server Latency))
 col_min(str(Client Latency))
 f.close()

I don't see a way to make this much faster as it is probably already i/o-
bound. You can try and calculate all four extrema at once, so you have to 
iterate over the file only once:



$ cat csv_minmax_chunked.py 
#!/usr/bin/env python   
import csv  
import locale   
from itertools import islice

def make_key(index, type):
def key(row): 
return type(row[index])
return key 

class Aggregator(object):
def __init__(self, name, index, type, key=None):
self.name = name
self.index = index  
self.type = type or float   
self.getvalue = make_key(index, type)   
self.key = {key: key} if key is not None else {}
def __repr__(self):   
return {0}(name={1}, index={2}, type={3}.format(
type(self).__name__, self.name, self.index, self.type)
def __str__(self):
try:  
return %s: %s...%s % (self.name, self.min, self.max)
except AttributeError:
return %s: (no values) % self.name  
def update(self, rows):   
values = map(self.getvalue, rows) 
chunkmin = min(values, **self.key)
chunkmax = max(values, **self.key)
try:  
curmin = self.min 
curmax = self.max 
except AttributeError:
self.min = chunkmin   
self.max = chunkmax   
else: 
self.min = min(curmin, chunkmin, **self.key)  
self.max = max(curmax, chunkmax, **self.key)  

def identity(s):
return s

convert = {
float: (float,),
int: (int,),
text: (lambda s: s, locale.strxfrm),
: (identity,)
}

def main():
locale.setlocale(locale.LC_ALL, )

import argparse
parser = argparse.ArgumentParser()
parser.add_argument(csvfile)
parser.add_argument(columns, nargs=+)
parser.add_argument(--chunksize, -s, type=int, default=2**12)
args = parser.parse_args()

ntpairs = (column.partition(:)[::2] for column in args.columns)
with open(args.csvfile, rb) as instream:
rows = csv.reader(instream)
header = dict((name, index) for index, name in 
enumerate(next(rows)))
aggregators = [
Aggregator(
{0}({1}).format(name, type or str),
header[name],
*convert[type])
for name, type in ntpairs]
chunksize = args.chunksize
while True:
chunk = list(islice(rows, chunksize))
if not chunk:
break
for agg in aggregators:
agg.update(chunk)
for agg in aggregators:
print agg

if __name__ == __main__:
main()
$ head sample.csv
alpha,beta,gamma,delta
69,-454,460960,ELIJAH
92,796,278885,SUFFICIENCY
42,895,934523,PIONEERED
88,-213,360633,reassert
63,-518,327010,mcmahon
84,604,540764,deprecatory
83,117,621832,VEGETARIANISM'S
61,411,844243,tan
29,-147,982043,plushest
$ ./csv_minmax_chunked.py sample.csv alpha:int beta:int beta gamma:float 
delta delta:text
alpha(int): 0...99
beta(int): -1000...999
beta(str): -1...999
gamma(float): 0.0...97.0
delta(str): AALIYAH...études
delta(text): a...ZYUGANOV'S


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


Re: TypeError: unbound method DefaultTracer() must be called with MyClass instance as first argument (got str instance instead)

2011-07-07 Thread Steven D'Aprano
Kannan Varadhan wrote:

 Hi Folks,
 
 Here is something I don't fully understand.
 
   1 def DefaultTracer(fmt, *args):
   2   fmt = 'in DefaultTracer ' + fmt
   3   print(fmt % args)
   4   pass
   5 def myTracer(fmt, *args):
   6   fmt = 'in myTracer ' + fmt
   7   print(fmt % args)

Please don't post code with line numbers. That makes it difficult to copy
and paste your function into an interactive session, so that we can run it
and see what it does.

[...]
 I want ClassDefaultTracer to store a reference to DefaultTracer and be
 used by instances of MyClass.  Why does line20 give me the following
 error:
 
 $ python foo.py
 in DefaultTracer Testing at first
 in myTracer Testing at first
 Traceback (most recent call last):
   File foo.py, line 20, in module
 MyClass().trace('Using ClassDefaultTracer')
   File foo.py, line 14, in trace
 self.InstanceTracer(fmt, *args)
 TypeError: unbound method DefaultTracer() must be called with MyClass
 instance as first argument (got str instance instead)

Unfortunately you've run into a side-effect of one of the very few Do What
I Mean aspects of Python: under many circumstances, storing a function in
a class automatically turns it into a method. This is almost always what
you want, but not this time.

Here's a simple example:

 def function(s):
... print s
...
 class C(object):
... func = function
... print func, type(func)
...
function function at 0xb7f892cc type 'function'
 print C.func, type(C.func)
unbound method C.function type 'instancemethod'

How to interpret this:

The class block is an executable statement which is executed at runtime.
During that execution, print func is called, and it sees func is an
actual function object.

After the block finishes executing, a class object (also called a type) is
created. This is where the DWIM behaviour happens: function attributes are
automatically turned into methods. That's normally what you want, but in
this case, it gives you the surprising result:

 C.func(hello world)
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: unbound method function() must be called with C instance as first
argument (got str instance instead)


Instead of calling it from the class C, you can call it from an instance:

 c = C()
 c.func(hello world)
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: function() takes exactly 1 argument (2 given)


Two arguments? What? Where's the second argument???

But wait: *bound* methods automatically get the instance as their first
argument. (When you define a method in the class, you write a function
with self as the first argument.) A bound method is one that is called
from an instance, not the class, and it gets the instance as first argument
automatically:

instance.method(args)  # a bound method

is translated by Python into:

theclass = type(instance)
theclass.method(instance, args)  # an unbound method

So if we do this, the method works:

 c.func()  # bound methods get the instance as first argument
__main__.C object at 0xb7f8fb6c



There are a couple of solutions to avoid this. One is to live with it:


def function(self, s):  # Define this as if it were a method.
print s

class C(object):
func = function


Now you can call:

instance = C()
# unbound method, you are responsible for supplying self
C.func(instance, arg)

# bound method, Python supplies self
instance.func(arg)


but of course now you can't call function(arg) from outside the class.

Another solution is to use a staticmethod:

def function(s):
print s

class C(object):
func = staticmethod(function)



A third is to disguise the function:

class C(object):
func = (function,)  # In a tuple

and then call C.func[0](arg)

but that's hideous. Don't do that.


Fourthly, the DWIM magic only happens when you store a function in the
*class*, not if you do it in the instance:


class C(object):
def __init__(self):
self.func = function


but now you can't call C.func because it doesn't exist, you have to
initialise an instance first.


 Alternately, how can I achieve what I want, i.e. a class-wide default
 used by all instances created off it, but
 itself be changeable, so that once changed, the changed default would
 be used by subsequent newer instances of that class.


class C(object):
default = staticmethod(function)
def __init__(self):
self.func = type(self).default


ought to do it.




-- 
Steven

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


Re: TypeError: unbound method DefaultTracer() must be called with MyClass instance as first argument (got str instance instead)

2011-07-07 Thread Paul Rudin
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes:


 Please don't post code with line numbers. That makes it difficult to copy
 and paste your function into an interactive session, so that we can run it
 and see what it does.

C-x r d

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


Re: Does hashlib support a file mode?

2011-07-07 Thread Andrew Berg
On 2011.07.06 06:16 PM, Steven D'Aprano wrote:
 Phlip wrote:

  Note the fix also avoids comparing to None, which, as usual, is also
  icky and less typesafe!

 Typesafe? Are you trying to make a joke?
Maybe he has a duck phobia. Maybe he denies the existence of ducks.
Maybe he doesn't like the sound of ducks. Maybe he just weighs the same
as a duck. In any case, duck tolerance is necessary to use Python
effectively.


On a side note, it turns out there's no word for the fear of ducks. The
closest phobia is anatidaephobia, which is the fear of being /watched/
by a duck.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: TypeError: unbound method DefaultTracer() must be called with MyClass instance as first argument (got str instance instead)

2011-07-07 Thread Peter Otten
Peter Otten wrote:

 or you wrap the callable in a descriptor:
 
 def DefaultTracer(*args): print args
 ...
 class D(object):
 ... def __init__(self, f):
 ... self.f = f
 ... def __get__(self, *args):
 ... return self.f
 ...

After skimming over Steven's post: use staticmethod.
No idea why I didn't think of that myself.

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


Re: Does hashlib support a file mode?

2011-07-07 Thread Phlip
 On 2011.07.06 06:16 PM, Steven D'Aprano wrote: Phlip wrote:

   Note the fix also avoids comparing to None, which, as usual, is also
   icky and less typesafe!

  Typesafe? Are you trying to make a joke?

No, I was pointing out that passing a type is more ... typesafe.

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


Re: Does hashlib support a file mode?

2011-07-07 Thread Andrew Berg
On 2011.07.07 08:11 AM, Phlip wrote:
 No, I was pointing out that passing a type is more ... typesafe.
None is a type.

 None.__class__
class 'NoneType'
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does hashlib support a file mode?

2011-07-07 Thread Phlip
On Jul 7, 6:24 am, Andrew Berg bahamutzero8...@gmail.com wrote:
 On 2011.07.07 08:11 AM, Phlip wrote: No, I was pointing out that passing a 
 type is more ... typesafe.

 None is a type.

I never said it wasn't.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does hashlib support a file mode?

2011-07-07 Thread Andrew Berg
On 2011.07.07 08:39 AM, Phlip wrote:
 On Jul 7, 6:24 am, Andrew Berg bahamutzero8...@gmail.com wrote:
  On 2011.07.07 08:11 AM, Phlip wrote: No, I was pointing out that passing a 
  type is more ... typesafe.
 
  None is a type.

 I never said it wasn't.
You are talking about this code, right?

def file_to_hash(path, m=None):
if m is None:
m = hashlib.md5()

What's not a type? The is operator compares types (m's value isn't the
only thing compared here; even an separate instance of the exact same
type would make it return False), and m can't be undefined.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Testing if a global is defined in a module

2011-07-07 Thread Grant Edwards
On 2011-07-06, Waldek M. wm@localhost.localdomain wrote:
 Dnia Wed, 06 Jul 2011 03:36:24 +1000, Steven D'Aprano napisa?(a):

 Because unless you are extremely disciplined, code and the comments
 describing them get out of sync. [...]

 True, but that gets far worse with external docs. Do you have in mind
 any better replacement?

You write code that's easy to read, and you provide the language with
introspection capabilities that allow you do do things like write a
program that will list the symbols exported by a module.

-- 
Grant Edwards   grant.b.edwardsYow! Now that I have my
  at   APPLE, I comprehend COST
  gmail.comACCOUNTING!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Tips/lessons learned for writing a Python powered DSL?

2011-07-07 Thread python
Looking for tips and lessons learned (advice on what to do and
not do) for writing a Python based DSL.

Googling python dsl yields some wonderful content which I've just
started to read. If there are specific articles or 3rd party
libraries that you used to implement a DSL, I would appreciate
hearing about them.

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


Re: Tips/lessons learned for writing a Python powered DSL?

2011-07-07 Thread Paul Woolcock
For me, diving into the data model really helped me grasp some of the
metaprogramming capabilities that python has, which is helping me as I am
implementing my own DSL in python.

http://docs.python.org/reference/datamodel.html

On Thu, Jul 7, 2011 at 10:20 AM, pyt...@bdurham.com wrote:

  Looking for tips and lessons learned (advice on what to do and not do) for
 writing a Python based DSL.

  Googling python dsl yields some wonderful content which I've just started
 to read. If there are specific articles or 3rd party libraries that you used
 to implement a DSL, I would appreciate hearing about them.

  Thank you,
  Malcolm


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




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


Question- Getting Windows 64bits information Python 32bits

2011-07-07 Thread António Rocha
Greetings

I'm running Python (32b) in Windows7 (at 64bits) and I would like to know
how can I check if my machine is a 32b or 64b in Python. Is it possible? I
saw a few examples (like platform) but they only provide information about
Python not the machine.
Thanks
Toze
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question- Getting Windows 64bits information Python 32bits

2011-07-07 Thread Andrew Berg
On 2011.07.07 10:21 AM, António Rocha wrote:
 I'm running Python (32b) in Windows7 (at 64bits) and I would like to
 know how can I check if my machine is a 32b or 64b in Python. Is it
 possible? I saw a few examples (like platform) but they only provide
 information about Python not the machine.
os.environ['processor_architecture']

os.environ is a dictionary of system environment variables. That exact
key probably only exists on Windows, but I'm there is a similar key on
other platforms.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Large number multiplication

2011-07-07 Thread Ian Kelly
On Thu, Jul 7, 2011 at 2:30 AM, Ulrich Eckhardt
ulrich.eckha...@dominolaser.com wrote:
 Even worse, most people would actually pay for its use, because they don't
 use numbers large enough to merit the Schönhage–Strassen algorithm.

As it stands, Karatsuba is only used for numbers greater than a
specific threshold.  Adding Schönhage–Strassen would just mean adding
another threshold, below which Karatsuba would still be used.  So at
worst it would just add another comparison or two for numbers within
the Karatsuba range.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Large number multiplication

2011-07-07 Thread Ian Kelly
On Thu, Jul 7, 2011 at 9:49 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
 On Thu, Jul 7, 2011 at 2:30 AM, Ulrich Eckhardt
 ulrich.eckha...@dominolaser.com wrote:
 Even worse, most people would actually pay for its use, because they don't
 use numbers large enough to merit the Schönhage–Strassen algorithm.

 As it stands, Karatsuba is only used for numbers greater than a
 specific threshold.  Adding Schönhage–Strassen would just mean adding
 another threshold, below which Karatsuba would still be used.  So at
 worst it would just add another comparison or two for numbers within
 the Karatsuba range.

And I just realized that you said as much yourself further down in
your message.  My apologies for the needless lecturing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Implicit initialization is EXCELLENT

2011-07-07 Thread Ian Kelly
On Thu, Jul 7, 2011 at 1:12 AM, Ulrich Eckhardt
ulrich.eckha...@dominolaser.com wrote:
 Just guessing, is it legacy, C-with-classes code rather than C++ code
 perhaps? Haven't looked at wx for a while. Such code typically lacks
 understanding of exceptions, which are the only way to signal failure
 from e.g. constructors.

 No, wx is C++ through and through.

 No namespaces. No templates but macros. No exceptions. No C++.

 Sorry, I beg to differ. BTW, they say themselves that they tolerate but not
 use exceptions, so they actually need two-stage construction if construction
 can fail, and for exactly the guessed legacy reasons.

Ah, I think I misunderstood your meaning.  By C-with-classes I
thought you were referring to the practice of OOP in C, and my
response was to the effect that building wx requires a C++ compiler,
not just a C compiler.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Large number multiplication

2011-07-07 Thread Parerga

Hi,


Billy Mays wrote:
 
 On 07/06/2011 04:02 PM, Ian Kelly wrote:
  On Wed, Jul 6, 2011 at 1:30 PM, Billy Maysno...@nohow.com  wrote:
  I was looking through the python source and noticed that long
 multiplication
  is done using the Karatsuba method (O(~n^1.5)) rather than using FFTs
 O(~n
  log n).  I was wondering if there was a reason the Karatsuba method
 was
  chosen over the FFT convolution method?
 
 The reason I ask is because convolution has a better (best ?) complexity 
 

Better complexity, yes. This means smaller execution time for LARGE ENOUGH
operands


Billy Mays wrote:
 
 I was more interested in finding previous discussion (if any) on why 
 Karatsuba was chosen, not so much as trying to alter the current 
 multiplication implementation.
 

I'm not a python developer, but I worked on multiplication algorithms for
GMP  [ http://gmplib.org/ ], and I can guess the answer:
 - Karatsuba is (by far) simpler to implement,
 - FFT-based multiplication is (by far) slower than Karatsuba for numbers
that are not huge.
I try to attach a small graph 
http://old.nabble.com/file/p32014454/karaVSfft.pdf karaVSfft.pdf , with
timings for multiplications of n-bits operands (with GMP, on my very old
laptop) with Toom(2,2) (it's Karatsuba!) and the FFT-based computation. The
first is faster than the latter up to 1 bits (GMP uses some Toom for
that size, to get the result even faster).

Regards,
Marco

--
http://bodrato.it/software/toom.html
-- 
View this message in context: 
http://old.nabble.com/Large-number-multiplication-tp32007815p32014454.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Re: Question- Getting Windows 64bits information Python 32bits

2011-07-07 Thread Philip Reynolds
On Thu, 07 Jul 2011, Andrew Berg wrote:

 On 2011.07.07 10:21 AM, António Rocha wrote:
  I'm running Python (32b) in Windows7 (at 64bits) and I would like to
  know how can I check if my machine is a 32b or 64b in Python. Is it
  possible? I saw a few examples (like platform) but they only provide
  information about Python not the machine.
 os.environ['processor_architecture']
 
 os.environ is a dictionary of system environment variables. That exact
 key probably only exists on Windows, but I'm there is a similar key on
 other platforms.

$ python -c 'import platform; print platform.architecture()'
('64bit', 'ELF')

  http://docs.python.org/library/platform.html

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


Re: Question- Getting Windows 64bits information Python 32bits

2011-07-07 Thread Robert Kern

On 7/7/11 11:33 AM, Philip Reynolds wrote:

On Thu, 07 Jul 2011, Andrew Berg wrote:


On 2011.07.07 10:21 AM, António Rocha wrote:

I'm running Python (32b) in Windows7 (at 64bits) and I would like to
know how can I check if my machine is a 32b or 64b in Python. Is it
possible? I saw a few examples (like platform) but they only provide
information about Python not the machine.

os.environ['processor_architecture']

os.environ is a dictionary of system environment variables. That exact
key probably only exists on Windows, but I'm there is a similar key on
other platforms.


$ python -c 'import platform; print platform.architecture()'
('64bit', 'ELF')

   http://docs.python.org/library/platform.html


This is not what the OP is looking for. The OP wants to know what the CPU and OS 
are capable of, not what the Python executable is compiled for. 
platform.architecture() gives the latter.


--
Robert Kern

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

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


Re: blist question

2011-07-07 Thread Daniel Stutzbach
On Thu, Jul 7, 2011 at 5:08 AM, dmitrey dmitre...@gmail.com wrote:

 I feel lack of native Python lists operations (e.g. taking N greatest
 elements with the involved key function and O(n) speed) and
 occasionally found blist
 http://pypi.python.org/pypi/blist/



 Its entry says it is better than Python list. Did anyone ensure?


It has better performance for many operations.  I made a very detailed
performance comparison here (against Python 3.1):
http://stutzbachenterprises.com/performance-blist

Undoubtedly, you can find sequences of operations where Python's built-in
list type has better performance by a constant factor.  Python's built-in
list type is more memory-efficient for small lists (blist's memory usage for
small lists could be improved to be similar, but I haven't gotten around to
making the necessary changes.)


 Will it ever be merged into Python source code?


Seems unlikely.

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


Re: Question- Getting Windows 64bits information Python 32bits

2011-07-07 Thread Brian Curtin
2011/7/7 António Rocha toyze.ro...@gmail.com

 Greetings

 I'm running Python (32b) in Windows7 (at 64bits) and I would like to know
 how can I check if my machine is a 32b or 64b in Python. Is it possible? I
 saw a few examples (like platform) but they only provide information about
 Python not the machine.
 Thanks
 Toze


Running CPython compiled for 32-bit on a Windows 7 64-bit machine gives the
following:

 platform.architecture()
('32bit', 'WindowsPE')
 platform.machine()
'AMD64'

This didn't used to be the case - it was corrected in
http://bugs.python.org/issue7860 so you may need to upgrade to get accurate
information if you have an older Python installed.
-- 
http://mail.python.org/mailman/listinfo/python-list


Programming tips :-)

2011-07-07 Thread Martin Schöön
I just found the following url in my archives at work and
thought you might enjoy it:
http://thc.org/root/phun/unmaintain.html

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


Re: module problem on windows 64bit

2011-07-07 Thread miamia
On Jul 5, 5:05 pm, Thomas Jollans t...@jollybox.de wrote:
 On 06/27/2011 06:59 PM, miamia wrote:

  Hello,

  on 32-bit windows everything works ok but on 64-bit win I am getting
  this error:
  Traceback (most recent call last):
    File app.py, line 1040, in do_this_now
    File kinterbasdb\__init__.pyc, line 119, in module
    File kinterbasdb\_kinterbasdb.pyc, line 12, in module
    File kinterbasdb\_kinterbasdb.pyc, line 10, in __load
  ImportError: DLL load failed: This application has failed to start
  because the application configuration is incorrect. Reinstalling the
  application may fix this problem.

  How to get it work on 64bit windows as well? many thanks

 A process can only link to a shared library compiled for the same
 architecture as the process. In layman's terms: A 32-bit DLL won't work
 with a 64-bit program. It looks like this package is attempting to load
 a 32-bit DLL. That's not going to work. Either procure a 64-bit version
 of the DLL, or use a 32-bit version of Python.

hello, it looks lite I solved it with files msvcp80.dll,
Microsoft.VC80.CRT.manifest. I forgot to extract these files from
firebird embedded pachage to my app folder. now it seems to be ok on
both systems 32 and 64bit (so It wasn't 64bit issue as I thought).
thank you
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: blist question

2011-07-07 Thread Miki Tebeka
Have you looked at 
http://docs.python.org/library/collections.html#collections.deque ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Implicit initialization is EVIL!

2011-07-07 Thread rantingrick
On Jul 7, 12:34 am, Gregory Ewing greg.ew...@canterbury.ac.nz wrote:
 rantingrick wrote:
  Yes but what benefit does that gain over say, Tkinter's design
  (because that has been your argument).

 Like I said, it's a tangential issue.

Agreed.

 The important thing is that it's okay for an app to stay
 alive until its *last* top level window is closed.

So your argument is:
 A window hierarchy is bad because if your application requires
a user to open a gazillion windows (read as: designed poorly) --each
representing completely different transactions-- and if you close the
original window all the other windows will close too. Boo :(

continuing...
 There
 doesn't have to be a special main window that kills the
 whole app when you close it.

So you prefer to close a gazillion windows one by one? If so, why not
just code the GUI correctly from the start; by creating separate
transactions? Thereby reducing the number of windows a user must
juggle? FYI: You know the user complexity of a GUI increases
exponentially by the number of windows present.

 However, I think what the original complaint was really
 about is that when you create a non-toplevel widget in Tkinter
 you have to specify its parent (and if you don't, it assumes
 you want it to be a child of the main window).

Thats was MY complaint yes. On the grounds that widgets require
windows NOT windows require widgets. This fact will confuse folks.

 You can't
 create the widget first and specify its parent later.

 This is another API flaw that is seen distressingly often
 in GUI libraries. It's a nuisance, because it means you can't
 write code that creates a widget hierarchy bottom-up.

Actually you can! Stay tuned for enlightenment!

 For
 example, in PyGUI you can write things like

    dialog_contents = Column([
      Label(Caution: Your underpants are on fire.),
      Row([Button(OK), Button(Cancel)])
    ])

 There's no way you could write Row and Column functions for
 Tkinter that work like that -- they would have to take parent
 widgets as arguments, and you wouldn't be able to nest the
 calls.

WRONG! A function or class structure can handle this just fine. And
lends itself nicely to GUI programming.

## START CODE ##
import Tkinter as tk

class DumbDialog(tk.Toplevel):
def __init__(self, master, **kw):
w=tk.Label(master, text=Caution: Your underpants are on
fire.)
w.pack()
w=tk.Button(master, text=OK).pack()
w=tk.Button(master, text=Cancel).pack()

print 'start script'
root = tk.Tk()
d = DumbDialog(root)
root.mainloop()

print 'continue script'
root = tk.Tk()
d = DumbDialog(root)
root.mainloop()

print 'end script'
## END CODE ##

*school bell rings*
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Large number multiplication

2011-07-07 Thread casevh
On Jul 7, 1:30 am, Ulrich Eckhardt ulrich.eckha...@dominolaser.com
wrote:
 Billy Mays wrote:
  On 07/06/2011 04:02 PM, Ian Kelly wrote:
  According to Wikipedia:

  
  In practice the Schönhage–Strassen algorithm starts to outperform
  older methods such as Karatsuba and Toom–Cook multiplication for
  numbers beyond 2**2**15 to 2**2**17 (10,000 to 40,000 decimal digits).
  

  I think most Python users are probably not working with numbers that
  large, and if they are, they are probably using specialized numerical
  libraries anyway, so there would be little benefit in implementing it
  in core.

  You are right that not many people would gain significant use of it.

 Even worse, most people would actually pay for its use, because they don't
 use numbers large enough to merit the Schönhage–Strassen algorithm.

  The reason I ask is because convolution has a better (best ?) complexity
  class than the current multiplication algorithm.

 The asymptotic complexity of algorithms (I guess that's what you mean) is
 concerned with large up to infinite n elements in operations. The claim
 there always excludes any number of elements below n_0, where the complexity
 might be different, even though that is usually not repeatedly mentioned. In
 other words, lower complexity does not mean that something runs faster, only
 that for large enough n it runs faster. If you never realistically reach
 that limit, you can't reap those benefits.

 That said, I'm sure that the developers would accept a patch that switches
 to a different algorithm if the numbers get large enough. I believe it
 already doesn't use Karatsuba for small numbers that fit into registers,
 too.

  I was more interested in finding previous discussion (if any) on why
  Karatsuba was chosen, not so much as trying to alter the current
  multiplication implementation.

 I would hope that such design decisions are documented in code or at least
 referenced from there. Otherwise the code is impossible to understand and
 argue about.

 Cheers!

 Uli

 --
 Domino Laser GmbH
 Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932- Hide 
 quoted text -

 - Show quoted text -

A quick search on the Python issue tracker (bugs.python.org) yields
the following issues:

http://bugs.python.org/issue560379

http://bugs.python.org/issue4258

The issues also refer to discussion threads on the python-dev mailing
list.

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


making socket.getaddrinfo use cached dns

2011-07-07 Thread high bandwidth
I use cached dns lookups with pdnsd on my ubuntu machine to speed up web
access as regular lookups can take 15-30 seconds. However, python's
mechanize and urllib etc use socket.getaddrinfo, which seems not to be using
dns cacheing or taking a long time because of ipv6 lookups. In either case,
I subsequent access to the same site to be fast and not require lengthy
calls to getaddrinfo. How can I get python to correctly use cached dns
lookups and ipv4 only (at least in those cases where it is appropriate).

As mentioned here:
http://stackoverflow.com/questions/2014534/force-python-mechanize-urllib2-to-only-use-a-requests/2035686#2035686
It seems that many python libraries are hardcoded to look for both ipv6 and
ipv4. Since ipv6 lookups are extremely slow at least for some users, perhaps
the devs should carry over these optional arguments to higher level
libraries like mechanize, urllib, httplib etc.
-- 
http://mail.python.org/mailman/listinfo/python-list


i get different answers based on run platform

2011-07-07 Thread linda
I have this simple palindrome program that yields different results
depending on whether I run it from Windows or from IDLE.  The answer
is correct off IDLE, but why is this the case?  Here's the code:

def reverse(text):
return text[::-1]
def is_palindrome(text):
return text==reverse(text)
while True:
something=input('enter text:')
print(something)
print(something[::-1])
if (is_palindrome(something)):
print(yes, it is a palindrome)
break
else:
print(no, it is not a palindrome)
continue
print ('done')

Thanks for your help.

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


Re: Implicit initialization is EVIL!

2011-07-07 Thread Chris Angelico
On Fri, Jul 8, 2011 at 3:29 AM, rantingrick rantingr...@gmail.com wrote:
 So your argument is:
     A window hierarchy is bad because if your application requires
 a user to open a gazillion windows (read as: designed poorly) --each
 representing completely different transactions-- and if you close the
 original window all the other windows will close too. Boo :(

Why should opening multiple windows AUTOMATICALLY equate to poor design?

 So you prefer to close a gazillion windows one by one? If so, why not
 just code the GUI correctly from the start; by creating separate
 transactions? Thereby reducing the number of windows a user must
 juggle? FYI: You know the user complexity of a GUI increases
 exponentially by the number of windows present.

By separate transactions do you mean that the user can
simultaneously perform multiple actions? Because that's best done with
multiple separate interfaces - such as, multiple windows. Or do you
really mean sequential transactions? That would not in any way be
good design.


 For
 example, in PyGUI you can write things like

    dialog_contents = Column([
      Label(Caution: Your underpants are on fire.),
      Row([Button(OK), Button(Cancel)])
    ])

 WRONG! A function or class structure can handle this just fine. And
 lends itself nicely to GUI programming.

You have to break your code into two pieces. Here's an alternative way
of laying out a dialog, this taken from Pike-GTK2:


mainwindow-add(GTK2.Vbox(0,0)-add(GTK2.HbuttonBox()-add(button(E_xit,window_destroy)-set_use_underline(1))-add(button(Set,setprops))-set_layout(GTK2.BUTTONBOX_SPREAD)))-show_all();

This program uses utility functions such as:

//Helper function to create a button and give it an event. Useful
because signal_connect doesn't return self.
GTK2.Button button(mixed content,function clickevent,mixed|void arg)
{
GTK2.Button ret=GTK2.Button(content);
ret-signal_connect(clicked,clickevent,arg);
return ret;
}

I make no apologies for the braces in the code :)

The 'button' function creates a button and assigns it an event. At
this stage, the button has no parent; it won't be drawn anywhere. The
GTK2.Button object is returned, and then added. It's added to the
HbuttonBox which is then added to the Vbox which is only then added to
the main window; although the code would work just fine if done in the
other order. It's important here that objects are simply objects -
they don't have to be built in a tree structure; and the window's
layout is entirely in the one place, I don't have to put half of it
into the window's constructor.

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


Re: making socket.getaddrinfo use cached dns

2011-07-07 Thread Chris Angelico
On Fri, Jul 8, 2011 at 4:18 AM, high bandwidth widebandwi...@gmail.com wrote:
 I use cached dns lookups with pdnsd on my ubuntu machine to speed up web
 access as regular lookups can take 15-30 seconds. However, python's
 mechanize and urllib etc use socket.getaddrinfo, which seems not to be using
 dns cacheing or taking a long time because of ipv6 lookups. In either case,
 I subsequent access to the same site to be fast and not require lengthy
 calls to getaddrinfo. How can I get python to correctly use cached dns
 lookups and ipv4 only (at least in those cases where it is appropriate).

One solution would be to do your own DNS lookups and then pass urllib
an IP address. Is pdnsd set up to be your computer's primary resolver?
(Is /etc/resolv.conf pointing to localhost?) If not, that might help.
I've generally done my DNS caching using BIND, so I can't help with
pdnsd specifically.

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


Re: Programming tips :-)

2011-07-07 Thread Andrew Berg
On 2011.07.07 12:22 PM, Martin Schöön wrote:
 I just found the following url in my archives at work and
 thought you might enjoy it:
 http://thc.org/root/phun/unmaintain.html
That's awesome.

 If a maintenance programmer can't quote entire Monty Python movies
 from memory, he or she has *no* business being a programmer. 
:-D
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: i get different answers based on run platform

2011-07-07 Thread John Gordon
In 842fce9d-1b3f-434a-b748-a6dc4828c...@h12g2000pro.googlegroups.com linda 
posts...@gmail.com writes:

 I have this simple palindrome program that yields different results
 depending on whether I run it from Windows or from IDLE.  The answer
 is correct off IDLE, but why is this the case?  Here's the code:

Your code contains debugging statements that print the value of the normal
string and the reversed string.  What do those statements print when you
run your program under Windows?  That should go a long way towards telling
you what the problem is.

(Perhaps Windows leaves a linefeed character hanging at the end of the
input line, which upsets the palindromic balance?)

By the way, I could not make your program work as you provided it; I had
to replace input() with raw_input().  Does it really work for you this way?

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

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


Re: i get different answers based on run platform

2011-07-07 Thread Ethan Furman

linda wrote:

I have this simple palindrome program that yields different results
depending on whether I run it from Windows or from IDLE.  The answer
is correct off IDLE, but why is this the case?  Here's the code:

def reverse(text):
return text[::-1]
def is_palindrome(text):
return text==reverse(text)
while True:
something=input('enter text:')


try changing this to:
  something = input('enter text:').rstrip('\n')


print(something)
print(something[::-1])
if (is_palindrome(something)):
print(yes, it is a palindrome)
break
else:
print(no, it is not a palindrome)
continue
print ('done')


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


Re: i get different answers based on run platform

2011-07-07 Thread MRAB

On 07/07/2011 19:18, linda wrote:

I have this simple palindrome program that yields different results
depending on whether I run it from Windows or from IDLE.  The answer
is correct off IDLE, but why is this the case?  Here's the code:

def reverse(text):
 return text[::-1]
def is_palindrome(text):
 return text==reverse(text)
while True:
 something=input('enter text:')
 print(something)
 print(something[::-1])
 if (is_palindrome(something)):
 print(yes, it is a palindrome)
 break
 else:
 print(no, it is not a palindrome)
 continue
print ('done')

Thanks for your help.


Try printing ascii(something) too.

There's a known bug in Python 3.2 where it leaves a training '\r', if
that's what you're using (http://bugs.python.org/issue12435), fixed in
Python 3.2.1.
--
http://mail.python.org/mailman/listinfo/python-list


Re: i get different answers based on run platform

2011-07-07 Thread Ethan Furman

John Gordon wrote:

By the way, I could not make your program work as you provided it; I had
to replace input() with raw_input().  Does it really work for you this way?


input() is the 3.x name for raw_input()

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


Re: i get different answers based on run platform

2011-07-07 Thread MRAB

On 07/07/2011 19:37, John Gordon wrote:

In842fce9d-1b3f-434a-b748-a6dc4828c...@h12g2000pro.googlegroups.com  
lindaposts...@gmail.com  writes:


I have this simple palindrome program that yields different results
depending on whether I run it from Windows or from IDLE.  The answer
is correct off IDLE, but why is this the case?  Here's the code:


Your code contains debugging statements that print the value of the normal
string and the reversed string.  What do those statements print when you
run your program under Windows?  That should go a long way towards telling
you what the problem is.

(Perhaps Windows leaves a linefeed character hanging at the end of the
input line, which upsets the palindromic balance?)

By the way, I could not make your program work as you provided it; I had
to replace input() with raw_input().  Does it really work for you this way?


It's Python 3.

Python 2's raw_input() has been renamed input() in Python 3 and Python
2's input() was never in Python 3 because it uses eval on the string,
which usually undesirable.
--
http://mail.python.org/mailman/listinfo/python-list


Serial reset of the device

2011-07-07 Thread yorick
Hello,

I'm trying to access a hardware board of my company through a serial
connection using a Python script and the pyserial module.

I use Python 2.7.1 with Ubuntu 11.04 (pyserial is the package python-
serial with version 2.5.2, http://pyserial.sourceforge.net/pyserial_api.html).

The board to which I'm trying to connect works correctly with serial
as some other guys did some TCL scripts to manage it.
My problem is that every time I open a new connection, the device is
reset. I'd like to not have the device reset.

The code is the following :

handler = serial.Serial(port=self.portname, baudrate=9600,
bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stHello,

I'm trying to access a hardware board of my company through a serial
connection using a Python script and the pyserial module.

I use Python 2.7.1 with Ubuntu 11.04 (pyserial is the package python-
serial with version 2.5.2, http://pyserial.sourceforge.net/pyserial_api.html).

The board to which I'm trying to connect works correctly with serial
as some other guys did some TCL scripts to manage it.
My problem is that every time I open a new connection, the device is
reset. I'd like to not have the device reset.

The code is the following :

handler = serial.Serial(port=self.portname, baudrate=9600,
bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE, timeout=None, dsrdtr=False)
# here the device is reset ...

handler.close()


I found the following post 
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1274205532
but I haven't tested it yet as I don't like the idea to change files
managed by the system (and it is for Windows).

Is there any possibility to not reset the device when opening the
connection ?

Thanks,
Yorickopbits=serial.STOPBITS_ONE, timeout=None, dsrdtr=False)
# here the device is reset ...

handler.close()


I found the following post 
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1274205532
but I haven't tested it yet as I don't like the idea to change files
managed by the system (and it is for Windows).

Is there any possibility to not reset the device when opening the
connection ?

Thanks,
Yorick
-- 
http://mail.python.org/mailman/listinfo/python-list


multiprocessing.Manager().Namespace() and data copying

2011-07-07 Thread ichi
Hi!
I'm trying to share data between processes using
multiprocessing.Manager and 
creating shared Namespace. I have the following code:


from multiprocessing import Manager
from scipy import rand

x = rand(5000, 5000)

m = Manager()
n = m.Namespace()
n.x = x  

It seems that at n.x = x data is serialized and copied. It seems it is
also 
serialized and copied at x = n.x. Is there a way to omit this to have
really 
shared objects with Namespace? I need read only objects (not
necessarily 
arrays)...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: i get different answers based on run platform

2011-07-07 Thread linda
I tried something = input('enter text:').rstrip('\n') as suggested but
the problem persists.  BTW, the intermediate print commands agree and
so are not an issue.  The disagreement is in IDLE correctly
identifying palindromes and Windows not.  I do suspect it may be a
trailing '\r' issue.  Is there an easy fix or shall I wait for the new
Python versions to be released?  Thanks for helping.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: i get different answers based on run platform

2011-07-07 Thread Ethan Furman

linda wrote:

I tried something = input('enter text:').rstrip('\n') as suggested but
the problem persists.  BTW, the intermediate print commands agree and
so are not an issue.  The disagreement is in IDLE correctly
identifying palindromes and Windows not.  I do suspect it may be a
trailing '\r' issue.  Is there an easy fix or shall I wait for the new
Python versions to be released?  Thanks for helping.


My apologies -- change the '\n' to '\r' and that will hopefully do the 
trick.


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


Re: i get different answers based on run platform

2011-07-07 Thread linda
On Jul 7, 2:42 pm, Ethan Furman et...@stoneleaf.us wrote:
 linda wrote:
  I tried something = input('enter text:').rstrip('\n') as suggested but
  the problem persists.  BTW, the intermediate print commands agree and
  so are not an issue.  The disagreement is in IDLE correctly
  identifying palindromes and Windows not.  I do suspect it may be a
  trailing '\r' issue.  Is there an easy fix or shall I wait for the new
  Python versions to be released?  Thanks for helping.

 My apologies -- change the '\n' to '\r' and that will hopefully do the
 trick.

 ~Ethan~

Thanks Ethan--that did work :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: blist question

2011-07-07 Thread Raymond Hettinger
On Jul 7, 5:08 am, dmitrey dmitre...@gmail.com wrote:
 hi all,
 I feel lack of native Python lists operations (e.g. taking N greatest
 elements with the involved key function and O(n) speed)

Take a look at heapq.nlargest()...


 and
 occasionally found blisthttp://pypi.python.org/pypi/blist/
 Its entry says it is better than Python list.

It should say:  better in some respects and worse in others

Do you honestly think that python's list implementation
as a simple array of pointers can be beaten in every
category of performance?


 Did anyone ensure?
 Will it ever be merged into Python source code?

It was rejected as a replacement for the existing list implementation.
There is some chance it will get accepted into the collections module
someday.


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


Re: Testing if a global is defined in a module

2011-07-07 Thread Chris Rebert
On Thu, Jul 7, 2011 at 7:18 AM, Grant Edwards invalid@invalid.invalid wrote:
 On 2011-07-06, Waldek M. wm@localhost.localdomain wrote:
 Dnia Wed, 06 Jul 2011 03:36:24 +1000, Steven D'Aprano napisa?(a):

 Because unless you are extremely disciplined, code and the comments
 describing them get out of sync. [...]

 True, but that gets far worse with external docs. Do you have in mind
 any better replacement?

 You write code that's easy to read

Reminded me of this excellent presentation:

Uncomment Your Code
https://docs.google.com/present/view?id=ah82mvnssv5d_162dbgx78gw

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


Re: Implicit initialization is EVIL!

2011-07-07 Thread Steven D'Aprano
rantingrick wrote:

 On Jul 7, 12:34 am, Gregory Ewing greg.ew...@canterbury.ac.nz wrote:

 The important thing is that it's okay for an app to stay
 alive until its *last* top level window is closed.

I partially disagree with Greg on this. This is not the only model: on the
Apple Mac, or any system with a similar GUI design, the application can
survive having the last window closed. There are other application types
that don't need any window at all. So while it is common for closing the
last window to exit the application, it is not a necessary requirement.


 
 There
 doesn't have to be a special main window that kills the
 whole app when you close it.
 
 So you prefer to close a gazillion windows one by one? 

Nonsense. Greg says nothing of the sort.

Avoiding the anti-pattern close a gazillion windows one by one is why you
have an application-wide Quit or Exit command, as opposed to a Close
command which applies only to the current window.


 If so, why not 
 just code the GUI correctly from the start; by creating separate
 transactions? Thereby reducing the number of windows a user must
 juggle? FYI: You know the user complexity of a GUI increases
 exponentially by the number of windows present.

Don't assume that there is a one-to-one relationship between transactions
(documents?) and windows. The relationship is actually many-to-many:
windows can contain tabbed or notepad interfaces, or can be split into
multiple panes, or both. Panes and tabs can be split into independent
windows, or rejoined into one main window.

E.g. I can have six Firefox windows open, each one with many different
websites open in separate tabs. I have Close Tab, Close Window and Exit
Firefox commands.

In Konquorer, not only can I have multiple windows and multiple tabs, but I
can split each tab into two or more panes, and display two views of the
same document in the same tab, or two different documents in the one tab.
This is especially useful when using it as a file manager.

In older versions of Word (and possibly current, although I haven't tested
it) you can open files multiple times. Each time opens in a new window,
representing a new view of the one file. Edits in one window update all the
others. This can be useful for, e.g. making edits to page 3 while
simultaneously viewing page 303. An alternate UI for to split the one
window into two panes, and scroll them independently. So a single file may
have one or two panes, in one or more windows.

So, you can have multiple documents in multiple windows, and there is no 1:1
relationship between them.



-- 
Steven

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


Re: Does hashlib support a file mode?

2011-07-07 Thread Steven D'Aprano
Andrew Berg wrote:

 On 2011.07.07 08:39 AM, Phlip wrote:
 On Jul 7, 6:24 am, Andrew Berg bahamutzero8...@gmail.com wrote:
  On 2011.07.07 08:11 AM, Phlip wrote: No, I was pointing out that
  passing a type is more ... typesafe.
 
  None is a type.

 I never said it wasn't.

Unfortunately, it isn't.

None is not a type, it is an instance.

 isinstance(None, type)  # is None a type?
False
 isinstance(None, type(None))  # is None an instance of None's type?
True

So None is not itself a type, although it *has* a type:

 type(None)
type 'NoneType'
 isinstance(type(None), type)  # is NoneType itself a type?
True


 You are talking about this code, right?
 
 def file_to_hash(path, m=None):
 if m is None:
 m = hashlib.md5()
 
 What's not a type? The is operator compares types (m's value isn't the
 only thing compared here; even an separate instance of the exact same
 type would make it return False), and m can't be undefined.

The is operator does not compare types, it compares instances for identity.
There is no need for is to ever care about the type of the arguments --
that's just a waste of time, since a fast identity (memory location) test
is sufficient.

This is why I initially thought that Phlip was joking when he suggested
that m is None could be type-unsafe. It doesn't matter what type m
has, m is anything will always be perfectly safe. 




-- 
Steven

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


Re: Implicit initialization is EVIL!

2011-07-07 Thread Gregory Ewing

rantingrick wrote:


So you prefer to close a gazillion windows one by one?


If I want to close all the windows, I can use the application's
Quit or Exit command, or whatever the platform calls it.

(Note that if there is a separate instance of the application
for each window -- as was suggested earlier -- then you don't
have that option, and you have to close them one by one
anyway.)


There's no way you could write Row and Column functions for
Tkinter that work like that -- they would have to take parent
widgets as arguments, and you wouldn't be able to nest the
calls.


WRONG! A function or class structure can handle this just fine.

class DumbDialog(tk.Toplevel):
def __init__(self, master, **kw):
w=tk.Label(master, text=Caution: Your underpants are on
fire.)
w.pack()
w=tk.Button(master, text=OK).pack()
w=tk.Button(master, text=Cancel).pack()


Which is *exactly* what I said you would have to do in
Tkinter! Each widget creation requires a separate statement,
with the parent passed in at each step. This is nowhere
near as convenient as the nested function call style.

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


Re: Does hashlib support a file mode?

2011-07-07 Thread Andrew Berg
On 2011.07.07 08:46 PM, Steven D'Aprano wrote:
 None is not a type, it is an instance.

  isinstance(None, type)  # is None a type?
 False
  isinstance(None, type(None))  # is None an instance of None's type?
 True

 So None is not itself a type, although it *has* a type:

  type(None)
 type 'NoneType'
  isinstance(type(None), type)  # is NoneType itself a type?
 True
I worded that poorly. None is (AFAIK) the only instance of NoneType, but
I should've clarified the difference.
 The is operator does not compare types, it compares instances for identity.
 There is no need for is to ever care about the type of the arguments --
 that's just a waste of time, since a fast identity (memory location) test
 is sufficient.
Compare was the wrong word. I figured the interpreter doesn't
explicitly compare types, but obviously identical instances are going to
be of the same type.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Programming tips :-)

2011-07-07 Thread Phlip
On Jul 7, 11:36 am, Andrew Berg bahamutzero8...@gmail.com wrote:
 On 2011.07.07 12:22 PM, Martin Schöön wrote: I just found the following url 
 in my archives at work and
  thought you might enjoy it:

 http://thc.org/root/phun/unmaintain.html

 That's awesome.

That's How To Write Unmaintainable Code - a venerable classic.

Compare these:

http://c2.com/cgi/wiki?HowToPissOffYourPair

http://c2.com/cgi/wiki?HelpSourceForgeSuck
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does hashlib support a file mode?

2011-07-07 Thread Phlip
 I worded that poorly. None is (AFAIK) the only instance of NoneType, but
 I should've clarified the difference. The is operator does not compare 
 types, it compares instances for identity.

None is typesafe, because it's strongly typed.

However, what's even MORE X-safe (for various values of X) is a method
that takes LESS for its arguments. That's why I switched from passing
an object to passing a type, because the more restrictive argument
type is more typesafe.

However, the MOST X-safe version so far simply passes a string, and
uses hashlib the way it designs to be used:

def file_to_hash(path, hash_type):

hash = hashlib.new(hash_type)

with open(path, 'rb') as f:

while True:
s = f.read(8192)
if not s:  break
hash.update(s)

return hash.hexdigest()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Serial reset of the device

2011-07-07 Thread Dan Stromberg
On Thu, Jul 7, 2011 at 12:34 PM, yorick yorick.bru...@gmail.com wrote:

 Hello,

 I'm trying to access a hardware board of my company through a serial
 connection using a Python script and the pyserial module.

 I use Python 2.7.1 with Ubuntu 11.04 (pyserial is the package python-
 serial with version 2.5.2,
 http://pyserial.sourceforge.net/pyserial_api.html).

 The board to which I'm trying to connect works correctly with serial
 as some other guys did some TCL scripts to manage it.
 My problem is that every time I open a new connection, the device is
 reset. I'd like to not have the device 
 reset.http://mail.python.org/mailman/listinfo/python-list


A few suggestions:

1) You could try strace'ing the TCL, and then strace'ing the Python, and
comparing - especially if you're comfortable with low-level I/O in C, but
not only.  Hunt for the open() call to the relevant device file, and other
system calls near it.  Even if you aren't that cozy with C, you could try
putting the strace results on a website or ftp server, and posting links to
them here.

2) Check and double check and triple check your line discipline parameters:
bits per second, parity, word size, start/stop bits.

3) It's also possible the cable is bad (or merely inappropriate), especially
if the TCL is accessing such a device over a different cable.  There is no
one true serial (RS-232) cable standard - RS-232 is a rather large
collection of ways of doing communications, and they are frequently not
compatible with one another.

4) One of the more likely causes of a reset of a device that is accessed
serially, is sending it a break signal.  There are official ways of sending
a break, and accidental ways.  Sometimes the two boil down to the same thing
behind the scenes, but look very different in the code.  A break signal is a
longish sequence of unframed 0 bits (IE, with no start/stop bits separating
one byte from another).  An accidental way of sending a break, is to set
your bits per second too low, and then sending a 0 byte - because those 8 0
bits at the too-low speed will look like a long series of unframed 0's from
the perspective of the reader process that's running at the correct speed.
So I guess the gist of point #4 (this point), is make sure your bps is set
correctly and check the device doc to see if a break signal causes a
reset

5) If the protocol layered over the serial communication is ASCII-based, you
could try connecting to the device using something like minicom, to make
sure the device is behaving as expected.  If the device is speaking a binary
protocol, this is unlikely to help much

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


Hello Sweet Friends.

2011-07-07 Thread Ashraf Ali
I bring you a source of entertaintment.Just visit the following link
and know about Bollywood actresses
www.bollywoodactresseshotpictures.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue10278] add time.wallclock() method

2011-07-07 Thread Matt Joiner

Matt Joiner anacro...@gmail.com added the comment:

What's the status of this bug? This is a very useful feature, I've had to use 
and add bindings to monotonic times for numerous applications. Can it make it 
into 3.3?

--

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



[issue8271] str.decode('utf8', 'replace') -- conformance with Unicode 5.2.0

2011-07-07 Thread Saul Spatz

Changes by Saul Spatz saul.sp...@gmail.com:


--
nosy: +spatz123

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



[issue12511] class/instance xyz has no attribute '_abc'

2011-07-07 Thread Andreas Hasenkopf

New submission from Andreas Hasenkopf webmas...@hasenkopf2000.net:

I'm using 64bit Arch Linux and Python 2.7.2 compiled with GCC 4.6.1.

I have noticed in several ocassions that the interpreter is complaining about

AttributeError: XMLGenerator instance has no attribute '_write' (in case of 
module xml.sax.saxutils.XMLGenerator)

or

AttributeError: RendererGDK instance has no attribute '_text2path' (in case of 
matplotlib when trying to use TeX formatting of text)

When I have a look into the corresponding modules I can clearly see method 
definitions (e.g. def _write(self, text) in line 97 of xml/sax/saxutils.py

I have no clue, why it is happening in some modules, but not in others. If a 
write my own module containing a class with a _write method it is working fine.
If I write a class derived from xml.sax.saxutils.XMLGenerator and overwrite the 
_write method it is known to the system, but many of the attributes beginning 
with an underscore appear still to be unknown...

This is very odd?!

--
components: XML
messages: 139966
nosy: Andreas.Hasenkopf
priority: normal
severity: normal
status: open
title: class/instance xyz has no attribute '_abc'
versions: Python 2.7

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



[issue9242] unicodeobject.c: use of uninitialized values

2011-07-07 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


--
nosy: +haypo

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



[issue5505] sys.stdin.read() doesn't return after first EOF on Windows

2011-07-07 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


--
nosy: +haypo

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



[issue10117] Tools/scripts/reindent.py fails on non-UTF-8 encodings

2011-07-07 Thread STINNER Victor

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

 Leaving open to discuss whether anything can/should be done
 for the case when reindent acts as an stdin

sys.stdin.buffer and sys.stdout.buffer should be used with 
tokenize.detect_encoding(). We may read first stdin and write it into a BytesIO 
object to be able to rewind after detect_encoding. Something like:

content = sys.stdin.buffer.read()
raw = io.BytesIO(content)
buffer = io.BufferedReader(raw)
encoding, _ = detect_encoding(buffer.readline)
buffer.seek(0)
text = TextIOWrapper(buffer, encoding)
# use text

--
nosy: +haypo

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



[issue10284] NNTP should accept bytestrings for username and password

2011-07-07 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


--
components: +Unicode
nosy: +haypo

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



[issue10945] bdist_wininst depends on MBCS codec, unavailable on non-Windows

2011-07-07 Thread STINNER Victor

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

Can't you only work with Unicode and avoid the MBCS encoding?

--
nosy: +haypo

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



[issue10872] Add mode to TextIOWrapper repr

2011-07-07 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


--
nosy: +haypo

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



[issue12512] codecs: StreamWriter issue with stateful codecs after a seek

2011-07-07 Thread STINNER Victor

New submission from STINNER Victor victor.stin...@haypocalc.com:

The following code fails with an AssertionError('###\ufeffdef'):

import codecs
_open = codecs.open
#_open = open
filename = test
with _open(filename, 'w', encoding='utf_16') as f:
f.write('abc')
pos = f.tell()
with _open(filename, 'w', encoding='utf_16') as f:
f.seek(pos)
f.write('def')
f.seek(0)
f.write('###')
with _open(filename, 'r', encoding='utf_16') as f:
content = f.read()
assert content == '###def', ascii(content)

It is a bug in StreamWriter.seek(): it should update the encoder state to not 
write a new BOM. It has to be fixed in the StreamWriter class of each stateful 
codec, or a stateful StreamWriter class should be implemented in the codecs 
module.

Python supports the following stateful codecs:

 * cp932
 * cp949
 * cp950
 * euc_jis_2004
 * euc_jisx2003
 * euc_jp
 * euc_kr
 * gb18030
 * gbk
 * hz
 * iso2022_jp
 * iso2022_jp_1
 * iso2022_jp_2
 * iso2022_jp_2004
 * iso2022_jp_3
 * iso2022_jp_ext
 * iso2022_kr
 * shift_jis
 * shift_jis_2004
 * shift_jisx0213
 * utf_8_sig
 * utf_16
 * utf_32

This bug has already been fixed in TextIOWrapper: issue #5006.

--
messages: 139969
nosy: haypo
priority: normal
severity: normal
status: open
title: codecs: StreamWriter issue with stateful codecs after a seek
versions: Python 2.7, Python 3.2, Python 3.3

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



[issue12512] codecs: StreamWriter issues with stateful codecs after a seek or with append mode

2011-07-07 Thread STINNER Victor

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

There is a similar bug for append mode:

import codecs
_open = codecs.open
#_open = open
filename = test
with _open(filename, 'w', encoding='utf_16') as f:
f.write('abc')
with _open(filename, 'a', encoding='utf_16') as f:
f.write('def')
with _open(filename, 'r', encoding='utf_16') as f:
content = f.read()
assert content == 'abcdef', ascii(content)

This bug has also been fixed by the issue #5006 in the io module.

--
title: codecs: StreamWriter issue with stateful codecs after a seek - codecs: 
StreamWriter issues with stateful codecs after a seek or with append mode

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



[issue12391] packaging install fails to clean up temp files

2011-07-07 Thread Roundup Robot

Roundup Robot devnull@devnull added the comment:

New changeset a4405b799e1b by Vinay Sajip in branch 'default':
Closes #12391: temporary files are now cleaned up.
http://hg.python.org/cpython/rev/a4405b799e1b

--
nosy: +python-dev
resolution:  - fixed
stage: commit review - committed/rejected
status: open - closed

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



[issue10647] scrollbar crash in non-US locale format settings

2011-07-07 Thread Hans Bering

Hans Bering hans.ber...@arcor.de added the comment:

Ok, _now_ I have run into the same problem. I have attached a small script 
similar to the original entry (but shorter) which will reliably crash with 
Python 3.1.4 on Windows 7 (64bit) when using a locale with a comma decimal 
fraction marker (e.g., German). The stacktrace is as follows:

Exception in Tkinter callback
Traceback (most recent call last):
  File C:\Python31\lib\tkinter\__init__.py, line 1400, in __call__
return self.func(*args)
  File C:\Python31\lib\tkinter\__init__.py, line 2799, in set
self.tk.call((self._w, 'set') + args)
_tkinter.TclError: expected floating-point number but got 0,2

The script runs fine with an English locale. It also runs fine with Python 3.2 
on the same machine  Windows  German locale.

The reason seems to be that the Scrollbar lets its self.tk compute fractions 
which self.tk returns as locale-dependent strings; the Scrollbar runs into 
problems when converting these strings into floats.

--
Added file: http://bugs.python.org/file22603/scrollbarCrash1.py

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



[issue10647] scrollbar crash in non-US locale format settings

2011-07-07 Thread Hans Bering

Changes by Hans Bering hans.ber...@arcor.de:


Removed file: http://bugs.python.org/file22535/tkinterCrash.py

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



[issue12167] test_packaging reference leak

2011-07-07 Thread Andreas Stührk

Andreas Stührk andy-pyt...@hammerhartes.de added the comment:

Attached is a patch that replaces `lib2to3.fixer_Base.BaseFix.set_filename()` 
during tests. With the patch applied, I don't get any refleaks for packaging.

Another approach would be to simply remove the logging attribute of lib2to3 
fixers, as it isn't used anyway.

--
keywords: +patch
nosy: +benjamin.peterson
Added file: http://bugs.python.org/file22604/issue12167_patch_2to3.patch

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



[issue10945] bdist_wininst depends on MBCS codec, unavailable on non-Windows

2011-07-07 Thread Ralf Schlatterbeck

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

On Thu, Jul 07, 2011 at 10:52:51AM +, STINNER Victor wrote:
 
 Can't you only work with Unicode and avoid the MBCS encoding?

I'm trying to build a windows binary package on Linux. This usually
works fine -- as long as the package description doesn't contain
unicode. If it *contains* unicode it will somehow internally use MBCS
encoding.
So if someone fixes windows binary package building on non-windows
platforms to not use MBCS encoding this is fine with me. But maybe the
easier way out here is to include that codec on all platforms.

(and don't tell me I have to install windows for building a windows
binary package :-)

Thanks, Ralf
-- 
Dr. Ralf Schlatterbeck  Tel:   +43/2243/26465-16
Open Source Consulting  www:   http://www.runtux.com
Reichergasse 131, A-3411 Weidling   email: off...@runtux.com
osAlliance member   email: r...@osalliance.com

--

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



[issue12513] codec.StreamReaderWriter: issues with interlaced read-write

2011-07-07 Thread STINNER Victor

New submission from STINNER Victor victor.stin...@haypocalc.com:

The following test fails with an AssertionError('a' != 'b') on the first read.

import codecs

FILENAME = 'test'

with open(FILENAME, 'wb') as f:
f.write('abcd'.encode('utf-8'))
with codecs.open(FILENAME, 'r+', encoding='utf-8') as f:
f.write(1)

pos = f.writer.tell()
assert pos == 1, writer pos: %s != 1 % pos
pos = f.reader.tell()
assert pos == 1, reader pos: %s != 1 % pos
pos = f.stream.tell()
assert pos == 1, stream pos: %s != 1 % pos

# read() must call writer.flush()
char = f.read(1)
assert char == 'b', %r != 'b' % (char,)
# write() must rewind the raw stream
f.write('3')
tail = f.read()
assert tail == 'd', %r != 'd' % (tail,)
f.flush()
with open(FILENAME, 'rb') as f:
assert f.read() == b'1b3d'

I suppose that readline(), readlines() and __next__() have also issues.

See also issue #12215: similar issue with io.TextIOWrapper.

--
components: Library (Lib), Unicode
messages: 139975
nosy: haypo
priority: normal
severity: normal
status: open
title: codec.StreamReaderWriter: issues with interlaced read-write
versions: Python 2.7, Python 3.2, Python 3.3

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



[issue12511] class/instance xyz has no attribute '_abc'

2011-07-07 Thread Andreas Hasenkopf

Andreas Hasenkopf webmas...@hasenkopf2000.net added the comment:

I'd like to mention that Python 2.6.7 does not show this erroneous behavior. In 
Python 2.6.7 I can call the _write method of xml.sax.saxutils.XMLGenerator...

Is this a bug or a feature in 2.7??

--
components:  -XML

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



[issue12511] class/instance xyz has no attribute '_abc'

2011-07-07 Thread Andreas Hasenkopf

Andreas Hasenkopf webmas...@hasenkopf2000.net added the comment:

The problem appeared to be the package from the Arch Linux repo.
Compiling the source codes myselfes gave me a Python interpreter not showing 
this bug...

--
resolution:  - accepted
status: open - closed

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



[issue12506] NIS module cant handle multiple NIS map entries for the same GID

2011-07-07 Thread bjorn lofdahl

Changes by bjorn lofdahl bjorn.lofd...@gmail.com:


--
versions: +Python 3.1, Python 3.2, Python 3.3, Python 3.4 -Python 2.6, Python 
2.7

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



[issue12506] NIS module cant handle multiple NIS map entries for the same GID

2011-07-07 Thread bjorn lofdahl

Changes by bjorn lofdahl bjorn.lofd...@gmail.com:


--
versions: +Python 2.6, Python 2.7

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



[issue12511] class/instance xyz has no attribute '_abc'

2011-07-07 Thread Benjamin Peterson

Changes by Benjamin Peterson benja...@python.org:


--
resolution: accepted - invalid

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



[issue12514] timeit disables garbage collection if timed code raises an exception

2011-07-07 Thread Gareth Rees

New submission from Gareth Rees g...@garethrees.org:

If you call timeit.timeit and the timed code raises an exception, then garbage 
collection is disabled. I have verified this in Python 2.7 and 3.2. Here's an 
interaction with Python 3.2:

Python 3.2 (r32:88445, Jul  7 2011, 15:52:49) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type help, copyright, credits or license for more information.
 import timeit, gc
 gc.isenabled()
True
 timeit.timeit('raise Exception')
Traceback (most recent call last):
  File stdin, line 1, in module
  File 
/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/timeit.py,
 line 228, in timeit
return Timer(stmt, setup, timer).timeit(number)
  File 
/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/timeit.py,
 line 194, in timeit
timing = self.inner(it, self.timer)
  File timeit-src, line 6, in inner
Exception
 gc.isenabled()
False

The problem is with the following code in Lib/timeit.py (lines 192–196):

gcold = gc.isenabled()
gc.disable()
timing = self.inner(it, self.timer)
if gcold:
gc.enable()

This should be changed to something like this:

gcold = gc.isenabled()
gc.disable()
try:
timing = self.inner(it, self.timer)
finally:
if gcold:
gc.enable()

--
components: Library (Lib)
messages: 139978
nosy: Gareth.Rees
priority: normal
severity: normal
status: open
title: timeit disables garbage collection if timed code raises an exception
type: behavior
versions: Python 2.7, Python 3.2

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



[issue10403] Use member consistently

2011-07-07 Thread Éric Araujo

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

Senthil, I’m not sure you read Alexander’s reply on Rietveld before committing.

--

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



[issue12514] timeit disables garbage collection if timed code raises an exception

2011-07-07 Thread Gareth Rees

Gareth Rees g...@garethrees.org added the comment:

Patch attached.

--
keywords: +patch
Added file: http://bugs.python.org/file22605/issue12514.patch

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



[issue12514] timeit disables garbage collection if timed code raises an exception

2011-07-07 Thread Raymond Hettinger

Changes by Raymond Hettinger raymond.hettin...@gmail.com:


--
assignee:  - rhettinger
nosy: +rhettinger

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



[issue12514] timeit disables garbage collection if timed code raises an exception

2011-07-07 Thread Raymond Hettinger

Raymond Hettinger raymond.hettin...@gmail.com added the comment:

Thank you.  The patch looks correct.  I will apply it as soon as I get a chance.

--

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



[issue12515] The email package modifies the message structure (when the parsed email is invalid)

2011-07-07 Thread xavierd

New submission from xavierd xdelan...@cloudmark.com:

the function 'email.message_from_file' modifies the message structure when the 
parsed is invalid (for example, when a closed boudary is missing). The 
attribute defects is also empty

In the attachment (sample.tgz) you will find:
   - orig.eml : an email with an invalid structure The boundary
000101020201080900040301 isn't closed
   - after_parsing.eml: same email after calling email.message_from_file()
The boundary is now closed. And the defects attribute is empty
   - test.py: python script to reproduce.

--
components: None
files: sample.tgz
messages: 139982
nosy: r.david.murray, xavierd
priority: normal
severity: normal
status: open
title: The email package modifies the message structure (when the parsed email 
is invalid)
versions: Python 2.6, Python 2.7
Added file: http://bugs.python.org/file22606/sample.tgz

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



[issue12504] packaging: fix uninstall and stop skipping its tests

2011-07-07 Thread Éric Araujo

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

Thanks for that!  I agree that it’s a fake optimization to work with generators 
instead of lists when the list is small or when we depend on other resources 
like file handles.  There are a few methods we could change in the database 
module.

The patch looks good, except that I wouldn’t move code to a nested function, 
but just change the “yield spam” line to “results.append(spam)”.

In our message, is the test log showing failure something you got before making 
changes or after?  IOW, does the patch fixes the bug?

--
assignee: tarek - eric.araujo
stage:  - patch review
title: Uninstall has disabled windows tests - packaging: fix uninstall and 
stop skipping its tests

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



[issue12167] test_packaging reference leak

2011-07-07 Thread Éric Araujo

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

Thanks a lot for the diagnosis.

To fix it, I don’t find the monkey-patching approach very good, I’d prefer 
properly using the logging API to remove handlers upon cleanup.  Would you like 
to look into that?

--

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



[issue12167] test_packaging reference leak

2011-07-07 Thread Antoine Pitrou

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

 To fix it, I don’t find the monkey-patching approach very good, I’d
 prefer properly using the logging API to remove handlers upon cleanup.

I don't think such stuff exists.

--

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



[issue12167] test_packaging reference leak

2011-07-07 Thread Éric Araujo

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

See http://hg.python.org/cpython/file/tip/Lib/packaging/tests/support.py#l81

--

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



[issue12167] test_packaging reference leak

2011-07-07 Thread Antoine Pitrou

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

 See http://hg.python.org/cpython/file/tip/Lib/packaging/tests/support.py#l81

AFAIU, the problem is that 2to3 creates a whole new logger for each
different file. So it's not about cleaning the handlers, but cleaning up
the loggers as well. And logging (deliberately, according to Vinay)
doesn't provide any API to destroy loggers (they are de facto eternal).

--

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



[issue12167] test_packaging reference leak

2011-07-07 Thread Éric Araujo

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

Thanks for clarifying, I had misread.  IMO, using one logger per file is a 
lib2to3 bug.

--

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



  1   2   >