Re: taking python enterprise level?...

2010-02-25 Thread Martin P. Hellwig
On 02/25/10 16:18, D'Arcy J.M. Cain wrote: Very interesting, I had a similar kind of problem (a network balancer that doesn't balance small tcp packages too well) and solved it by wrapping the TCP package in UDP. UDP was treated differently, although in overall switch and router manager it has

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 Martin P. Hellwig
On 02/27/10 09:36, @ Rocteur CC wrote: Hi a couple of fragmented things popped in my head reading your question, non of them is very constructive though in what you actually want, but here it goes anyway. - Oneline through away script with re as a built in syntax, yup that sounds like perl t

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: Python dos2unix one liner

2010-02-28 Thread Martin P. Hellwig
On 02/28/10 11:05, Stefan Behnel wrote: Steven D'Aprano, 28.02.2010 09:48: There ought to be some kind of competition for the least efficient solution to programming problems That wouldn't be very interesting. You could just write a code generator that spits out tons of garbage code including

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: Queue peek?

2010-03-02 Thread Martin P. Hellwig
On 03/02/10 19:44, MRAB wrote: information, such as when it was completed, the status (OK or failed), etc. You might want to wrap it in a class with locks (mutexes) to ensure it's threadsafe. What actually happens if multiple threads at the same time, write to a shared dictionary (Not using the

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

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
* Mike Kent: On Mar 4, 12:30 pm, Robert Kern wrote: He's ignorant of the use cases of the with: statement, true. Ouch! Ignorant of the use cases of the with statement, am I? Odd, I use it all the time. Given only your example of the with: statement, it is hard to fault him for thinking

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
* Mike Kent: On Mar 4, 8:04 pm, Robert Kern wrote: No, the try: finally: is not implicit. See the source for contextlib.GeneratorContextManager. When __exit__() gets an exception from the with: block, it will push it into the generator using its .throw() method. This raises the exception insid

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: start function in new process

2010-03-05 Thread Martin P. Hellwig
On 03/05/10 19:21, wongjoek...@yahoo.com wrote: Any specific reason why threading.Thread or multiprocessing is not suitable to solve your problem? -- mph -- http://mail.python.org/mailman/listinfo/python-list

Re: start function in new process

2010-03-05 Thread Martin P. Hellwig
On 03/05/10 19:45, wongjoek...@yahoo.com wrote: On 5 mrt, 20:40, "Martin P. Hellwig" wrote: On 03/05/10 19:21, wongjoek...@yahoo.com wrote: Any specific reason why threading.Thread or multiprocessing is not suitable to solve your problem? -- mph Because I got a memory leak in my

Re: Conditional based on whether or not a module is being used

2010-03-05 Thread Martin P. Hellwig
On 03/05/10 19:24, Pete Emerson wrote: In a module, how do I create a conditional that will do something based on whether or not another module has been loaded? > If someone is using foo module, I want to take advantage of its features and use it in foobar, otherwise, I want to do something els

Re: start function in new process

2010-03-05 Thread Martin P. Hellwig
On 03/05/10 20:09, wongjoek...@yahoo.com wrote: On 5 mrt, 21:02, "Martin P. Hellwig" wrote: On 03/05/10 19:45, wongjoek...@yahoo.com wrote: On 5 mrt, 20:40, "Martin P. Hellwig" wrote: On 03/05/10 19:21, wongjoek...@yahoo.com wrote: Any specific reason why

Re: A "scopeguard" for Python

2010-03-05 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: start function in new process

2010-03-06 Thread Martin P. Hellwig
On 03/06/10 09:45, wongjoek...@yahoo.com wrote: Yes, I saw this example also before. HOwever what I want is to call an internal function which gets a reference of another internal function as input and not calling an external program. Do you have any example on that with subprocess module ? Tha

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 in a CPU? In that case I thi

Re: killing own process in windows

2010-03-07 Thread Martin P. Hellwig
at: http://code.google.com/p/dcuktec/source/browse/source/wrapped_xmlrpc_server/rpc.py with perhaps special interest at the comment on lines 172-174. -- mph -- http://mail.python.org/mailman/listinfo/python-list

Re: killing own process in windows

