Re: Python-list Digest, Vol 18, Issue 208

2005-03-14 Thread Jeff Shannon
sizes, octal is nearly useless but is still carried about for backwards compatibility. Jeff Shannon -- http://mail.python.org/mailman/listinfo/python-list

Re: Python-list Digest, Vol 18, Issue 208

2005-03-14 Thread Jeff Shannon
Steven Bethard wrote: Jeff Shannon wrote: now that almost the entire industry has standardized on power-of-2 word sizes, octal is nearly useless but is still carried about for backwards compatibility. So do you think it's worth lobbying for its removal in Python 3.0 when we can break

Re: will it cause any problems to open a read-only file & not close it?

2005-03-14 Thread Jeff Shannon
that, then this idiom should be harmless even under Jython. Jeff Shannon -- http://mail.python.org/mailman/listinfo/python-list

Re: urllib (and urllib2) read all data from page on open()?

2005-03-14 Thread Jeff Shannon
the system network code instead of the application code.) If you need to care about when the network access happens, then you should be using the lower-level protocols -- httplib and/or socket. Jeff Shannon -- http://mail.python.org/mailman/listinfo/python-list

Re: a program to delete duplicate files

2005-03-14 Thread Jeff Shannon
m constructing a single hash collision to make it worthwhile to invest a *large* number of petaflops of processing power.) Sure it's not "100% perfect", but... how perfect do you *really* need? Jeff Shannon -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I load a module when I will only know the name 'on the fly'

2005-03-14 Thread Jeff Shannon
Tobiah wrote: m = get_next_module() some_nice_function_somehow_loads( m ) that'd be mymodule = __import__('modulename') Jeff Shannon -- http://mail.python.org/mailman/listinfo/python-list

Re: Python-list Digest, Vol 18, Issue 208

2005-03-15 Thread Jeff Shannon
Martin v. Löwis wrote: Jeff Shannon wrote: I'd be in favor of that, unless someone can come up with a compelling current use-case for octal literals. Existing code. It may use octal numbers, and it would break if they suddenly changed to decimal. Right, which was my original point -- i

Re: Python becoming less Lisp-like

2005-03-15 Thread Jeff Shannon
my guess being that it's towards the hight end of that range. Jeff Shannon -- http://mail.python.org/mailman/listinfo/python-list

Re: Python becoming less Lisp-like

2005-03-15 Thread Jeff Shannon
icial things, and in many cases there's real evidence to support the contention that Python's design choices will decrease the frequency of bugs. Perhaps Python *is* becoming less Lisp-like... but I've never been convinced that Lisp is the best of all possible programming l

Re: will it cause any problems to open a read-only file & not close it?

2005-03-16 Thread Jeff Shannon
the automatic file closing happens as part of the object deletion, files opened in this way won't be closed until the garbage collector runs (and collects this file object). Most of the time, this won't be a problem, but it's good to be aware that things are not necessar

Re: Python becoming less Lisp-like

2005-03-16 Thread Jeff Shannon
in other cases it won't be, so it's important to keep in mind that the cost exists. Jeff Shannon -- http://mail.python.org/mailman/listinfo/python-list

Re: multiple import of a load of variables

2005-03-16 Thread Jeff Shannon
As far as I'm concerned, if you're just going to 'import *' your helper modules, you might as well leave the whole mess as one big file, because you're throwing away almost all of the benefits of dividing it into modules. Jeff Shannon -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting current variable name

2005-03-17 Thread Jeff Shannon
st would enable you to do this for multiple local names with a single call, but getvinfo() doesn't try to do that... Don't forget, in Python, all names are references. You only have to be careful when you start re-binding names... Jeff Shannon -- http://mail.python.org/mailman/listinfo/python-list

Re: Python becoming less Lisp-like

2005-03-18 Thread Jeff Shannon
Antoon Pardon wrote: Op 2005-03-16, Jeff Shannon schreef <[EMAIL PROTECTED]>: Bruno Desthuilliers wrote: - if x is a class attribute of class A and a is an instance of A, a.x=anyvalue create a new instance attribute x instead of modifying A.x This is very consistent with the way that bin

