Re: Regular expressions

2015-11-03 Thread Dan Sommers
On Tue, 03 Nov 2015 19:04:23 -0700, Michael Torrie wrote: > On 11/03/2015 05:33 PM, rurpy--- via Python-list wrote: >> I consider regexs more fundemental. One need not even be a programmer >> to use them: consider grep, sed, a zillion editors, database query >> languages, etc. > > Grep can use

Re: What does “grep” stand for?

2015-11-05 Thread Dan Sommers
On Thu, 05 Nov 2015 19:36:11 -0800, Larry Hudson wrote: > Anyone besides me remember the CP/M editor Mince (Mince Is Not > Complete EMACS)? It was an emacs-like editor, without any e-Lisp or > other way of extending it. I believe it was my first exposure to a > screen-oriented editor. I quite l

Re: Python's re module and genealogy problem

2014-06-13 Thread Dan Sommers
On Fri, 13 Jun 2014 17:17:06 +0200, BrJohan wrote: > Or to put the namevariants in some sequence of sets having elements > like: ("Kristina", "Christina", "Cristine", "Kristine") > Matching is then just applying the 'in' operator. That's definitely a better approach, for the reasons you mention

Re: Python's numeric tower

2014-06-15 Thread Dan Sommers
On Sun, 15 Jun 2014 22:17:57 -0400, Roy Smith wrote: > I don't believe HandGrenade implements throw(). It does, however, > implement lobbeth(). And therein lies the problem with Object Oriented Programming: instances of HandGrenade neither throw nor lobbeth. One, Two, Five'ly yours, Dan -- htt

Re: PEP8 and 4 spaces

2014-07-05 Thread Dan Sommers
On Sun, 06 Jul 2014 09:27:59 +1000, Chris Angelico wrote: > How often do you ever have multiple consecutive blank lines? My > newlines are either single (line end) or in pairs (one blank line), > and I don't remember having anything else (at least, not > intentionally). Greater separation than a b

Re: PEP8 and 4 spaces