2010-03-07 Thread Martin P. Hellwig
or example look at: http://code.google.com/p/dcuktec/source/browse/source/wrapped_xmlrpc_server/rpc.py with perhaps special interest at the comment on lines 172-174. I Thanks. this looks like a good solution for an XMLRPC server. However when playing with different server modules I fall over and

Re: running a program on many processors

2010-03-07 Thread Martin P. Hellwig
On 03/08/10 00:18, Paweł Banyś wrote: Hello, I have already read about Python and multiprocessing which allows using many processors. The idea is to split a program into separate tasks and run each of them on a separate processor. However I want to run a Python program doing a single simple task

Re: write to remote ile

2010-03-07 Thread Martin P. Hellwig
On 03/08/10 02:10, monkeys paw wrote: I can xfer a file from a remote server using: import urllib2 as u x=u.urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl') for line in x: print line How can i write a file to the remote server? I tried: x = u.url.open('http://joemoney.net/somefile.txt

Re: write to remote ile

2010-03-07 Thread Martin P. Hellwig
On 03/08/10 02:51, monkeys paw wrote: On 3/7/2010 9:20 PM, Martin P. Hellwig wrote: On 03/08/10 02:10, monkeys paw wrote: I can xfer a file from a remote server using: import urllib2 as u x=u.urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl') for line in x: print line How can

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: Trouble with quotes

2010-03-08 Thread Martin P. Hellwig
On 03/08/10 17:06, Stephen Nelson-Smith wrote: Hi, I've written some (primitive) code to parse some apache logfies and establish if apache has appended a session cookie to the end. We're finding that some browsers don't and apache doesn't just append a "-" - it just omits it. It's working fine

Re: String is ASCII or UTF-8?

2010-03-09 Thread Alf P. Steinbach
* C. Benson Manica: Hours of Googling has not helped me resolve a seemingly simple question - Given a string s, how can I tell whether it's ascii (and thus 1 byte per character) or UTF-8 (and two bytes per character)? This is python 2.4.3, so I don't have getsizeof available to me. Generally, i

Re: equivalent of Ruby's Pathname?

2010-03-09 Thread Martin P. Hellwig
On 02/09/10 14:00, Phlip wrote: Ah, now we get down to the root of the problem. Because Python is so stuck on the "one best way to do it" mentality, language bigotry prevented the Committee from picking from among several equally valid but non-best options. And after 20 years of growth, Python s

Does this already exists?: A module that checks if the used platform is supported

2010-03-10 Thread Martin P. Hellwig
Hi all, Before I start reinventing a squared wheel, I have the following question: Is there already a (standard) module that wraps around the various os/sys information which checks if the platform + version is supported for what I want to do with it. For example I am currently looking at mak

Re: Named loops for breaking

2010-03-10 Thread Alf P. Steinbach
* James Harris: On 10 Mar, 06:29, "Gabriel Genellina" wrote: En Tue, 09 Mar 2010 18:41:10 -0300, Daniel Klein escribi : Basically I'm wondering if there are any plans to implemented named loops in Python, so I can tell a break command to break out of a specific loop in the case of nested l

Re: Ideas for creating processes