Re: how to handle repetitive regexp match checks

2005-03-18 Thread Jeff Shannon
raise ValueError("...") The for/else pattern may look a bit odd, but the key feature here is that the else clause only runs if the for loop terminates normally -- if you break out of the loop, the else does *not* run. Jeff Shannon -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python like VB?

2005-03-18 Thread Jeff Shannon
lopers working on OO.o), it's not too surprising that OpenOffice hasn't changed that much. Jeff Shannon -- http://mail.python.org/mailman/listinfo/python-list

Re: Pre-PEP: Dictionary accumulator methods

2005-03-18 Thread Jeff Shannon
Raymond Hettinger wrote: def count(self, value, qty=1): try: self[key] += qty except KeyError: self[key] = qty I presume that the argument list is a typo, and should actually be def count(self, key, qty=1): ... Correct? Jeff

Re: RELEASED Python 2.4 (final)

2004-11-30 Thread Jeff Shannon
Now(tm), though, now that 2.4 is officially released. Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: installing 2.4

2004-12-02 Thread Jeff Shannon
ll have 2.4-compiled binary distributions pretty soon. As for 2.3 being broken, check your application path and file associations. You may be inadvertently running the 2.3 version of Pythonwin under the 2.4 interpreter. Jeff Shannon Technician/Programmer Credit International -- http://mai

Re: installing 2.4

2004-12-02 Thread Jeff Shannon
ou can try reinstalling 2.4, uninstalling the packages, and then uninstalling 2.4 again... or, if the packages' files were deleted when Python was uninstalled, you may have to hack your registry to remove those entries from the uninstall list. Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: Replace string except inside quotes?

2004-12-03 Thread Jeff Shannon
;""My "foo" object"""), then things break down again. In order to handle this sort of nested structure with anything resembling true reliability, it's necessary to step up to a true lexing/parsing procedure, instead of mere string matching and regular

Re: updating locals() and globals() (WAS: How do I do this? (eval() on the left hand side))

2004-12-08 Thread Jeff Shannon
such special-case behavior would be extremely foolish to do...) Of course, I'm just going off of what I remember having been said elsewhere on c.l.p., and I wouldn't recommend anyone betting their life savings on the reliability of my memory... :) Jeff Shannon Technician/Programmer Credi

Re: exec'ing functions (WAS: updating locals() and globals())

2004-12-08 Thread Jeff Shannon
Steven Bethard wrote: Jeff Shannon wrote: Note also that functions which use exec cannot use the static namespace optimization, and thus tend to be *much* slower than normal functions In what circumstances will this be true? I couldn't verify it: [...] exec """\ def fib2

Re: Creating Fixed Length Records

2004-12-08 Thread Jeff Shannon
ed-length block. Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I do this? (eval() on the left hand side)

2004-12-09 Thread Jeff Shannon
eference C++ members despite the fact that 'this' was not required, just because I wanted to be able to *see* which variables were members and which weren't...) Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I do this? (eval() on the left hand side)

2004-12-09 Thread Jeff Shannon
have my modules use 'from const import const'. But I will admit that the extra complication on import may not be worth the "cleaner" module internals... As always, it's a tradeoff, and each programmer must decide which costs are worth bearing in their particular situ

Re: Ideas for projects

2004-12-09 Thread Jeff Shannon
a UI to use that code in IDLE. An optional stage two could then be rewriting the name-finding code to be smarter. Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: Calling a C program from a Python Script

2004-12-09 Thread Jeff Shannon
hon code is slow, and not all C code is fast, and if you're writing C from scratch then you want to be sure where the hotspots are and focus on converting only those areas to C. Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: Loading a file only once into an object and being able to access it from other modules - still have a problem

