Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* Steve Holden: So now the whole thing boils down to "Alf against the world"? The reminds me of the story about the woman who went to see her son qualify from his basic army training. When asked what she thought of the parade she said it was very nice, but that "everyone but our

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* Steve Holden: Alf P. Steinbach wrote: * Steve Holden: Alf P. Steinbach wrote: [snip] Since in the quoting above no reference to definition of "pointer" remains: "pointer" refers to a copyable reference value as seen from the Python level, in the same way as "poi

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* Steve Holden: Alf P. Steinbach wrote: * Steve Holden: So now the whole thing boils down to "Alf against the world"? The reminds me of the story about the woman who went to see her son qualify from his basic army training. When asked what she thought of the parade she said it was

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* Steven D'Aprano: On Wed, 10 Feb 2010 23:56:36 +0100, Alf P. Steinbach wrote: * Steven D'Aprano: On Wed, 10 Feb 2010 21:02:14 +0100, Alf P. Steinbach wrote: "pointer" refers to a copyable reference value as seen from the Python level, in the same way as "pointer&

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* alex23: "Alf P. Steinbach" wrote: Telling someone to "learn to read" is a Steve Holden'sk way to imply that the person is an ignoramus who hasn't bothered to learn to read. Ad hominem. So, you are misrepresenting -- again -- and in a quite revealing w

Re: Modifying Class Object

2010-02-11 Thread Alf P. Steinbach
* I V: On Thu, 11 Feb 2010 07:37:35 +0100, Alf P. Steinbach wrote: * Steven D'Aprano: s = [1] t = s # Binds the name t to the object bound to the name s. t[0] = 2 # Changes the object bound to the name t print(s) # Checks the object via the original name. Notice that

Re: Modifying Class Object

2010-02-11 Thread Alf P. Steinbach
* Steve Holden: Alf P. Steinbach wrote: * Steven D'Aprano: [...] accusing them of lying for having an opinion that differs from yours, That is untrue. Well, that says it all really. You seem to insinuate that I'm saying that Steven is lying, and/or that Steven is lying. Fr

Re: Modifying Class Object

2010-02-11 Thread Alf P. Steinbach
* Steve Holden: Alf P. Steinbach wrote: * Steve Holden: [...] In this particular part of the thread I am attempting, unsuccessfully, to convince you that a change in *your* behavior would lead to less hostility directed towards the way you present your ideas. You apparently feel it is quite

Re: Is a merge interval function available?

2010-02-11 Thread Alf P. Steinbach
.c++ who responded/responds to homework questions with the most advanced, convoluted and, except for misleading names, technically correct solutions. Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: Modifying Class Object

2010-02-11 Thread Alf P. Steinbach
* Terry Reedy: On 2/11/2010 1:37 AM, Alf P. Steinbach wrote: Consider just the assert( t is not s ) t = s Does this change anything at all in the computer's memory? By 'computer', do you mean 'anything that computes' (including humans) or specifically 'e

Re: Please help with MemoryError

2010-02-11 Thread Alf P. Steinbach
o not, however, need to be concerned about circular references, at least unless you need some immediate deallocation. For although circular references will prevent the objects involved from being immediately deallocated, the general garbage collector will take care of them later. Cheers &a

Re: Modifying Class Object

2010-02-11 Thread Alf P. Steinbach
* Steven D'Aprano: On Thu, 11 Feb 2010 23:26:34 +0100, Alf P. Steinbach wrote: I presume you agree that the name 'Alf P. Steinbach' refers to you. Do you then consider it to be a 'reference' to you? Yes, and that's irrelevant, because you can't chang

Re: Modifying Class Object

2010-02-11 Thread Alf P. Steinbach
acks and by group action. Or perhaps it didn't, but at this point it would not surprise me in the slightest. Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: Modifying Class Object

