Re: dbf.py API question concerning Index.index_search()

2012-08-15 Thread Ethan Furman
Steven D'Aprano wrote: On Wed, 15 Aug 2012 16:26:09 -0700, Ethan Furman wrote: Indexes have a new method (rebirth of an old one, really): .index_search( match, start=None, stop=None, nearest=False, partial=False ) [...] Why "index_search" r

Re: type(None)()

2012-08-16 Thread Ethan Furman
Ramchandra Apte wrote: Are they the same object Yes. -- http://mail.python.org/mailman/listinfo/python-list

Re: type(None)()

2012-08-16 Thread Ethan Furman
Hans Mulder wrote: On 8/08/12 04:14:01, Steven D'Aprano wrote: NoneType raises an error if you try to create a second instance. bool just returns one of the two singletons (doubletons?) again. py> type(None)() Traceback (most recent call last): File "", line 1, in TypeError: cannot create 'N

Re: dbf.py API question concerning Index.index_search()

2012-08-16 Thread Ethan Furman
MRAB wrote: On 16/08/2012 02:22, Ethan Furman wrote: Steven D'Aprano wrote: On Wed, 15 Aug 2012 16:26:09 -0700, Ethan Furman wrote: Indexes have a new method (rebirth of an old one, really): .index_search( match, start=None, stop=None, nearest=False, pa

Re: dbf.py API question concerning Index.index_search()

2012-08-16 Thread Ethan Furman
MRAB wrote: On 16/08/2012 17:13, Ethan Furman wrote: Currently there are: .index(data) --> returns index of data in Index, or raises error .query(string) --> brute force search, returns all matching records .search(match) --> binary search through table, returns all

Re: [ANNC] pybotwar-0.8

2012-08-16 Thread Ethan Furman
MRAB wrote: On 16/08/2012 16:40, Ramchandra Apte wrote: On 16 August 2012 21:00, Mark Lawrence wrote: and "bottom" reads better than "top" [snip] Look you are the only person complaining about top-posting. GMail uses top-posting by default. I can't help it if you feel irritated by it.

python-list@python.org

2012-08-24 Thread Ethan Furman
Chris Angelico wrote: PLEASE add attribution back in. It's not about he-said/she-said, it's about honesty and clarity in reporting. It's far easier to understand the conversation when we know who said each part [. . .] +1 -- http://mail.python.org/mailman/listinfo/python-list

proper reply format [was Re: help with simple print statement!]

2012-08-24 Thread Ethan Furman
Prasad, Ramit wrote: Willem Krayenhoff Any idea why print isn't working here? I tried restarting my Command prompt. Also, print doesn't work inside a class. Ramit, The standard for attribution is something along the lines of: Prasad, Ramit wrote: or Willem Kayenhoff wrote: Just havi

Re: thanks! (was "Test message - please ignore")

2012-08-31 Thread Ethan Furman
Tim Chase wrote: On 08/31/12 09:15, Skip Montanaro wrote: We just upgraded the Mailman installation on mail.python.org. Part of that installation includes spam filtering on messages gated from Usenet to the python- l...@python.org mailing list. This message is a quick test of that function.

Re: Least-lossy string.encode to us-ascii?

2012-09-13 Thread Ethan Furman
[sorry for the direct reply, Tim] Tim Chase wrote: I've got a bunch of text in Portuguese and to transmit them, need to have them in us-ascii (7-bit). I'd like to keep as much information as possible, just stripping accents, cedillas, tildes, etc. So "serviço móvil" becomes "servico movil". I

Re: Comparing strings from the back?

2012-09-17 Thread Ethan Furman
*plonk* -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparing strings from the back?

2012-09-18 Thread Ethan Furman
Neil Hodgson wrote: Ethan Furman: *plonk* I can't work out who you are plonking. While more than one of the posters on this thread seem worthy of a good plonk, by not including sufficient context, you've left me feeling puzzled. Is there a guideline for this in basic

technologies synergistic with Python

