Re: Modifying Class Object

2010-02-09 Thread Alf P. Steinbach
* Steve Holden: Alf P. Steinbach wrote: * Stephen Hansen: [...] I've heard that before, and have no idea why, nor any real interest in solving it: I don't want to read cpl via Usenet, and prefer to read it as a mailing list. Somewhere between Gmail->python.org->python.org &l

Re: Modifying Class Object

2010-02-09 Thread Alf P. Steinbach
* Steve Holden: Alf P. Steinbach wrote: * Steve Holden: Alf P. Steinbach wrote: * Stephen Hansen: [...] I've heard that before, and have no idea why, nor any real interest in solving it: I don't want to read cpl via Usenet, and prefer to read it as a mailing list. Somewhere bet

Re: ANN: obfuscate

2010-02-09 Thread Alf P. Steinbach
* David Robinow: On Tue, Feb 9, 2010 at 5:10 PM, Simon Brunning wrote: On 9 February 2010 16:29, Robert Kern wrote: On 2010-02-09 09:37 AM, Daniel Fetchinson wrote: If the code base stabilizes in a production version after losing the alphas and betas they would be a great addition to the std

Easter Eggs

2010-02-09 Thread Alf P. Steinbach
I know 3 Python Easter Eggs, from __future__ import braces import this help( "antigravity" ) Are there more? Cheers, - Alf -- http://mail.python.org/mailman/listinfo/python-list

Re: Modifying Class Object

2010-02-09 Thread Alf P. Steinbach
* Steven D'Aprano: On Tue, 09 Feb 2010 21:04:08 +0100, Alf P. Steinbach wrote: You thought you cold do a bit of ad hominem attack. That phrase you keep using, "ad hominem"... it doesn't mean what you seem to think it means. An ad hominem attack is not when somebody

Re: Personal criticisms and logical fallacies

2010-02-09 Thread Alf P. Steinbach
* Ben Finney: Steven D'Aprano writes: An ad hominem attack is not when somebody makes a criticism of you personally. It is when somebody says something along the lines of "Don't pay any attention to Alf, he doesn't know what he's talking about, he's a ". In other words, a criticism of the pe

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

2010-02-09 Thread Alf P. Steinbach
* Tim Chase: Larry Hudson wrote: But a minor rearrangement is simpler, and IMHO clearer: if 'mystring' not in s: print 'not found' else: print 'foundit' print 'processing' I've always vacillated on whether that would better be written as Larry does, or as if 'mystring' in

Re: Personal criticisms and logical fallacies

2010-02-09 Thread Alf P. Steinbach
* Ben Finney: "D'Arcy J.M. Cain" writes: On Wed, 10 Feb 2010 01:38:50 +0100 "Alf P. Steinbach" wrote: However, although in this particular case the Ad Hominems constituted logical fallacies, not all Ad Hominems are logical fallacies. Yes they are. Using the reput

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* Stephen Hansen: On Tue, Feb 9, 2010 at 1:08 PM, Alf P. Steinbach <mailto:al...@start.no>> wrote: [abundant snips which do not accurately represent who said what where due to my own laziness] Not sure, but perhaps it's possible to mail directly

Re: Creating formatted output using picture strings

2010-02-10 Thread Alf P. Steinbach
* Olof Bjarnason: 2010/2/10 Peter Otten <__pete...@web.de>: pyt...@bdurham.com wrote: Does Python provide a way to format a string according to a 'picture' format? For example, if I have a string '123456789' and want it formatted like '(123)-45-(678)[9]', is there a module or function that wi

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* Duncan Booth: "Alf P. Steinbach" wrote: In CPython objects once created remain in the same memory location (and their id is their address). Compare that to IronPython where the objects themselves can move around in memory so they have no fixed address. Try comparing the

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* Steven D'Aprano: On Wed, 10 Feb 2010 09:13:22 +0100, Alf P. Steinbach wrote: You've dismissed at least one of my arguments with a simple hand-waving of, "That's invalid, cuz." That is not a quote of me. It is a lie. Alf, although your English in this forum has

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* 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 "pointer" is used by e.g. the Java languag