2010-02-12 Thread Alf P. Steinbach
* Michael Sparks: Hi Alf, Before I start, note we're talking about semantics, not implementation. That distinction is very important. Yes. It would seem to readers that posters here do not grasp and are unable to grasp that distinction. However, all those references to implement

Re: Please help with MemoryError

2010-02-12 Thread Alf P. Steinbach
alking about something else than argument passing. The standard terminology is in my view fine. Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: Please help with MemoryError

2010-02-12 Thread Alf P. Steinbach
cate the pass by reference at the call site, then that would exclude C#. But if one allows some indication at the call site, then that would perhaps include C (applying the & address op), which everyone agrees does not have call by reference. So, to understand the conventional meaning of th

Re: Modifying Class Object

2010-02-12 Thread Alf P. Steinbach
* Steve Holden: Alf P. Steinbach wrote: You may note that that Wikipedia article refers to an article that I wrote about pointers in C++. It's a broken link, referring to a non-existent server. Yes, sorry. It's been that way a long time, and for the same reason my C++ tutorial,

Re: Please help with MemoryError

2010-02-12 Thread Alf P. Steinbach
* Antoine Pitrou: Le Fri, 12 Feb 2010 23:12:06 +0100, Alf P. Steinbach a écrit : Steven talks about the standard meaning of "pass by reference". See my answer to Steve's message. You can't postulate a "standard meaning" of "pass by reference" ind

Re: Modifying Class Object

2010-02-12 Thread Alf P. Steinbach
* Steven D'Aprano: On Fri, 12 Feb 2010 21:26:24 +0100, Alf P. Steinbach wrote: Yes, I do count this as a personal attack and flaming. The litmus test for that is that it says something very negative about the person you're debating with. As negative as accusing somebody of int

Re: Modifying Class Object

2010-02-12 Thread Alf P. Steinbach
* Mark Lawrence: Alf P. Steinbach wrote: An extremely long thread dedicated to the notion that there are no references in Python (which is blatantly false), coupled with personal attacks on the one person arguing that there are. I could easily think that you were having me on. Of course

Re: fork vs threading.Thread

2010-02-12 Thread Alf P. Steinbach
ram to terminate, if you want that. it seems that tftpserv runs but wont go on to spawn xmlserv as well. do I need to fork if I want both these to run at the same time? It was my impression that by using Thread execution in the main program would continue. See above. Cheers & hth.,

Re: How do you implement a Progress Bar

2010-02-12 Thread Alf P. Steinbach
ild widgets of a given parent widget use the same layout manager, otherwise the typical result is a hang. for i in range(100): f.set(i,"Hello") print i This will probably happen too fast to see, before the window is presented. One idea might be to add a few buttons for testing things. mainloop() Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: python crash on windows but not on linux

2010-02-13 Thread Alf P. Steinbach
g very similar to that measure. You can display additional columns in Task Manager, and one useful one is how much virtual memory is allocated,. And perhaps then (if that's not what you're looking it already) it'll be closer to 2 GiB? Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: how do I write a scliceable class?

2010-02-13 Thread Alf P. Steinbach
ocumented that that what's a subclass should override, then, OK. No problem. So what is there to do? Any suggestion? An alternative can be to simply check for argument value None in the constructor, and if so, don't do anything. Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: Modifying Class Object

2010-02-13 Thread Alf P. Steinbach
ction. But then two others ended up arguing that Python does not have references, with one of them maintaining that "refers to" in the language spec does not mean "refers to", but instead means "refers to", so I'm guessing it's religious, yes? Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: Modifying Class Object

2010-02-13 Thread Alf P. Steinbach
the last word) Hoping this was useful on some level, Yes. I elected to respond to just /one/ of the many arguments you presented. The other arguments, about why there are no references in Python, shared, however, the basic property of being logical fallacies packaged in kilometers of rambling text. Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: Modifying Class Object

