Re: set using alternative hash function?

2009-10-15 Thread Ethan Furman
Austin Bingham wrote: Yes, I can construct a dict as you specify, where all of the keys map to values with name attributes equal to the key. My point is that dict doesn't really help me enforce that beyond simply letting me set it up; it doesn't care about the values at all, just the keys. All th

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Ethan Furman
Mick Krippendorf wrote: Steve Holden wrote: Many such designs make mistakes like using multiple columns (or, even worse, comma-separated values) instead of many-to-many relationships. BTW, the comma-separted-values-in-a-field is officially called the First Anormal Form. There *has to be* som

Re: Object Relational Mappers are evil (a meditation)

2009-10-15 Thread Ethan Furman
Mick Krippendorf wrote: Ethan Furman schrieb: Mick Krippendorf wrote: BTW, the comma-separted-values-in-a-field is officially called the First Anormal Form. There *has to be* some value to it since I've seen it used quite a few times... Just because you've seen something, doesn

Re: set using alternative hash function?

2009-10-16 Thread Ethan Furman
Austin Bingham wrote: On Thu, Oct 15, 2009 at 7:49 PM, Ethan Furman wrote: Austin Bingham wrote: I'm feeling really dense about now... What am I missing? What you're missing is the entire discussion up to this point. I was looking for a way to use an alternative uniqueness cri

Re: restriction on sum: intentional bug?

2009-10-16 Thread Ethan Furman
Jon Clements wrote: On Oct 16, 5:59 pm, Tim Chase wrote: Stephen Hansen wrote: Why doesn't duck typing apply to `sum`? Because it would be so hideously slow and inefficient that it'd be way too easy a way for people to program something they think should work fine but really doesn't... al

Re: restriction on sum: intentional bug?

2009-10-18 Thread Ethan Furman
Dave Angel wrote: Dieter Maurer wrote: Christian Heimes writes on Fri, 16 Oct 2009 17:58:29 +0200: Alan G Isaac schrieb: I expected this to be fixed in Python 3: sum(['ab','cd'],'') Traceback (most recent call last): File "", line 1, in TypeError: sum() ca

Re: restriction on sum: intentional bug?

2009-10-18 Thread Ethan Furman
Carl Banks wrote: On Oct 18, 4:07 pm, Ethan Furman wrote: Dave Angel wrote: Earlier, I would have agreed with you. I assumed that this could be done invisibly, with the only difference being performance. But you can't know whether join will do the trick without error till you know

Re: File not closed on exception

2009-10-19 Thread Ethan Furman
arve.knud...@gmail.com wrote: Hi I thought that file objects were supposed to be garbage-collected and automatically closed once they go out of scope, at least that's what I've been told by more merited Python programmers. I'm also quite sure that this is quite a common assumption in various pro

Re: print()

2009-10-19 Thread Ethan Furman
Dave Angel wrote: It was intended to be understood, not copied. +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: os.system() question

2009-10-19 Thread Ethan Furman
Bryan Irvine wrote: I'm a python n00b and so pardon me in advance if this is really stupid question. I have my suspicions but why does the following not work the way I'm anticipating it will? (python 2.4.4) import os if (os.system('echo test')): ...print 'success' ... else: ...prin

Re: Checking a Number for Palindromic Behavior

2009-10-19 Thread Ethan Furman
gslindstrom wrote: On Oct 18, 5:56 pm, Gary Herron wrote: Benjamin Middaugh wrote: Thanks to everyone who helped with my query on reversing integers. I have one more simple problem I'm having trouble solving. I want to check a number for palindromic behavior (reading the same backwards and f

Re: Checking a Number for Palindromic Behavior

2009-10-19 Thread Ethan Furman
ru...@yahoo.com wrote: On Oct 19, 12:41 pm, Ethan Furman wrote: gslindstrom wrote: On Oct 18, 5:56 pm, Gary Herron wrote: Benjamin Middaugh wrote: Thanks to everyone who helped with my query on reversing integers. I have one more simple problem I'm having trouble solving. I wa

os.path.join

2009-10-19 Thread Ethan Furman
Following closely on the heels of the whole sum()ing strings debate, I think I found an error -- at least, it's not documented to behave this way... def uncompress_job(job_num, save_path='z:\\old_jobs', restore_path='z:\\orders'): destination = os.path.

Re: os.path.join

