Re: Python's "only one way to do it" philosophy isn't good?

2007-06-29 Thread Douglas Alan
Lenard Lindstrom <[EMAIL PROTECTED]> writes: > Douglas Alan wrote: >> [I]n Python, you can be 100% sure that your files >> will be closed in a timely manner without explicitly closing them, as >> long as you are safe in making certain assumptions about how your

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-30 Thread Douglas Alan
Paul Rubin <http://[EMAIL PROTECTED]> writes: > Douglas Alan <[EMAIL PROTECTED]> writes: >> But that's a library issue, not a language issue. The technology >> exists completely within Lisp to accomplish these things, and most >> Lisp programmers ev

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-30 Thread Douglas Alan
Michele Simionato <[EMAIL PROTECTED]> writes: >> Right. So? I understand this issue completely and I code >> accordingly. > What does it mean you 'code accordingly'? IMO the only clean way out > of this issue is to NOT rely on the garbage collector and to manage > resource deallocation explicit

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-30 Thread Douglas Alan
Paul Rubin <http://[EMAIL PROTECTED]> writes: > Douglas Alan <[EMAIL PROTECTED]> writes: >> P.S. Besides Haskell is basically a refinement of ML, which is a >> dialect of Lisp. > I'd say Haskell and ML are descended from Lisp, just like mammals are > de

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-30 Thread Douglas Alan
Paul Rubin writes: > Haskell and ML are both evaluate typed lambda calculus unlike Lisp > which is based on untyped lambda calculus. Certainly the most > familiar features of Lisp (dynamic typing, S-expression syntax, > programs as data (Lisp's macro system results from

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-30 Thread Douglas Alan
Lenard Lindstrom <[EMAIL PROTECTED]> writes: > Explicitly clear the exception? With sys.exc_clear? Yes. Is there a problem with that? |>oug -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-30 Thread Douglas Alan
I wrote: > P.S. The last time I took a language class (about five or six years > ago), the most interesting languages I thought were descended from > Self, not any functional language. (And Self, of course is descended > from Smalltalk, which is descended from Lisp.) I think that Cecil is the p

Re: Python's "only one way to do it" philosophy isn't good?

2007-07-02 Thread Douglas Alan
Lenard Lindstrom <[EMAIL PROTECTED]> writes: >>> Explicitly clear the exception? With sys.exc_clear? >> Yes. Is there a problem with that? > As long as nothing tries to re-raise the exception I doubt it breaks > anything: > > >>> import sys > >>> try: > raise StandardError("Hello") > ex

Re: Python's "only one way to do it" philosophy isn't good?

2007-07-02 Thread Douglas Alan
Lenard Lindstrom <[EMAIL PROTECTED]> writes: >> You don't necessarily want a function that raises an exception to >> deallocate all of its resources before raising the exception, since >> you may want access to these resources for debugging, or what have >> you. > No problem: > > [...] > > >>> c

Re: Python's "only one way to do it" philosophy isn't good?

2007-07-02 Thread Douglas Alan
Lenard Lindstrom <[EMAIL PROTECTED]> writes: >> I'm not sure I understand you here. You're saying that I should have >> the foresight to wrap all my file opens is a special class to >> facilitate debugging? > Obviously you had the foresight to realize with statements could > compromise debugging

Re: Python's "only one way to do it" philosophy isn't good?

2007-07-02 Thread Douglas Alan
Lenard Lindstrom <[EMAIL PROTECTED]> writes: >> Also, any caught exception is automatically cleared when >> the catching procedure returns anyway, so it's not like Python has >> ever considered a caught exception to be precious information that >> ought to be preserved long past the point where it

Re: Programming Idiomatic Code

2007-07-03 Thread Douglas Woodrow
On Tue, 3 Jul 2007 10:19:07, Nathan Harmston <[EMAIL PROTECTED]> wrote > >i m in the UK and dont have the experience but hey 10 minutes of >programming python beats 12 hours of programming in Clipper-derived >unreadable drivel (you dont know how much I appreciate Python atm). "Clipper-derived unr

Re: Python's "only one way to do it" philosophy isn't good?

2007-07-05 Thread Douglas Alan
"Chris Mellon" <[EMAIL PROTECTED]> writes: >> Some people here have been arguing that all code should use "with" to >> ensure that the files are closed. But this still wouldn't solve the >> problem of the large data structures being left around for an >> arbitrary amount of time. > I don't think

Re: Python's "only one way to do it" philosophy isn't good?

2007-07-06 Thread Douglas Alan
"Chris Mellon" <[EMAIL PROTECTED]> writes: > Sure, but thats part of the general refcounting vs GC argument - > refcounting gives (a certain level of) timeliness in resource > collection, GC often only runs under memory pressure. If you're > saying that we should keep refcounting because it provid

Re: Python's "only one way to do it" philosophy isn't good?

2007-07-09 Thread Douglas Alan
"Chris Mellon" <[EMAIL PROTECTED]> writes: >> And why would you do that? People rely very heavily in C++ on when >> destructors will be called, and they are in fact encouraged to do so. >> They are, in fact, encouraged to do so *so* much that constructs like >> "finally" and "with" have been reje

Re: Python's "only one way to do it" philosophy isn't good?

2007-07-09 Thread Douglas Alan
Steve Holden <[EMAIL PROTECTED]> writes: >> I'm relying on a feature that has worked fine since the early '90s, >> and if it is ever changed in the future, I'm sure that plenty of other >> language changes will come along with it that will make adapting code >> that relies on this feature to be th

Re: The best platform and editor for Python

2007-07-10 Thread Douglas Alan
[EMAIL PROTECTED] (Alex Martelli) writes: > Kay Schluehr <[EMAIL PROTECTED]> wrote: >> half of the community is happy with Emacs and the other half wants to >> program in a VS-like environment, neither consensus nor progress has > Calling all vi/vim users (and we'll heartily appreciate the suppo

Re: asyncore and OOB data

2007-07-11 Thread Douglas Wells
n my system, I get back an error (EINVAL - Invalid argument). I would expect that asyncore would report this error somehow or other. In summary, you almost certainly can't use the concept of a separate OOB channel to transfer data in an FTP environment. If you really, really need something like

Re: asyncore and OOB data

2007-07-12 Thread Douglas Wells
In article <[EMAIL PROTECTED]>, Steve Holden <[EMAIL PROTECTED]> writes: > Douglas Wells wrote: > > > > Third, the TCP protocol, which you have selected via the SOCK_STREAM > > option doesn't support OOB at all, so there's no way that you can > &

Re: asyncore and OOB data

2007-07-12 Thread Douglas Wells
In article <[EMAIL PROTECTED]>, billiejoex <[EMAIL PROTECTED]> writes: > Douglas Wells wrote: > > > Second, when I look at the FTP specification, I don't find the > > concept of OOB anywhere. So, it's not clear what OOB data would > > mean in

Re: Execute commands from file

2007-05-17 Thread Douglas Woodrow
On Thu, 17 May 2007 00:30:23, i3dmaster <[EMAIL PROTECTED]> wrote >f = open(file,'rb') >for i in f: >exec i Why are you opening the file in binary mode? -- Doug Woodrow -- http://mail.python.org/mailman/listinfo/python-list

Re: Execute commands from file

2007-05-18 Thread Douglas Woodrow
On Fri, 18 May 2007 04:45:30, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote >On 17 May 2007 13:12:10 -0700, i3dmaster <[EMAIL PROTECTED]> declaimed >the following in comp.lang.python: > >> 'b' is generally useful on systems that don't treat binary and text >> files differently. It will improve porta

Re: python shell

2007-05-20 Thread Douglas Woodrow
On Sat, 19 May 2007 21:42:27, Steve Holden <[EMAIL PROTECTED]> wrote > http://en.wikipedia.org/wiki/Doctest >Since you claim to be exercising your pedantry, I wonder why I get the >results I do. Since we *are* being pedantic, by the way, surely the >name is actually "doctest", not "Doctest".

Re: c[:]()

2007-05-31 Thread Douglas Woodrow
On Wed, 30 May 2007 23:23:22, Warren Stringer <[EMAIL PROTECTED]> wrote > >def a(): return 'b' >def b(): print 'polly! wakey wakey' >c = {} >c['a'] = b >c[a()]() #works! (typo correction for other easily-confused newbies like myself) I think you mean , | c['a']() #works! ` -- Doug Wo

Re: c[:]()

2007-05-31 Thread Douglas Woodrow
On Thu, 31 May 2007 08:57:56, Douglas Woodrow <[EMAIL PROTECTED]> wrote >On Wed, 30 May 2007 23:23:22, Warren Stringer <[EMAIL PROTECTED]> wrote >> >>def a(): return 'b' >>def b(): print 'polly! wakey wakey' >>c = {} >>c['a

Re: Comparing RFC1123 based Dates

2007-08-05 Thread Douglas Wells
limited to processing date/times. Even then, I then explicitly set the locale (LC_TIME) to the "C" locale. Otherwise, I use ad hoc code that explicitly recognizes the RFC-defined forms. -- . Douglas Wells . Connection Technologies . . Internet: -sp9804- -at - contek.com- . -- http://mail.python.org/mailman/listinfo/python-list

Re: Socket - gaierror

2007-08-27 Thread Douglas Wells
s in DNS. In UNIX/Linux you can use the hostname command; in any system you can write a python script to print the result of socket.gethostname(). - dmw -- . Douglas Wells . Connection Technologies . . Internet: -sp9804- -at - contek.com- . -- http://mail.python.org/mailman/listinfo/python-list

Re: Socket - gaierror

2007-08-27 Thread Douglas Wells
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] writes: > On Aug 27, 4:22 pm, [EMAIL PROTECTED] (Douglas Wells) wrote: > > In article <[EMAIL PROTECTED]>, > > > > [EMAIL PROTECTED] writes: > > > On Aug 27, 12:32 pm, Larry Bates <[EMAIL PROTECTED]

Re: [PyCON-Organizers] Next PyCon Organizers' Meeting Tuesday, 11 September

2007-09-10 Thread Douglas Napoleone
I have found that jabber accounts no longer work, but google accounts do. I had a jabber account, but could never get it working in GAIM. My google account works fine. -Doug On 9/10/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > David> Connection details: > David> > http://wik

Re: Embedded and extending python 2.5: trouble with __main__ in PyRun_SimpleFileExFlags?

2007-03-04 Thread Carl Douglas
} if (PyRun_SimpleFile(PyFile_AsFile(PyFileObject), ofn.lpstrFile) == -1) { PyErr_Print(); PyErr_Clear(); } Py_DECREF(PyFileObject); } On 2/19/07, Carl Douglas <[E

Re: [Swig-user] How to receive a FILE* from Python under MinGW?

2007-03-20 Thread Carl Douglas
Hi John, I had exactly this problem... use the PyFile_AsFile function. Below is a code snippet from my project: // Thank you: http://www.ragestorm.net/tutorial?id=21#8 PyObject* PyFileObject = PyFile_FromString(ofn.lpstrFile, "r"); if (PyFileObje

Re: [Swig-user] How to receive a FILE* from Python under MinGW?

2007-03-20 Thread Carl Douglas
gt; > And > http://mail.python.org/pipermail/python-list/2007-March/430695.html > http://groups.google.com/group/comp.lang.python/browse_frm/thread/6d7569e7fd996daf/ > http://groups.google.com/group/comp.lang.python/browse_frm/thread/17558adbc053f26d/ > > Carl Douglas wrote: >

Re: How to receive a FILE* from Python under MinGW?

2007-03-20 Thread Carl Douglas
On 20 Mar 2007 23:12:45 -0700, John Pye <[EMAIL PROTECTED]> wrote: > On Mar 21, 4:49 pm, "Carl Douglas" <[EMAIL PROTECTED]> wrote: > > 1) Rebuild Python with a different compiler/linker kit so it links to > > the same CRT as my project, in your case find a ming

Re: [Swig-user] How to receive a FILE* from Python under MinGW?

2007-03-21 Thread Carl Douglas
On 3/22/07, Giovanni Bajo <[EMAIL PROTECTED]> wrote: > On 21/03/2007 6.49, Carl Douglas wrote: > > > Hi John, > > > > In my case, all I needed was a PyFile_AsFile to get the File *. > > However I found that Python errors going to stdout/stderr were not > &

Problem with shelve/gdbm

2007-10-19 Thread Douglas Applegate
Hi- I am having a problem with shelve. The problem I think is really with gdbm. I'll write out a file using shelve/gdbm on an amd64 machine and then I'll try to read it in on a i386 machine. The result is a 'gdbm fatal: read error.' Reversing directions results in the same problem. Below a

Re: result of os.times() is different with 'time' command

2007-02-02 Thread Douglas Wells
d 100 on the OP's OS X(*). (BTW, this sort of historic code is exactly why POSIX no longer defines HZ.) In support of this, I note that the following ratios exist: user time from os.times / user time from time command 39.85 / 23.938 => 1.665

Embedded and extending python 2.5: trouble with __main__ in PyRun_SimpleFileExFlags?

2007-02-19 Thread Carl Douglas
Hi Python fans, I am developing a DLL that is loaded by a host application on windows. I'm using python 2.5. My DLL uses an embedded python interpreter which can access the host application through an API which I have exposed using SWIG 1.3.31. Therefore I have both extended and embedded Python

Re: Can anyone help, please?

2008-02-13 Thread Douglas Wells
- start print "%7.3f: %d octets from %s" % (elapsed, total_data_length, addr) except socket.error, e: print "Socket error" + e break ## ==

Re: sockets -- basic udp client

2008-02-17 Thread Douglas Wells
one non-zero length response (such that buf is modified) and seeing if it ever terminates. I would also like to point out that the original example (quoted from the book) used "connect' and "recv" w/ UDP). One of the purposes of using this construct (rather than using "recvfrom") is to simplify identification of the remote system: When you "connect" to a UDP socket, the OS will only send messages to that system and will ignore messages that do not originate from that IP address (ignoring the issue IP address spoofing). - dmw -- . Douglas Wells . Connection Technologies . . Internet: -sp9804- -at - contek.com- . -- http://mail.python.org/mailman/listinfo/python-list

Re: Threading the Python interpreter

2008-02-19 Thread Douglas Wells
ms were eventually accepted by the larger computing community with little change in their original meanings. But, the OP should still be safe. - dmw -- . Douglas Wells . Connection Technologies . . Internet: -sp9804- -at - contek.com- . -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess.Popen pipeline bug?

2008-03-13 Thread Douglas Wells
/dev/null',shell = True,stdin = a.stdout) b = subprocess.Popen('cat >/dev/null',shell = True,stdin = a.stdout, close_fds = True) # * end of changes a.stdin.close() b.wait() a.wait() Good luck. - dmw -- . Douglas Wells . Connection Technologies . . Internet: -sp9804- -at - contek.com- . -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding the instance reference of an object

2008-10-27 Thread Douglas Alan
Steven D'Aprano <[EMAIL PROTECTED]> writes: > I understand that Python's object and calling semantics are exactly the > same as Emerald (and likely other languages as well), and that both > Emerald and Python are explicitly based on those of CLU, as described by > by Barbara Liskov in 1979: > >

Re: Finding the instance reference of an object

2008-10-27 Thread Douglas Alan
greg <[EMAIL PROTECTED]> writes: > Seems to me that (1) describes exactly how parameter passing > works in Python. So why insist that it's *not* call by value? Because there's an important distinction to be made, and the distinction has been written up in the Computer Science literature since Lis

Re: Finding the instance reference of an object

2008-10-28 Thread Douglas Alan
Joe Strout <[EMAIL PROTECTED]> writes: > There are only the two cases, which Greg quite succinctly and > accurately described above. One is by value, the other is by > reference. Python quite clearly uses by value. You make a grave error in asserting that there are only two cases. Algol, for in

Re: [PyCon-Organizers] PyCon 2009 (US) - Call for tutorials Extended to 11/3

2008-10-30 Thread Douglas Napoleone
We should get an announcement out on the blog: http://pycon.blogspot.com/ and note that the deadline is approaching for both talks and tutorials. For some reason blogger does not like my google account, so I cant seem to do it :-( -Doug On Thu, Oct 30, 2008 at 3:28 PM, Greg Lindstrom <[EMAI

Re: Finding the instance reference of an object

2008-10-30 Thread Douglas Alan
greg <[EMAIL PROTECTED]> writes: > Douglas Alan wrote: >> greg <[EMAIL PROTECTED]> writes: >> >>>Seems to me that (1) describes exactly how parameter passing >>>works in Python. So why insist that it's *not* call by value? >> Beca

Re: Finding the instance reference of an object

2008-10-31 Thread Douglas Alan
greg <[EMAIL PROTECTED]> writes: > Douglas Alan wrote: >> greg <[EMAIL PROTECTED]> writes: > >>> This holds for *all* languages that I know about, both static and >>> dynamic. > >> Then you don't know about all that many languages. There ar

Re: Finding the instance reference of an object

2008-11-07 Thread Douglas Alan
Joe Strout <[EMAIL PROTECTED]> writes: > As for where I get my definitions from, I draw from several sources: > > 1. Dead-tree textbooks You've been reading the wrong textbooks. Read Liskov -- she's called CLU (and hence Python's) calling strategy "call-by-sharing" since the 70s. > 2. Wikipedia

Re: Finding the instance reference of an object

2008-11-07 Thread Douglas Alan
Joe Strout <[EMAIL PROTECTED]> writes: > Yes, OK, that's great. But there are several standard pass-by- > somethings that are defined by the CS community, and which are simple > and clear and apply to a wide variety of languages. "Pass by object" > isn't one of them. "Call-by-sharing" *is* one

Re: Finding the instance reference of an object

2008-11-19 Thread Douglas Alan
greg <[EMAIL PROTECTED]> writes: > Steven D'Aprano wrote: >> At least some sections of the Java community seem to prefer a >> misleading and confusing use of the word "value" over clarity and >> simplicity, but I for one do not agree with them. > I don't see anything inherently confusing or misl

Re: Finding the instance reference of an object

2008-11-19 Thread Douglas Alan
Joe Strout <[EMAIL PROTECTED]> writes: >> Q. What type of calling semantics do Python and Java use? >> >> A. Call-by-sharing. > > Fair enough, but if the questioner then says "WTF is call-by-sharing," > we should answer "call-by-sharing is the term we prefer for call-by- > value in the case wh

Re: Kill an OS process from script (perhaps unix specific)

2008-04-19 Thread Douglas Wells
not just an arbitrary delay), you could use the simple construct: import os code = os.system ("ulimit -t ; ...") That's not guaranteed to work on all POSIX systems, but it should work with at least ash, bash, and ksh. And it would would be "limit cputime ; ...&q

Re: Any advantage in LISPs having simpler grammars than Python?

2006-03-07 Thread Douglas Alan
Terry Hancock <[EMAIL PROTECTED]> writes: > I think experienced Lisp programmers must learn to visually parse > the *words* in the Lisp program to determine the structure, but I > find that really unhelpful, myself. Experienced Lisp programmers use indentation to visually parse the program struct

Re: Any advantage in LISPs having simpler grammars than Python?

2006-03-07 Thread Douglas Alan
Grant Edwards <[EMAIL PROTECTED]> writes: > On 2006-03-07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> Is there any advantage to a language having a nice mathematically >> compact grammar like LISP does? (or at least used to?) Yes, Lisp's syntax allows for a very powerful macro mechanism tha

Re: Any advantage in LISPs having simpler grammars than Python?

2006-03-08 Thread Douglas Alan
"Carl Banks" <[EMAIL PROTECTED]> writes: > Douglas Alan wrote: > >> For instance, if Python were to have been designed so that you would >> write: >> >>let myVeryLongVariableName = 3 >> >> I would have preferred this over >> &

Re: Python Evangelism

2006-03-09 Thread Douglas Alan
rtilley <[EMAIL PROTECTED]> writes: > Steve Holden wrote: >> Doug Bromley wrote: >>> I can see Ruby overtaking Python if we don't ALL do something about it. > I think it's the name. Python. Let's change it to something nicer. I agree that names are very important -- Java would never have caught

Re: Python Evangelism

2006-03-17 Thread Douglas Alan
Andrew Gwozdziewycz <[EMAIL PROTECTED]> writes: > Douglas Alan wrote: >> Ruby didn't start catching on until Ruby on Rails came out. If >> Python has a naming problem, it's with the name of Django, rather >> than Python. Firstly, Django doesn't h

Spam avoidance

2006-03-21 Thread Douglas Alan
I've noticed that there is little to no spam in comp.lang.python and am wondering how this is accomplished. Is there a moderator who actively cancels spam? If so, that wouldn't seem to prevent spam from making it through to the mailing list version of the newsgroup. Is there an exceptionally goo

Merging two dictionaries

2010-08-01 Thread Douglas Garstang
7;, 'platform': { 'elements': { 'data_source': { 'elements': { 'username': 'username', 'password': 'password', 'db_min_pool_size': 10 # This was added from the default. }, }, }, }, } } Thanks, Doug. -- Regards, Douglas Garstang http://www.linkedin.com/in/garstang Email: doug.garst...@gmail.com Cell: +1-805-340-5627 -- http://mail.python.org/mailman/listinfo/python-list

Re: Merging two dictionaries

2010-08-02 Thread Douglas Garstang
On Sun, Aug 1, 2010 at 11:57 PM, Gary Herron wrote: > On 08/01/2010 11:11 PM, Douglas Garstang wrote: >> >> On Sun, Aug 1, 2010 at 10:58 PM, Gary Herron >>  wrote: >> >>> >>> On 08/01/2010 10:09 PM, Douglas Garstang wrote: >>> >>>>

Re: Merging two dictionaries

2010-08-02 Thread Douglas Garstang
On Mon, Aug 2, 2010 at 12:47 AM, Paul Rubin wrote: > Douglas Garstang writes: >> default = {... >>                 'data_sources': { ... >> cluster = {... >>                 'data_source': { ... > > Did you want both of those to say the same t

Re: Merging two dictionaries

2010-08-02 Thread Douglas Garstang
On Mon, Aug 2, 2010 at 1:09 AM, Peter Otten <__pete...@web.de> wrote: > Douglas Garstang wrote: > >> I have the two dictionaries below. How can I merge them, such that: >> >> 1. The cluster dictionary contains the additional elements from the >> default dicti

Efficient binary search tree stored in a flat array?

2009-07-13 Thread Douglas Alan
I couldn't find a good algorithms forum on the Internet, so I guess I'll ask this question here instead: Is it possible to efficiently maintain a binary search tree in a flat array (i.e., without using pointers), as is typically done for a binary heap? It *is* possible, of course, to keep an order

Re: Efficient binary search tree stored in a flat array?

2009-07-13 Thread Douglas Alan
On Jul 13, 3:57 pm, a...@pythoncraft.com (Aahz) wrote: > Still, unless your list is large (more than thousands of elements), > that's the way you should go.  See the bisect module.  Thing is, the > speed difference between C and Python means the constant for insertion > and deletion is very very s

Re: Efficient binary search tree stored in a flat array?

2009-07-14 Thread Douglas Alan
On Jul 14, 7:38 am, Florian Brucker wrote: > Douglas Alan wrote: > > Thank you. My question wasn't intended to be Python specific, though. > > I am just curious for purely academic reasons about whether there is > > such an algorithm. All the sources I've skimmed

Re: Efficient binary search tree stored in a flat array?

2009-07-14 Thread Douglas Alan
On Jul 14, 8:10 am, Piet van Oostrum wrote: > Of course you can take any BST algorithm and replace pointers by indices > in the array and allocate new elements in the array. But then you need > array elements to contain the indices for the children explicitely. And why is this a problem? This is

Re: Efficient binary search tree stored in a flat array?

2009-07-14 Thread Douglas Alan
On Jul 14, 9:19 am, Scott David Daniels wrote: > It may well be that there is no good simple solution, and people avoid > writing about non-existent algorithms. I can't imagine why that should be the case. The CLRS textbook on algorithms, for instance, goes to some pains to mathematically prove

Re: Efficient binary search tree stored in a flat array?

2009-07-14 Thread Douglas Alan
I wrote: > On Jul 14, 8:10 am, Piet van Oostrum wrote: > > > Of course you can take any BST algorithm and replace pointers by indices > > in the array and allocate new elements in the array. But then you need > > array elements to contain the indices for the children explicitely. > And why is t

Unrecognized escape sequences in string literals

2009-08-09 Thread Douglas Alan
A friend of mine is just learning Python, and he's a bit tweaked about how unrecognized escape sequences are treated in Python. This is from the Python 3.0 reference manual: Unlike Standard C, all unrecognized escape sequences are left in the string unchanged, i.e., the backslash is left

Re: Unrecognized escape sequences in string literals

2009-08-09 Thread Douglas Alan
Steven D'Aprano wrote: > Why should a backslash in a string literal be an error? Because in Python, if my friend sees the string "foo\xbar\n", he has no idea whether the "\x" is an escape sequence, or if it is just the characters "\x", unless he looks it up in the manual, or tries it out in the R

Re: Unrecognized escape sequences in string literals

2009-08-09 Thread Douglas Alan
On Aug 9, 8:06 pm, Steven D'Aprano wrote: > while the behaviour your > friend wants is "treat a backslash as an error, except for these > exceptions". Besides, can't all error situations be described as, "treat the error situation as an error, except for the exception of when the situation isn't

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread Douglas Alan
On Aug 10, 2:03 am, Steven D'Aprano wrote: > On Sun, 09 Aug 2009 17:56:55 -0700, Douglas Alan wrote: > > Because in Python, if my friend sees the string "foo\xbar\n", he has no > > idea whether the "\x" is an escape sequence, or if it is just the >

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread Douglas Alan
On Aug 10, 2:10 am, Steven D'Aprano > I've never had any errors caused by this. But you've seen an error caused by this, in this very discussion. I.e., "foo\xbar". "\xba" isn't an escape sequence in any other language that I've used, which is one reason I made this error... Oh, wait a minute --

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread Douglas Alan
On Aug 10, 4:37 am, Steven D'Aprano > There is at least one good reason for preferring an error, namely that it > allows Python to introduce new escape codes without going through a long, > slow process. But the rest of these complaints are terribly unconvincing. What about: o Beautiful is b

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread Douglas Alan
On Aug 10, 10:58 am, Scott David Daniels wrote: > The string rules reflect C's rules, and I see little > excuse for trying to change them now. No they don't. Or at least not C++'s rules. C++ behaves exactly as I should like. (Or at least g++ does. Or rather *almost* as I would like, as by defau

Re: Unrecognized escape sequences in string literals

2009-08-10 Thread Douglas Alan
From: Steven D'Aprano wrote: > On Mon, 10 Aug 2009 00:32:30 -0700, Douglas Alan wrote: > > In C++, if I know that the code I'm looking at compiles, > > then I never need worry that I've misinterpreted what a > > string literal means. > If you don't k

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Douglas Alan
On Aug 11, 2:00 pm, Steven D'Aprano wrote: > > test.cpp:1:1: warning: unknown escape sequence '\y' > > Isn't that a warning, not a fatal error? So what does temp contain? My "Annotated C++ Reference Manual" is packed, and surprisingly in Stroustrup's Third Edition, there is no mention of the iss

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Douglas Alan
Steven D'Aprano wrote: > Because the cost isn't zero. Needing to write \\ in a string > literal when you want \ is a cost, I need to preface this entire post with the fact that I've already used ALL of the arguments that you've provided on my friend before I ever even came here with the topic, an

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Douglas Alan
On Aug 10, 11:27 pm, Steven D'Aprano wrote: > On Mon, 10 Aug 2009 08:21:03 -0700, Douglas Alan wrote: > > But you're right, it's too late to change this now. > > Not really. There is a procedure for making non-backwards compatible > changes. If you care deeply eno

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Douglas Alan
On Aug 11, 4:38 pm, Ethan Furman wrote: > Mind you, I'm not really vested in how Python *should* handle > backslashes one way or the other, but I am glad it has rules that it > follows for consitent results, and I don't have to break out a byte-code > editor to find out what's in my string litera

Re: Unrecognized escape sequences in string literals

2009-08-11 Thread Douglas Alan
I wrote: > But you're right, it's too late to change this now. P.S. But if it weren't too late, I think that your idea to have "\s" be the escape sequence for a backslash instead of "\\" might be a good one. |>ouglas -- http://mail.python.org/mailman/listinfo/python-list

Re: Unrecognized escape sequences in string literals

2009-08-12 Thread Douglas Alan
On Aug 12, 3:08 am, Steven D'Aprano wrote: > On Tue, 11 Aug 2009 14:48:24 -0700, Douglas Alan wrote: > > In any case, my argument has consistently been that Python should have > > treated undefined escape sequences consistently as fatal errors, > > A reasonable positio

Re: Unrecognized escape sequences in string literals

2009-08-12 Thread Douglas Alan
On Aug 12, 3:36 am, Steven D'Aprano wrote: > On Tue, 11 Aug 2009 13:20:52 -0700, Douglas Alan wrote: > > My "Annotated C++ Reference Manual" is packed, and surprisingly in > > Stroustrup's Third Edition, there is no mention of the issue in the > > entire

Re: Unrecognized escape sequences in string literals

2009-08-12 Thread Douglas Alan
On Aug 12, 5:32 am, Steven D'Aprano wrote: > That problem basically boils down to a deep-seated > philosophical disagreement over which philosophy a > language should follow in regard to backslash escapes: > > "Anything not explicitly permitted is forbidden" > > versus > > "Anything not explicitl

Re: Unrecognized escape sequences in string literals

2009-08-13 Thread Douglas Alan
On Aug 12, 7:19 pm, Steven D'Aprano wrote: > You are making an unjustified assumption: \y is not an error. You are making in an unjustified assumption that I ever made such an assumption! My claim is and has always been NOT that \y is inately an error, but rather that treating unrecognized esca

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-14 Thread Douglas Alan
On Aug 14, 12:17 pm, Grant Edwards wrote: > On 2009-08-14, Steven D'Aprano wrote: > > On Fri, 14 Aug 2009 07:07:31 -0700, Aahz wrote: > >> "I saw `cout' being shifted "Hello world" times to the left and stopped > >> right there."  --Steve Gonedes > > > Assuming that's something real, and not i

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-15 Thread Douglas Alan
On Aug 14, 10:25 pm, Dave Angel wrote: > Benjamin Kaplan wrote: > > On Fri, Aug 14, 2009 at 12:42 PM, Douglas Alan wrote: > >> P.S. Overloading "left shift" to mean "output" does indeed seem a bit > >> sketchy, but in 15 years of C++ programming,

Re: Unrecognized escape sequences in string literals

2009-08-15 Thread Douglas Alan
On Aug 14, 1:55 pm, Steven D'Aprano wrote: > Douglas, you and I clearly have a difference of opinion on > this. Neither of us have provided even the tiniest amount > of objective, replicable, reliable data on the > error-proneness of the C++ approach versus that of >

Re: Python or ActionScript 3.0

2009-08-15 Thread Douglas Alan
On Aug 15, 5:32 pm, Jaseem wrote: > Is python similar to actionscript 3.0 For some very rough sense of "similar" it might be, but not really. > Which is better to create a rich gui internet application? > Is it AS 3.0 with flex or python with its GUI libs? Python doesn't run in your typical we

Re: Python- javascript

2009-08-15 Thread Douglas Alan
On Aug 15, 8:02 pm, Mike Paul wrote: > I'm trying to scrap a dynamic page with lot of javascript in it. > Inorder to get all the data from the page i need to access the > javascript. But i've no idea how to do it. I'm not sure exactly what you are trying to do, but scraping websites that use a l

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-15 Thread Douglas Alan
On Aug 15, 10:19 pm, Steven D'Aprano wrote: > On Sat, 15 Aug 2009 13:01:43 -0700, Douglas Alan wrote: > > P.S. I find it strange, however, that anyone who is not okay with > > "abusing" operator overloading in this manner, wouldn't also take > > umbra

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-15 Thread Douglas Alan
On Aug 16, 1:05 am, Steven D'Aprano wrote: > On Sat, 15 Aug 2009 20:00:23 -0700, Douglas Alan wrote: > > So, as far as I can tell, Python has no real authority to throw stones > > at C++ on this little tiny particular issue. > I think you're being a tad over-defensiv

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Douglas Alan
On Aug 16, 4:22 am, Steven D'Aprano wrote: > I don't like normal assignment. After nearly four decades of mathematics > and programming, I'm used to it, but I don't think it is especially good. > It confuses beginners to programming: they get one set of behaviour > drilled into them in maths clas

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Douglas Alan
On Aug 16, 4:48 am, Erik Max Francis wrote: > Douglas Alan wrote: > > Personally, my favorite is Lisp, which looks like > > >    (set! y (+ y 1)) > > For varying values of "Lisp."  `set!` is Scheme. Yes, I'm well aware! There are probably as many

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Douglas Alan
On Aug 16, 8:45 am, MRAB wrote: > No, APL is strictly right-to-left. > >      -> x > > means "goto x". > > Writing to the console is: > >      [] <- myVar > > Reading from the console is: > >      myVar <- [] Ah, thanks for the correction. It's been 5,000 years since I used APL! |>ouglas -- ht

Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]

2009-08-16 Thread Douglas Alan
On Aug 16, 6:18 am, Steven D'Aprano wrote: > On Sun, 16 Aug 2009 01:41:41 -0700, Douglas Alan wrote: > > I would definitely not like a language that obscures assignment by > > moving it over to the right side of lines. > One could argue that left-assigned-from-right

Re: python GUIs comparison (want)

2006-10-25 Thread Douglas Soares de Andrade
Stephen Eilert escreveu: > BartlebyScrivener wrote: > >> Well, I am woefully unqualified to speak to the general state of Python >> gui frameworks, but I am in a similar situation as the OP, i.e., a >> beginner looking to TRY some easy gui programming in Python. Not being >> a computer science p

Re: Python Jogos

2006-11-09 Thread Douglas Soares de Andrade
sa lista é o inglês, caso não se sinta a vontade em fazer pergutas em inglês, favor perguntar na lista do grupo pythonbrasil. Acesse o site aí: www.pythonbrasil.com.br Até -- Douglas Soares de Andrade msn: [EMAIL PROTECTED] jabber: [EMAIL PROTECTED] Quote: Real programmers don't die, they just

Binary numbers

2005-06-07 Thread Douglas Soares de Andrade
many places like python.org and google, but not found anything useful. Thats why im asking this. And another question... if python has not a way to do this, why i let me use oct(), hex() and not bin() ? Thanks for the help ! -- Douglas Soares de Andrade http://douglasandrade.cjb.net - dsa at

Re: Binary numbers

2005-06-07 Thread Douglas Soares de Andrade
Hi ! Pardon me, but what itoa has to do it the history ? See ya ! Em Quarta 08 Junho 2005 00:34, Dan Bishop escreveu: > Douglas Soares de Andrade wrote: > > Hi ! > > > > How to work with binary numbers in python ? Is there a way to print a > > number in its binary fo

<    1   2   3   >