2010-02-13 Thread Alf P. Steinbach
* Steve Holden: Alf P. Steinbach wrote: * Michael Sparks: [Due to the appearance of reasoned discussion (it's not practical to read it all!) [...] Therefore to say "in reality the implementation will be passing a reference or pointer" is invalid. There is after a

Re: Selecting a file in a directory

2010-02-13 Thread Alf P. Steinbach
it can even be multiple files. Otherwise, tkinter has, as I recall, a standard file chooser dialog. These "standard" dialogs are generally called "common dialogs". Just google for tkinter and suitable words. Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: Modifying Class Object

2010-02-13 Thread Alf P. Steinbach
* Benjamin Kaplan: On Sat, Feb 13, 2010 at 7:50 PM, Alf P. Steinbach wrote: At this point consider whether it's possible to implement Pascal in Haskell. If it is possible, then you have a problem wrt. drawing conclusions about pointers in Pascal, uh oh, they apparently can't exist.

Re: Modifying Class Object

2010-02-13 Thread Alf P. Steinbach
tc. ad nauseam, sprinkled with misrepresentations etc. I don't know the point of that. Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: Modifying Class Object

2010-02-13 Thread Alf P. Steinbach
* Steve Holden: Alf P. Steinbach wrote: * Steve Holden: Alf P. Steinbach wrote: * Michael Sparks: [Due to the appearance of reasoned discussion (it's not practical to read it all!) [...] Therefore to say "in reality the implementation will be passing a reference or pointer&q

Re: Modifying Class Object

2010-02-13 Thread Alf P. Steinbach
* Bruno Desthuilliers: Alf P. Steinbach a écrit : (snip) This group has an extraordinary high level of flaming and personal attacks Oh my... (snip remaining non-sense) Mr Steinbach, I bet you'll count this as another "flaming" and "personal attack", but nonetheless

Re: Modifying Class Object

2010-02-13 Thread Alf P. Steinbach
* Aahz: In article , Alf P. Steinbach wrote: My original statement, with reference to the Java language spec, didn't say much more about the language than that it has assignable references. Assuming this is what you're referring to: Python passes pointers by value, just as

Re: Modifying Class Object

2010-02-13 Thread Alf P. Steinbach
stently remove all possible ambiguity the term "name" can't be used about formal arguments. I think, even though "pass by name" is much less well known than "pass by reference", this indicates that it's not practically possible to remove all possible ambiguity. I think some Common Sense(TM) must in any case be assumed, and applied. Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: Modifying Class Object

2010-02-14 Thread Alf P. Steinbach
of that terminology means traveling into a pretty chaotic territory. But on the other hand, going for the more abstract it gets cleaner and simpler. The Wikipedia article is about in the middle somewhere. It is perhaps not confusing that it is confusing to many. :-) Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: hi can any one please help me..

2010-02-15 Thread Alf P. Steinbach
ditional) directories where gcc should search for libraries via the LIBRARY_PATH environment variable. At least according to my MinGW documentation for Windows, but I assume that it's the same in Linux. Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: trouble installing matplotlib - syslibroot: multiply specified

2010-02-15 Thread Alf P. Steinbach
coughed up the following discussion: http://lists.apple.com/archives/unix-porting/2005/Oct/msg3.html> Quoting from that thread: "Try not setting LDFLAGS. Passing -isysroot to gcc might cause it to pass -isyslibroot to the linker if you're using gcc to link." Cheers, - Alf

Re: Executing a command from within python using the subprocess module

2010-02-15 Thread Alf P. Steinbach
ge.png # # is derived from the variables above Assuming that the extra right square bracket in 'colors' is a typo, here's one way: s = "convert -size {w}x{h} gradient:{g1}-{g2} {f}".format( w = width, h = height, g1 = colors[0], g2 = colors[1], f = filename

Re: Modifying Class Object

2010-02-15 Thread Alf P. Steinbach
ing enthusiasts here go wrong can be of help to readers of the thread, although I've given up hope on those holding the functional programming view (since I'm only human, and even the Gods contend in vain against that sort of thing). Cheers & hth., - Alf Notes: [1] Steven D&

Re: listing existing windows services with python

2010-02-15 Thread Alf P. Steinbach
27; command also has some functionality related to services, e.g. 'net start'. Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: listing existing windows services with python

2010-02-15 Thread Alf P. Steinbach
one, u'StartMode': None, u'DesktopInteract': None, u'ServiceType': None, u'T agId': None, u'StartName': None, u'AcceptPause': None, u'CreationClassName': Non e, u'SystemCreationClassName': None, u'ExitCode': None} >>> s.Name u'Alerter' >>> s.Started False >>> s.ServiceType u'Share Process' 1: http://timgolden.me.uk/python/wmi/index.html Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: listing existing windows services with python