2009-10-19 Thread Ethan Furman
Ethan Furman wrote: Following closely on the heels of the whole sum()ing strings debate, I think I found an error -- at least, it's not documented to behave this way... def uncompress_job(job_num, save_path='z:\\old_jobs', restore_p

Re: File not closed on exception

2009-10-20 Thread Ethan Furman
arve.knud...@gmail.com wrote: On Oct 19, 3:48 pm, Ethan Furman wrote: arve.knud...@gmail.com wrote: Hi I thought that file objects were supposed to be garbage-collected and automatically closed once they go out of scope, at least that's what I've been told by more meri

Re: Checking a Number for Palindromic Behavior

2009-10-20 Thread Ethan Furman
Steven D'Aprano wrote: On Mon, 19 Oct 2009 13:29:52 -0700, Ethan Furman wrote: Your arguments are most persuasive. Consider me convinced. Even if the worst-case scenario is true (homework problem, ack!), either the poster will learn from the answer in which case all is well, or the p

Re: A stupid newbie question about output...

2009-10-20 Thread Ethan Furman
J wrote: Can someone explain why this code results in two different outputs? for os in comp.CIM_OperatingSystem (): print os.Name.split("|")[0] + " Service Pack", os.ServicePackMajorVersion osVer = os.Name.split("|")[0] + " Service Pack", os.ServicePackMajorVersion print osVer the first pri

Re: unittest wart/bug for assertNotEqual

2009-10-20 Thread Ethan Furman
Steven D'Aprano wrote: On Tue, 20 Oct 2009 14:45:49 -0700, Zac Burns wrote: My preference would be that failIfEqual checks both != and ==. This is practical, and would benefit almost all use cases. If "!=" isn't "not ==" (IEEE NaNs I hear is the only known use case) numpy uses == and != as

Re: Why does passing tuple as arg WITHOUT scattering work?

2009-10-20 Thread Ethan Furman
MRAB wrote: Alf P. Steinbach wrote: Hi all. I'm just learning Python from scratch, on my own. Apologies if this question is too newbie... Or perhaps answered in some FAQ (where?). Here's my original code for simple starter program, using the ActivePython implementation in Windows XP Prof,

Re: Windows file paths, again

2009-10-21 Thread Ethan Furman
Dan Guido wrote: I'm trying to write a few methods that normalize Windows file paths. I've gotten it to work in 99% of the cases, but it seems like my code still chokes on '\x'. I've pasted my code below, can someone help me figure out a better way to write this? This seems overly complicated for

Re: unittest wart/bug for assertNotEqual

2009-10-22 Thread Ethan Furman
Gabriel Genellina wrote: En Tue, 20 Oct 2009 19:57:19 -0300, Ethan Furman escribió: Steven D'Aprano wrote: On Tue, 20 Oct 2009 14:45:49 -0700, Zac Burns wrote: My preference would be that failIfEqual checks both != and ==. This is practical, and would benefit almost all use case

attribute access and indirection

2009-10-22 Thread Ethan Furman
Greetings, List! Say I have an old-fashioned dbf style table, with a single name field of 50 characters: names = dbf.Table(':memory:', 'name C(40)') Then I add a bunch of names from who-knows-where: for name in some_iterable(): names.append((name)) Now I want to know how many start wi

unicode and dbf files

2009-10-22 Thread Ethan Furman
Greetings, all! I would like to add unicode support to my dbf project. The dbf header has a one-byte field to hold the encoding of the file. For example, \x03 is code-page 437 MS-DOS. My google-fu is apparently not up to the task of locating a complete resource that has a list of the 256 p

Re: Parsing a large number of parms to a print statement.

2009-10-22 Thread Ethan Furman
KB wrote: Hi, I have to pass over 150 parameters to a print statement ala: print "%s %s %s <150'th unique text> %s" % (v [0], v[1], ... v[150]) I can't use a for loop like I normally would over the list "v" due to the different text fragments between each var. Is there a lambda function

Re: unicode and dbf files

2009-10-22 Thread Ethan Furman
John Machin wrote: On Oct 23, 7:28 am, Ethan Furman wrote: Greetings, all! I would like to add unicode support to my dbf project. The dbf header has a one-byte field to hold the encoding of the file. For example, \x03 is code-page 437 MS-DOS. My google-fu is apparently not up to the task

Re: unicode and dbf files

