Re: data attributes override method attributes?

2012-09-25 Thread Terry Reedy
me conflicts consider using verbs for methods and nouns for data attributes" This applies within and between. I opened http://bugs.python.org/issue16048 -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: data attributes override method attributes?

2012-09-25 Thread Terry Reedy
On 9/25/2012 4:07 PM, Ian Kelly wrote: On Tue, Sep 25, 2012 at 1:58 PM, Terry Reedy wrote: On 9/25/2012 11:03 AM, Chris Angelico wrote: Instance attributes override (shadow) class attributes. except for (some? all?) special methods Those names are shadowed too. If you call foo.__len__

Re: Article on the future of Python

2012-09-26 Thread Terry Reedy
If anything, it will make unicode more alive and Python better suited for international applications. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Article on the future of Python

2012-09-26 Thread Terry Reedy
On 9/26/2012 4:45 AM, Dwight Hutto wrote: Why do you keep repeating this rubbish when you've already been shot to pieces? I still feel intact, so whatever little shards of pain you intended to emit were lost on my ego. Uh, Dwight, he was not talking to you. -- Terry Jan Reedy --

Re: Article on the future of Python

2012-09-26 Thread Terry Reedy
t 3.3 does one operation 10, 100, 1000,... times faster than 3.2. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Fwd: Re: Article on the future of Python

2012-09-26 Thread Terry Reedy
s the idea came from and much or most of the implementation was done by Europeans, not Americans. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Article on the future of Python

2012-09-27 Thread Terry Reedy
ndows. Overall, Unicode is nearly as fast as bytes and 3.3 as fast as 3.2. Find/replace is the notable exception in stringbench, so it is an anomaly. Other things are faster in 3.3. I think this should be raised as a performance regression. I agree, and Mark did it. -- Terry Jan Reedy --

Re: Article on the future of Python

2012-09-27 Thread Terry Reedy
ere are hot new people in other growing areas where Python is growing. Computing for science, megadata, and education are not going away. Being a glue language for numerical computing was Python's first killer application nearly two decades ago, and it still is an important one. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: data attributes override method attributes?

2012-09-28 Thread Terry Reedy
? Efficiency and perhaps simpler implementation, especially for binary ops. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: print or write on a text file ?

2012-09-28 Thread Terry Reedy
r the hint parameter to limit the bytes read. That is little harder to do with the iterator. If you have any iterator of lines, for line in lines: line.print() is quite sufficient. There is little or no need for output limitation. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Editing in IDLE

2012-09-29 Thread Terry Reedy
unning one statement at a time. You can put the cursor on a previous statement and hit return to make it the current statement, where you can edit it. You edit normal multi-statement code in edit windows, hit F5 to run, edit, run, edit, run. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: EOL for Python 3.2?

2012-09-29 Thread Terry Reedy
t was unable to find one. Don't know where written, but last 3.x bugfix about the time of 3.(x+1).0 and 3 years security is standard. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Are ABCs an anti-pattern?

2012-10-02 Thread Terry Reedy
ted that it would take awhile for them to see good, pythonic uses. We obviously did okay without them up to 2.7. They are partly informational, partly meant to help duck typing. I don't think they are used much in the stdlib (except to register classes) and I have not used them myself.

Re: Slicing iterables in sub-generators without loosing elements

2012-10-02 Thread Terry Reedy
th an 'act human' module seem more human to at least some humans than humans. Perhaps that is because humans have to become bot-like to play UT well. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Anybody know what's up with Gmane?

2012-10-04 Thread Terry Reedy
success. Anyone > any ideas on how to sort this out? This is the longest outage I remember, but it is back up now. I am reading and replying via gmane. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Experimental Python-based shell

2012-10-04 Thread Terry Reedy
mands can access Python variables when specified. And it is a simple rule, without footnotes needed. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: unit testing class hierarchies

