Re: Why does this launch an infinite loop of new processes?

2011-12-21 Thread Ethan Furman
Andrew Berg wrote: I am trying to understand the multiprocessing module, and I tried some simple code: import multiprocessing def f(): print('bla bla') p = multiprocessing.Process(target=f) p.start() p.join() And the result is a new process that spawns a new process that spawns a new

Re: [OT] Quick intro to C++ for a Python and C user?

2011-12-21 Thread Ethan Furman
Grant Edwards wrote: On 2011-12-21, Neil Cerutti ne...@norwich.edu wrote: I cheerfully agree that programmers ignorant of C++ should not write programs in it. But furthermore, they should also not define a subset of C++ for use in embedded programming. ;) I fully agree that programmers

Re: what does 'a=b=c=[]' do

2011-12-22 Thread Ethan Furman
Rolf Camps wrote: alex23 schreef op wo 21-12-2011 om 16:50 [-0800]: I'd say that _is_ the most pythonic way, it's very obvious in its intent (or would be with appropriate names). If it bothers you that much: def listgen(count, default=[]): for _ in xrange(count): yield

Re: Can't I define a decorator in a separate file and import it?

2011-12-22 Thread Ethan Furman
Saqib Ali wrote: MYCLASS.PY: #!/usr/bin/env python import os, sys, string, time, re, subprocess import Singleton This should be 'from Singleton import Singleton' @Singleton class myClass: def __init__(self): print 'Constructing myClass' At this point, the *instance* of

Re: Can't I define a decorator in a separate file and import it?

2011-12-22 Thread Ethan Furman
Saqib Ali wrote: I'm using this decorator to implement singleton class in python: http://stackoverflow.com/posts/7346105/revisions The strategy described above works if and only if the Singleton is declared and defined in the same file. If it is defined in a different file and I import that

Re: what does 'a=b=c=[]' do

2011-12-23 Thread Ethan Furman
Ian Kelly wrote: On Thu, Dec 22, 2011 at 7:10 PM, alex23 wuwe...@gmail.com wrote: On Dec 22, 6:51 pm, Rolf Camps r...@roce.be wrote: I'm afraid it's dangerous to encourage the use of '[]' as assignment to a parameter in a function definition. If you use the function several times 'default'

Re: what does 'a=b=c=[]' do

2011-12-23 Thread Ethan Furman
rusi wrote: On Dec 23, 7:10 am, alex23 wuwe...@gmail.com wrote: On Dec 22, 6:51 pm, Rolf Camps r...@roce.be wrote: I'm afraid it's dangerous to encourage the use of '[]' as assignment to a parameter in a function definition. If you use the function several times 'default' always points to the

Re: Test None for an object that does not implement ==

2011-12-25 Thread Ethan Furman
GZ wrote: Hi, I run into a weird problem. I have a piece of code that looks like the following: f(, a=None, c=None): assert (a==None)==(c==None) Um -- if you don't want a and c being passed in, why put them in the function signature? ~Ethan~ --

Re: Test None for an object that does not implement ==

2011-12-25 Thread Ethan Furman
Nobody wrote: nothing should compare equal to None except for None itself, so x is None and x == None shouldn't produce different results unless there's a bug in the comparison method. Why wouldn't you want other types that can compare equal to None? It could be useful for a Null type to ==

Re: Test None for an object that does not implement ==

2011-12-26 Thread Ethan Furman
Devin Jeanpierre wrote: Um -- if you don't want a and c being passed in, why put them in the function signature? He wants both or neither to be passed in. Ah -- right. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: .format vs. %

2012-01-02 Thread Ethan Furman
Andrew Berg wrote: On 12/31/2011 12:19 PM, davidfx wrote: Should we always be using .format() for formatting strings or %? %-style formatting will eventually go away, but probably not for a long time. %-style formatting isn't going away. ~Ethan~ --

Re: Spamming PyPI with stupid packages