2012-09-21 Thread Ethan Furman
Greetings! What is the consensus... okay, okay -- what are some wide ranging opinions on technologies that I should know if my dream job is one that consists mostly of Python, and might allow telecommuting? (Please don't say Java, please don't say Java, please don't say... ;) ~Ethan~ -- http

Re: technologies synergistic with Python

2012-09-22 Thread Ethan Furman
Walter Hurry wrote: On Sat, 22 Sep 2012 10:58:38 -0700, Emile van Sebille wrote: On 9/21/2012 2:59 PM Ethan Furman said... ...if my dream job is one that consists mostly of Python, and might allow telecommuting? Hi Ethan, I have an open position in my two man office I've tried to f

Re: [Python-Dev] [RELEASED] Python 3.3.0 release candidate 3

2012-09-24 Thread Ethan Furman
Mark Lawrence wrote: On 24/09/2012 07:18, Georg Brandl wrote: [snip impressive list of improvements] Yes, but apart from all that, what have the python devs ever done for us? Nothing :) I'll take that kind of nothing any day of the week! ;) ~Ethan~ -- http://mail.python.org/mailman/list

Re: A little morning puzzle

2012-09-24 Thread Ethan Furman
Ian Kelly wrote: On Sat, Sep 22, 2012 at 9:44 PM, Dwight Hutto wrote: Why don't you all look at the code(python and C), and tell me how much code it took to write the functions the other's examples made use of to complete the task. Just because you can use a function, and make it look easier,

Re: For Counter Variable

2012-09-24 Thread Ethan Furman
jimbo1qaz wrote: On Sunday, September 23, 2012 9:36:19 AM UTC-7, jimbo1qaz wrote: Am I missing something obvious, or do I have to manually put in a counter in the for loops? That's a very basic request, but I couldn't find anything in the documentation. Ya, they should really give a better w

Re: Who's laughing at my responses, and who's not?

2012-09-24 Thread Ethan Furman
Dwight Hutto wrote: context and cut the potty mouth stuff. It was meant as a little shop talk, but I forgot there were ladies here as well. Not only ladies, but gentlemen. Foul-mouthed "shop talk" is not necessary to teach Python. Practice some self-control, or at least self-editing. ~Et

Re: Who's laughing at my responses, and who's not?

2012-09-24 Thread Ethan Furman
Dwight Hutto wrote: Been getting slammed by a few for some insignificant things, so who's laughing at me, and who takes me seriously. I don't claim to be the best, just trying to help. Mis-interpreting posts is not insignificant. Being rude is not insignificant. Refusing to see these things,

Re: Article on the future of Python

2012-09-26 Thread Ethan Furman
wxjmfa...@gmail.com wrote: Py 3.3 succeeded to somehow kill unicode and it has been transformed into an "American" product for "American" users. *plonk* -- http://mail.python.org/mailman/listinfo/python-list

Re: Article on the future of Python

2012-09-26 Thread Ethan Furman
extremely useful contributor. I certainly prefer him to Xah Lee, who's attempts at improving Python documentation were beautifully torn to pieces here, IIRC by Ethan Furman, apologies to him and the actual author if I'm incorrect. I don't think it was me -- my troll tolerance is

Re: Article on the future of Python

2012-09-26 Thread Ethan Furman
Chris Angelico wrote: On Wed, Sep 26, 2012 at 10:19 PM, wrote: After all, if replacing a Nabla operator in a string take 10 times more times in Py33 than in Python32 [. . .] But I'll give you the benefit of the doubt; maybe your number is in binary. +1 QOTW -- http://mail.python.org/mailma

Re: Article on the future of Python

2012-09-27 Thread Ethan Furman
Mark Lawrence wrote: On 27/09/2012 17:16, Devin Jeanpierre wrote: On Thu, Sep 27, 2012 at 10:25 AM, Steven D'Aprano wrote: On Thu, 27 Sep 2012 08:11:13 -0400, Devin Jeanpierre wrote: Summary of that article: "Sure, you have all these legitimate concerns, but look, cake!" Did you read the ar

instance.attribute lookup

2012-10-05 Thread Ethan Furman
There is a StackOverflow question [1] that points to this on-line book [2] which has a five-step sequence for looking up attributes: > When retrieving an attribute from an object (print > objectname.attrname) Python follows these steps: > > 1. If attrname is a special (i.e. Python-provided) attr

Re: instance.attribute lookup

2012-10-05 Thread Ethan Furman
Steven D'Aprano wrote: On Fri, 05 Oct 2012 10:39:53 -0700, Ethan Furman wrote: There is a StackOverflow question [1] that points to this on-line book [2] which has a five-step sequence for looking up attributes: > When retrieving an attribute from an object (print > objectna