2012-10-04 Thread Terry Reedy
None ... class TestHeapPython(TestHeap): module = py_heapq @skipUnless(c_heapq, 'requires _heapq') class TestHeapC(TestHeap): module = c_heapq ... def test_main(verbose=None): test_classes = [TestModules, TestHeapPython, TestHeapC, # TestHeap is omitted from the list and not run directly -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Experimental Python-based shell

2012-10-04 Thread Terry Reedy
On 10/3/2012 4:22 PM, Terry Reedy wrote: Indexing Python code is ugly. I suggest prefixing non-Python with $. Indenting, meaning indenting the Python header lines but not non-Python lines. On 10/3/2012 1:24 PM, Jonathan Hayward wrote: I am open to suggestions and patches. I don't

Re: sum function

2012-10-05 Thread Terry Reedy
getting the data from hbase. If you want as many people as possible to read your posts, stop using a mail-agent and site that spits in the face of readers by doubling blank lines each iteration. Alternatives have been discussed previously. -- Terry Jan Reedy -- http://mail.python.org/mailman

Re: try/except KeyError vs "if name in ..."

2012-10-06 Thread Terry Reedy
10-20%) use try', applies here. For if/them versus try/except, I don't worry too much about it. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: wordnet semantic similarity: how to refer to elements of a pair in a list? can we sort dictionary according to the value?

2012-10-07 Thread Terry Reedy
;automobile'? Thanks for your tips. >>> pairs = [('car', 'automobile'), ('gem', 'jewel')] >>> pairs[0][0] 'car' >>> pairs[1][1] 'jewel' >>> for a,b in pairs: a,b ('car', 'automobile') ('gem', 'jewel') -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Unpaking Tuple

2012-10-07 Thread Terry Reedy
t way. See the example below. Unpacking is for when you have known-length iterables. For instance, enumerate produces pairs. >>> for i, v in enumerate('abc'): print('Item {} is {}.'.format(i, v)) Item 0 is a. Item 1 is b. Item 2 is c. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Question on Python Split

2012-10-07 Thread Terry Reedy
') print(' '.join((tup1,tup2,tup3,tup4,tup5))) >>> Project Gutenberg has 36000 free ebooks for Kindle Android iPad -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: To get the accurate value of 1 - 0.999999999999999 ,how to implement the python algorithm ?

2012-10-08 Thread Terry Reedy
;from decimal import Decimal as D; a = D('1.0'); b = D('0.99')") [0.14685526219517442, 0.12909696344064514, 0.12646059371189722] A factor of 3, as S. Krah, the cdecimal author, claimed -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Insert item before each element of a list

2012-10-08 Thread Terry Reedy
x27;insert me', 1, 'insert me', 2, 'insert me', 3] Paul Rubin's list(gfunc(prefix, lst)) is similar in execution. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Is `wsample` a proper name for a function like this?

2012-10-10 Thread Terry Reedy
author did not use 'ws' as would have once been common. So when I saw this `wsample` function, I considered it a improper name. Because `wsample`makes me think of `random.sample`, which returns a list of randomly generated elements, not a element. -- Terry Jan Reedy -- http://mai

Re: Insert item before each element of a list

2012-10-11 Thread Terry Reedy
, idiomatic python in that it separates interleaving from creating a list. In many situations, creating a list from the interleaved stream will not be needed. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: __setitem__ without position

2012-10-11 Thread Terry Reedy
etting, setting, and deleting for free. Try Dave's line in your code. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Understanding and dealing with an exception

2012-10-14 Thread Terry Reedy
hing except a few things like Keyboard Interrupt that you normally should not catch. >>> BaseException This catches everything, but signals that doing so is probably intentional. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: What's the tidy/elegant way to protect this against null/empty parameters?

2012-10-15 Thread Terry Reedy
"", line 1, in ','.join([None]) TypeError: sequence item 0: expected str instance, NoneType found >>> ','.join([]) '' -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Exception Messages

2012-10-15 Thread Terry Reedy
27;__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__suppress_context__', '__traceback__', 'args', 'with_traceback'] >>> Exception('abc', 1) Exception('abc', 1) So class MyError(Exception) will get that basic default behavior. For fancier printing, one needs a fancier .__str__ method ;-). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Aggressive language on python-list

2012-10-16 Thread Terry Reedy
those item you request. News readers should collapse threads to a single line and allow you to mark all as read. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: list comprehension question

2012-10-16 Thread Terry Reedy
s.append(f(item)) res <==> [f(item) for item in source] Matrix multiplication does not fit the pattern above. The reduction is number addition rather than list appending. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: list comprehension question

2012-10-17 Thread Terry Reedy
On 10/17/2012 3:13 AM, rusi wrote: On Oct 17, 10:22 am, Terry Reedy wrote: On 10/16/2012 9:54 PM, Kevin Anthony wrote: I've been teaching myself list comprehension, and i've run across something i'm not able to convert. My response is to the part Kevin could *not* convert, n

Re: len() on mutables vs. immutables