Re: Modifying Class Object

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

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* 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" is used by e.g. the Java language spec. Python doesn't have "copya

Re: Modifying Class Object

2010-02-10 Thread Alf P. Steinbach
* Steven D'Aprano: On Wed, 10 Feb 2010 23:02:27 +0100, Alf P. Steinbach wrote: For a less likely more technical interpretation, as far as I know in Python there's just one case of a pointer that does not point to anything, namely as exemplified by def foo(): print( x )

Re: Get __doc__ from main module in imported module.

2010-02-10 Thread Alf P. Steinbach
* David: I have a module toolkit.py with some functions I use often. One of these functions displays a usage message (__doc__). def usage(messages=[], exit=-1): """Print the doc string as wells as any useful messages.""" print(__doc__) for message in messages: print("\033[91

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 Alf was out of s

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
* Jonathan Gardner: On Feb 10, 3:23 pm, Peng Yu wrote: I'm wondering there is already a function in python library that can merge intervals. For example, if I have the following intervals ('[' and ']' means closed interval as inhttp://en.wikipedia.org/wiki/Interval_(mathematics)#Excluding_the_

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
* Jeremy: I have been using Python for several years now and have never run into memory errors… until now. My Python program now consumes over 2 GB of memory and then I get a MemoryError. I know I am reading lots of files into memory, but not 2GB worth. I thought I didn't have to worry about

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
* Martin P. Hellwig: Well at least you are well written and more subtle than Xah Lee. Though I find him also quite amusing, I do like a good flame-war every now and again, and in that perspective I solute you. The technical discussion is now at point where one poster maintains that reference

Re: Modifying Class Object

2010-02-12 Thread Alf P. Steinbach
ation aspects, persisting in the face of corrections, have just, IMHO, been consistent attempts at misrepresentation. On Feb 11, 4:49 am, "Alf P. Steinbach" wrote: *The* standard general language independent definition? [ of pointer ] Yes. As defined where? For example, as I us

Re: Please help with MemoryError

2010-02-12 Thread Alf P. Steinbach
* Christian Heimes: mk wrote: Hmm how about "call by label-value"? Or "call by guido"? How do you like "call like a dutch"? :] Just a note: it might be more clear to talk about "pass by XXX" than "call by XXX". Unless you're talking about something else than argument passing. The standard

Re: Please help with MemoryError

2010-02-12 Thread Alf P. Steinbach
* Antoine Pitrou: Le Fri, 12 Feb 2010 17:14:57 +, Steven D'Aprano a écrit : What Python does is called "pass by sharing", or sometimes "pass by object reference". It is exactly the same as what (e.g.) Ruby and Java do, except that confusingly the Ruby people call it "pass by reference" and t

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
* Jordan Apgar: I'm trying to run two servers in the same program at once. Here are the two: class TftpServJ(Thread): def __init__(self, ip, root, port=69, debug = False ): Thread.__init__(self) setup stuff here def run(self): try: self.server.listen(

Re: How do you implement a Progress Bar

2010-02-12 Thread Alf P. Steinbach
* J Wolfe: I would really appreciate some help with this. I'm fairly new to using classes...What am I doing wrong? All I get is a blank window. I can't seem to figure out how to initialize this Progress Bar. Thanks, Jonathan ##file Meter.py fro

Re: python crash on windows but not on linux

2010-02-13 Thread Alf P. Steinbach
* hjebbers: I enlarged the windows page file from 750Kb to 1.5Gb . The crash still happens. btw, the crash does not happen at a peak memory usage. According to windows task manager, at the moment of crash mem usage of my program is 669kb, peak memory usage is 1.136kb henk-jan Probably you mean

Re: how do I write a scliceable class?