2009-10-23 Thread Ethan Furman
John Machin wrote: On Oct 23, 3:03 pm, Ethan Furman wrote: John Machin wrote: On Oct 23, 7:28 am, Ethan Furman wrote: Greetings, all! I would like to add unicode support to my dbf project. The dbf header has a one-byte field to hold the encoding of the file. For example, \x03 is

Re: unicode and dbf files

2009-10-26 Thread Ethan Furman
John Machin wrote: On Oct 24, 4:14 am, Ethan Furman wrote: John Machin wrote: On Oct 23, 3:03 pm, Ethan Furman wrote: John Machin wrote: On Oct 23, 7:28 am, Ethan Furman wrote: Greetings, all! I would like to add unicode support to my dbf project. The dbf header has a one

Re: unicode and dbf files

2009-10-26 Thread Ethan Furman
John Machin wrote: On Oct 27, 3:22 am, Ethan Furman wrote: John Machin wrote: Try this: http://webhelp.esri.com/arcpad/8.0/referenceguide/ Wow. Question, though: all those codepages mapping to 437 and 850 -- are they really all the same? 437 and 850 *are* codepages. You mean &quo

Re: unicode and dbf files

2009-10-27 Thread Ethan Furman
John Machin wrote: On Oct 27, 7:15 am, Ethan Furman wrote: > Let me rephrase -- say I get a dbf file with an LDID of \x0f that maps to a cp437, and the file came from a german oem machine... could that file have upper-ascii codes that will not map to anything reasonable on my \x01 cp

Re: restriction on sum: intentional bug?

2009-10-27 Thread Ethan Furman
Steve wrote: On Oct 17, 8:28 pm, Tim Chase wrote: Christian Heimes wrote: Alan G Isaac wrote: On 10/16/2009 5:03 PM, Christian Heimes wrote: It's not going to happen. That's a prediction, not a justification. It's not a prediction, it's a statement. It's not going to happend because

Re: unicode and dbf files

2009-10-27 Thread Ethan Furman
John Machin wrote: There may possibly different interpretations of a codepage out there somewhere, but they are all *intended* to be the same, and I advise you to cross the different-cp437s bridge *if* it exists and you ever come to it. Have you got access to files with LDID not in (0, 1) that y

Re: Web development with Python 3.1

2009-10-29 Thread Ethan Furman
Bruno Desthuilliers wrote: Dotan Cohen a écrit : I don't want to learn some "templating language" that duplicates what Python already has built in! Then use Mako - it uses plain Python to manage the presentation logic. And if you go for Mako, then you might as well switch to Pylons. Great f

Re: Bug(s) in Python 3.1.1 Windows installation

2009-10-29 Thread Ethan Furman
Mark Hammond wrote: On 29/10/2009 11:06 AM, Alf P. Steinbach wrote: So I suggest switching to some other more light-weight installer technology. Thanks for the suggestion, but I expect we will stick with MSI even with its shortcomings. Using MSI files has significant other advantages, par

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-29 Thread Ethan Furman
Alf P. Steinbach wrote: * James Harris: You get way too deep into Python in places (for a beginner's course in programming). For example, "from now on I’ll always use from __future__ in any program that uses print." Sorry, but I think that hiding such concerns is a real disservice. The diss

Re: Bug(s) in Python 3.1.1 Windows installation

2009-10-29 Thread Ethan Furman
Alf P. Steinbach wrote: * Ethan Furman: Mark Hammond wrote: On 29/10/2009 11:06 AM, Alf P. Steinbach wrote: So I suggest switching to some other more light-weight installer technology. Thanks for the suggestion, but I expect we will stick with MSI even with its shortcomings. Using

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-29 Thread Ethan Furman
Alf P. Steinbach wrote: * Ethan Furman: Alf P. Steinbach wrote: * James Harris: You get way too deep into Python in places (for a beginner's course in programming). For example, "from now on I’ll always use from __future__ in any program that uses print." Sorry, but I th

ANN: python-dBase 0.86 Released!

2009-11-03 Thread Ethan Furman
Greetings! I am happy to announce the latest release of python-dBase (dbf for short)! At this point it supports dBase III and Visual FoxPro 6 dbf files. It's a bit quicker now since it's using array.array to hold the records and not strings, and the API has been standardized. It also now ha

Re: Pyfora, a place for python

2009-11-03 Thread Ethan Furman
Daniel Fetchinson wrote: I was referring to this comment by Ben: "Suggestion: Please don't make efforts to fragment the community." This IMHO is hostile, because it presupposes that the mere goal of the OP is fragmenting the community It presupposes nothing of any goal. It describes a predict

Re: self.__dict__ tricks

2009-11-03 Thread Ethan Furman
Simon Brunning wrote: 2009/11/1 Steven D'Aprano : The only stupid question is the one you are afraid to ask. I was once asked, and I quote exactly, "are there any fish in the Atlantic sea?" That's pretty stupid. ;-) Are there any fish in the Dead Sea? ~Ethan~ -- http://mail.python.org/m

Re: Pyfora, a place for python

2009-11-04 Thread Ethan Furman
Daniel Fetchinson wrote: I was referring to this comment by Ben: "Suggestion: Please don't make efforts to fragment the community." This IMHO is hostile, because it presupposes that the mere goal of the OP is fragmenting the community It presupposes nothing of any goal. It describes a predict

Re: self.__dict__ tricks

2009-11-04 Thread Ethan Furman
Dennis Lee Bieber wrote: > Perfectly valid answer -- there are no fish as there is no > Atlantic sea Steven D'Aprano wrote: > Once in the distant past, there were no fish in what would become the > Atlantic Ocean (not sea) What's with the bias against the word 'sea'? sea –noun 1. the salt w

Re: Python as network protocol

2009-11-10 Thread Ethan Furman
Daniel Fetchinson wrote: I'm the king in my castle, although I'm fully aware of the fact that my castle might be ugly from the outside :) +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: Python as network protocol