2012-01-03 Thread Ethan Furman
Peter Otten wrote: Lie Ryan wrote: On 01/02/2012 11:20 PM, Peter Otten wrote: Felinx Lee wrote: I have removed those packages (girlfriend and others) from PyPI forever, I apologize for that. The thought police has won :( I think the community has a right to defend themselves against

Re: .format vs. %

2012-01-03 Thread Ethan Furman
Ian Kelly wrote: I'm not sure it's true that there are no plans to do so in the foreseeable future. According to the release notes from Python 3.0, % formatting was supposed to be deprecated in Python 3.1. Eric Smith wrote (from a thread on pydev in 02-2011): The last thread on this I have a

Re: .format vs. %

2012-01-03 Thread Ethan Furman
Ian Kelly wrote: http://mail.python.org/pipermail/python-dev/2009-September/092399.html Thanks, that link is very informative. Here's the link to the last discussion last February: http://mail.python.org/pipermail/python-dev/2011-February/108155.html ~Ethan~ --

Re: .format vs. %

2012-01-03 Thread Ethan Furman
Devin Jeanpierre wrote: one obvious way != only one way Which way is the obvious way? Why is it obvious? Apparently, %-style is obvious to C and similar coders, while {}-style is obvious to Java and similar coders. :) ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: .format vs. %

2012-01-03 Thread Ethan Furman
Neil Cerutti wrote: On 2012-01-03, Stefan Krah stefan-use...@bytereef.org wrote: Andrew Berg bahamutzero8...@gmail.com wrote: To add my opinion on it, I find format() much more readable and easier to understand (with the exception of the {} {} {} {} syntax), and would love to see %-style

Re: Spamming PyPI with stupid packages