2010-02-13 Thread Alf P. Steinbach
* Ernest Adrogué: Hello everybody, I'm designing a container class that supports slicing. The problem is that I don't really know how to do it. class MyClass(object): def __init__(self, input_data): self._data = transform_input(input_data) def __getitem__(self, k

Re: Modifying Class Object

2010-02-13 Thread Alf P. Steinbach
* Aahz: In article , Steve Holden wrote: Whether in CPython, Jython or IronPython the value returned by calling id(x) (whether x is a literal, a simple name or a more complex expression) is absolutely no use as an accessor: it does not give you access to the referenced value. If you disagree,

Re: Modifying Class Object

2010-02-13 Thread Alf P. Steinbach
* Michael Sparks: [Due to the appearance of reasoned discussion (it's not practical to read it all!), I felt it necessary to respond. It turned out to be a long sequence of trivial fallacies, peppered with various allegations and insinuations.] [snip extremely much] Now let's move to the

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
* vsoler: Hi, My python script needs to work with a .txt file in a directory. I would like to give the user the possibility to choose the file he needs to work on in as much the same way as I open a .xls file in Excel, that is, I want to make appear the "Windows'" window and let the user choose.

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
* Steve Howell: This thread is interesting on many levels. What is the core question that is being examined here? I think that regarding the technical it is whether a Python name refers to an object or not. I maintain that it does, and that the reference can be copied, and that the semantics

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
* Steven D'Aprano: On Sat, 13 Feb 2010 21:33:50 -0800, Steve Howell wrote: You seem to be missing the point that "curly braces" is a concrete term that very specifically applies to spelling. And you seem to be missing the point that "pointer" is also a concrete term that very specifically ap

Re: Modifying Class Object

2010-02-14 Thread Alf P. Steinbach
* Ethan Furman: Steve Howell wrote: Going back to pointers vs. references, I think the key distinction being made is that pointers allow specific memory manipulation, although I think even there you're really just dealing with abstractions. The address 0x78F394D2 is a little bit closer to the

Re: hi can any one please help me..

2010-02-15 Thread Alf P. Steinbach
* chiranjeevi muttoju: Hi, when i'm installing the pytc(python wrapper for tokyo cabinet.) i'm getting the fallowing error.. i'm getting this error for python2.6 only.. for python 2.4 its working fine.. - running install running build running build_ext

Re: trouble installing matplotlib - syslibroot: multiply specified

2010-02-15 Thread Alf P. Steinbach
* katrine: Hope you guys don't mind a question about building matplotlib from a biologist who wants to learn how to use python. I am trying to install matplotlib on my mac with OS X 10.4.11, using python 2.6.4 and Xcode 2.2.1. I have had a few fights with freetype and Tkinter, and I think I've

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

2010-02-15 Thread Alf P. Steinbach
* R (Chandra) Chandrasekhar: width = 5 height = 30 colors = ['#abcdef]', '#456789'] filename = "/tmp/image.png" # I want to get the equivalent of variable interpolation in Perl # so that the command # # convert -size 5x30 gradient:#abcdef-#456789 /tmp/image.png # # is derived from the variables

Re: Modifying Class Object

2010-02-15 Thread Alf P. Steinbach
* Steven D'Aprano: On Mon, 15 Feb 2010 21:25:23 +, Arnaud Delobelle wrote: John Posner writes: [...] x = s[0] [...] assigns the name *x* to the object that *s[0]* refers to s[0] does not refer to an object, it *is* an object (once evaluated of course, otherwise it's just a Python e

Re: listing existing windows services with python

2010-02-15 Thread Alf P. Steinbach
* News123: Hi, What is the best way with python to get a list of all windows services. As a start I would be glad to receive only the service names. However it would be nicer if I could get all the properties of a service as well. Thanks for any info and bye * Library: If there is some

Re: listing existing windows services with python

2010-02-15 Thread Alf P. Steinbach
* alex23: News123 wrote: What is the best way with python to get a list of all windows services. As a start I would be glad to receive only the service names. However it would be nicer if I could get all the properties of a service as well. I highly recommend Tim Golden's fantastic WMI modu

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
* Tim Golden: On 16/02/2010 12:18, News123 wrote: I don't use the script often, so if it would start a WMI service during runtime and stop it afterwards it would be fine. FWIW -- your other considerations notwithstanding -- I'm not aware of WMI having this effect. Generally you can assume that

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
* Paul Rubin: John Nagle writes: However, things have changed, and lists and tuple *are* effectively mutable and hashable versions of each other... It's the concurrency aspect of this that interests me, though. A language with immutable objects can potentially handle concurrency more safely

Re: Efficiently building ordered dict

2010-02-22 Thread Alf P. Steinbach
* Bryan: I am looping through a list and creating a regular dictionary. From that dict, I create an ordered dict. I can't think of a way to build the ordered dict while going through the original loop. Is there a way I can avoid creating the first unordered dict just to get the ordered dict?

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

2010-02-22 Thread Alf P. Steinbach
* 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 Windows in the Python standard library. But OK, it was non-trivial to

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
* Paul Rubin: Steve Howell writes: My gut instinct is that functional programming works well for lots of medium sized problems and it is worth learning. I think it's worth learning because it will make you a better programmer even if you never use it for anything beyond academic exercises. I

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

2010-02-24 Thread Alf P. Steinbach
* Nomen Nescio: Hello, Can someone help me understand what is wrong with this example? class T: A = range(2) B = range(4) s = sum(i*j for i in A for j in B) It produces the exception: : global name 'j' is not defined Which Python implementation are you using? I can't reproduce the er

Re: When will Java go mainstream like Python?

2010-02-25 Thread Alf P. Steinbach
* sjdevn...@yahoo.com: On Feb 24, 8:05 pm, Lawrence D'Oliveiro wrote: In message , Wanja Gayk wrote: Reference counting is about the worst technique for garbage collection. It avoids the need for garbage collection. That's like saying that driving a VW Beetle avoids the need for an automob

Re: When will Java go mainstream like Python?

2010-02-25 Thread Alf P. Steinbach
* Chris Gray: Lawrence D'Oliveiro writes: In message , Wanja Gayk wrote: Reference counting is about the worst technique for garbage collection. It avoids the need for garbage collection. It means I can write things like I'm by no means an expert, but how does reference counting deal with

Re: lists of variables

2010-02-26 Thread Alf P. Steinbach
* Michael Pardee: I'm relatively new to python and I was very surprised by the following behavior: a=1 b=2 'a' refers to an object representing the integer 1. Since 1 is an immutable value you can just as well think of it as 'a' containing the value 1, because a reference to an immutable va

Re: loop through each line in a text file

2010-02-26 Thread Alf P. Steinbach
* qtrimble: I'm a python newbie but I do have some basic scripting experience. I need to take the line starting with "wer" and extract the year and day of year from that string. I want to be able to add the year and day of year from the last line having "wer*" to the lines occurring in between

Re: Variable definition

2010-02-26 Thread Alf P. Steinbach
* Raphael Mayoraz: Hello, I'd like to define variables with some specific name that has a common prefix. Something like this: varDic = {'red': 'a', 'green': 'b', 'blue': 'c'} for key, value in varDic.iteritems(): 'myPrefix' + key = value I know this is illegal, but there must be a trick s

Re: Docstrings considered too complicated

2010-02-26 Thread Alf P. Steinbach
* MRAB: Steven D'Aprano wrote: On Fri, 26 Feb 2010 09:09:36 -0600, Tim Daneliuk wrote: Reminiscent of: mov AX,BX ; Move the contents of BX into AX That's a *good* comment, because without it most English-speaking people would assume you were moving the contents of AX into B

Re: Python dos2unix one liner

2010-02-27 Thread Alf P. Steinbach
* @ Rocteur CC: On 27 Feb 2010, at 12:44, Steven D'Aprano wrote: On Sat, 27 Feb 2010 10:36:41 +0100, @ Rocteur CC wrote: cat file.dos | python -c "import sys,re; [sys.stdout.write(re.compile('\r\n').sub('\n', line)) for line in sys.stdin]" >file.unix Holy cow!!! Calling a regex just fo

Re: Turtle graphics speed(). Seems broken

2010-02-27 Thread Alf P. Steinbach
* Dr. Phillip M. Feldman: Stefan Behnel-3 wrote: alexander@gmail.com wrote: I think the speed function may be broken from the turtle graphics package "from turtle import * speed('fastest') forward(50)" I have tried all of the different speed settings, but I get no change in the turtl

Re: Method / Functions - What are the differences?

2010-02-28 Thread Alf P. Steinbach
* Michael Rudolf: Out of curiosity I tried this and it actually worked as expected: >>> class T(object): x=[] foo=x.append def f(self): return self.x >>> t=T() >>> t.f() [] >>> T.foo(1) >>> t.f() [1] >>> At first I thought "hehe, always fun to play around with p

Re: Printing the arguments of an attribute in a class

2010-02-28 Thread Alf P. Steinbach
* vsoler: I have a class that is a wrapper: class wrapper: def __init__(self, object): self.wrapped = object def __getattr__(self, attrname): print 'Trace: ', attrname #print arguments to attrname, how? return getattr(self.wrapped, attrname) I can run it

Sample code usable Tkinter listbox

2010-02-28 Thread 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. import tkinter as t import tkinter.simpledialog import tkinter.messagebox t.askstring = tkinter.simpledialog.askstr

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
How to crash CPython 3.1.1 in Windows XP: python -c "import os; os.spawnl( os.P_WAIT, 'blah' )" I reported this as a bug, http://bugs.python.org/issue8036> Workaround: it seems that spawnl is happy with an absolute path as second arg, followed by a third arg which should be the name of the p

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

2010-03-02 Thread Alf P. Steinbach
* Steven Woody: Hi, I want to interactive with an OLE application with pywin32. The problem is I get totally no idea how to find the object in OLEView and how to figure out it's interface. With pywin32's example, I even don't understand that in the below statement, win32com.client.Dispatch(

Re: case do problem

2010-03-02 Thread 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 valid Pascal? As I recall

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
* Patrick Maupin: On Mar 2, 5:36 pm, Steven D'Aprano wrote: You seem to be taking the position that if you start with a config file config.json, it is "too hard to edit", but then by renaming it to config.rson it magically becomes easier to edit. That *is* ludicrous. No, but that seems to be

A "scopeguard" for Python

2010-03-03 Thread Alf P. Steinbach
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 end of a scope, even when the scope is exited via an exception, is to declare a Scope

Re: A "scopeguard" for Python

2010-03-03 Thread Alf P. Steinbach
* 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 cleanup by the way, that's one advantage: a "with Cleanup" is difficult to get wrong, while a "try"

Re: Docstrings considered too complicated

2010-03-03 Thread Alf P. Steinbach
* Steven D'Aprano: On Wed, 03 Mar 2010 15:30:36 +, Grant Edwards wrote: I definitely remember that old MS-DOS programs would treat Ctrl-Z as an EOF marker when it was read from a text file and would terminate a text file with a Ctrl-Z when writing one. I believe that Windows (at least up

Re: A "scopeguard" for Python

2010-03-03 Thread Alf P. Steinbach
* Robert Kern: On 2010-03-03 09:39 AM, Mike Kent wrote: What's the compelling use case for this vs. a simple try/finally? original_dir = os.getcwd() try: os.chdir(somewhere) # Do other stuff finally: os.chdir(original_dir) # Do other cleanup A custo

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

<    1   2   3   4   5   6   >