2012-10-18 Thread Terry Reedy
least all built-in types observe this behavior, str, bytes, bytearrays, arrays, sets, frozensets, dicts, dictviews, and ranges should all return len in O(1) time. That includes the possibility of a subtraction as indicated above. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: len() on mutables vs. immutables

2012-10-18 Thread Terry Reedy
On 10/18/2012 3:18 PM, Prasad, Ramit wrote: Terry Reedy wrote: On 10/18/2012 1:23 PM, Demian Brecht wrote: When len() is called passing an immutable built-in type (such as a string), I'd assume that the overhead in doing so is simply a function call and there are no on-call calculations

Re: len() on mutables vs. immutables

2012-10-18 Thread Terry Reedy
On 10/18/2012 2:42 PM, Demian Brecht wrote: Awesome. Pretty much what I figured. Of course, I'll have to dig around the source just to confirm this with my own eyes (more just curiosity than anything), If you do, please followup with a report. -- Terry Jan Reedy -- http://mail.pytho

Re: Add if...else... switch to doctest?

2012-10-18 Thread Terry Reedy
ned. IE, you would have to set the 'global_var' in the doctext code itself. >>> def function(): ... if global_var: return [1,2] ... else: return [1,2,3] >>> global_var = True >>>function() [1,2] >>> global_var = False >>> function() [1,2,3] -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: How to access the document for __call__ from command line?