2010-02-15 Thread Alf P. Steinbach
* alex23: On Feb 16, 1:28 pm, "Alf P. Steinbach" wrote: It's probably Very Good, but one Microsoft-thing one should be aware of: using WMI functionality generally starts up a background WMI service... "Probably"? That means that since you say it's fant

Re: listing existing windows services with python

2010-02-16 Thread Alf P. Steinbach
* alex23: "Alf P. Steinbach" wrote: it's great that you provide the kind of help that you did, pointing out a probably very good module that it seems gives the required functionality, and giving an URL. Yes, because that's _actually helping people_ and not just contrib

Re: listing existing windows services with python

2010-02-16 Thread Alf P. Steinbach
I don't know how that works with programmatic access, but it's worth checking out. Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: listing existing windows services with python

2010-02-16 Thread Alf P. Steinbach
* Tim Golden: On 16/02/2010 12:48, Alf P. Steinbach wrote: I just googled the filename from memory, found http://www.neuber.com/taskmanager/process/wmiprvse.exe.html> Don't know if I've disabled it because invoking wmic didn't produce it. Uh, wait, since it hosts the

Re: listing existing windows services with python

2010-02-16 Thread Alf P. Steinbach
* Steve Holden: Alf P. Steinbach wrote: [...] I'll do some further research to see what's going on there. Cheers, - Alf (is this off-topic for the group?) It's gone a lot further off than this without anyone complaining. I think your experiences to date should convince y

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

2010-02-16 Thread Alf P. Steinbach
r applying assumptions about mutability/constantness, then types may not be The Answer. Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: Efficiently building ordered dict

2010-02-22 Thread Alf P. Steinbach
real code (copy and paste). The above code is not real. Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: What's Going on between Python and win7?

2010-02-22 Thread Alf P. Steinbach
ickle? I just want to duplicate the program in another folder, and not link to an ancestor. Copy and paste. Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: What's Going on between Python and win7?

2010-02-22 Thread Alf P. Steinbach
* W. eWatson: On 2/22/2010 8:50 PM, Alf P. Steinbach wrote: * W. eWatson: So what's the bottom line? This link notion is completely at odds with XP, Well, Windows NT has always had *hardlinks*. I found it a bit baffling that that functionality is documented as not implemented for Wi

Re: Interesting talk on Python vs. Ruby and how he would like Python to have just a bit more syntactic flexibility.

2010-02-22 Thread Alf P. Steinbach
cises. It's just like playing Bach fugues in some of your practice hours will make you a better musician even if you are professionally a heavy metal rock guitarist. Uhm, Paganini... As I understand it he invented the "destroy your instruments on stage". :-) Cheers, - Alf

Re: scope of generators, class variables, resulting in global na

2010-02-24 Thread Alf P. Steinbach
r j in B]) ... Traceback (most recent call last): File "", line 1, in File "", line 4, in T File "", line 4, in NameError: global name 'B' is not defined >>> exit() C:\test> _ From one point of view it's good that Py3 provides about the same behavior for generator expressions and list comprehensions. But I'd really like the above examples to Just Work. :-) Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: When will Java go mainstream like Python?