2012-01-03 Thread Ethan Furman
Ben Finney wrote: I have no idea what it would take to persuade you in particular. I do know that the combined privileges of being white, male, not-poor, and English-fluent (and many more privileges, I'm sure) grant both of us the luxury of barely even perceiving the harm done by a pervasive

Re: replacing __dict__ with an OrderedDict

2012-01-06 Thread Ethan Furman
Ulrich Eckhardt wrote: Hi! The topic explains pretty much what I'm trying to do under Python 2.7[1]. The reason for this is that I want dir(SomeType) to show the attributes in the order of their declaration. This in turn should hopefully make unittest execute my tests in the order of their

Re: copy on write

2012-01-13 Thread Ethan Furman
Steven D'Aprano wrote: Normally this is harmless, but there is one interesting little glitch you can get: t = ('a', [23]) t[1] += [42] Traceback (most recent call last): File stdin, line 1, in module TypeError: 'tuple' object does not support item assignment t ('a', [23, 42]) There is

NaN, Null, and Sorting

2012-01-13 Thread Ethan Furman
With NaN, it is possible to get a list that will not properly sort: -- NaN = float('nan') -- spam = [1, 2, NaN, 3, NaN, 4, 5, 7, NaN] -- sorted(spam) [1, 2, nan, 3, nan, 4, 5, 7, nan] I'm constructing a Null object with the semantics that if the returned object is Null, it's actual value is

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

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 line 4,

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

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 module import * For example if I write: def f(a): return

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 et...@stoneleaf.us 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

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 et...@stoneleaf.us 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 even

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... code class NameSpace(object): def __init__(self, globals): self.globals = globals

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 = ...` and

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: code class NameSpace(object): def __init__(self

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

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

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

Re: Python math is off by .000000000000045

2012-02-27 Thread Ethan Furman
jmfauth wrote: On 25 fév, 23:51, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info 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'

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

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.

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,

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 the reloaded

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

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: SNIP 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

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 text

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

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

Re: Python is readable

2012-03-16 Thread Ethan Furman
Neil Cerutti wrote: On 2012-03-16, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info 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

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 *yoursurrogate...@gmail.com* wrote: snip make

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

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

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

meta-class troubles

2010-08-30 Thread Ethan Furman
Good Day! I am stuck... hopefully a few fresh pairs of eyes will spot what I am missing. I have a metaclass, Traits, and two different testing files, test_traits.py and tests.py. test_traits works fine, tests generates the following error:

Re: meta-class troubles

2010-08-30 Thread Ethan Furman
Chris Rebert wrote: Shouldn't meta= instead be metaclass= ? Xavier Ho wrote: I think you need to have metaclass in the class statement, not just meta. Argh. Thank you both. I'm glad it was simple! ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Difference between queues and pipes in multiprocessing

2010-09-09 Thread Ethan Furman
James Mills wrote: On Wed, Aug 4, 2010 at 7:20 PM, Navkirat Singh navkir...@gmail.com wrote: I was wondering what are the differences between queues and pipes implemented using multiprocessing python module. Am I correct if I say, in pipes, if another process writes to one receiving end

Re: Difference between queues and pipes in multiprocessing

2010-09-09 Thread Ethan Furman
Nobody wrote: On Thu, 09 Sep 2010 12:23:17 -0700, Ethan Furman wrote: basically a Queue is a syncronization primitive used to share and pass data to and from parent/child processes. A pipe is as the name suggests, a socket pair connected end-to-end allowing for full-duplex communications

it doesn't work ;) [class recursive function]

2010-09-15 Thread Ethan Furman
I need some fresh eyes, or better brains, or both! The expected debugging output is a list of names in alphabetical order from each node (there are about 90 of them); what I am getting is this: -- dbf.tables.Index.from_file('', r'aad13658_last_name_for_state.idx') starting next_item call

Re: it doesn't work ;) [class recursive function]

2010-09-17 Thread Ethan Furman
MRAB wrote: On 17/09/2010 17:55, Ethan Furman wrote: MRAB wrote: On 16/09/2010 00:23, Ethan Furman wrote: PS My apologies if this shows up twice, I haven't seen my other post yet and it's been 27 hours. That's probably because you sent it directly to me. That would explain it -- like I

Re: The trouble with dynamic attributes.

2010-09-17 Thread Ethan Furman
Lie Ryan wrote: [snip] And even dict-syntax is not perfect for accessing XML file, e.g.: a bfoo/b bbar/b /a should a['b'] be 'foo' or 'bar'? Attribute style access would also fail in this instance -- how is this worked-around? -- ~Ethan~ --

parsing compact index files (*.cdx)

2010-09-17 Thread Ethan Furman
Greetings! Does anybody have any pointers, tips, web-pages, already written routines, etc, on parsing *.cdx files? I have found the pages on MS's sight for Foxpro, but they neglect to describe the compaction algorithm used, and my Google-fu has failed to find any sites with that information.

Re: parsing compact index files (*.cdx)

2010-09-17 Thread Ethan Furman
Ethan Furman wrote: Greetings! Does anybody have any pointers, tips, web-pages, already written routines, etc, on parsing *.cdx files? I have found the pages on MS's sight for Foxpro, but they neglect to describe the compaction algorithm used, and my Google-fu has failed to find any sites

Re: parsing compact index files (*.cdx)

2010-09-17 Thread Ethan Furman
MRAB wrote: On 17/09/2010 20:16, Ethan Furman wrote: Greetings! Does anybody have any pointers, tips, web-pages, already written routines, etc, on parsing *.cdx files? I have found the pages on MS's sight for Foxpro, but they neglect to describe the compaction algorithm used, and my Google-fu

Re: [DB-SIG] dbf files and compact indices

2010-09-18 Thread Ethan Furman
Carl Karsten wrote: On Sat, Sep 18, 2010 at 1:11 AM, Ethan Furman et...@stoneleaf.us wrote: Does anybody have any pointers, tips, web-pages, already written routines, etc, on parsing *.cdx files? I have found the pages on MS's sight for Foxpro, but they neglect to describe the compaction

Re: [DB-SIG] dbf files and compact indices

2010-09-18 Thread Ethan Furman
Carl Karsten wrote: On Sat, Sep 18, 2010 at 11:16 AM, Ethan Furman et...@stoneleaf.us wrote: Carl Karsten wrote: On Sat, Sep 18, 2010 at 1:11 AM, Ethan Furman et...@stoneleaf.us wrote: Does anybody have any pointers, tips, web-pages, already written routines, etc, on parsing *.cdx files

Re: [DB-SIG] dbf files and compact indices

2010-09-18 Thread Ethan Furman
Vernon Cole wrote: Ethan: I cannot see where you mentioned your operating system, I am assuming Windows. Perhaps you have already investigated this ... I have no way to test it ... but you might try: ADO can access almost any data source, and a quick look seems to show that .dbf is

Re: [DB-SIG] dbf files and compact indices

2010-09-18 Thread Ethan Furman
Dennis Lee Bieber wrote: On Sat, 18 Sep 2010 10:44:06 -0700, Ethan Furman et...@stoneleaf.us declaimed the following in gmane.comp.python.general: I have a pure-python module to read db3 and vfp 6 dbf files, and I find that I need to read (and write) the idx and cdx index files that foxpro

Re: [DB-SIG] dbf files and compact indices

2010-09-18 Thread Ethan Furman
Carl Karsten wrote: On Sat, Sep 18, 2010 at 11:23 PM, Ethan Furman et...@stoneleaf.us wrote: Thanks for the suggestion, but I don't want to be tied to Foxpro, which means I need to be able to parse these files directly. I have the dbf files, now I need the idx and cdx files. What do you

Re: [DB-SIG] dbf files and compact indices

2010-09-19 Thread Ethan Furman
M.-A. Lemburg wrote: If you are working on Windows, you can install the MS MDAC package to get a hold of the MS FoxPro ODBC drivers. They are usually already installed in Vista and 7, in XP they comes with MS SQL Server and MS Office as well. mxODBC can then provide Python access on Windows,

Re: os.path.normcase rationale?

2010-09-20 Thread Ethan Furman
Steven D'Aprano wrote: On Mon, 20 Sep 2010 19:45:37 +0100, Chris Withers wrote: Well, no, that doesn't feel right. Normalisation of case, for me, means give me the case as the filesystem thinks it should be, What do you mean the filesystem? Well, if it were me, it would be either the

Re: feature request: string.contains('...')

2010-09-24 Thread Ethan Furman
John Posner wrote: Another missing feature candidate: sublist 'bc' in 'abcde' True list('bc') in list('abcde') False I'm not aware of any idioms, but how about a simple function? def listinlist(list1, list2): checks if list1 is in list2 if not list1: return True

Re: Supplementing the std lib (Was: partial sums problem)

2010-09-29 Thread Ethan Furman
kj wrote: I'm interested in reading people's take on the question and their way of dealing with those functions they consider worthy of the standard library.) Well, I have no functions than I'm lobbying to get into the stdlib, but for all those handy-dandy utility functions, decorators, and

Re: if the else short form

2010-10-01 Thread Ethan Furman
John Nagle wrote: On 10/1/2010 12:42 AM, bruno.desthuilli...@gmail.com wrote: On 30 sep, 19:22, Andreas Waldenburgeruse...@geekmail.invalid wrote: But it does violate the explicit is better than implicit tenet, don't you think? Why so ? The doc clearly states that booleans are integers

difference between %s and %d

2010-10-01 Thread Ethan Furman
If I'm printing the number 735, or any other positive or negative integer, is there any difference between %7s and %7d? ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: difference between %s and %d

2010-10-01 Thread Ethan Furman
Ethan Furman wrote: If I'm printing the number 735, or any other positive or negative integer, is there any difference between %7s and %7d? Grant Edwards wrote: Let's ask Python: -- [n for n in range(-,,123) if (%7d % n) != (%7s % n)] [] -- [n for n

Re: sequence multiplied by -1

2010-10-04 Thread Ethan Furman
Antoon Pardon wrote: Suppose you write your class so that '+' will provide addition and you provide a method concat to concatenate. Now no matter how usefull the sequence library would be for you, you can't use it. You will have to rewrite those function you need, in terms of a concat method

meta-class review

2010-10-05 Thread Ethan Furman
On one the many mini-reports we use, we have a bunch of counts that are frequently zero; because the other counts can also be low, it becomes easy to miss the non-zero counts. For example: Code Description Conv Errors : 6 31,N DPV Failure : 4

Re: meta-class review

2010-10-05 Thread Ethan Furman
MRAB wrote: On 06/10/2010 00:17, Ethan Furman wrote: [snip] Any comments appreciated, especially ideas on how to better handle class- and staticmethods I think that's a bit of overkill. The problem lies in the printing part, but you're spreading the solution into the rest

Re: meta-class review

2010-10-06 Thread Ethan Furman
Carl Banks wrote: On Oct 5, 4:17 pm, Ethan Furman et...@stoneleaf.us wrote: class DashInt(int): __metaclass__ = Perpetuate def __str__(x): if x == 0: return '-' return int.__str__(x) Well, it's definitely overkill for printing a dash instead of a zero

Re: Eclipse/PyDev - BOM Lexical Error

2010-10-08 Thread Ethan Furman
Lawrence D'Oliveiro wrote: In message 87hbgyosdc@web.de, Diez B. Roggisch wrote: Lawrence D'Oliveiro l...@geek-central.gen.new_zealand writes: In message 87d3rorf2f@web.de, Diez B. Roggisch wrote: Lawrence D'Oliveiro l...@geek-central.gen.new_zealand writes: What exactly is the

Re: Many newbie questions regarding python

2010-10-09 Thread Ethan Furman
Steven D'Aprano wrote: And how often do you have an list that you are creating where you don't know what items you have to initialise the list with? [snip] You are right to point out that the third case is a Python gotcha: [[]]*n doesn't behave as expected by the naive or inexperienced

Re: Many newbie questions regarding python

2010-10-10 Thread Ethan Furman
Peter Pearson wrote: On Sat, 09 Oct 2010 19:30:16 -0700, Ethan Furman et...@stoneleaf.us wrote: Steven D'Aprano wrote: [snip] But that doesn't mean that the list comp is the general purpose solution. Consider the obvious use of the idiom: def func(arg, count): # Initialise the list

Re: Class-level variables - a scoping issue

2010-10-10 Thread Ethan Furman
John Nagle wrote: On 10/10/2010 12:53 AM, Lawrence D'Oliveiro wrote: In message4cb14f8c$0$1627$742ec...@news.sonic.net, John Nagle wrote: Within fn1, the first reference to self.classvar references the class- level version of classvar. The assignment overrides that and creates an

Re: Eclipse/PyDev - BOM Lexical Error

2010-10-10 Thread Ethan Furman
Lawrence D'Oliveiro wrote: In message mailman.1466.1286556950.29448.python-l...@python.org, Ethan Furman wrote: Lawrence D'Oliveiro wrote: But they can only recognize it as a BOM if they assume UTF-8 encoding to begin with. Otherwise it could be interpreted as some other coding. Not so

Re: Eclipse/PyDev - BOM Lexical Error

2010-10-11 Thread Ethan Furman
Lawrence D'Oliveiro wrote: In message mailman.1533.1286774527.29448.python-l...@python.org, Ethan Furman wrote: Lawrence D'Oliveiro wrote: In message mailman.1466.1286556950.29448.python-l...@python.org, Ethan Furman wrote: Lawrence D'Oliveiro wrote: But they can only recognize

Re: [Python-ideas] [Python-Dev] Inclusive Range

2010-10-11 Thread Ethan Furman
Antoon Pardon wrote: On Sat, Oct 09, 2010 at 01:37:03AM +, Steven D'Aprano wrote: On Fri, 08 Oct 2010 15:53:17 -0400, Jed Smith wrote: On Fri, Oct 8, 2010 at 1:26 PM, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Fri, 08 Oct 2010 10:21:16 +0200, Antoon Pardon wrote:

Re: I don't get why sys.exit(1) doesn't exit the while loop in the follow case

2010-10-11 Thread Ethan Furman
Lawrence D'Oliveiro wrote: In message pan.2010.10.05.20.44.49.109...@nowhere.com, Nobody wrote: If I'm catching exceptions in order to perform clean-up, I'll use a bare except and re-raise the exception afterwards. In that situation, a bare except is usually the right thing to do. Wrong way

Re: Help with sets

2010-10-11 Thread Ethan Furman
Lawrence D'Oliveiro wrote: In message 8h9ob9fku...@mid.individual.net, Gregory Ewing wrote: Lawrence D'Oliveiro wrote: Did you know that applying the “set” or “frozenset” functions to a dict return a set of its keys? Seems a bit dodgy, somehow. That's just a consequence of the fact that

Re: My first Python program

2010-10-13 Thread Ethan Furman
Seebs wrote: On 2010-10-12, Hallvard B Furuseth h.b.furus...@usit.uio.no wrote: self.type, self.name = None, None Actually you can write self.type = self.name = None, though assignment statements are more limited than in C. (And I think they're assigned left-to-right.) Python 2.5.4

multiple assignments (was: My first Python program)

2010-10-14 Thread Ethan Furman
Ian Kelly wrote: here is an example where the order of assignment actually matters: d['a'] = d = {} Traceback (most recent call last): File stdin, line 1, in module NameError: name 'd' is not defined d = d['a'] = {} d {'a': {...}} As you can see, they're assigned left-to-right.

Re: embarrassing class question

2010-10-21 Thread Ethan Furman
Jonas H. wrote: On 10/21/2010 08:09 PM, Brendan wrote: Two modules: x.py: class x(object): pass y.py: from x import x class y(x): pass Now from the python command line: import y dir(y) ['__builtins__', '__doc__', '__file__', '__name__', '__package__', 'x', 'y'] I do not

Re: how to scrutch a dict()

2010-10-22 Thread Ethan Furman
Neil Cerutti wrote: On 2010-10-21, James Mills prolo...@shortcircuit.net.au wrote: Rather than creating a new dict why don't you just do: def _scrunch(d): for k, v in d.items(): if v is None: del d[k] In Python 3, where items returns an iterator, modifying the dictionary in

Re: how to scrutch a dict()

2010-10-22 Thread Ethan Furman
John Nagle wrote: On 10/20/2010 9:32 PM, Phlip wrote: Not Hyp: def _scrunch(**dict): result = {} for key, value in dict.items(): if value is not None: result[key] = value return result That says throw away every item in a dict if the Value is None. Are there any

Re: Unix-head needs to Windows-ize his Python script (II)

2010-10-22 Thread Ethan Furman
gb345 wrote: In mailman.128.1287758336.2218.python-l...@python.org Tim Golden m...@timgolden.me.uk writes: On 22/10/2010 15:25, gb345 wrote: 3. Both versions of the app work fine on Windows 7, as long as I do the following: a. run CMD b. cd to where the GUI script and my original

Re: how to scrutch a dict()

2010-10-22 Thread Ethan Furman
John Nagle wrote: On 10/22/2010 6:10 AM, Ethan Furman wrote: John Nagle wrote: class nonnulldict(dict) : def __setitem__(self, k, v) : if not (v is None) : dict.__setitem__(self, k, v) That creates a subclass of dict which ignores stores of None values. So you never store the unwanted

Re: Nested Mapping

2010-10-22 Thread Ethan Furman
Raymond Hettinger wrote: On Oct 21, 5:18 pm, Paul Rubin no.em...@nospam.invalid wrote: The API you suggested looks reasonable although you should also say how to delete a context, how to find the inner contexts of a context, etc. The c.parent.parent.parent chain finds successive enclosing

Re: Why flat is better than nested?

2010-10-25 Thread Ethan Furman
kj wrote: In mailman.232.1288020268.2218.python-l...@python.org Steve Holden st...@holdenweb.com writes: On Oct 25, 5:07 am, kj no.em...@please.post wrote: In The Zen of Python, one of the maxims is flat is better than nested? Why? Can anyone give me a concrete example that illustrates

<    6   7   8   9   10   11   12   13   14   15   >