2012-10-18 Thread Terry Reedy
lf-x >>> help(C.__call__) Help on function __call__ in module __main__: __call__(self, x) return the difference between self and x Similarly for builtin methods you actually need to know about >>> help(list.append) Help on method_descriptor: append(...) L.append(obj

Re: Recursive Generator Error?

2012-10-21 Thread Terry Reedy
yields. Replace 'flat_yield(t)' with for item in flat_yield(t): yield item and the output is what you want. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: turn list of letters into an array of integers

2012-10-24 Thread Terry Reedy
ce single characters (letters) with single characters (digits), use maketrans and translate. >>> 'a b c'.translate(str.maketrans('abc', '123')) '1 2 3' -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: classes

2012-10-24 Thread Terry Reedy
category of classes rather than two. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: while expression feature proposal

2012-10-24 Thread Terry Reedy
Keep in mind that any new syntax has to be a substantial improvement in some sense or make something new possible. There was no new syntax in 3.2 and very little in 3.3. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: while expression feature proposal

2012-10-25 Thread Terry Reedy
On 10/25/2012 6:50 AM, Steven D'Aprano wrote: On Thu, 25 Oct 2012 11:52:31 +0200, Thomas Rachel wrote: Am 25.10.2012 06:50 schrieb Terry Reedy: Keep in mind that any new syntax has to be a substantial improvement in some sense or make something new possible. There was no new syntax i

Re: bit count or bit set && Python3

2012-10-25 Thread Terry Reedy
tset is the correct approach, I'll need it to implement those operations, or their equivalents in terms of union and intersection.) Or do I need to drop into C for this? If I wanted 1000s of fast limited-length bitsets, I would consider using Cython to make an extension class. -- Terry Jan

Re: a.index(float('nan')) fails

2012-10-25 Thread Terry Reedy
nan = float('nan') >>> nan is nan True >>> nan == nan False >>> nanlist = [nan] >>> nan in nanlist True >>> nanlist.index(nan) 0 Containment of nan in collection is tested by is, not ==. >>> nan2 = float('nan') >>>

Re: a.index(float('nan')) fails

2012-10-26 Thread Terry Reedy
On 10/25/2012 10:44 PM, Steven D'Aprano wrote: On Thu, 25 Oct 2012 22:04:52 -0400, Terry Reedy wrote: It is a consequence of the following, which some people (but not all) believe is mandated by the IEEE standard. >>> nan = float('nan') >>> nan is nan

Re: a.index(float('nan')) fails

2012-10-26 Thread Terry Reedy
On 10/25/2012 10:19 PM, MRAB wrote: On 2012-10-26 03:04, Terry Reedy wrote: On 10/25/2012 9:46 PM, mambokn...@gmail.com wrote: a = [float('nan'), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] a [nan, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] a.index(float('nan')) This is a second nan obje

Re: a.index(float('nan')) fails

2012-10-26 Thread Terry Reedy
On 10/26/2012 11:26 AM, Steven D'Aprano wrote: On Fri, 26 Oct 2012 03:54:02 -0400, Terry Reedy wrote: On 10/25/2012 10:44 PM, Steven D'Aprano wrote: On Thu, 25 Oct 2012 22:04:52 -0400, Terry Reedy wrote: It is a consequence of the following, which some people (but not all)

Re: a.index(float('nan')) fails

2012-10-26 Thread Terry Reedy
On 10/26/2012 12:23 PM, Steven D'Aprano wrote: On Fri, 26 Oct 2012 04:00:03 -0400, Terry Reedy wrote: This inconsistency is an intentional decision to not propagate the insanity of nan != nan to Python collections. That's a value judgement about NANs which is not shared by everyo

Re: OrderedDict / DIctComprehension

2012-10-29 Thread Terry Reedy
ordered' ((), {}) 0.724609 sec 'comprehension' ((), {}) 0.098318 sec -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Immutability and Python

2012-10-29 Thread Terry Reedy
worlds, or also physical worlds. Even mathematically, I do not think there necessarily a problem with mutable collections. The fact that sets are defined by content does not mean that everything has to be. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Immutability and Python

2012-10-29 Thread Terry Reedy
e a custom .__setattr__ that prevents changes thereafter. If you want the class itself to be immutable (after creation), write a custom metaclass. You may also need to think about .__getattribute__, but I never studied the detail completely and have forgotten what I learned. -- Terry

Re: pythonic way

2012-11-01 Thread Terry Reedy
This was too easy') This was too easy -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: How to improve the usability of nested packages

2012-11-02 Thread Terry Reedy
the subpackages. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: surprising += for lists

2012-11-04 Thread Terry Reedy
exists to implement '+'. [].extend() will clearly be a list, and accepts any iterable. I believe the same logic is used for set operations. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: __unicode__() works, unicode() blows up. (Never mind!)

2012-11-04 Thread Terry Reedy
t;", line 1, in len(C()) TypeError: 'str' object cannot be interpreted as an integer >>> class C: def __len__(self): return -42 # whoops again >>> len(C()) Traceback (most recent call last): File "", line 1, in len(C())

Re: who can give me some practical tutorials on django 1.4 or 1.5?

2012-11-04 Thread Terry Reedy
also django-users list https://www.djangoproject.com/community/ -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: accepting file path or file object?

2012-11-05 Thread Terry Reedy
ith statement or might want to do other operations on the file before or after passing it to your grep_file. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between range and xrange ??

2012-11-05 Thread Terry Reedy
ed list a nuisance. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: multiprocessing help

2012-11-06 Thread Terry Reedy
On 11/6/2012 7:52 PM, Stephen Bunn wrote: I'm looking for some help with multiprocessing. Questions about using Python go to python-list. python-dev is for developing future versions of Python. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: multiprocessing help

2012-11-06 Thread Terry Reedy
On 11/6/2012 11:04 PM, Terry Reedy wrote: On 11/6/2012 7:52 PM, Stephen Bunn wrote: I'm looking for some help with multiprocessing. Questions about using Python go to python-list. python-dev is for developing future versions of Python. My apologies. I intended to and thought I had o

Re: int.__init__ incompatible in Python 3.3

2012-11-08 Thread Terry Reedy
not overridden. ''' I say open a bug report and let the devs sort it out. Please do not. The current situation is the result of 'sorting it out' over several years. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: duck typing assert‏

2012-11-08 Thread Terry Reedy
ent to the user. One use of properties is to make something that is not a Mallard act like a Mallard. So this check breaks duck typing. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: duck typing assert‏

2012-11-08 Thread Terry Reedy
On 11/8/2012 6:40 PM, Steven D'Aprano wrote: On Thu, 08 Nov 2012 15:39:24 -0500, Terry Reedy wrote: [...] test.py:21: UserWarning: 'bar': is not property. assert looks(Foo).like(IFoo) Traceback (most recent call last): File "test.py", line 21, in as

Re: duck typing assert‏

2012-11-09 Thread Terry Reedy
On 11/9/2012 1:30 AM, Steven D'Aprano wrote: On Thu, 08 Nov 2012 23:44:54 -0500, Terry Reedy wrote: On 11/8/2012 6:40 PM, Steven D'Aprano wrote: [...] IFoo.bar # returns a computed property Assuming IFoo is a class and bar is a property attribute of the class, IFoo.bar is th

Re: Python3.3 str() bug?

2012-11-09 Thread Terry Reedy
he meanwhile, if you cannot have the object constructed with strings rather than bytes, I suggest you write a custom converter function that understands the structure and replaces bytes with strings. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Method default argument whose type is the class not yet defined

2012-11-10 Thread Terry Reedy
Point.distance = distance ... def __sub__(self, other): ... return Point(self.x - other.x, self.y - other.y) ... >>> def distance(self, point=Point()): ... return math.sqrt((self - point).x ** 2 + (self - point).y ** 2) ... >>> p = Point() >>> p.distance(Point(3, 4)) 5.0 Is there a better solution? -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: List comprehension for testing **params

2012-11-11 Thread Terry Reedy
or if you want them to be identified by keyword only (since 7 positional args is a bit much) def __init__(self, smtp, login, *, subject, from, to, msg): (I forget when this feature was added) # ... And then Python will do all the work of requiring them to be present for you. --

Re: Is there a way to creat a func that returns a cursor that can be used?

2012-11-12 Thread Terry Reedy
27;'') works fine. SQL treats newlines in statements as whitespace. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Bugs: Content-Length not updated by reused urllib.request.Request / has_header() case-sensitive

2012-11-12 Thread Terry Reedy
;) True request.get_header("Content-Type") # this return None, which is not printed request.get_header("Content-type") 'application/x-www-form-urlencoded' Judging from 'Content-type', 'User-agent', 'Content-length', 'Host', urllib.request consistently capitalizes the first word of all header tags and expects them in that form. If that is not standard, it should be documented. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Bugs: Content-Length not updated by reused urllib.request.Request / has_header() case-sensitive

2012-11-12 Thread Terry Reedy
On 11/12/2012 5:59 PM, Cameron Simpson wrote: On 12Nov2012 16:35, Terry Reedy wrote: | On 11/12/2012 10:52 AM, Johannes Kleese wrote: | > While at it, I noticed that urllib.request.Request.has_header() and | > .get_header() are case-sensitive, | | Python is case sensitive. To be more p

Re: Bugs: Content-Length not updated by reused urllib.request.Request / has_header() case-sensitive

2012-11-12 Thread Terry Reedy
On 11/12/2012 4:35 PM, Terry Reedy wrote: import urllib.request opener = urllib.request.build_opener() request = urllib.request.Request("http://example.com/";, headers = {"Content-Type": "application/x-www-form-urlencoded"}) opener.open(request,

Re: Simple Question regarding running .py program

2012-11-12 Thread Terry Reedy
the shell window. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: access spreadsheet data

2012-11-14 Thread Terry Reedy
data are in data.txt in current directory. Then start with with open('data.txt') as lines: for line in lines -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple Question regarding running .py program

2012-11-14 Thread Terry Reedy
many 'mail' programs such as Outlook Express or Thunderbird also handle news -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple Question regarding running .py program

2012-11-14 Thread Terry Reedy
with Thunderbird was, as I remember rather easy, easier than setting up a mail account. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: error importing smtplib

2012-11-15 Thread Terry Reedy
r raise ValueError('unsupported hash type %s' % name) ValueError: unsupported hash type sha224 [snip similar messages] It is also unusual to get multiple tracebacks. *Exactly* how are you running python and is 2.7 what you intend to run? -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: error importing smtplib

2012-11-15 Thread Terry Reedy
-login code carefully, or disable (comment out) parts of it to see what makes the import fail. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: error importing smtplib

2012-11-16 Thread Terry Reedy
obably better, only load it if there is no system version). What else should I be checking? Thinking more, you can look at sys.modules, but this does not have any info about non-module libraries wrapped by modules, even if the latter are C-coded. -- Terry Jan Reedy -- http://ma

Re: Point of idle curiosity

2012-11-18 Thread Terry Reedy
n the back of however's mind. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Spam source (Re: Horror Horror Horror!!!!!)

2012-11-18 Thread Terry Reedy
The question was raised as to how much spam comes from googlegroups. Not all, but more that half, I believe. This one does. From: MoneyMaker ... Message-ID: <2d2a0b98-c587-4459-9489-680b1ddc4...@googlegroups.com> -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Interview Questions

2012-11-19 Thread Terry Reedy
est of 3: 43.2 usec per loop C:\>python -m timeit -s "import operator as o; x = list(range(1000)); g = o.itemgetter(*range(len(x)))" "g(x)" 1 loops, best of 3: 43.7 usec per loop C:\>python -m timeit -s "import operator as o; x = tuple(range(1)); g = o.itemgetter(*range(len(x)))" "g(x)" 1000 loops, best of 3: 422 usec per loop C:\>python -m timeit -s "import operator as o; x = list(range(1)); g = o.itemgetter(*range(len(x)))" "g(x)" 1000 loops, best of 3: 447 usec per loop -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Interview Questions

2012-11-19 Thread Terry Reedy
__, index, and count ... class collections.abc.Sequence class collections.abc.MutableSequence ABCs for read-only and mutable sequences. ''' >>> from collections.abc import Sequence >>> issubclass(tuple, Sequence) True -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Path Browser seems to be broken

2012-11-20 Thread Terry Reedy
Path browser works in 2.7 and 3.2. It was broken in 3.3.0 and has been fixed for 3.3.1 and 3.4.0. The issue status is 'closed', so one must change the search status field from the default of 'open' to find it. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with list.remove() method

2012-11-20 Thread Terry Reedy
already seen this element The itertools doc, in the last section, has a recipe for this problem that uses the above approach. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Yet another Python textbook

2012-11-20 Thread Terry Reedy
uture. Many people who want to move to Py3 cannot because they *have to use* a Py2-only library. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Inconsistent behaviour os str.find/str.index when providing optional parameters

2012-11-21 Thread Terry Reedy
non-existent index. For the string "spam", the range is 0..4. I tend to agree, but perhaps the doc should be changed. In edge cases like this, there sometimes is no 'right' answer. I suspect that the current behavior is intentional. You might find a discussion on the tracker. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Yet another Python textbook

2012-11-21 Thread Terry Reedy
got the cases where % formatting has to be special cased. >>> "The answer is {}.".format(1) 'The answer is 1.' >>> "The answer is {}.".format((1,)) 'The answer is (1,).' >>> "The answer is %s" % 1 'The answer is 1' >>> "The anwser is %s" % (1,) 'The answer is 1' >>> "The answer is %s" % ((1,),) 'The answer is (1,)' -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Yet another Python textbook

2012-11-22 Thread Terry Reedy
or now? Nonsense. The issues above are the same for % formatting. If you try to format one object with two % format specs, it will fail for the same reason. Try the % equivalent of what failed. '%-14f%14d' % ((-25.61, 95 ),) -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Is it bad style to override the built-in function `type`?

2012-11-23 Thread Terry Reedy
language. It leads to non obvious errors -- especially when revisting old code. Why not call the thing 'key_stroke'? I agree. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: argparse -- mutually exclusive sets of arguments?

2012-11-23 Thread Terry Reedy
l and handle the 'more complicated logic' in your own code after argparse returns. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: changing dicts in a threaded environment ?

2012-11-27 Thread Terry Reedy
t does both locking and watcher notification. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Bugs: Content-Length not updated by reused urllib.request.Request / has_header() case-sensitive

2012-11-27 Thread Terry Reedy
On 11/12/2012 8:58 PM, Terry Reedy wrote: On 11/12/2012 4:35 PM, Terry Reedy wrote: import urllib.request opener = urllib.request.build_opener() request = urllib.request.Request("http://example.com/";, headers = {"Content-Type": "application/x-www-form-u

Re: please help me to debud my local chat network program

2012-11-27 Thread Terry Reedy
P, which you defined elsewhere, whatever it is, is not valid for udpSock, also defined elsewhere. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: weird isinstance/issubclass behavior?

2012-11-29 Thread Terry Reedy
lse are correct. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Weird exception handling behavior -- late evaluation in except clause

2012-12-02 Thread Terry Reedy
' is very cheap. Searching ahead any checking names in all the except clauses would be much more expensive -- and useless after the first time the code is run after being revised. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: [newbie] problem with usbtmc-communication

2012-12-04 Thread Terry Reedy
27; % number, measurementcurr ... print 'Measured voltage %d: ' % number, measurementvolt Now you can make changes in only one place and easily add more test values. print "Goodbye, data logged in file:" print filename usbkeith.close() keithdata.close() can anyone here what is

Re: Good use for itertools.dropwhile and itertools.takewhile

2012-12-04 Thread Terry Reedy
ion, the same idea applies to the split list. def split_product_itertools(s): words = s.split() product = list(takewhile(allcaps, words)) return ' '.join(product), ' '.join(words[len(product):]) -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: assign only first few items of a tuple/list

2012-12-04 Thread Terry Reedy
arate item. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3   4   5   6   7   8   9   10   >