2010-02-25 Thread Alf P. Steinbach
for simplicity in one dimension is some complexity in another dimension, here deterministic cleanup and the problem of zombie objects (garbage collection simplifies a lot of things while zombie objects, objects that have had explicit cleanup performed and thus are invalid in a sense, compensate by adding back in a lot of complexity). Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: When will Java go mainstream like Python?

2010-02-25 Thread Alf P. Steinbach
lected, causing a memory leak. Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: lists of variables

2010-02-26 Thread Alf P. Steinbach
s only copy references. I can think of some ways to work around this, including using single element lists as "pointers": aa=[1] bb=[2] myplist=[aa,bb] print myplist [[1], [2]] aa[0]=3 print myplist [[3], [2]] This is the same as your last example above, except that now you're

Re: loop through each line in a text file

2010-02-26 Thread Alf P. Steinbach
ver 500,000 lines that need processed. wer1999001 31.2234 82.2367 37.9535 82.3456 wer1999002 31.2234 82.2367 37.9535 82.3456 >>> line = "wer1999001" >>> line 'wer1999001' >>> line[3:3+4] '1999

Re: Variable definition

2010-02-26 Thread Alf P. Steinbach
d it anyway -- import collections Color = namedtuple( "Color", "red green blue" ) myPrefix = Color( 'a', 'b', 'c' ) Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: Docstrings considered too complicated

2010-02-26 Thread Alf P. Steinbach
my eyes... and ARM: SUB R0,R1,R2 MOV R0,R1 which does: R0 := R1 - R2 R0 := R1 The only assembly language I know of which does it the other way round is 68x00: SUB D0,D1 MOVE D0,D1 which does: D1 := D1 - D0 D1 := D0 I know which I prefer! :-) Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: Python dos2unix one liner

2010-02-27 Thread Alf P. Steinbach
TITUTION', line)) for line in sys.stdin]" Nothing to do with Perl, Perl only takes a handful of characters to do this and certainly does not require the creation an intermediate file, I simply found the above example on wiki.python.org whilst searching Google for a quick

Re: Turtle graphics speed(). Seems broken

2010-02-27 Thread Alf P. Steinbach
print "Total drawing time: ", t.time() raw_input('Hit Enter to close figure window.') if __name__ == "__main__": msg = main() print(msg) Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: Method / Functions - What are the differences?

2010-02-28 Thread Alf P. Steinbach
) 'HELLO' >>> >>> >>> >>> f.__self__ 'Hello' >>> f.__call__ >>> print( f.__doc__ ) S.upper() -> str Return a copy of S converted to uppercase. >>> _ A common use for delegates is as command handlers in a GUI application, and in general for event notifications. Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: Printing the arguments of an attribute in a class

2010-02-28 Thread Alf P. Steinbach
e might be an existing Python implementation. Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Sample code usable Tkinter listbox

2010-02-28 Thread Alf P. Steinbach
rn "" if i is None else self.lb.get( i ) def append( self, item ): return self.lb.insert( "end", item ) def add_selection_event_handler( self, handler ): "An event handler takes one argument, a Tkinter Event" return self.lb.bind( "<>", handler ) Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: Sample code usable Tkinter listbox

2010-02-28 Thread Alf P. Steinbach
* rantingrick: On Feb 28, 6:30 pm, "Alf P. Steinbach" wrote: In case Someone Else(TM) may need this. This code is just how it currently looks, what I needed for my code, so it's not a full-fledged or even tested class. Thanks for sharing Alf, Thats works fine "a

Re: Sample code usable Tkinter listbox

2010-03-01 Thread Alf P. Steinbach
* rantingrick: kw.setdefault('activestyle', 'none') Hm, let me steal this line... Thanks! Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list

How to crash CPython 3.1.1 in Windows XP