Re: [ann] pysha3 0.2.1 released

2012-10-06 Thread Ethan Furman
Christian Heimes wrote: today I've released pysha3 0.2.1 [1]. pysha3 is available for Python 2.6, 2.7, 3.2 and 3.3. It has been tested on Linux (X86, X86_64 with gcc 4.6 and clang), FreeBSD and Windows (X86, X86_64). 32 and 64bit Windows binaries for all supported Python versions are available

Re: __setitem__ without position

2012-10-11 Thread Ethan Furman
Kevin Anthony wrote: I'm not supprised... and understand why it's happening. I'm asking how to get around it. I don't think you do understand what's happening. What's happening is the basic application of name binding in Python: --> C = anything whatever C was bound to before, it no longer

Re: __setitem__ without position

2012-10-12 Thread Ethan Furman
Terry Reedy wrote: In 3.x, you would write __setitem__ to recognize that the 'key' is a slice object rather than an int and act accordingly. (In 2.x, you would write __setslice__.) I'm not sure how far back it goes, but at least from 2.4 forward __setitem__ works with slices just fine. ~Et

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

2012-10-28 Thread Ethan Furman
Steven D'Aprano wrote: The list.index method tests for the item with equality. Since NANs are mandated to compare unequal to anything, including themselves, index cannot match them. This is incorrect. .index() uses identity first, then equality, and will match the same NaN in a list. The OP

Re: Style help for a Smalltalk-hack

2012-10-28 Thread Ethan Furman
Travis Griggs wrote: I'm writing some code that does a structured read from formatted binary file. The code I came up with looks like: # get the first four bytes, the first gap field chunk = byteStream.read(4) while chunk: # interpret the gap bytes gap, = struct.unpack('>I', chunk)

Re: calling one staticmethod from another

2012-10-30 Thread Ethan Furman
Ulrich Eckhardt wrote: I can call a staticmethod f() of class C like "C.f()" or with an instance like "C().f()". Inside that staticmethod, I have neither the class (at least not the original one) nor do I have an instance, so I can't call a different staticmethod from the same class. The obviou

Re: Negative array indicies and slice()

2012-10-30 Thread Ethan Furman
Andrew Robinson wrote: I can see that the slice() function can pass in arbitrary arguments. I'm not sure for lists, which is what the range is applied to, why an argument like "a" would be part of a slice. Well, in my dbf.py Record class you can use the names of fields as the slice arguments,

Re: Negative array indicies and slice()

2012-11-01 Thread Ethan Furman
Andrew Robinson wrote: On 10/31/2012 02:20 PM, Ian Kelly wrote: On Wed, Oct 31, 2012 at 7:42 AM, Andrew Robinson wrote: Then; I'd note: The non-goofy purpose of slice is to hold three data values; They are either numbers or None. These *normally* encountered values can't create a memory l

Re: Negative array indicies and slice()

2012-11-01 Thread Ethan Furman
Chris Angelico wrote: On Fri, Nov 2, 2012 at 1:12 AM, Ethan Furman wrote: In other words, the slice contains the strings, and my code calculates the offsets -- Python doesn't do it for me. That's correct, but you're still translating those strings into numeric indices. True

Re: Negative array indicies and slice()

2012-11-01 Thread Ethan Furman
Ian Kelly wrote: On Thu, Nov 1, 2012 at 5:32 AM, Andrew Robinson wrote: Don't bother to fix the bug; allow Python to crash with a subtle bug that often take weeks to track down by the very small minority doing strange things (Equivalent to the "monkey patch" syndrome of D'Aprano; BTW: The long

Re: Multi-dimensional list initialization

2012-11-07 Thread Ethan Furman
After this post the only credibility you have left (with me, anyway) is that you seem to be willing to learn. So learn the way Python works before you try to reimplement it. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Multi-dimensional list initialization

2012-11-07 Thread Ethan Furman
Oscar Benjamin wrote: On Nov 7, 2012 5:41 AM, "Gregory Ewing" > wrote: > > If anything is to be done in this area, it would be better > as an extension of list comprehensions, e.g. > > [[None times 5] times 10] > > which would be equivalent to > >

Re: Multi-dimensional list initialization

2012-11-09 Thread Ethan Furman
Prasad, Ramit wrote: Dennis Lee Bieber wrote: Of course, if one has a language that, for some reason, evaluates right-to-left (APL, anyone), then x := x - x - x becomes x := x - 0 Is that not the same as x:=-x? No, its the same as 'x = x'. ~Ethan~ -- http://mail.p