2004-12-09 Thread Jeff Shannon
7;s called, an instance of this class is created. All subsequent calls just return a reference to the same instance. This ensures that any changes to the instance are reflected anywhere that the object is used. (In your code, only changes to the class SW1_DICT are reflected elsewhere, not changes

Re: python gui

2004-12-14 Thread Jeff Shannon
VS.NET, and hopes to have wxPython built for 2.4 Real Soon Now(tm). Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: Why no list heritable type?

2004-12-16 Thread Jeff Shannon
her copyright information. >>> type(list) >>> class my_list(list): ... pass ... >>> type(my_list) >>> l = my_list() >>> l.append('foo') >>> l.extend(['bar', 'baz']) >>> l[2] 'baz' >>> l [

Re: BASIC vs Python

2004-12-16 Thread Jeff Shannon
pdated the website yet. ;) But Windows installers for 2.4 are available on Sourceforge... Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: Adding paths to sys.path permanently, and another problem...

2004-12-16 Thread Jeff Shannon
x27;APPDATA'] might be useful as well. Of course, if you're trying to get something to work cross-platform, things may be more difficult -- but that's because Windows doesn't normally use ~ so its use is not supported very well. You may be able to create a $HOME that's eq

Re: Module question

2004-12-16 Thread Jeff Shannon
Simon Brunning wrote: On Wed, 15 Dec 2004 18:10:40 -0800, Jeff Shannon <[EMAIL PROTECTED]> wrote: The difference being that when Excel opens up a *.CSV, it goes through the import wizard. Are you sure that's true? When I open a *.csv file, Excel *appears* to open it without

Re: lies about OOP

2004-12-16 Thread Jeff Shannon
Peter Hansen wrote: P.S.: I'm only half Danish, but the other half is from a particularly bloodthirsty line of Canadians. I thought it was physically impossible for Canadians to be bloodthirsty outside of hockey games... ;) Jeff Shannon Technician/Programmer Credit International --

Re: Why are tuples immutable?

2004-12-16 Thread Jeff Shannon
t some of the time (by postulating, for example, that if one mutates a dict key then things will break), this will result in more bugs and more confusion over time. There is no way for Python to be able to behave consistently in the face of mutable dict keys, therefore ("In the face of ambigu

Re: Why are tuples immutable?

2004-12-16 Thread Jeff Shannon
Antoon Pardon wrote: Op 2004-12-16, Jeff Shannon schreef <[EMAIL PROTECTED]>: nevermind the fact that I can't think of a case where I'm likely to "retrieve" a key from a dict, modify it, and then put it back. (I can think of endless cases where I'd want to

Re: Why no list heritable type?

2004-12-17 Thread Jeff Shannon
re only as a matter of backward compatibility. Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are tuples immutable?

2004-12-17 Thread Jeff Shannon
Antoon Pardon wrote: Op 2004-12-17, Jeff Shannon schreef <[EMAIL PROTECTED]>: (And I have to reiterate, here, that I have *never* felt it a hardship to be unable to use lists as dictionary keys; it's just never come up that the data that I had in a list was something that I wanted

Re: Why are tuples immutable?

2004-12-17 Thread Jeff Shannon
Antoon Pardon wrote: Op 2004-12-17, Jeff Shannon schreef <[EMAIL PROTECTED]>: To take another approach -- given some function that allows lists to (pretend to be) hashable: .>>> key = [1,2] .>>> d[key] = 'foo' .>>> d[[1,2]] .>>> key.a

Re: better lambda support in the future?

2004-12-17 Thread Jeff Shannon
n lambdas is a direct consequence of the fact that a function def is an executable statement rather than a compilation-time declaration. Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: Why no list heritable type?

2004-12-17 Thread Jeff Shannon
Mike Meyer wrote: Jeff Shannon <[EMAIL PROTECTED]> writes: Additionally, as I understand it UserList and UserDict are implemented entirely in Python, which means that there can be significant performance differences as well. Actually, UserList and UserDict are just wrappers arou

Re: Why are tuples immutable?

2004-12-17 Thread Jeff Shannon
Roy Smith wrote: Jeff Shannon <[EMAIL PROTECTED]> wrote: The aesthetic purity I'm referring to is that Python respects the proper meaning of hashing, even if it doesn't force the programmer to. The builtin objects that Python provides don't offer a __hash__() method t

Re: Is this a good use for lambda

2004-12-17 Thread Jeff Shannon
tually a parameter to findRoot(). I suppose that opinions may vary, however. Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: better lambda support in the future?

2004-12-17 Thread Jeff Shannon
Steven Bethard wrote: Jeff Shannon wrote: It occurs to me that, in a statically compiled language, function definitions all happen before the program starts, and thus that definition can't be affected by other variables (i.e. an outer function's parameters). I think you might be

Re: Why are tuples immutable?

2004-12-17 Thread Jeff Shannon
Jp Calderone wrote: On Fri, 17 Dec 2004 11:21:25 -0800, Jeff Shannon <[EMAIL PROTECTED]> wrote: No -- the mathematical definition of 'hashable' fails for mutable types, and Python doesn't try to pretend that it can hash mutable types. Python also provides features

Re: A problem with list

2004-12-13 Thread Jeff Shannon
from .ini-style files and/or the Windows Registry. Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: gather information from various files efficiently

2004-12-14 Thread Jeff Shannon
may be able to store your data in a shelve, or even proper database, saving you lots of time in parsing through these files on each run. Even if it's entirely new data on each run, you may be able to find a more efficient way of transferring data from whatever the source is into yo

Re: Module question

2004-12-15 Thread Jeff Shannon
g gets done correctly, since you won't have the option of setting the formatting explicitly during import. (I frequently deal with numbers that have significant leading zeros, and Excel just loves to strip those off unless you set formatting to 'text'...) Jeff Shannon Te

Re: Why are tuples immutable?

2004-12-15 Thread Jeff Shannon
were copied when added to a dict, just so that every once in a while someone might be able to avoid a few conversions to/from tuple, then you're adding the overhead of an object copy to *every* dict insertion, thus slowing down (possibly by a significant amount) a large proportion of Py

Re: Adding paths to sys.path permanently, and another problem...

2004-12-16 Thread Jeff Shannon
rectory to add to sys.path. Thus, if you drop a mymodule.pth file in site-packages, which contains a list of the directories you're interested in, sys.path will automatically be amended for you every time Python starts. Jeff Shannon Technician/Programmer Credit International -- http:/

Re: Why are tuples immutable?

2004-12-21 Thread Jeff Shannon
possible to behave sensibly. So prove us wrong, by implementing something that behaves sensibly in the face of mutating keys (which compare by value, as lists do, rather than by identity). Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are tuples immutable?

2004-12-21 Thread Jeff Shannon
Antoon Pardon wrote: Op 2004-12-17, Jeff Shannon schreef <[EMAIL PROTECTED]>: Now, even if hash were made to equal id... suppose I then pass that dict to a function, and I want to get the value that I've stored under [1,2]. In order to do that, I'd *also* have to pass in

Re: Is this a good use for lambda

2004-12-21 Thread Jeff Shannon
re was what wouldn't work consistently; the corrected version, using list() and reverse(), doesn't look like it has anything that'll be a problem in my 2.2 installation, and probably not in 2.1 Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: break/continue - newbe

2004-12-21 Thread Jeff Shannon
bring you back up to the top of the loop body and the start of the next loop iteration. Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: input record sepArator (equivalent of "$|" of perl)

2004-12-21 Thread Jeff Shannon
John Machin wrote: Subtle distinction: A metER is a measuring device. A MetRE is a unit of distance. ... except in the US, where we stubbornly apply the same spelling to both of those. (It figures that we Americans just ignore subtle distinctions) Jeff Shannon Technician/Programmer

Re: How about "pure virtual methods"?

2004-12-21 Thread Jeff Shannon
specification, and then write code that would pass the unit tests. If you are subclassing from a common base, then you'd only need to change the unit test for that common base class (presuming that all derived classes would run those unit tests as well). Jeff Shannon Technic

Re: Why are tuples immutable?

2004-12-22 Thread Jeff Shannon
Antoon Pardon wrote: Op 2004-12-21, Jeff Shannon schreef <[EMAIL PROTECTED]>: Antoon Pardon wrote: So show us a dictionary (i.e. hash table) implementation that can do this. Why should I, Do you doubt that it is possible? Yes. You'll need to be able to derive the old ha

Re: Why are tuples immutable?

2004-12-22 Thread Jeff Shannon
Antoon Pardon wrote: Op 2004-12-21, Jeff Shannon schreef <[EMAIL PROTECTED]>: How does the dict know which value is associated with which key? Because there is a link between the key and the value. The problem with a mutated key in a dictionary is not that the link between the key a

Re: Mutable objects which define __hash__ (was Re: Why are tuples immutable?)

2004-12-22 Thread Jeff Shannon
rrent dict off of object id, I don't see much real value in creating a separate dict type that does it by default. But as long as it's an addition, rather than a change to existing behavior, then the only real problem with it is the standard "makes the language bigger".

Re: How about "pure virtual methods"?

2004-12-22 Thread Jeff Shannon
more bother than it's worth to me. I'm perfectly willing to "struggle" along without abstract base classes enforcing an interface, and merely make do with unenforced, informal protocols... but then, I'm hardly an expert in such matters. (Or any other sort

Re: Newbie namespace question

2004-12-22 Thread Jeff Shannon
ld be able to avoid the circular import problem... Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: error problems for import some copora with nltk

2004-12-22 Thread Jeff Shannon
meric that are required, and then ensure that you have (or get) an appropriate version. Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: error problems for import some copora with nltk

2004-12-23 Thread Jeff Shannon
-- it doesn't happen automatically.) Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: list IndexError

2004-12-23 Thread Jeff Shannon
almost identical) instances of Spam. Using list() to create a copy of a list is analogous, but we're used to thinking of list() as a converter rather than a constructor... Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: list Integer indexing dies??

2004-12-23 Thread Jeff Shannon
18 STORE_FAST 0 (y) 21 LOAD_CONST 0 (None) 24 RETURN_VALUE >>> Given that Python may not even have access to the .py file, only the .pyc (which has lost all record of the source representation), there's no way for the interpreter to do

Re: Why tuples use parentheses ()'s instead of something else like <>'s?

2004-12-29 Thread Jeff Shannon
alphabet / character set, but even then there's a significant weight of historical reasons to overcome. Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: Securing a future for anonymous functions in Python

2004-12-30 Thread Jeff Shannon
e purpose without quite as much risk of code pollution. Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: Why tuples use parentheses ()'s instead of something else like <>'s?

2004-12-30 Thread Jeff Shannon
27;s attempts to get away from the tyranny of the straight line, and even with the EMP there's certain details which turned out well, but the overall effect is that of an overturned garbage pail. Jeff Shannon Technician/Programmer Credit International -- http://mail.python.org/mailman/listinfo/python-list

Re: Securing a future for anonymous functions in Python

2004-12-30 Thread Jeff Shannon
Bengt Richter wrote: On Thu, 30 Dec 2004 15:15:51 -0800, Jeff Shannon <[EMAIL PROTECTED]> wrote: Mimicking function-def indentation inside of another function's arglist strikes me as an abomination just waiting to happen; in comparison, the need to type a name twice seems trivial. Sel

Re: Python becoming less Lisp-like

2005-03-21 Thread Jeff Shannon
Antoon Pardon wrote: Op 2005-03-18, Jeff Shannon schreef <[EMAIL PROTECTED]>: I find it odd that you start by saying you still find them very consistent and here state there is a slight inconsistency. I said that the way that binding a name on a class instance always creates an instance att

Re: getting text from WinXP console

2005-03-21 Thread Jeff Shannon
- the capture app would pass (almost) all input to the child app and then retrieve the child app's output (and probably perform the actual display on-screen). This won't let you capture the text of an arbitrary window, though, and would probably be pretty fragile. Jeff Shannon -- http://mail.python.org/mailman/listinfo/python-list

Re: For loop extended syntax

2005-03-21 Thread Jeff Shannon
trol-variable tuples are not so straightforward as is being claimed. There may be valid arguments in favor of enhancing tuple unpacking in this way (indeed, I believe I recall a thread or two on this subject), but it's important to consider the general consequences, not just the single aspect of f

Re: getting text from WinXP console

2005-03-21 Thread Jeff Shannon
Peter Hansen wrote: Jeff Shannon wrote: Unless I'm seriously mistaken, the only way that this will be possible is if there's a Win32 API call that will give the correct information. This might be possible to find in the MSDN documentation, if it exists, but I suspect that it probab

<    1   2