2010-03-01 Thread Alf P. Steinbach
ould be the name of the program (repeated). Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: How to find an COM object in using of pywin32

2010-03-02 Thread Alf P. Steinbach
ed as a readable but more name-collision-prone alternative to the 128-bit UUID. You can find the programmatic identifiers in the Windows registry (use e.g. regedit); often they're not documented. Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: case do problem

2010-03-02 Thread Alf P. Steinbach
rogramming is at a level where that kind of efficiency doesn't count. Or, ideally it shouldn't count. Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: case do problem

2010-03-02 Thread Alf P. Steinbach
* Alf P. Steinbach: * Tracubik: hi, i've to convert from Pascal this code: iterations=0; count=0; REPEAT; iterations = iterations+1; ... IF (genericCondition) THEN count=count+1; ... CASE count OF: 1: m = 1 2: m = 10 3: m = 100 Uhm, is this syntactically

Re: case do problem

2010-03-02 Thread Alf P. Steinbach
* Alf P. Steinbach: * Alf P. Steinbach: * Tracubik: hi, i've to convert from Pascal this code: iterations=0; count=0; REPEAT; iterations = iterations+1; ... IF (genericCondition) THEN count=count+1; ... CASE count OF: 1: m = 1 2: m = 10 3: m = 100 Uhm, is

Re: Draft PEP on RSON configuration file format

2010-03-02 Thread Alf P. Steinbach
less of whether some simpler to edit alternative existed. Simply because there are so many XML tools out there, and people know about XML. It's like MS-DOS once became popular in spite of being extremely technically imperfect for its purpose, and then Windows... :-) Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list

A "scopeguard" for Python

2010-03-03 Thread Alf P. Steinbach
egenerate tree that for all purposes is a list. Then the above, or some variant, can help to /flatten/ the structure. To get rid of that silly & annoying nesting. :-) Cheers, - Alf (just sharing, it's not seriously tested code) -- http://mail.python.org/mailman/listinfo/python-list

Re: A "scopeguard" for Python

2010-03-03 Thread Alf P. Steinbach
stuff" can be a lot of code and also, with more than one action the try-else introduces a lot of nesting finally: os.chdir(original_dir) # Do other cleanup cheers & hth., - alf -- http://mail.python.org/mailman/listinfo/python-list

Re: Docstrings considered too complicated

2010-03-03 Thread Alf P. Steinbach
st up to Windows XP) still supports using ctrl-Z as EOF when reading text files. It does, at least when the Ctrl Z is the sole contents of a "line". And it's a pain. :-( As a practical matter, when entering text in a console window the F6 key generates Ctrl Z. Ch

Re: A "scopeguard" for Python

2010-03-03 Thread Alf P. Steinbach
where): ... I don't think a general purpose ScopeGuard context manager has any such benefits over the try: finally:, though. I don't think that's a matter of opinion, since one is correct while the other is incorrect. Cheers, - ALf -- http://mail.python.org/mailman/listinfo/python-list

Re: A "scopeguard" for Python

2010-03-03 Thread Alf P. Steinbach
* Robert Kern: On 2010-03-03 09:56 AM, Alf P. Steinbach wrote: * Mike Kent: What's the compelling use case for this vs. a simple try/finally? if you thought about it you would mean a simple "try/else". "finally" is always executed. which is incorrect for clean

Re: Sample code usable Tkinter listbox

2010-03-03 Thread Alf P. Steinbach
* Alf P. Steinbach: In case Someone Else(TM) may need this. This code is just how it currently looks, what I needed for my code, so it's not a full-fledged or even tested class. But it works. That code evolved a little to cover more Tk listbox quirks (thanks to Ratingrick fo

Re: A "scopeguard" for Python

2010-03-03 Thread Alf P. Steinbach
* Robert Kern: On 2010-03-03 11:18 AM, Alf P. Steinbach wrote: * Robert Kern: On 2010-03-03 09:56 AM, Alf P. Steinbach wrote: * Mike Kent: What's the compelling use case for this vs. a simple try/finally? if you thought about it you would mean a simple "try/else". "