2009-11-10 Thread Ethan Furman
Steven D'Aprano wrote: I can only repeat what I said to Daniel: can you guarantee that the nice safe, low-risk environment will never change? If not, then choose a more realistic threat model, and build the walls of your locked box accordingly. Seems to me you can't really *guarentee* anythin

Re: How can a module know the module that imported it?

2009-11-11 Thread Ethan Furman
Aahz wrote: In article , kj wrote: The subject line says it all. You are probably trying to remove a screw with a hammer -- why don't you tell us what you really want to do and we'll come up with a Pythonic solution? Well, I don't know what kj is trying to do, but my project is another

using inspect

2009-11-11 Thread Ethan Furman
Greetings! How wise is it to base code on inspect? Specifically on things like live frames on the stack and whatnot. It occurs to me that this is leaning towards implementation details, and away from pure, pristine Python. As an example, I have this routine in a module I'm working on: def

Re: How can a module know the module that imported it?

2009-11-12 Thread Ethan Furman
AK Eric wrote: so: # moduleA.py import moduleB # moduleB.py import sys stuff = sys._getframe(1).f_locals print stuff Prints: {'__builtins__': , '__file__': 'C:\\Documents and SettingsMy Documents\ \python\\moduleA.py', '__name__': '__main__', '__doc__': None} Looks like you could query s

the unicode saga continues...

2009-11-13 Thread Ethan Furman
So I've added unicode support to my dbf package, but I also have some rather large programs that aren't ready to make the switch over yet. So as a workaround I added a (rather lame) option to convert the unicode-ified data that was decoded from the dbf table back into an encoded format. Here

Re: Calling Python functions from Excel

2009-11-17 Thread Ethan Furman
Chris Withers wrote: Mark Tolonen wrote: The book Python: Programming on Win32 has a whole chapter on COM, and a section on COM servers. ...and it's generally accepted that COM sucks rocks through straws, so explore alternatives when they're available ;-) +1 QOTW :D -- http://mail.python.o

Re: non-copy slices

2009-11-18 Thread Ethan Furman
tbour...@doc.ic.ac.uk wrote: Hi, I was looking for a facility similar to slices in python library that would avoid the implicit creation of a new list and copy of elements that is the default behaviour. Instead I'd rather have a lazy iteratable object on the original sequence. Well, in the en

Re: non-copy slices

2009-11-19 Thread Ethan Furman
Please don't top post. :) tbour...@doc.ic.ac.uk wrote: On Thu, Nov 19, 2009 at 3:00 AM, Rami Chowdhury mailto:rami.chowdh...@gmail.com>> wrote: I'm not sure you're understanding the point others have been making. A list item is merely another reference to an existing object -- it

Re: non-copy slices