2010-03-10 Thread Martin P. Hellwig
On 03/10/10 21:52, J wrote: I'm working on a project and thought I'd ask for a suggestion on how to proceed (I've got my own ideas, but I wanted to see if I was on the right track) Well I can't speak with authority but I would go into similar lines, especially since you want to call an externa

Re: Where can I find documentation for data[:,9]

2010-03-11 Thread Martin P. Hellwig
On 03/11/10 22:08, Cal Who wrote: Thanks, that helped a lot. I'm having trouble knowing what to search for to find documenatation. For example, is print a Python command, a numpy command or a java command? I like to read the documentation even if the command is working for me. Thanks again

Platform Requirement Checker (was Does this already exists?: A module that checks if the used platform is supported)

2010-03-11 Thread Martin P. Hellwig
On 03/11/10 01:37, Gabriel Genellina wrote: En Wed, 10 Mar 2010 10:54:27 -0300, Martin P. Hellwig escribió: Before I start reinventing a squared wheel, I have the following question: Is there already a (standard) module that wraps around the various os/sys information which checks if the

Re: inspect.stack() and frame

2010-03-11 Thread Alf P. Steinbach
* Félix-Antoine Fortin: Given this code : # Experience with frame import sys import inspect def foo(): stack = inspect.stack() print "foo frame : " + str(hex(id(sys._getframe( hex returns a string. applying str is therefore redundant. def foo2(): inspect.stack() print "f

Re: python to exe

2010-03-13 Thread Alf P. Steinbach
* Gib Bogle: Steven D'Aprano wrote: As the old proverb goes: give a man a fish, and you feed him for a day. Teach him how to fish, and he has food forever. I like this version: Light a man a fire, and you keep him warm for hours. Set a man on fire, and you keep him warm for the rest of his

Re: python to exe

2010-03-13 Thread Martin P. Hellwig
On 03/13/10 19:23, Steven D'Aprano wrote: On Sat, 13 Mar 2010 12:52:39 -0600, John Bokma wrote: For quite some time I thought that comp.lang.perl.misc was quite unfriendly because of a certain attitude. comp.lang.python was quite a refreshment for a while: very newbie friendly, less pissing con

Re: xml-rpc

2010-03-14 Thread Martin P. Hellwig
On 03/14/10 08:14, ahmet erdinc yilmaz wrote: Hello, Recenetly we are developing a senior project and decide to use xmlrpclib. However I have some questions. In the documentation I could not find any clue about handling requests? Does the server handles each request in a separate thread? Or is t

Re: xml-rpc

2010-03-14 Thread Martin P. Hellwig
On 03/14/10 10:32, hackingKK wrote: Instead of using the library directly, isn't python-twisted a better choice? Why? -- mph -- http://mail.python.org/mailman/listinfo/python-list

Re: Python unicode and Windows cmd.exe

2010-03-14 Thread Alf P. Steinbach
* Mark Tolonen: "Terry Reedy" wrote in message news:hnjkuo$n1...@dough.gmane.org... On 3/14/2010 4:40 PM, Guillermo wrote: Adding the byte that some call a 'utf-8 bom' makes the file an invalid utf-8 file. Not true. From http://unicode.org/faq/utf_bom.html: Q: When a BOM is used, is it o

Re: dll in project?

2010-03-14 Thread Alf P. Steinbach
* Alex Hall: Hi all, I have a dll I am trying to use, but I get a Windows error 126, "the specified module could not be found". Here is the code segment: nvdaController=ctypes.windll.LoadLibrary("nvdaControllerClient32.dll") I have the specified dll file in the same directory as the file

Re: File existence check with partial filename

2010-03-14 Thread Alf P. Steinbach
* Sang-Ho Yun: I learned that I can check the existence of a file using os.path.isfile("filename"). What if I need to check if there is a file that contains "HV" in the filename? What should I do? from __future__ import print_function import os for filename in os.listdir( "." ):

Re: dll in project?

2010-03-15 Thread Alf P. Steinbach
* Alex Hall: On 3/15/10, Ulrich Eckhardt wrote: Alex Hall wrote: I have a dll I am trying to use, but I get a Windows error 126, "the specified module could not be found". Here is the code segment: nvdaController=ctypes.windll.LoadLibrary("nvdaControllerClient32.dll") In addition to Alf's ans

Re: import antigravity

2010-03-16 Thread Alf P. Steinbach
* Ulrich Eckhardt: Chris Rebert wrote: You're a bit behind the times. If my calculations are right, that comic is over 2 years old. import timetravel C:\test> python Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credi

Re: import antigravity

2010-03-16 Thread Martin P. Hellwig
On 03/16/10 19:30, Hans Mulder wrote: Ulrich Eckhardt wrote: Chris Rebert wrote: You're a bit behind the times. If my calculations are right, that comic is over 2 years old. import timetravel I think you mean: from __future__ import timetravel -- HansM Well according to Marty it is: fr

Re: Python bindings tutorial

2010-03-17 Thread Alf P. Steinbach
* Dave Angel: Stefan Behnel wrote: mikelisa...@gmail.com, 17.03.2010 10:08: Its interesting you've mentioned the hard work involved in this interface (binding to an EXE instead of a DLL). A year or more ago I was looking at interfacing IPMITOOL to python. Do to the problems incurred with swig/py

Re: multiprocessing on freebsd

2010-03-17 Thread Martin P. Hellwig
On 03/17/10 13:30, Tim Arnold wrote: Hi, I'm checking to see if multiprocessing works on freebsd for any version of python. My server is about to get upgraded from 6.3 to 8.0 and I'd sure like to be able to use multiprocessing. I think the minimal test would be: - import mult

Re: import antigravity

2010-03-18 Thread Alf P. Steinbach
* Lawrence D'Oliveiro: In message , Chris Rebert wrote: I see that you published my unobfuscated e-mail address on USENET for all to see. I obfuscated it for a reason, to keep the spammers away. I'm assuming this was a momentary lapse of judgement, for which I expect an apology. Otherwise, it b

Re: import antigravity

2010-03-18 Thread Alf P. Steinbach
* Stefan Behnel: Alf P. Steinbach, 18.03.2010 09:53: Path: feeder.eternal-september.org!eternal-september.org!feeder.erje.net!newsfeed.straub-nv.de!news.linkpendium.com!news.linkpendium.com!newsfeeds.ihug.co.nz!lust.ihug.co.nz!ihug.co.nz!not-for-mail From: Lawrence D'Oliveiro Newsg

Re: import antigravity

2010-03-18 Thread Alf P. Steinbach
* Jussi Piitulainen: Alf P. Steinbach writes: The point is, if he's upset about Chris quoting that, then he's probably unaware that he's posting it in plaintext himself. The complaint was not about quoting but about using in public. Chris sent his piece to three addresses. F

Re: Need to create subprocess...

2010-03-18 Thread Martin P. Hellwig
On 03/18/10 16:17, drstoka wrote: Hello, I have to run a program as a child process inside my python program and redirect it's output through a pipe to a parent program process. So, I wrote this: pipe = Popen('example_program', shell=True, bufsize=0, stdout=PIPE).stdout and it works great. No

Re: Python bindings tutorial

2010-03-18 Thread Alf P. Steinbach
* Dave Angel: Alf P. Steinbach wrote: * Dave Angel: Stefan Behnel wrote: mikelisa...@gmail.com, 17.03.2010 10:08: Its interesting you've mentioned the hard work involved in this interface (binding to an EXE instead of a DLL). A year or more ago I was looking at interfacing IPMITOOL to p

Re: Python bindings tutorial

2010-03-19 Thread Alf P. Steinbach
* Tim Roberts: Dave Angel wrote: There's no real reason parts of an exe cannot be exported, same as a dll. They are in fact the same structure. And in fact many other files in the Windows environment are also the same structure, from fonts to ocx's This is a bit off-topic, but your explan

Re: Simple lock

2010-03-19 Thread Alf P. Steinbach
* MRAB: Gabriel Genellina wrote: En Fri, 19 Mar 2010 23:31:23 -0300, MRAB escribió: moerchendiser2k3 wrote: class SetPointer { private: void *ptr; MY_LOCK lock; public: void SetPointer(void *p) { Lock(this->lock); this->ptr = p; } 3.

Re: accessing variable of the __main__ module

2010-03-20 Thread Alf P. Steinbach
* News123: I wondered about the best way, that a module's function could determine the existance and value of variables in the __main__ module. What I came up with is: ### main.py ## import mod A = 4 if __name__ == "__main__": mod.f() ### mod.py ## def f():

Re: nonuniform sampling with replacement

2010-03-21 Thread Alf P. Steinbach
probabilities ): assert len( values ) == len( probabilities ) get2nd = operator.itemgetter( 1 ) v_p = sorted( zip( values, probabilities ), key = get2nd, reverse = True ) v_ap = []; sum = 0; for (v, p) in v_p: v_ap.append( (v, p + sum) ); sum += p

Re: nonuniform sampling with replacement

2010-03-21 Thread Alf P. Steinbach
* Alf P. Steinbach: * Jah_Alarm: I've got a vector length n of integers (some of them are repeating), and I got a selection probability vector of the same length. How will I sample with replacement k (<=n) values with the probabilty vector. In Matlab this function is randsample. I could

Re: chroot fails with mount point passed to subprocess.Popen?

2010-03-22 Thread Alf P. Steinbach
* newton10471: Hi, I'm trying to use subprocess.Popen() to do a Linux chroot to a mount point passed in as a parameter to the following function: def getInstalledKernelVersion(mountPoint): linuxFsRoot = mountPoint + "/root" print "type of linuxFsRoot is %s" % type(linuxFsRoot) insta

Re: How to automate accessor definition?

2010-03-22 Thread Alf P. Steinbach
* kj: In Dennis Lee Bieber writes: On Sun, 21 Mar 2010 16:57:40 + (UTC), kj declaimed the following in gmane.comp.python.general: Regarding properties, is there a built-in way to memoize them? For example, suppose that the value of a property is obtained by parsing the contents of a

Some silly code for Easter holiday

2010-03-23 Thread Alf P. Steinbach
of like an Easter holiday mystery. # Py3 # Copyright 2010 Alf P. Steinbach import tkinter as tk from collections import namedtuple import random Point = namedtuple( "Point", "x, y" ) Size= namedtuple( "Size", "x, y" ) RGB

Re: Pythonic way to trim and keep leading and trailing whitespace

2010-03-23 Thread Martin P. Hellwig
On 03/23/10 23:38, Tim Chase wrote: Just in case you're okay with a regexp solution, you can use >>> s = "\t\tabc def " >>> import re >>> r = re.compile(r'^(\s*)(.*?)(\s*)$') >>> m = re.match(s) >>> m.groups() ('\t\t', 'abc def', ' ') >>> leading, text, trailing = m.groups() Ahhh regex,

Re: exiting threaded program?

2010-03-24 Thread Alf P. Steinbach
* Alex Hall: Hi all, I have a program with a timer in it, therefore I have multiple threads. Is the "therefore..." an inference or independendent information? If it is an inference then it may not be correct. For example, timers in a GUI program need not involve additional threads. My meth

Re: sum for sequences?

2010-03-25 Thread Alf P. Steinbach
* Neil Cerutti: On 2010-03-25, Steven D'Aprano wrote: You might not want to be so glib. The sum doc sure doesn't sound like it should work on lists. Returns the sum of a sequence of numbers (NOT strings) plus the value of parameter 'start' (which defaults to 0). What part of that sugg

Don't understand behavior; instance form a class in another class' instance

2010-03-25 Thread Martin P. Hellwig
Hi all, When I run the following snippet (drastically simplified, to just show what I mean): >> import platform, sys class One(object): def __init__(self): self.one = True def change(self): self.one = False class Two(object): def __init__(self): self._inst

Re: Don't understand behavior; instance form a class in another class' instance

2010-03-25 Thread Martin P. Hellwig
On 03/25/10 23:41, Christian Heimes wrote: Martin P. Hellwig schrieb: What I don't understand why in the second test, the last boolean is True instead of (what I expect) False. Could somebody enlighten me please as this has bitten me before and I am confused by this behavior. Hint: TEST

Re: Don't understand behavior; instance form a class in another class' instance

2010-03-25 Thread Martin P. Hellwig
On 03/26/10 01:10, Rhodri James wrote: Pretty much. In the sense that you're thinking of, every assignment works that way, even the initial "TEST1 = One()". Assignment binds names to objects, though you have to be aware that names can be such exotic things as "t", "a[15]" or "TEST2.__instance_o

Re: Traversing through Dir()

2010-03-26 Thread Alf P. Steinbach
* Andrej Mitrovic: I would like to traverse through the entire structure of dir(), and write it to a file. Now, if I try to write the contents of dir() to a file (via pickle), I only get the top layer. So even if there are lists within the returned list from dir(), they get written as a list of

Re: sum for sequences?

2010-03-28 Thread Alf P. Steinbach
* Steve Howell: On Mar 28, 8:17 am, Duncan Booth wrote: Steve Howell wrote: The mildly surprising part of sum() is that is does add vs. add-in- place, which leads to O(N) vs. O(1) for the inner loop calls, for certain data structures, notably lists, even though none of the intermediate result

Re: sum for sequences?

2010-03-29 Thread Alf P. Steinbach
* Steven D'Aprano: On Sun, 28 Mar 2010 18:56:26 +0200, Alf P. Steinbach wrote: From a more practical point of view, the sum efficiency could be improved by doing the first addition using '+' and the rest using '+=', without changing the behavior. But that would

Re: "Usability, the Soul of Python"

2010-03-30 Thread Alf P. Steinbach
* Jean-Michel Pichavant: John Nagle wrote: Jonathan Hayward wrote: I've posted "Usability, the Soul of Python: An Introduction to the Python Programming Language Through the Eyes of Usability", at: http://JonathansCorner.com/python/ No, it's just a rather verbose introduction to Python

<    9   10   11   12   13   14   15   16   17   >