Re: A "scopeguard" for Python

2010-03-03 Thread Alf P. Steinbach
* Robert Kern: On 2010-03-03 13:32 PM, Alf P. Steinbach wrote: * Robert Kern: On 2010-03-03 11:18 AM, Alf P. Steinbach wrote: * Robert Kern: On 2010-03-03 09:56 AM, Alf P. Steinbach wrote: * Mike Kent: What's the compelling use case for this vs. a simple try/finally? if you thought

Re: A "scopeguard" for Python

2010-03-03 Thread Alf P. Steinbach
* Robert Kern: On 2010-03-03 15:35 PM, Alf P. Steinbach wrote: * Robert Kern: On 2010-03-03 13:32 PM, Alf P. Steinbach wrote: * Robert Kern: On 2010-03-03 11:18 AM, Alf P. Steinbach wrote: * Robert Kern: On 2010-03-03 09:56 AM, Alf P. Steinbach wrote: * Mike Kent: What's the compe

Re: A "scopeguard" for Python

2010-03-04 Thread Alf P. Steinbach
* Jean-Michel Pichavant: Alf P. Steinbach wrote: From your post, the scope guard technique is used "to ensure some desired cleanup at the end of a scope, even when the scope is exited via an exception." This is precisely what the try: finally: syntax is for. You'd have to

Re: A "scopeguard" for Python

2010-03-04 Thread Alf P. Steinbach
* Robert Kern: On 2010-03-03 18:49 PM, Alf P. Steinbach wrote: * Robert Kern: [snip] can you understand why we might think that you were saying that try: finally: was wrong and that you were proposing that your code was equivalent to some try: except: else: suite? No, not really. His code

Re: A "scopeguard" for Python

2010-03-04 Thread Alf P. Steinbach
* Robert Kern: On 2010-03-04 09:48 AM, Alf P. Steinbach wrote: * Jean-Michel Pichavant: Alf P. Steinbach wrote: From your post, the scope guard technique is used "to ensure some desired cleanup at the end of a scope, even when the scope is exited via an exception." This is precisel

Re: A "scopeguard" for Python

2010-03-04 Thread Alf P. Steinbach
* Robert Kern: On 2010-03-04 10:56 AM, Alf P. Steinbach wrote: * Robert Kern: On 2010-03-03 18:49 PM, Alf P. Steinbach wrote: [snippety] If you call the possibly failing operation "A", then that systematic approach goes like this: if A fails, then it has cleaned up its own mess

Re: A "scopeguard" for Python

2010-03-04 Thread Alf P. Steinbach
ght was syntactically invalid. I think that if he's written that, then it must have been something he thought of. Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: A "scopeguard" for Python

2010-03-04 Thread Alf P. Steinbach
* Robert Kern: On 2010-03-04 12:37 PM, Alf P. Steinbach wrote: * Robert Kern: On 2010-03-04 10:56 AM, Alf P. Steinbach wrote: * Robert Kern: On 2010-03-03 18:49 PM, Alf P. Steinbach wrote: [snippety] If you call the possibly failing operation "A", then that systematic approach

Re: A "scopeguard" for Python

2010-03-04 Thread Alf P. Steinbach
* Steve Holden: Alf P. Steinbach wrote: * Robert Kern: [...] No, it only argues that "with Cleanup():" is supernumerary. I don't know what "supernumerary" means, but to the degree that the argument says anything about a construct that is not 'finally', i

Re: A "scopeguard" for Python

2010-03-05 Thread Alf P. Steinbach
* Robert Kern: On 2010-03-04 17:52 , Alf P. Steinbach wrote: * Robert Kern: On 2010-03-04 12:37 PM, Alf P. Steinbach wrote: * Robert Kern: On 2010-03-04 10:56 AM, Alf P. Steinbach wrote: * Robert Kern: On 2010-03-03 18:49 PM, Alf P. Steinbach wrote: [snippety] If you call the possibly