2009-11-19 Thread Ethan Furman
Themis Bourdenas wrote: On Thu, Nov 19, 2009 at 2:44 PM, Ethan Furman <mailto:et...@stoneleaf.us>> wrote: So "shallow copy" == "new label created for existing object". So is your desired behavior to write back to the original list if your sub-list is m

Re: Is an interactive command a block?

2009-11-20 Thread Ethan Furman
Alf P. Steinbach wrote: * Benjamin Kaplan: On Thu, Nov 19, 2009 at 4:42 PM, Alf P. Steinbach wrote: >>> I feel that there's still something lacking in my understanding though, like how/where the "really actually just pure local not also global" is defined for function definition, but it's n

Re: Newsgroup for beginners

2009-11-20 Thread Ethan Furman
Aahz wrote: In article , Grant Edwards wrote: You've really got to try pretty hard to create one. But if you want to, here's how to do it: 1) Start by complaining that your program doesn't work because of a bug in Python. [...] Post of the month! I'll second that! I really needed a

Re: Relative versus absolute paths on Windows

2009-11-20 Thread Ethan Furman
Jason R. Coombs wrote: The current implementation of Python (2.6.4, 3.1.1) treats \bar as a relative path but reports it as an absolute path. ntpath.isabs('\\bar') True ntpath.abspath('\\bar') 'C:\\bar' os.chdir('d:\\') ntpath.abspath('\\bar') 'd:\\bar' os.chdir('server\\share'

Re: Is an interactive command a block?

2009-11-20 Thread Ethan Furman
Steven D'Aprano wrote: On Fri, 20 Nov 2009 08:02:38 -0800, Ethan Furman wrote: module scope == global scope That is, there is nothing higher than module scope. (So, yes, global is a slight misnomer... in Python it means 'global to a module'.) Actually there is: built-ins.

Re: semantics of [:]

2009-11-20 Thread Ethan Furman
Dave Angel wrote: Esmail wrote: Esmail schrieb: Could someone help confirm/clarify the semantics of the [:] operator in Python? a = range(51,55) # 1 ## b = a[:] # b receives a copy of a, but they are independent Semi-aside, if I wanted to make local copy of a li

attributes, properties, and accessors -- philosophy

2009-11-23 Thread Ethan Furman
The problem I have with properties is my typing. I'll end up assigning to an attribute, but get the spelling slightly wrong (capitalized, or missing an underscore -- non-obvious things when bug-hunting), so now I have an extra attribute which of course has zero effect on what I'm trying to do

Re: Relative versus absolute paths on Windows

2009-11-23 Thread Ethan Furman
Jason R. Coombs wrote: On Nov 20, 3:52 pm, Ethan Furman wrote: It is often said on this list that 'Python is not Java'. It is also true that 'Windows is not Unix'. Unlike the *nix world where there is a *single* root, and everything else is relative to that, in the Win

Re: Relative versus absolute paths on Windows

2009-11-23 Thread Ethan Furman
Christian Heimes wrote: Gregory Ewing wrote: ntpath.join('d:\\foo', '\\bar') '\\bar' This does seem like a bug, though -- the correct result should really be 'd:\\bar', since that's what you would get if you used the name '\\bar' with 'd:' as your current drive. No, it's not a bug. Since

Re: attributes, properties, and accessors -- philosophy

2009-11-24 Thread Ethan Furman
Bruno Desthuilliers wrote: Ethan Furman a écrit : The problem I have with properties is my typing. I'll end up assigning to an attribute, but get the spelling slightly wrong (capitalized, or missing an underscore -- non-obvious things when bug-hunting), so now I have an extra attr

Re: attributes, properties, and accessors -- philosophy

2009-11-24 Thread Ethan Furman
Chris Rebert wrote: On Tue, Nov 24, 2009 at 9:39 AM, Ethan Furman wrote: Bruno Desthuilliers wrote: Ethan Furman a écrit : The problem I have with properties is my typing. I'll end up assigning to an attribute, but get the spelling slightly wrong (capitalized, or missing an under

Re: attributes, properties, and accessors -- philosophy

2009-11-25 Thread Ethan Furman
Bruno Desthuilliers wrote: Ethan Furman a écrit : Let's head towards murkier waters (at least murkier to me -- hopefully they can be easily clarified): some of the attributes are read-only, such as record count; others are not directly exposed, but still settable, such as table ve

Re: Python and Ruby

2010-02-05 Thread Ethan Furman
Robert Kern wrote: On 2010-02-04 14:55 PM, Jonathan Gardner wrote: On Feb 3, 3:39 pm, Steve Holden wrote: Robert Kern wrote: On 2010-02-03 15:32 PM, Jonathan Gardner wrote: I can explain all of Python in an hour; I doubt anyone will understand all of Python in an hour. With all respect,

Re: Your beloved python features

2010-02-05 Thread Ethan Furman
Julian wrote: Hello, I've asked this question at stackoverflow a few weeks ago, and to make it clear: this should NOT be a copy of the stackoverflow-thread "hidden features of Python". I want to design a poster for an open source conference, the local usergroup will have a table there, and in t

Re: Python and Ruby

2010-02-05 Thread Ethan Furman
Robert Kern wrote: On 2010-02-04 17:46 PM, Ethan Furman wrote: Robert Kern wrote: On 2010-02-04 14:55 PM, Jonathan Gardner wrote: On Feb 3, 3:39 pm, Steve Holden wrote: Robert Kern wrote: On 2010-02-03 15:32 PM, Jonathan Gardner wrote: I can explain all of Python in an hour; I doubt

Re: How to guard against bugs like this one?

2010-02-05 Thread Ethan Furman
John Nagle wrote: kj wrote: ... Through a *lot* of trial an error I finally discovered that the root cause of the problem was the fact that, in the same directory as buggy.py, there is *another* innocuous little script, totally unrelated, whose name happens to be numbers.py. The right ans

Re: "if {negative}" vs. "if {positive}" style

2010-02-10 Thread Ethan Furman
Tim Chase wrote: Any thoughts on how others make the choice? -tkc If one branch is only a few lines, it comes first. As often as not, that tiny branch is checking for errors, and the "else" branch doesn't need to be indented. def func(arg1): if arg1 is 'stupid': raise ValueErr

Re: Modifying Class Object

2010-02-10 Thread Ethan Furman
Steven D'Aprano wrote: Believe me Alf, the fact that people are taking the time to try to argue with you instead of just kill-filing you is a compliment. It's a compliment I am not paying, although I am grateful to those who are attempting to teach him. At the rate it's going, though, I don

Re: Please help with MemoryError

2010-02-12 Thread Ethan Furman
mk wrote: John Posner wrote: http://effbot.org/zone/call-by-object.htm http://en.wikipedia.org/wiki/Evaluation_strategy [1] http://mail.python.org/pipermail/edu-sig/2008-May/008583.html Hmm how about "call by label-value"? That is, you change labels by assignment, but pass the v

Re: Modifying Class Object

2010-02-14 Thread Ethan Furman
Steve Howell wrote: On Feb 14, 7:11 am, Steven D'Aprano wrote: On Sat, 13 Feb 2010 23:45:47 -0800, Steve Howell wrote: The term "pointer" is very abstract. Please give me a concrete definition of a pointer. A programming language data type whose value directly specifies (or "points to") a

Re: The future of "frozen" types as the number of CPU cores increases

2010-02-18 Thread Ethan Furman
John Nagle wrote: John Nagle wrote: I look at this as Python's answer to multicore CPUs and "Go". On that note, I went to a talk at Stanford yesterday by one of the designers of Intel's Nelahem core. The four-core, eight thread version is out now. The six-core, twelve thread version i

Re: python dowload

2010-02-23 Thread Ethan Furman
monkeys paw wrote: NEW QUESTION if y'all are still reading: Is there an integer increment operation in Python? I tried using i++ but had to revert to 'i = i + 1' Nope, but try i += 1. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: Renaming identifiers & debugging

2010-02-25 Thread Ethan Furman
Luca wrote: [snippety] Maybe you are right, but being italian myself i can remember when i was a middle schooler (no computer before that) and the hours spent on my MSX figuring out how the thing worked. I learned all the commands as "brandnames" without really understanding them. I had _no_

Advanced Python Programming Oxford Lectures [was: Re: *Advanced* Python book?]

2010-03-25 Thread Ethan Furman
Michele Simionato wrote: On Jan 16, 9:27 pm, mk wrote: Hello everyone, I looked for it I swear, but just can't find it. Most Python books seem to focus on examples of how to call functions from standard library. I don't need that, I have online Python documentation for that. I mean really a

Re: Python database of plain text editable by notepad or vi

2010-03-26 Thread Ethan Furman
Jon Clements wrote: On 26 Mar, 09:49, James Harris wrote: On 25 Mar, 22:56, Jon Clements wrote: On 25 Mar, 22:40, James Harris wrote: I am looking to store named pieces of text in a form that can be edited by a standard editor such as notepad (under Windows) or vi (under Unix) and th

Simple Traits Questions

2010-03-27 Thread Ethan Furman
Okay, different post for my actual questions. :) On the PyPI page for strait (http://pypi.python.org/pypi/strait/0.5.1) it has the example of choosing which methods to keep in the composed class: class TOSWidget(BaseWidget): __metaclass__ = include(Pack, Place, Grid) info = Pack.info.

Simple Traits

2010-03-27 Thread Ethan Furman
Wow. I just stumbled across one of Michele Simionato's offerings, called simple traits (strait for short) which looks *really* cool. You can find it here: http://pypi.python.org/pypi/strait/0.5.1 Extremely quick summary: Instead of multiple inheritance, with it's range of problems, use singl

Re: Classes as namespaces?

2010-03-27 Thread Ethan Furman
Jonathan Hartley wrote: Hey everyone. By coincidence, only yesterday I was wondering about using classes as a way of labeling a block of code, ie. an lightweight alternative to defining a function that would only be called from one location. eg. instead of: x = 1 ((some complex logic)) y = 2

Re: Simple Traits Questions

2010-03-28 Thread Ethan Furman
Robert Kern wrote: On 2010-03-27 08:19 , Ethan Furman wrote: Okay, different post for my actual questions. :) On the PyPI page for strait (http://pypi.python.org/pypi/strait/0.5.1) it has the example of choosing which methods to keep in the composed class: class TOSWidget(BaseWidget

Python 3.1, object, and setattr()

2010-04-01 Thread Ethan Furman
Greetings! Perhaps I woke up too early this morning, but this behaviour has me baffled: Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. --> test = object() --> setattr(test, 'example'

Re: Python 3.1, object, and setattr()

2010-04-01 Thread Ethan Furman
Many thanks for the replies, and especially for the very detailed explanation. Makes much more sense now. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: C-style static variables in Python?

2010-04-02 Thread Ethan Furman
kj wrote: class _Spam(object): @classmethod def _(cls, x, y, z): try: mongo = cls.mongo except AttributeError: mongo = cls.mongo = heavy_lifting_at_runtime() return frobnicate(x, y, z, mongo) ham = _Spam._(1, 2, 3) Is this really more n

Re: subclass of object

2010-04-02 Thread Ethan Furman
Steve Holden wrote: Alf P. Steinbach wrote: * Jason Friedman: Hi, what is the difference between: def MyClass(object): pass and def MyClass(): pass If you really meant 'def', then the first is a routine taking one argument, and the second is a routine of no arguments. If you meant

Re: C-style static variables in Python?

2010-04-02 Thread Ethan Furman
Patrick Maupin wrote: On Apr 2, 1:21 pm, Ethan Furman wrote: For this type of situation, my preference would be: class spam(object): def __call__(self, x, y, z): try: mongo = self.mongo except AttributeError: mongo = self.mongo

Re: C-style static variables in Python?

2010-04-02 Thread Ethan Furman
Patrick Maupin wrote: [snippage] Well, I think the whole discussion has basically been about personal preference. OTOH, but if you call the function a few million times, you might find the cost of try/except to be something that you would rather not incur -- it might become a performance issue

Re: (a==b) ? 'Yes' : 'No'

2010-04-02 Thread Ethan Furman
kj wrote: In Steve Holden writes: John Nagle wrote: Chris Rebert wrote: On Tue, Mar 30, 2010 at 8:40 AM, gentlestone wrote: Hi, how can I write the popular C/JAVA syntax in Python? Java example: return (a==b) ? 'Yes' : 'No' My first idea is: return ('No','Yes')[bool(a==b)] Is th

Re: C-style static variables in Python?

2010-04-02 Thread Ethan Furman
Terry Reedy wrote: In Duncan Booth writes: class Spam(object): mongo = None def __call__(self, x, y, z): if self.mongo is None: self.mongo = heavy_lifting_at_runtime() return frobnicate(x, y, z, self.mongo) Unless one wants the intialization of mongo delayed

Re: C-style static variables in Python?

2010-04-02 Thread Ethan Furman
Steven D'Aprano wrote: On Fri, 02 Apr 2010 12:39:16 -0700, Patrick Maupin wrote: On Apr 2, 2:38 pm, Ethan Furman wrote: [...] Sounds like a personal preference issue, rather than a necessary / unnecessary issue -- after all, if you call that function a thousand times, only once is

Traits implementation for Python 3

2010-04-02 Thread Ethan Furman
Well, it's been said than imitation is the sincerest form of flattery, so be flattered, Michele! In order to gain a better understanding of the whole metaclass issue, I decided to make my own implementation, targeting Python 3. I figured I could leave out a bunch of the complexity required to

Re: C-style static variables in Python?

2010-04-02 Thread Ethan Furman
Steven D'Aprano wrote: On Fri, 02 Apr 2010 19:48:59 -0700, Ethan Furman wrote: The heuristic I use is, if I expect the try block to raise an exception more than about one time in ten, I change to an explicit test. In this case, since the exception should only be raised once, and then

Re: Packages at Python.org

2010-12-01 Thread Ethan Furman
kirby.ur...@gmail.com wrote: With Microsoft abandoning Visual FoxPro come 2015, we have 100K developers jumping ship (rough guess), perhaps to dot NET, but not necessarily.** This page is potentially getting a lot of hits (I'm not privy to the analytics): http://packages.python.org/dbf/ The

Re: DBF (VFP) to XLS (Excel) in pure Python

2010-12-02 Thread Ethan Furman
kirby.ur...@gmail.com wrote: Some ideas: for (i, name) in enumerate(thedbf.field_names): sheet1.write(0, i, name, header_style) thetype = thedbf.type(name) thelen, thedec = thedbf.size(name) if thetype == "M": thelen = 100 elif thelen == 0:

Re: Exception handling in Python 3.x

2010-12-03 Thread Ethan Furman
Peter Otten wrote: > http://mail.python.org/pipermail/python-list/2010-October/1258606.html http://mail.python.org/pipermail/python-list/2010-October/1259024.html I found #6210 on bugs.python.org -- does anyone know if there are any others regarding this issue? Or any progress on MRAB's idea

Re: Exception handling in Python 3.x

2010-12-03 Thread Ethan Furman
Peter Otten wrote: Hrvoje Niksic wrote: Peter Otten <__pete...@web.de> writes: Note that StopIteration is an internal detail of no relevance whatsoever to the caller. Expose this is unnecessary at best and confusing at worst. http://mail.python.org/pipermail/python-list/2010-October/1258606.

Re: Proposed changes to logging defaults

2010-12-09 Thread Ethan Furman
Vinay Sajip wrote: Some changes are being proposed to how logging works in default configurations. I like the changes proposed. Question about the "handler of last resort": is there only one of them, or will each library have its own so it can decide what the minimum severity should be for

Re: Exception handling in Python 3.x

2010-12-13 Thread Ethan Furman
Please don't top-post. Rob Richardson wrote: -Original Message- I missed the start of this discussion but there are two simpler ways: def func(iterable): for x in iterable: print(x) return raise ValueError("... empty iterable") Or using 3.x's next's optional

Re: Exception handling in Python 3.x

2010-12-13 Thread Ethan Furman
Arnaud Delobelle wrote: I missed the start of this discussion but there are two simpler ways: def func(iterable): for x in iterable: print(x) return raise ValueError("... empty iterable") For the immediate case this is a cool solution. Unfortunately, it doesn't fix t

Re: Exception handling in Python 3.x

2010-12-13 Thread Ethan Furman
Ethan Furman wrote: Please don't top-post. Rob Richardson wrote: -Original Message- I missed the start of this discussion but there are two simpler ways: def func(iterable): for x in iterable: print(x) return raise ValueError("... empty iterable&q

Re: Exception handling in Python 3.x

2010-12-13 Thread Ethan Furman
Ethan Furman wrote: Arnaud Delobelle wrote: I missed the start of this discussion but there are two simpler ways: def func(iterable): for x in iterable: print(x) return raise ValueError("... empty iterable") For the immediate case this is a cool solutio

Re: Request for feedback on API design

2010-12-13 Thread Ethan Furman
Steven D'Aprano wrote: I am soliciting feedback regarding the API of my statistics module: http://code.google.com/p/pycalcstats/ Specifically the following couple of issues: (1) Multivariate statistics such as covariance have two obvious APIs: A pass the X and Y values as two separate it

<    11   12   13   14   15   16   17   18   19   20   >