Re: stackoverflow quote on Python

2012-11-13 Thread Ethan Furman
wxjmfa...@gmail.com wrote: Le mardi 13 novembre 2012 06:42:19 UTC+1, Steven D'Aprano a écrit : On Tue, 13 Nov 2012 03:08:54 +, Mark Lawrence wrote: * strings are now proper text strings (Unicode), not byte strings; Let me laugh. *plonk* -- http://mail.python.org/mailman/listinfo/python-l

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-15 Thread Ethan Furman
Emile van Sebille wrote: brucegoodst...@gmail.com wrote: Using a decorator works when named arguments are not used. When named arguments are used, unexpected keyword error is reported. Is there a simple fix? Extend def wrapper(*args) to handle *kwargs as well Emile Code: - from funct

Re: Is there a simpler way to modify all arguments in a function before using the arguments?

2012-11-16 Thread Ethan Furman
bruceg113...@gmail.com wrote: On Thursday, November 15, 2012 11:16:08 PM UTC-5, Ethan Furman wrote: Emile van Sebille wrote: Using a decorator works when named arguments are not used. When named arguments are used, unexpected keyword error is reported. Is there a simple fix? Extend def

Re: Supporting list()

2012-12-17 Thread Ethan Furman
Skip Montanaro wrote: What method(s) does a class have to support to properly emulate a container which supports turning it into a list? For example: class Foo: pass f = Foo() print list(f) Is it just __iter__() and next()? (I'm still using 2.4 and 2.7.) You can either use __ite

Re: Supporting list()

2012-12-17 Thread Ethan Furman
Dave Angel wrote: On 12/17/2012 09:33 AM, Skip Montanaro wrote: What method(s) does a class have to support to properly emulate a container which supports turning it into a list? For example: class Foo: pass f = Foo() print list(f) Is it just __iter__() and next()? (I'm still usin

Re: Understanding while...else...

2013-01-22 Thread Ethan Furman
On 01/22/2013 09:44 AM, Terry Reedy wrote: Several people have trouble understanding Python's while-else and for-else constructs. It is actually quite simple if one starts with if-else, which few have any trouble with. Start with, for example if n > 0: n -= 1 else: n = None The else clau

Re: Retrieving an object from a set

2013-01-25 Thread Ethan Furman
On 01/25/2013 03:14 PM, Arnaud Delobelle wrote: I've got a seemingly simple problem, but for which I cannot find a simple solution. I have a set of objects (say S) containing an object which is equal to a given object (say x). So x in S is true. So there is an object y in S which is equa

Re: Using an object inside a class

2012-01-23 Thread Ethan Furman
Gary Herron wrote: If the method does not bind it, then Python will look in the class for foo. This could work class Class1: foo = whatever # Available to all instances def __init__(self): foo.bar.object self.foo.bar.object ^- needs the self r

Re: Weird newbie question

2012-01-26 Thread Ethan Furman
Matty Sarro wrote: from sys import argv script,filename=argv txt=open(filename) print "Here is your file %r:" % filename print txt.read() print "I'll also ask you to type it again:" file_again=raw_input("> ") txt_again=open(file_again) print txt_again.read() IDLE is saying that my error is on li

Re: except clause syntax question

2012-01-31 Thread Ethan Furman
Charles Yeomans wrote: On Jan 31, 2012, at 9:51 AM, Steven D'Aprano wrote: On Tue, 31 Jan 2012 08:57:31 -0500, Charles Yeomans wrote: I don't think of a tuple as a container, and I don't think it a misunderstanding on my part to think this. >> Well, it is a misunderstanding, because tuples A

Re: Question about name scope

2012-02-01 Thread Ethan Furman
Olive wrote: I am learning python and maybe this is obvious but I have not been able to see a solution. What I would like to do is to be able to execute a function within the namespace I would have obtained with from import * For example if I write: def f(a): return sin(a)+cos(a) I c

Re: Question about name scope

2012-02-01 Thread Ethan Furman
Ian Kelly wrote: I am not a dev, but I believe it works because assigning to locals() and assigning via exec are not the same thing. The problem with assigning to locals() is that you're fundamentally just setting a value in a dictionary, and even though it happens to be the locals dict for the

Re: Question about name scope

2012-02-01 Thread Ethan Furman
Ethan Furman wrote: Ian Kelly wrote: I am not a dev, but I believe it works because assigning to locals() and assigning via exec are not the same thing. The problem with assigning to locals() is that you're fundamentally just setting a value in a dictionary, and even though it happens

Re: Question about name scope

2012-02-01 Thread Ethan Furman
Ian Kelly wrote: On Wed, Feb 1, 2012 at 3:24 PM, Ethan Furman wrote: Definitely should rely on it, because in CPython 3 exec does not un-optimize the function and assigning to locals() will not actually change the functions variables. Well, the former is not surprising, since exec was

Re: Question about name scope

2012-02-01 Thread Ethan Furman
Ian Kelly wrote: On Wed, Feb 1, 2012 at 4:41 PM, Ethan Furman wrote: I'm not sure what you mean by temporary: --> def f(x, y): ... frob = None ... loc = locals() ... loc[x] = y ... print(loc) ... print(locals()) ... print(loc) ... print(locals()) ... -

Re: Question about name scope

2012-02-01 Thread Ethan Furman
Ian Kelly wrote: Sure, but that's not actually out of sync. The argument of your exec evaluates to 'print (a)'. You get two different results because you're actually printing two different variables. Ah -- thanks, I missed that. You can get the dict temporarily out of sync: def f(x, y):

Re: Question about name scope

2012-02-01 Thread Ethan Furman
Ethan Furman wrote: Ethan Furman wrote: Ian Kelly wrote: I am not a dev, but I believe it works because assigning to locals() and assigning via exec are not the same thing. The problem with assigning to locals() is that you're fundamentally just setting a value in a dictionary, and

Re: multiple namespaces within a single module?

2012-02-09 Thread Ethan Furman
Peter Otten wrote: jkn wrote: is it possible to have multiple namespaces within a single python module? Unless you are abusing classes I don't think so. Speaking of... class NameSpace(object): def __init__(self, globals): self.globals = globals self.current_keys =

Re: multiple namespaces within a single module?

2012-02-09 Thread Ethan Furman
Peter Otten wrote: Hm, what about with NameSpace(globals()) as a: x = "inside a!" def function(): print(x) with NameSpace(globals()) as b: x = "inside b!" def function(): print(x) x = "inside main!" a.function() b.function() It would have to be `a.x = ...` an

Re: multiple namespaces within a single module?

2012-02-09 Thread Ethan Furman
Ethan Furman wrote: Hrm -- and functions/classes/etc would have to refer to each other that way as well inside the namespace... not sure I'm in love with that... Not sure I hate it, either. ;) Slightly more sophisticated code: class NameSpace(object): def __init__

OT (waaaayyyyyyyyy off-topic) [was Re: How can I catch misnamed variables?]

2012-02-10 Thread Ethan Furman
Ben Finney wrote (from signature): > “It's a terrible paradox that most charities are driven by religious > belief. . . . if you think altruism without Jesus is not altruism, > then you're a dick.” —Tim Minchin, 2010-11-28 1) Why is it paradoxical? If anything it's a sad commentary on those who

ANN: dbf.py 0.90.001

2012-02-10 Thread Ethan Furman
Still messing with .dbf files? Somebody brought you a 15 year old floppy, which still luckily (?) worked, and now wants that ancient data? dbf to the rescue! Supported tables/features = - dBase III - FoxPro - Visual FoxPro supported - Null value Supported fiel

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

2012-02-15 Thread Ethan Furman
Steven D'Aprano wrote: On Wed, 15 Feb 2012 10:04:34 +, Duncan Booth wrote: Actually, I thought it was a bit weird that I saw ChrisA's comment but not the message he was commenting on until I went and looked for it. I read this group on a couple of machines and it looks like Rick's killfile

Re: Is this the right list?

2012-02-16 Thread Ethan Furman
On Fri, Feb 17, 2012 at 1:43 AM, Rick Johnson wrote: On 2/15/2012 4:51 PM, Alan McKay wrote: Is this the right list? >> This is neither the "right" or "left" list, however, it may be either the correct or incorrect depending on your question. Alan, Welcome to the list. There are lots of fr

Re: A quirk/gotcha of for i, x in enumerate(seq) when seq is empty

2012-02-23 Thread Ethan Furman
Steven D'Aprano wrote: On Thu, 23 Feb 2012 16:30:09 -0800, Alex Willmer wrote: This week I was slightly surprised by a behaviour that I've not considered before. I've long used for i, x in enumerate(seq): # do stuff as a standard looping-with-index construct. In Python for loops don't crea

Re: Python math is off by .000000000000045

2012-02-27 Thread Ethan Furman
jmfauth wrote: On 25 fév, 23:51, Steven D'Aprano wrote: On Sat, 25 Feb 2012 13:25:37 -0800, jmfauth wrote: (2.0).hex() '0x1.0p+1' (4.0).hex() '0x1.0p+2' (1.5).hex() '0x1.8p+0' (1.1).hex() '0x1.1999ap+0' jmf What's your point? I'm afraid my cr

Re: Question about circular imports

2012-02-28 Thread Ethan Furman
OKB (not okblacke) wrote: Anyway, testing this just reinforced my distaste for circular imports. Just trying to think about how it ought to work with a importing c but then c and d importing each other makes my brain hurt. Refactoring the files so that common code is in a separate librar

Re: Python math is off by .000000000000045

2012-02-28 Thread Ethan Furman
Michael Torrie wrote: He's simply showing you the hex (binary) representation of the floating-point number's binary representation. As you can clearly see in the case of 1.1, there is no finite sequence that can store that. You end up with repeating numbers. Thanks for the explanation. Thi

Re: A possible change to decimal.Decimal?

2012-03-02 Thread Ethan Furman
Jeff Beardsley wrote: HISTORY: In using python 2.7.2 for awhile on a web project (apache/wsgi web.py), I discovered a problem in using decimal.Decimal. A short search revealed that many other people have been having the problem as well, in their own apache/wsgi implementations (django, mos

Re: A possible change to decimal.Decimal?

2012-03-04 Thread Ethan Furman
A. Lloyd Flanagan wrote: On Friday, March 2, 2012 6:49:39 PM UTC-5, Ethan Furman wrote: Jeff Beardsley wrote: HISTORY: ... What you should be doing is: import decimal from decimal import Decimal reload(decimal) Decimal = decimal.Decimal # (rebind 'Decimal' to th

Re: A possible change to decimal.Decimal?

2012-03-04 Thread Ethan Furman
Jeff Beardsley wrote: The problem with that though: I am not calling reload(), except to recreate the error as implemented by the web frameworks. I am also unlikely to get a patch accepted into several different projects, where this is ONE project, and it's a simple change Simple -- maybe.

Re: newb __init__ inheritance

2012-03-08 Thread Ethan Furman
hyperboogie wrote: Hello everyone. This is my first post in this group. I started learning python a week ago from the "dive into python" e- book and thus far all was clear. However today while reading chapter 5 about objects and object orientation I ran into something that confused me. it says h

Re: What's the best way to write this regular expression?

2012-03-08 Thread Ethan Furman
Dave Angel wrote: On 03/08/2012 04:40 PM, John Salerno wrote: http://i271.photobucket.com/albums/jj138/JohnJSal/lxml_error.png Nothing to do with Python, but you'd save us all a lot of space and bandwidth if you learned how to copy/paste from a Windows cmd window. On Windows XP it is: Mo

stackoverflow question

2012-03-09 Thread Ethan Furman
Hey all! I posted a question/answer on SO earlier, but there seems to be some confusion around either the question or the answer (judging from the comments). http://stackoverflow.com/q/9638921/208880 If anyone here is willing to take a look at it and let me know if I did not write it well,

Re: stackoverflow question

2012-03-10 Thread Ethan Furman
Terry Reedy wrote: Thanks for the review, Terry! On 3/9/2012 5:10 PM, Ethan Furman wrote: http://stackoverflow.com/q/9638921/208880 If anyone here is willing to take a look at it and let me know if I did not write it well, I would appreciate the feedback Here's the question

Re: stackoverflow question

2012-03-10 Thread Ethan Furman
Owen Jacobson wrote: On 2012-03-09 22:10:18 +, Ethan Furman said: Hey all! I posted a question/answer on SO earlier, but there seems to be some confusion around either the question or the answer (judging from the comments). http://stackoverflow.com/q/9638921/208880 If anyone here is

Re: avoid import short-circuiting

2012-03-16 Thread Ethan Furman
Andrea Crotti wrote: I started the following small project: https://github.com/AndreaCrotti/import-tree because I would like to find out what exactly depends on what at run-time, using an import hook. It works quite well for small examples but the main problem is that once a module is impor

Re: Python is readable

2012-03-16 Thread Ethan Furman
Neil Cerutti wrote: On 2012-03-16, Steven D'Aprano wrote: Ah, perhaps you're talking about *prescriptivist* grammarians, who insist on applying grammatical rules that exist only in their own fevered imagination. Sorry, I was talking about the other sort, the ones who apply the grammatical rules

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-03-23 Thread Ethan Furman
Nathan Rice wrote: Logo. It's turtles all the way down. +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: Good web-development Python book

2012-03-23 Thread Ethan Furman
Chris Rebert wrote: On Fri, Mar 23, 2012 at 10:13 AM, Dennis Lee Bieber wrote: On Fri, 23 Mar 2012 09:30:24 -0700, Chris Rebert declaimed the following in gmane.comp.python.general: On Fri, Mar 23, 2012 at 9:16 AM, Yves S. Garret ** wrote: make web-applications using Python (as oppose

Re: Stream programming

2012-03-23 Thread Ethan Furman
Kiuhnm wrote: On 3/23/2012 17:33, Nathan Rice wrote: Given the examples you pose here, it is clear that you are assuming that the streams are synchronized in discrete time. Since you do not provide any mechanism for temporal alignment of streams you are also assuming every stream will have an e

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Ethan Furman
Peter Daum wrote: On 2012-03-28 12:42, Heiko Wundram wrote: Am 28.03.2012 11:43, schrieb Peter Daum: ... in my example, the variable s points to a "string", i.e. a series of bytes, (0x61,0x62 ...) interpreted as ascii/unicode characters. No; a string contains a series of codepoints from the un

Re: "convert" string to bytes without changing data (encoding)

2012-03-28 Thread Ethan Furman
Prasad, Ramit wrote: You can read as bytes and decode as ASCII but ignoring the troublesome non-text characters: print(open('text.txt', 'br').read().decode('ascii', 'ignore')) Das fr ASCII nicht benutzte Bit kann auch fr Fehlerkorrekturzwecke (Parittsbit) auf den Kommunikationsleitungen oder f

Re: unittest: assertRaises() with an instance instead of a type

2012-03-29 Thread Ethan Furman
Steven D'Aprano wrote: On Wed, 28 Mar 2012 14:28:08 +0200, Ulrich Eckhardt wrote: Hi! I'm currently writing some tests for the error handling of some code. In this scenario, I must make sure that both the correct exception is raised and that the contained error code is correct: try:

Re: unittest: assertRaises() with an instance instead of a type

2012-03-30 Thread Ethan Furman
Steven D'Aprano wrote: To the degree that the decision of how finely to slice tests is a matter of personal judgement and/or taste, I was wrong to say "that is not the right way". I should have said "that is not how I would do that test". I believe that a single test is too coarse, and three o

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-04-02 Thread Ethan Furman
Tim Rowe wrote: On 22 March 2012 19:14, Chris Angelico wrote: In any case, though, I agree that there's a lot of people professionally writing code who would know about the 3-4 that you say. I'm just not sure that they're any good at coding, even in those few languages. All the best people I'v

remainder of dividing by zero

2012-04-12 Thread Ethan Furman
Okay, so I haven't asked a stupid question in a long time and I'm suffering withdrawal symptoms... ;) 5 % 0 = ? It seems to me that the answer should be 5: no matter how many times we add 0 to itself, the remainder of the intermediate step will be 5. Is there a postulate or by definition ans

Re: remainder of dividing by zero

2012-04-13 Thread Ethan Furman
Ethan Furman wrote: Okay, so I haven't asked a stupid question in a long time and I'm suffering withdrawal symptoms... ;) 5 % 0 = ? Thanks for your replies, much appreciated. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: with statement

2012-04-19 Thread Ethan Furman
Ian Kelly wrote: On Thu, Apr 19, 2012 at 3:33 PM, Terry Reedy wrote: On 4/19/2012 1:15 PM, Kiuhnm wrote: A with statement is not at the module level only if it appears inside a function definition or a class definition. This is true, I believe, of all statements. Am I forgetting something?

Re: syntax for code blocks

2012-04-28 Thread Ethan Furman
Kiuhnm wrote: I'd like to change the syntax of my module 'codeblocks' to make it more pythonic. Current Syntax: with res << func(arg1) << 'x, y': print(x, y) with res << func(arg1) << block_name << 'x, y': print(x, y) New Syntax: with res == func(arg1) .taking_bl

Re: syntax for code blocks

2012-05-01 Thread Ethan Furman
Arnaud Delobelle wrote: On May 1, 2012 6:42 PM, "Jerry Hill" wrote: On Tue, May 1, 2012 at 1:07 PM, Kiuhnm wrote: If you had read the module's docstring you would know that the public version uses Are you aware that you've never posted a link to your module, nor it's docstrings? Are you also

__del__ and wisdom

2012-05-09 Thread Ethan Furman
Every time discussion about __del__ had come up I had thought to myself, "yeah, but I'm being careful to not have reference loops -- /my/ classes are okay." and then... BITE! But hey, it wasn't a reference loop that got me, it was data being written back to disk after the disk portion had c

ANN: dbf version 0.92.002 released

2012-05-10 Thread Ethan Furman
Available at http://pypi.python.org/pypi/dbf Fixed issue with Memo fields not returning correct unicode data. Updated many docstrings. Nulls now fully supported. Getting closer to a 1.0 (non-beta!) release; working on PEP 8 compliance, index files, and actual documentation. Biggest change =

PyPI is being spammed

2012-05-10 Thread Ethan Furman
with Dr Sultan Spells of various natures. Can anybody put a stop to that? ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

__all__, public API, private stuff, and leading _

2012-05-11 Thread Ethan Furman
Style question: Since __all__ (if defined) is the public API, if I am using that should I also still use a leading underscore on my private data/functions/etc? ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: __all__, public API, private stuff, and leading _

2012-05-11 Thread Ethan Furman
Emile van Sebille wrote: On 5/11/2012 9:41 AM Ethan Furman said... Style question: Since __all__ (if defined) is the public API, if I am using that should I also still use a leading underscore on my private data/functions/etc? I would, even if only to alert any future maintainer of the

Re: Newbie naive question ... int() throws ValueError

2012-05-12 Thread Ethan Furman
Devin Jeanpierre wrote: On Fri, May 11, 2012 at 11:21 PM, Chris Angelico wrote: There are times when you want to catch all exceptions, though. Top-level code will often want to replace exception tracebacks with error messages appropriate to some external caller, or possibly log the exception an

Re: Dealing with the __str__ method in classes with lots of attributes

2012-05-12 Thread Ethan Furman
Karl Knechtel wrote: On Thu, May 10, 2012 at 9:33 AM, Andreas Tawn wrote: And there's also something like... return "\n".join((": ".join((str(k), str(self.__dict__[k]))) for k in self.__dict__)) which is a nice length, but I lose control of the order of the attributes and the formatting is

cPython, IronPython, Jython, and PyPy (Oh my!)

2012-05-16 Thread Ethan Furman
Just hit a snag: In cPython the deterministic garbage collection allows me a particular optimization when retrieving records from a dbf file -- namely, by using weakrefs I can tell if the record is still in memory and active, and if so not hit the disk to get the data; with PyPy (and probably

Re: cPython, IronPython, Jython, and PyPy (Oh my!)

2012-05-16 Thread Ethan Furman
Ian Kelly wrote: On Wed, May 16, 2012 at 3:33 PM, Ethan Furman wrote: Just hit a snag: In cPython the deterministic garbage collection allows me a particular optimization when retrieving records from a dbf file -- namely, by using weakrefs I can tell if the record is still in memory and

Re: cPython, IronPython, Jython, and PyPy (Oh my!)

2012-05-16 Thread Ethan Furman
Tim Delaney wrote: On 17 May 2012 07:33, Ethan Furman wrote: Just hit a snag: In cPython the deterministic garbage collection allows me a particular optimization when retrieving records from a dbf file -- namely, by using weakrefs I can tell if the record is still in memory and active, and if

Re: cPython, IronPython, Jython, and PyPy (Oh my!)

2012-05-16 Thread Ethan Furman
Chris Angelico wrote: On Thu, May 17, 2012 at 9:01 AM, Ethan Furman wrote: A record is an interesting critter -- it is given life either from the user or from the disk-bound data; its fields can then change, but those changes are not reflected on disk until .write_record() is called; I do

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