Re: A "scopeguard" for Python

2010-03-05 Thread Alf P. Steinbach
* Robert Kern: On 2010-03-04 16:27 , Alf P. Steinbach wrote: * Mike Kent: However, I fail to understand his response that I must have meant try/ else instead, as this, as Mr. Kern pointed out, is invalid syntax. Perhaps Mr. Steinbach would like to give an example? OK. Assuming that you

Re: A "scopeguard" for Python

2010-03-05 Thread Alf P. Steinbach
print( "C u, {}!".format( name ) ) try: with sensitive_hello_goodbye( "Jane" ): print( "Talk talk talk..." ) raise RuntimeError( "Offense" ) except: pass Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: A "scopeguard" for Python

2010-03-05 Thread Alf P. Steinbach
* Steve Howell: On Mar 3, 7:10 am, "Alf P. Steinbach" wrote: For C++ Petru Marginean once invented the "scope guard" technique (elaborated on by Andrei Alexandrescu, they published an article about it in DDJ) where all you need to do to ensure some desired cleanup at the

Re: A "scopeguard" for Python

2010-03-05 Thread Alf P. Steinbach
iginal_dir ) ) Disclaimer: haven't tested this, but it just occurred to me that for such small init/cleanup wrappers the Cleanup class provides a nice alternative to @contextmanager, as above: fewer lines, and perhaps even more clear code. :-) Cheers, - Alf -- http://mail.python.org/mailman/

Re: Escape curly bracket together to a variable extension

2010-03-06 Thread Alf P. Steinbach
* Joan Miller: How to escape the first '}' in the next string? s = "}\n{0}".format('foo') s = "}}\n{0}".format('foo') Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: compiler with python

2010-03-06 Thread Alf P. Steinbach
Since Mohamed is talking about compilation I think it's more likely he's talking about an intermediate program represention based on quad tuples like (OP, DESTINATION, ARG1, ARG2) Cheers, - Alf * Steven Howe: Is it possible he's talking about a 'quad core'? as

Re: A "scopeguard" for Python

2010-03-07 Thread Alf P. Steinbach
* Gabriel Genellina: En Thu, 04 Mar 2010 20:52:04 -0300, Alf P. Steinbach escribió: Sorry, as with the places noted above, I can't understand what you're trying to say here. Regarding your posts, neither can I. All the time. Sorry, deciphering your posts would force me to spend

Re: String is ASCII or UTF-8?

2010-03-09 Thread Alf P. Steinbach
und then it indicates utf-8 for almost-sure and more expensive searching can be avoided. It's just three bytes to check. Cheers & hth., - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: Named loops for breaking

2010-03-10 Thread Alf P. Steinbach
in(): needle = 42 x_range = inclusive_range( 1, 10 ) y_range = inclusive_range( 1, 10 ) pos = None for (x, y) in xy_range( x_range, y_range ): if x*y == needle: pos = (x, y) break if pos is None: print( "Sorry, {0} not found.&q

Re: inspect.stack() and frame

2010-03-11 Thread Alf P. Steinbach
s on the implementation's memory and id allocation strategy. Or why the call to "stack = inspect.stack()" change the address of the frame? Does it? Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: python to exe

2010-03-13 Thread Alf P. Steinbach
st of his life. ;-) Hey! I was going to post that! And there it was, in the next article... :-) Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: Python unicode and Windows cmd.exe

2010-03-14 Thread Alf P. Steinbach
lets it handle narrow character literals with non-ASCII chars) is to preprocess the source code. But that's not a general solution since the g++ preprocessor, via another bug, accepts some constructs (which then compile nicely) which the compiler doesn't accept when explicit preprocessing

<    1   2   3   4   5   6   7   >