2014-07-06 Thread Dan Sommers
On Mon, 07 Jul 2014 11:00:59 +1000, Ben Finney wrote: > The makefile syntax is one of the excellent examples of why it's a > terrible idea to use tab characters in source code. It's also an > excellent example of how a poor design decision (a line beginning with > U+0020 SPACE is semantically diff

Re: Storing instances using jsonpickle

2014-09-04 Thread Dan Sommers
On Thu, 04 Sep 2014 15:17:17 +1000, Chris Angelico wrote: > On Thu, Sep 4, 2014 at 9:39 AM, MRAB wrote: >> The key of a dict could also be int, float, or tuple. > > Yes! Yes! DEFINITELY do this!! Ahem. Calm down a little, it's not that > outlandish an idea... Using floats is a bad idea. Consi

Re: How to structure packages

2011-09-08 Thread Dan Sommers
On Thu, 08 Sep 2011 10:29:26 +1000, Steven D'Aprano wrote: > I suppose "one class per file" might be useful for those using an editor > with no search functionality. Other than that, is there any > justification for this rule? Any Java fans want to defend this? Back in the dark ages known as the

Re: try - except. How to identify errors unknown in advance?

2011-11-16 Thread Dan Sommers
On Wed, 16 Nov 2011 17:57:27 +0100, Frederic Rentsch wrote: > I'd like to log MySQL errors. If I do: > > try: (command) > except MySQLdb.OperationalError, e: print e > > I may get something like: > > (1136, "Column count doesn't match value count at row 1") > > If I don't kno

Re: Py-dea: Streamline string literals now!

2011-12-28 Thread Dan Sommers
On Wed, 28 Dec 2011 22:54:16 +, Steven D'Aprano wrote: > On Wed, 28 Dec 2011 11:36:17 -0800, Rick Johnson wrote: > >> The point is people, we should be using string delimiters that are >> ANYTHING besides " and '. Stop being a sheep and use your brain! > > "ANYTHING", hey? > > I propose we

Re: Spamming PyPI with stupid packages

2012-01-03 Thread Dan Sommers
On Wed, 04 Jan 2012 13:37:24 +1100, Chris Angelico wrote: > And "import pickle" objectifies pickles ... Not quite: "import pickle" merely readies the machinery that objectifies pickles. In order to objectify a pickle, you have to call pickle.loads: >>> import pickle # get ready to objectify

Re: while True or while 1

2012-01-22 Thread Dan Sommers
On Sun, 22 Jan 2012 05:25:25 +, Steven D'Aprano wrote: > Or they've been writing Python code since before version 2.2 when True > and False were introduced, and so they are used to the "while 1" idiom > and never lost the habit. That would be me. As per a now-ancient suggestion on this maili

Re: Why does 1**2**3**4**5 raise a MemoryError?

2013-04-02 Thread Dan Sommers
On Mon, 01 Apr 2013 21:45:30 -0700, Tim Roberts wrote: > morphex wrote: >> >>While we're on the subject, wouldn't it be nice to have some cap there >>so that it isn't possible to more or less block the system with large >>exponentiation? > > There IS a cap. It's called the "MemoryError" excepti

Re: PyQt not working well on Mac OS X

2005-12-14 Thread Dan Sommers
s grayed out. > Does anyone have any ideas? You may have to "bundle" your app -- i.e., create the whole application.app structure -- rather that just run the python program from within a shell. Cocoa looks for a bunch of resources in standard places before it will let your app inter

Re: Python packages on OS X vs Windows

2005-12-14 Thread Dan Sommers
the PC world? It can be like falling off a log in the Linux world. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: Why and how "there is only one way to do something"?

2005-12-15 Thread Dan Sommers
er to get only > the piece of zen knowledge you need. That's just wrong. [throws hands and arms up in [mock] disgust] Enlightenment does not come in discrete pieces, to be learned one at a time, to be applied selectively. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/d

Re: Socket programming design problem

2005-12-22 Thread Dan Sommers
ad for > each, or is there some other way I can listen on two sockets at once > (maybe non-blocking ones?) Try the select module: http://www.python.org/doc/current/lib/module-select.html Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: recursive function return value problems

2005-12-28 Thread Dan Sommers
instead: result = reTest(True) [ rest of example snipped ] HTH, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: Python article in Free Software Magazine

2006-01-01 Thread Dan Sommers
d language" ... So does <http://www.python.org/doc/Summary.html>. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: PYTHONDOCS

2006-01-02 Thread Dan Sommers
o set a variable and not export it, which means that echo works but nothing else does. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: Filename case-insensitivity on OS X

2006-01-03 Thread Dan Sommers
age and then erase it > (again, using Disk Utility) and put UFS on it. You'll find that > "touch foo FOO" will create two files. You may also find some native Mac OS X applications failing in strange ways. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: Python or Java or maybe PHP?

2006-01-03 Thread Dan Sommers
that > effect. That would eliminate eval and exec, too. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: Is 'everything' a refrence or isn't it?

2006-01-05 Thread Dan Sommers
idx = lst; _idx < lst + NLST; ++_idx ) { int *i; i = *_idx; /* compare "the item to which i is bound" to "a constant" */ if( *i == *(&_i2) ) /* rebind i to _i4 */ i = &_i4; } > for (_idx = 0; _idx < NLST; ++_idx) > printf("%d\n"

Re: CGI question

2006-01-05 Thread Dan Sommers
this > entire URL (or even just the bit after the question mark) ... import os query_string = os.environ['QUERY_STRING'] HTH, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: Is 'everything' a refrence or isn't it?

2006-01-05 Thread Dan Sommers
On Thu, 05 Jan 2006 14:28:51 +0100, David Murmann <[EMAIL PROTECTED]> wrote: > Dan Sommers schrieb: >> int **_idx; >> for( _idx = lst; _idx < lst + NLST; ++_idx ) { >> int *i; >> i = *_idx; >> /* compare "the item to which i is bound" to &quo

Re: creating dictionarie names, using variables?

2006-01-11 Thread Dan Sommers
],'dict_'+devDictName] Put the dictionaries you create into another dictionary instead: devDict = { } key = item[5].replace(' ','+') devDict[key] = {'Group':item[2], 'Status':item[3], # etc. } HTH, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: creating dictionarie names, using variables?

2006-01-12 Thread Dan Sommers
asy to call them from within the dictionary. The names of the child dictionaries exist as keys in the parend dictionary. > - also, they dictionary will be dynamic, thus the # of devices is > always changing so they need to be created on-the-fly. Yes, child dictionaries can be creat

Re: How can I create a dict that sets a flag if it's been modified

2006-01-12 Thread Dan Sommers
oats, tuples, etc can be keys on > initialization ... That has nothing to do with your code: >>> dict(1=4) SyntaxError: keyword can't be an expression >>> int(4=5) SyntaxError: keyword can't be an expression The names of keyword arguments have look like Python identif

Re: how do "real" python programmers work?

2006-01-13 Thread Dan Sommers
On Fri, 13 Jan 2006 17:09:13 +, Tom Anderson <[EMAIL PROTECTED]> wrote: > Ah, of course - to an true believer, emacs *is* the unix toolset. > :) To the true believer, unix runs under emacs. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.

Re: On Numbers

2006-01-14 Thread Dan Sommers
to Chapter 12, <http://www.lisp.org/HyperSpec/Body/chap-12.html>. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: instance attributes not inherited?

2006-01-15 Thread Dan Sommers
n though it *does* indeed work). The __init__ method is an *initializer*, *not* a constructor. By the time __init__ runs, the object has already been constructed; __init__ just does extra initialization. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: Preventing class methods from being defined

2006-01-15 Thread Dan Sommers
bar"] class A: if "foo" in allow: def foo( ): ... if "bar" in allow: def bar( ): ... > Don't ask why I would need such a strange animal ... Consider yourself not asked. HTH, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: Preventing class methods from being defined

2006-01-16 Thread Dan Sommers
it magically appear and disappear). By the principle of least surprise, if dir(some_sobject) contains foo, then some_object.foo should *not* raise a NameError. All of the posted solutions to the OP's problem could easily be extended to do something noisy with the (dis-)allowed methods. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: verify a user

2006-01-18 Thread Dan Sommers
print pwd.getpwnam( unix_user_name ) except KeyError: print unix_user_name, 'does not exist' There's a grp module for making similar queries against /etc/group (or the modern equivalent thereof). Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: Python code written in 1998, how to improve/change it?

2006-01-19 Thread Dan Sommers
achine by examining attributes of its argument). And then there are (or should be!) purists who will claim that if your state machine requires information to be shared between states, then you don't have enough states! ;-) > We want a goto. No, we don't. Regards, Dan -- Dan Sommers <

Re: War chest for writing web apps in Python?

2006-07-28 Thread Dan Sommers
sy for platform dependencies to sneak in without being caught. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: War chest for writing web apps in Python?

2006-07-28 Thread Dan Sommers
On Fri, 28 Jul 2006 13:03:25 +0200, Sybren Stuvel <[EMAIL PROTECTED]> wrote: > Dan Sommers enlightened us with: >> We just did that at work (developed on the corporate-issued non-Unix >> computers and then deployed on a Linux box), and had no problems at >> all. In

Re: md5 question

2006-08-03 Thread Dan Sommers
gt; value '3e25960a79dbc69b674cd4ec67a72c62'. Is that possible? I've looked > for initialization options in the documentation and searched c.l.p., > but no luck. According to http://docs.python.org/lib/module-md5.html, you want the copy method of your existing md5 object. Rega

Re: recommended general-purpose string template packages?

2006-08-14 Thread Dan Sommers
s, form letters, source > code, whatever. And don't forget Python's Template class: http://docs.python.org/lib/node109.html Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: Printing n elements per line in a list

2006-08-15 Thread Dan Sommers
if counter == n: print counter = 0 Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: Printing n elements per line in a list

2006-08-15 Thread Dan Sommers
On 15 Aug 2006 18:33:51 -0700, "John Machin" <[EMAIL PROTECTED]> wrote: > Dan Sommers wrote: >> >> counter = 0 >> for an_element in the_list: >> print an_element, >> counter = counter + 1 >> if counter == n: >> print >> coun

Re: what is the keyword "is" for?

2006-08-16 Thread Dan Sommers
doing anything special; nans have [the equivalent of] an __eq__ method that always returns False. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: Reverse string-formatting (maybe?)

2006-10-15 Thread Dan Sommers
rmation, and the web addresses in the source code aren't available, so I hesitate to post my ancient copy.) HTH, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: IDE that uses an external editor?

2006-10-15 Thread Dan Sommers
better with grep and a decent REPL.) Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: dynamic inheritance

2006-06-08 Thread Dan Sommers
lass D(C): pass Why do you want to change a class' base class during runtime? HTH, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: Looking for Python code to obsfucate mailto links on web site

2006-06-25 Thread Dan Sommers
s(text)) The newlines within the triple quoted string are important; use that function something like this: print "" print "Title print " print "%s" % spam_averse_email_address( '[EMAIL PROTECTED]', 

Re: How do you use this list ?

2006-06-27 Thread Dan Sommers
type said, "This is a press conference. The last thing I want to do is answer a lot of questions." Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: Coding Nested Loops

2006-09-16 Thread Dan Sommers
hat you can iterate through the elements yourself. HTH, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: Coding Nested Loops

2006-09-16 Thread Dan Sommers
On Sat, 16 Sep 2006 10:06:25 -0700 (PDT), Rich Shepard <[EMAIL PROTECTED]> wrote: > On Sat, 16 Sep 2006, Dan Sommers wrote: >> When you import random, all you're doing is importing the module; you >> have to specify any given attribute thereof: > I thought that wa

[OT] Re: why a main() function?

2006-09-18 Thread Dan Sommers
nction? Compiler optimizations because of const and restrict keywords don't count. And what other C code *isn't* inside a function? Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist

Re: OO question

2007-01-01 Thread Dan Sommers
round than I have can probably tell you why or when one way might be better than the other.) The definitions of Person, Address, and Relationship, as well as the user-interface(s) and the persistent storage mechanism(s), are left as exercises to the interested reader. ;-) Regards, Dan -- Dan

Re: how to find the longst element list of lists

2007-01-07 Thread Dan Sommers
r than sorting the list just to pick off one element (O(n) vs. O(n log n) for all of you Big-Oh notation fans out there; you know who you are!). Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with running external process

2006-01-23 Thread Dan Sommers
re no more zombies. A good time/place to do this is right before you start another process. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with running external process

2006-01-23 Thread Dan Sommers
, 0) > It seems to work without leaving zombies. If your parent process just sits around and waits for each child process to finish before moving on, why not use os.spawnl(os.P_WAIT, 'ext_script.py') instead of forking and execing "manually"? Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange behavior of int()

2006-01-26 Thread Dan Sommers
2.3/.25)*.25 0.049822 Then check out <http://docs.python.org/tut/node16.html>. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: Using non-ascii symbols

2006-01-27 Thread Dan Sommers
On Fri, 27 Jan 2006 22:29:20 GMT, Neil Hodgson <[EMAIL PROTECTED]> wrote: > ... I'm so used to "/" for division that "÷" now looks strange. Strange, indeed, and too close to + for me (at least within my newsreader). Regards, Dan -- Dan Sommers <http:/

Re: Question about idioms for clearing a list

2006-02-06 Thread Dan Sommers
L = [] # or insert your favorite list-clearing/emptying statement here What damage is done now that O is still referring to one of the items that used to be in L? The trouble begins when references to "the list to which L refers" end up somewhere else. Then we have to wonder if re

Re: Yet another GUI toolkit question...

2006-02-10 Thread Dan Sommers
mer: I have no financial or business ties to Trolltech or to Riverbank. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

[OT] Separation of Functionality in C (was: Re: how to write a C-style for loop?)

2006-02-15 Thread Dan Sommers
stles (e.g., logging options) depending on the application. But now we're off topic for comp.lang.python. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 354: Enumerations in Python

2006-02-27 Thread Dan Sommers
;re using enums as meaningful names for pairwise distinct concepts, then I think otherwise. IMO, if your program breaks if someone re-assigns the values randomly, then a better solution than an enum exists. (Or maybe that's because I think of the tags as nothing more than keywords that work

Re: [PyQt] browse for a directory

2005-05-10 Thread Dan Sommers
On 10 May 2005 16:49:25 -0700, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > But I can't find any Qt widget that enables me to browse for a > directory! ... Try QFileDialog.getExistingDirectory. HTH, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -

Re: Python Polymorphism

2005-05-12 Thread Dan Sommers
dd 22 to a.myAttribute > I want to use the power of polymorphism to modelate the problem. Polymorphism in Python is a solution looking for a problem. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: function with variable arguments

2005-05-13 Thread Dan Sommers
ne, step = 1 ): if stop == None: # i,e., we only got one argument stop = start start = 1 # rest of function goes here HTH, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: question about the id()

2005-05-17 Thread Dan Sommers
ossible. > Many things in Python programs cannot be proved. But what about > suggesting optimisations, not doing them automatically? At that point, you can do the optimization yourself: class A: def method( self ): pass a = A( ) m = a.method # optimize runti

Re: speeding up Python script

2005-05-18 Thread Dan Sommers
sult.append( [ somevar, per, s, t, v, n, l ] ) (Appending the results is probably quicker than inserting them, but I don't know for sure.) But a better-than-an-exhaustive-search algorithm sounds like a good idea, too. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert from numbers to letters

2005-05-19 Thread Dan Sommers
,m,n,o,p,q,r,s,t,u,v,w,x,y,z) = range( 1, 27 ) > Now if we really want some bonus points.. > a=1, b=2, c=3 ... z=26 aa=27 ab=28 etc.. It's still one line, following the pattern from above, just longer. Now why do you want to do this? Regards, Dan -- Dan Sommers <http://www.tombston

Re: Q: "...Learning with Python" ...a property that addition and multiplication have...

2005-05-25 Thread Dan Sommers
and multiplication have" is "the distributive property," but the distributive property of multiplcation over addition does not translate to a distributive property of repetition over concatenation: 2 * ( 3 + 4 ) == 14 2 * 3 + 2 * 4 == 14 but 2 * ( "ABC" + "DEF

Re: __init__() not called automatically

2005-05-26 Thread Dan Sommers
On 25 May 2005 21:31:57 -0700, "Sriek" <[EMAIL PROTECTED]> wrote: > Similarly, why do we have to explicitly use the 'self' keyword > everytime? Why do they (the C++ programmers) prepend "m_" to otherwise perfectly good member names? Regards, Dan --

Re: Incrementing letters

2005-05-27 Thread Dan Sommers
as your sample code corrupts punctuation. > Wow, that's quite nice. You really learn something new every day :-) A > minor improvement: Use string.ascii_letters as the first parameter for > string.maketrans And use string.ascii_letters[ 1 : ] + string.ascii_letters[ 0 ] for the second parameter to string.maketrans. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: Incrementing letters

2005-05-31 Thread Dan Sommers
On 27 May 2005 10:52:36 -0400, Dan Sommers <[EMAIL PROTECTED]> wrote: > And use string.ascii_letters[ 1 : ] + string.ascii_letters[ 0 ] for the > second parameter to string.maketrans. Oops. Thank you Duncan and Rocco for correcting my mistake. Regards, Dan -- Dan S

Re: OO re-factoring (was Pythonese/Efficiency/Generalese critique [on Tutor])

2005-06-08 Thread Dan Sommers
ethods and recursion are *not* mutually exclusive (e.g., an Integer class with a factorial method, or a binary tree class whose nodes are also binary trees). Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: Annoying behaviour of the != operator

2005-06-09 Thread Dan Sommers
do not claim to be an expert, but that doesn't seem very Pythonic to me. AIUI, __cmp__ exists for backwards compatibility, and __eq__ and friends are flexible enough to cover any possible comparison scheme. Why make the rules, the documentation, and the implementation even more "interesting" than they already are? Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: Annoying behaviour of the != operator

2005-06-10 Thread Dan Sommers
On Fri, 10 Jun 2005 09:50:56 -0500, Rocco Moretti <[EMAIL PROTECTED]> wrote: > Dan Sommers wrote: >> On Thu, 09 Jun 2005 15:50:42 +1200, >> Greg Ewing <[EMAIL PROTECTED]> wrote: >> >>> Rocco Moretti wrote: >>> >>>> The main problem

Re: case/switch statement?

2005-06-12 Thread Dan Sommers
quot;foo" or 3j). The biggest drawback here, as others have noted in previous discussions, is that the do_* functions execute in a separate scope. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get/set class attributes in Python

2005-06-12 Thread Dan Sommers
there's no need for my program to recheck every parameter on every function call all the way down. Either everything works, or that same UI code catches and logs a TypeError or ValueError or KeyError exception and asks the user what to do next. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: Tiff Image Reader/writer

2005-06-13 Thread Dan Sommers
ry (PIL) at effbot.org. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: string formatting using the % operator

2005-06-13 Thread Dan Sommers
x27;smith'+'%' >sql += 'WHERE name LIKE %s' % searchterm > Any Ideas? Let the DB-API do more work for you: cursor = connection.cursor( ) sql = """SELECT column2, columns3 FROM table WHERE name LIKE %s""" values

Re: Resume after exception

2005-06-14 Thread Dan Sommers
irst_line == "FILE LOCKED" and read_if_locked == FALSE: return False [read the rest] return True def open_command(): if open_file("foo.bar") == False: [ask the user what to do] if ans == tkMessageBox.YES:

Re: sudo open() ? (python newbee question)

2005-06-14 Thread Dan Sommers
kernel or filesystem bug, in which case all bets are off anyway). Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> -- http://mail.python.org/mailman/listinfo/python-list

Re: sudo open() ? (python newbee question)

2005-06-14 Thread Dan Sommers
On Tue, 14 Jun 2005 16:18:19 +0300, Christos "TZOTZIOY" Georgiou <[EMAIL PROTECTED]> wrote: > I believe that the suid bit on scripts (either *sh or python) is > completely ignored on most *nix systems. Most *modern* systems, yes. ;-) I must be getting old. :-( Regards

Re: dynamic

2005-06-15 Thread Dan Sommers
rith from > the choosed nx class is this one. > If there is a better approach, I can implement it. class single(object): pass class n1(single): pass class n2(single): pass class n3(single): pass HTH, Dan -- Dan Sommers <http://www.tombston

Re: Biased random?

2007-08-28 Thread Dan Sommers
want to tend towards the beginning of the list, and don't care what the envelope looks like, how about this: def biasedselection(thelist): index = random.random() * random.random() * len(thelist) # or index random.random() ** 2 * len(thelist)

Re: Tools Designing large/complicated applications

2007-01-12 Thread Dan Sommers
sign? > Yes : coffee, beer, pizzas, cigarettes, paper napkins, pen, and a good > wiki. It is a well-known fact that the best engineering tools ever invented are the cocktail napkin and the white board. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people

Re: Endianness conversion

2007-02-24 Thread Dan Sommers
uld use in the standard library, or do I have to > write my own C extension? You could try the struct module. If your input comes in fixed sized chunks, just call struct.unpack and struct.pack once per chunk. HTH, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> Atoms are

Re: Endianness conversion

2007-02-25 Thread Dan Sommers
On Sat, 24 Feb 2007 17:27:12 +, Toby wrote: > Dan Sommers wrote: >> You could try the struct module. If your input comes in fixed sized >> chunks, just call struct.unpack and struct.pack once per chunk. > > Thanks, but it was a bit awkward to use for big chunks. de

Re: [OT] Any Python lullabies?

2006-04-18 Thread Dan Sommers
gt; but he somehow wasn't very interested :) Then isn't that the perfect lullaby material? ;-) Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: Writing backwards compatible code - when?

2006-04-18 Thread Dan Sommers
#x27;t. I thought it was more cohesive, but googling for python "what's new" turns up a collection of such documents in various places. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife

Re: can anyone advise me

2006-04-27 Thread Dan Sommers
and 1, since x is now 2. And another x. Since this might be homework, I'll stop at a hint: you need to think about when you want each printed line to end, and make sure that you tell python to end it there. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> &quo

Re: printing list

2006-05-07 Thread Dan Sommers
;license" for more information. >>>> a=[1,2,3,4,5] >>>> print ', '.join (a) > Traceback (most recent call last): > File "", line 1, in ? > TypeError: sequence item 0: expected string, int found >>>> print ', '.join

Re: advanced number recognition in strings?

2006-05-09 Thread Dan Sommers
st the code somewhere if anyone is interested. > x = 0.032 +/- 0.5 x 10(-4) > y = 0.032 +/- 1.0 x 10(-4) > print x == y > print out? Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: data entry tool

2006-05-10 Thread Dan Sommers
just the opposite: that's 2MB of things someone else wrote in order that your application code remain small. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

[OT] Unix Tools (was: deleting texts between patterns)

2006-05-12 Thread Dan Sommers
c/p' -e'/xyz/,$p' file.txt Or even awk '/abc/,/xyz/' file.txt Excluding the abc and xyz lines is left as an exercise to the interested reader. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: common practice for creating utility functions?

2006-05-15 Thread Dan Sommers
, then there's nothing wrong with a function consisting solely of another function call. If you end up with a lot of those tiny functions, though, and they persist through multiple development cycles, then you may be making a systematic mistake in your design. Regards, Dan -- Dan Sommers <ht

Re: round numbers in an array without importing Numeric or Math?

2006-05-16 Thread Dan Sommers
7;, u'58.6', u'97.8', u'10.0', u'9.6', u'28.1'] Then you'll have to convert your strings to floats first: [int(float(x)+0.5) for x in Test] HTH, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die

Re: MySQLdb - parameterised SQL - how to see resulting SQL ?

2006-05-17 Thread Dan Sommers
pysqlite and the API spec, I'd say no, not a standard way. OTOH, eventually, mysqldb has to create that SQL in order to pass it to the database for execution, so it's probably as simple as finding the right place to put a "print" statement and/or to store the fi

Re: Python sqlite and regex.

2006-05-19 Thread Dan Sommers
sql = 'select foo from test where foo regex %s' cur.execute( sql, tuple( fooregex ) ) See the DP API spec for more information. Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: Python sqlite and regex.

2006-05-19 Thread Dan Sommers
' matches one or more characters, and '?' matches > any single character - maybe add '#' to match any single digit and '@' > to match any single alpha character). Doesn't SQL already have lightweight wildcards? SELECT somefield FROM sometable WHE

Re: Python sqlite and regex.

2006-05-19 Thread Dan Sommers
On Fri, 19 May 2006 18:52:38 GMT, "Paul McGuire" <[EMAIL PROTECTED]> wrote: > "Dan Sommers" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Doesn't SQL already have lightweight wildcards? >> >> SELECT somefield FR

Re: dict!ident as equivalent of dict["ident"]

2006-05-21 Thread Dan Sommers
at the "Bunch" recipe in the Python Cookbook: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52308 Regards, Dan -- Dan Sommers <http://www.tombstonezero.net/dan/> "I wish people would die in alphabetical order." -- My wife, the genealogist -- http://mail.python.org/mailman/listinfo/python-list

Re: for loop without variable

2008-01-09 Thread Dan Sommers
ot;in" operator may work better: for thing in array_or_file_or_dictionary: do_something_with(thing) HTH, Dan -- Dan Sommers A death spiral goes clock- <http://www.tombstonezero.net/dan/> wise north of the equator. Atoms are n

<    1   2   3   4   5   >