Re: Automatic binding of **kwargs to variables

2005-10-29 Thread Mike Meyer
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Peter Hansen wrote: >> Do you mean this instead? >> >> elif name in expected_form1_kwargs and name not in kwargs: >> >> What you wrote doesn't do what you think it does... it actually tests >> for whether True or False is a key in kwargs, dep

Re: query a port

2005-10-29 Thread eight02645999
thanks alot! that's all there is to it..so it's just a simple connect. Dan M wrote: > On Sat, 29 Oct 2005 20:21:20 -0700, eight02645999 wrote: > > > hi > > in python, how do one query a port to see whether it's up or not? > > thanks > > I'm an absolute beginner, but let's see if I can help. Assumi

Re: SNMP

2005-10-29 Thread Sam Merca
py wrote: > >From what I have seen Python does not come with an snmp module built > in, can anyone suggest some other SNMP module (preferably one you have > used/experienced)..I have googled and seen yapsnmp and pysnmp (which > seem to be the two most active SNMP modules). > > Thanks I've used py

Re: Automatic binding of **kwargs to variables

2005-10-29 Thread [EMAIL PROTECTED]
Alex Martelli wrote: > I find this style of coding repulsive when compared to: > > def foo(arg1=None, arg2=None): > print dict(arg1=arg1, arg2=arg2) > > I don't understand what added value all of those extra, contorted lines > are supposed to bring to the party. Hi Alex, the thing is that I

Re: Automatic binding of **kwargs to variables

2005-10-29 Thread [EMAIL PROTECTED]
Don't know about this particular case but sometimes, I don't want to have a default argument value. That is, argument not there is different from argument = None. Though in general, I prefer the None as special meaning coding style. But even python's builtin function prefers to distinguish between

Re: Automatic binding of **kwargs to variables

2005-10-29 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: ... > def foo(**kwargs): > expected_form1_kwargs = ["arg1", "arg2"] > > for name in expected_form1_kwargs: > if name not in kwargs: > kwargs[name]=None > > for name in kwargs: > if name in kwargs and name not

Re: Expanding Python as a macro language

2005-10-29 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > For the other Alex observations (about Mac OsX and my examples of > automation centered on web automation) I have a PC, and the fact that > Python is very good at dealing with the web, doesn't help too much > in this case... All of your sensible use cases were

Re: query a port

2005-10-29 Thread Dan M
On Sat, 29 Oct 2005 20:21:20 -0700, eight02645999 wrote: > hi > in python, how do one query a port to see whether it's up or not? > thanks I'm an absolute beginner, but let's see if I can help. Assuming you want to check a port on another machine, import socket port=25 # Port we

Re: Automatic binding of **kwargs to variables

2005-10-29 Thread [EMAIL PROTECTED]
Peter Hansen wrote: > Do you mean this instead? > > elif name in expected_form1_kwargs and name not in kwargs: > > What you wrote doesn't do what you think it does... it actually tests > for whether True or False is a key in kwargs, depending on whether "name > in expected_form1_kwargs" ret

Re: Examples of Python code compared to other languages

2005-10-29 Thread Terji78
http://pleac.sourceforge.net/ probably is what you're looking for. It shows how to to stuff from the perl cookbook in a plethora of other languages, including Python. Kind regards Terji Petersen -- http://mail.python.org/mailman/listinfo/python-list

Online Poker Pays! Learn All The Secrets Now!NBP Unregistered.

2005-10-29 Thread Poker Paid Us
Did you know that online Poker pays huge money? In the last three days my wife and I have made over 343.00 USD with online poker while we slept Want to know our secret? Click HERE and visit a link of your choice. -- http://mail.python.org/mailman/listinfo/python-list

query a port

2005-10-29 Thread eight02645999
hi in python, how do one query a port to see whether it's up or not? thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: dreaming in Python

2005-10-29 Thread [EMAIL PROTECTED]
The Eternal Squire wrote: > All, > > I have to tell all of you this, at least for some laughs. Honestly, I > had the silliest dream involving the language last night. I dreamt > that it was a decade into the future and that Grand Central Station in > NYC was installing a cement and steel "compute

Re: Expanding Python as a macro language

2005-10-29 Thread SPE - Stani's Python Editor
> some future Firefox version might perhaps integrate a Python engine For those who never heard about Firefox 1.9, check the following urls. It looks very promising: 1) http://wiki.mozilla.org/Roadmap_Scratchpad#Python_for_XUL Python for XUL Significant potential contributors in both the Python

Re: How to translate python into C

2005-10-29 Thread Johnny Lee
Thanks Szabolcs and Laurence, it's not the crash of python but the crash of cygwin. We can locate the line number but when we submit the crash to cygwin's mail list, they told us they don't speak python. So I'm just trying to re-produce the crash in C. Regards, Johnny -- http://mail.python.org

Re: Automatic binding of **kwargs to variables

2005-10-29 Thread [EMAIL PROTECTED]
FormEncode. [EMAIL PROTECTED] wrote: > What do u think of the following? I could keep the form schema as > expected_form1_kwargs in a separate module and import * and wrap the > kwargs check done in the for loop in a function for use in the whole > site. > > The elif part is useful for checkboxes

Re: Automatic binding of **kwargs to variables

2005-10-29 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > if name not in expected_form1_kwargs: > raise ValueError, "Unrecognized keyword" + name > elif name in expected_form1_kwargs not in kwargs.keys(): > kwargs.update(name=None) Do you mean this instead? elif name in expected_fo

Re: How do I sort these?

2005-10-29 Thread Bengt Richter
On Fri, 28 Oct 2005 20:00:42 +0100, Steve Holden <[EMAIL PROTECTED]> wrote: >KraftDiner wrote: >> I have two lists. >> I want to sort by a value in the first list and have the second list >> sorted as well... Any suggestions on how I should/could do this? >> > >>> first = [1, 3, 5, 7, 9, 2, 4, 6,

Re: Automatic binding of **kwargs to variables

2005-10-29 Thread [EMAIL PROTECTED]
What do u think of the following? I could keep the form schema as expected_form1_kwargs in a separate module and import * and wrap the kwargs check done in the for loop in a function for use in the whole site. The elif part is useful for checkboxes which are not passed by the browser if they're no

Re: Scanning a file

2005-10-29 Thread netvaibhav
Steve Holden wrote: > Indeed, but reading one byte at a time is about the slowest way to > process a file, in Python or any other language, because it fails to > amortize the overhead cost of function calls over many characters. > > Buffering wasn't invented because early programmers had nothing b

Re: Expanding Python as a macro language

2005-10-29 Thread Mike Meyer
[EMAIL PROTECTED] writes: > My answer is the same as that given to Michael about low level > programming. > But I must thank anyway Alex for giving informations to such a level > (I didn't know that under Linux there was such a level of > sophistication with the possibility for an application to di

Re: Automatic binding of **kwargs to variables

2005-10-29 Thread [EMAIL PROTECTED]
Thanks everybody for their reply. I'll see what solution is best for my case and maybe follow up here. Thanks again, Lorenzo -- http://mail.python.org/mailman/listinfo/python-list

Re: Recursive generators and backtracking search

2005-10-29 Thread George Sakkis
"Talin" <[EMAIL PROTECTED]> wrote: > I've been using generators to implement backtracking search for a while > now. Unfortunately, my code is large and complex enough (doing > unification on math expressions) that its hard to post a simple > example. So I decided to look for a simpler problem that

Re: Expanding Python as a macro language

2005-10-29 Thread qwweeeit
At first you must forgive my double posting (4 & 5 in terms of date and 4 & 7 in terms of answers). I must then thank the new comers: Michael, Alex Martelli and Mike Meyer. Michel wrote: >> [EMAIL PROTECTED] wrote: >> But then I changed idea... Also if it is already one year that I try >> to find

Re: Scanning a file

2005-10-29 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote: ... > I should also point out that for really serious work, the idiom: > > f = file("parrot") > handle(f) > f.close() > > is insufficiently robust for production level code. That was a detail I > didn't think I needed to drop on the original newbie po

Re: Scanning a file

2005-10-29 Thread Alex Martelli
Paul Watson <[EMAIL PROTECTED]> wrote: > "Alex Martelli" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > > In today's implementations of Classic Python, yes. In other equally > > valid implementations of the language, such as Jython, IronPython, or, > > for all we know, some f

Re: lambda functions within list comprehensions

2005-10-29 Thread Alex Martelli
Max Rybinsky <[EMAIL PROTECTED]> wrote: > Thank you for explanation, Alex. > It appears that almost every beginner to Python gets in trouble with > this ...feature. :) Almost every beginner to Python gets in trouble by expecting "do what I'm thinking of RIGHT NOW"-binding, which no language offer

Re: How to replace all None values with the string "Null" in a dictionary

2005-10-29 Thread Bruno Desthuilliers
dcrespo a écrit : >>I think it would be time for you to read the Fine Manual... > > > hi, thanks for your answer... I really did it the same way you > suggested, but I forgot to tell you that I wanted to get a better way > for doing it. Let us know if you find one... > > By the way, knowing yo

Re: Scanning a file

2005-10-29 Thread David Rasmussen
Steven D'Aprano wrote: > On Fri, 28 Oct 2005 06:22:11 -0700, [EMAIL PROTECTED] wrote: > >>Which is quite fast. The only problems is that the file might be huge. > > What *you* call huge and what *Python* calls huge may be very different > indeed. What are you calling huge? > I'm not saying that

Re: Recursive generators and backtracking search

2005-10-29 Thread Mike Meyer
"Talin" <[EMAIL PROTECTED]> writes: > As an alternative, I'd like to present the following implementation. If > you compare this one with the one in lib/test/test_generator.py you > will agree (I hope) that by using recursive generators to implement > backtracking, the resulting code is a little mo

Re: Scanning a file

2005-10-29 Thread Mike Meyer
"Paul Watson" <[EMAIL PROTECTED]> writes: > "Mike Meyer" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> "Paul Watson" <[EMAIL PROTECTED]> writes: > ... >> Did you do timings on it vs. mmap? Having to copy the data multiple >> times to deal with the overlap - thanks to strings be

Re: Scanning a file

2005-10-29 Thread Steven D'Aprano
On Sat, 29 Oct 2005 21:08:09 +, Tim Roberts wrote: >>In any case, you are assuming that Python will automagically close the >>file when you are done. > > Nonsense. This behavior is deterministic. At the end of that line, the > anonymous file object out of scope, the object is deleted, and t

dreaming in Python

2005-10-29 Thread The Eternal Squire
All, I have to tell all of you this, at least for some laughs. Honestly, I had the silliest dream involving the language last night. I dreamt that it was a decade into the future and that Grand Central Station in NYC was installing a cement and steel "computer core" for directing its trains and

Examples of Python code compared to other languages

2005-10-29 Thread Nicolas Pernetty
Hello, I'm looking (without success so far) for code sources for common problems in different languages, but especially Python, C, Fortran, Ada and Matlab. It would help people coming from other languages to understand the 'python way of thinking'. Priority is clean code, performance is not an i

Re: Scanning a file

2005-10-29 Thread David Rasmussen
[EMAIL PROTECTED] wrote: > I think implementing a finite state automaton would be a good (best?) > solution. I have drawn a FSM for you (try viewing the following in > fixed width font). Just increment the count when you reach state 5. > > <---| >

Re: Automatic binding of **kwargs to variables

2005-10-29 Thread Mike Meyer
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Mike Meyer wrote: > [snip] >>for name, value in kwargs.items(): >>if name in ('a', 'list', 'of', 'valid', 'keywords'): >> exec "%s = %s" % (name, value) >>else: >> raise ValueError, "Unrecognized keyword " +

Re: Scanning a file

2005-10-29 Thread Paul Rubin
"Paul Watson" <[EMAIL PROTECTED]> writes: > How could I identify when Python code does not close files and depends on > the runtime to take care of this? I want to know that the code will work > well under other Python implementations and future implementations which may > not have this provide

Re: lambda functions within list comprehensions

2005-10-29 Thread Max Rybinsky
Thank you for explanation, Alex. It appears that almost every beginner to Python gets in trouble with this ...feature. :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Scanning a file

2005-10-29 Thread Paul Watson
"Alex Martelli" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > In today's implementations of Classic Python, yes. In other equally > valid implementations of the language, such as Jython, IronPython, or, > for all we know, some future implementation of Classic, that may well > not

Re: lambda functions within list comprehensions

2005-10-29 Thread Jean-Paul Calderone
On 29 Oct 2005 14:25:24 -0700, Max Rybinsky <[EMAIL PROTECTED]> wrote: >Hello! > >Please take a look at the example. > a = [(x, y) for x, y in map(None, range(10), range(10))] # Just a list of tuples a >[(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, >8), (9, 9)

Re: Scanning a file

2005-10-29 Thread Steve Holden
[EMAIL PROTECTED] wrote: > I think implementing a finite state automaton would be a good (best?) > solution. I have drawn a FSM for you (try viewing the following in > fixed width font). Just increment the count when you reach state 5. > > <---| >

Re: Any Pythonic GTK Undo library?

2005-10-29 Thread Tony Nelson
In article <[EMAIL PROTECTED]>, Dave Cook <[EMAIL PROTECTED]> wrote: > On 2005-10-29, Tony Nelson <[EMAIL PROTECTED]> wrote: > > > I'm looking for a "pythonic" GTK Undo library/class. It would have a > > You might ask the authors of Kiwi if they plan to add undo/redo. Or help > them add it i

Re: lambda functions within list comprehensions

2005-10-29 Thread Alex Martelli
Max Rybinsky <[EMAIL PROTECTED]> wrote: ... > >>> funcs = [lambda n: x * y / n for x, y in a] ... > It seems, all functions have x and y set to 9. > What's wrong with it? Is it a bug? It's known as *late binding*: names x and y are looked up when the lambda's body is executing, and at that t

lambda functions within list comprehensions

2005-10-29 Thread Max Rybinsky
Hello! Please take a look at the example. >>> a = [(x, y) for x, y in map(None, range(10), range(10))] # Just a list of >>> tuples >>> a [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9)] Now i want to get a list of functions x*y/n, for each (x, y) in a: >>> funcs

Re: Recursive generators and backtracking search

2005-10-29 Thread Alex Martelli
Talin <[EMAIL PROTECTED]> wrote: > even simpler - for examle, the idea of being able to return the output > of one generator directly from another instead of having to iterate > through all of the results and then re-yield them has already been > discussed in this forum. I missed those discussion

Re: extracting numbers from a file, excluding fixed words

2005-10-29 Thread Alex Martelli
dawenliu <[EMAIL PROTECTED]> wrote: > Hi, I have a file with this content: > xxx xx x xxx > 1 > 0 > 0 > 0 > 1 > 1 > 0 > (many more 1's and 0's to follow) > y yy yyy yy y yyy > > The x's and y's are FIXED and known words which I will ignore, such as > "This is t

Re: Scanning a file

2005-10-29 Thread Alex Martelli
Tim Roberts <[EMAIL PROTECTED]> wrote: ... > >> print file("filename", "rb").read().count("\x00\x00\x01\x00") > > > >Funny you should say that, because I can't stand unnecessary one-liners. > > > >In any case, you are assuming that Python will automagically close the > >file when you are done. >

Re: Scanning a file

2005-10-29 Thread Scott David Daniels
Paul Watson wrote: > Here is a better one that counts, and not just detects, the substring. This > is -much- faster than using mmap; especially for a large file that may cause > paging to start. Using mmap can be -very- slow. > > > ... > b = fp.read(blocksize) > count = 0 > while len(b) > b

Re: Scanning a file

2005-10-29 Thread Tim Roberts
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > >On Fri, 28 Oct 2005 15:29:46 +0200, Björn Lindström wrote: > >> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: >> >>> f = open("filename", "rb") >>> s = f.read() >>> sub = "\x00\x00\x01\x00" >>> count = s.count(sub) >>> print count >> >> That's a lot

Re: how to discard a line if it's not a number?

2005-10-29 Thread bearophileHUGS
This is a possible solution, using exceptions: fileName = "data" out = file(fileName + "_filt.txt", "w") for line in file(fileName + ".txt"): try: nline = float(line) except ValueError: pass else: out.write(str(nline) + "\n") out.close() If the file is small en

Re: popen2

2005-10-29 Thread Grant Edwards
On 2005-10-29, Piet van Oostrum <[EMAIL PROTECTED]> wrote: >>GE> That would require that the application know about the named >>GE> pipe and open it. I don't think there is any way to swap a >>GE> pipe in for stdin/stdout once a process is running. > > Sure. 'myprogram' should be designed to comm

how to discard a line if it's not a number?

2005-10-29 Thread dawenliu
Hi, I'm reading a file line by line, and whenever a line is not consisted of a single number (such as 0.315), I want to discard that line (and store only the single numbers). For example, 0.315 discarded this line of text 3.8 -1.44 forget about me also 2.6 Then I want to store only the four num

Re: extracting numbers from a file, excluding fixed words

2005-10-29 Thread dawenliu
I've changed the code a little bit and works fine now: inf = open('input.txt') out = open('output.txt', 'w') skips = [ 'xxx xx x xxx', 'y yy yyy yy y yyy'] for line in inf: flag = 0 for skip in skips: if skip in line: flag = 1 continue i

Re: Scanning a file

2005-10-29 Thread Steve Holden
Peter Otten wrote: > Bengt Richter wrote: > > >>What struck me was >> >> > gen = byblocks(StringIO.StringIO('no'),1024,len('end?')-1) > [gen.next() for i in xrange(10)] >> >>['no', 'no', 'no', 'no', 'no', 'no', 'no', 'no', 'no', 'no'] > > > Ouch. Seems like I spotted the subtle cornerca

Recursive generators and backtracking search

2005-10-29 Thread Talin
I've been using generators to implement backtracking search for a while now. Unfortunately, my code is large and complex enough (doing unification on math expressions) that its hard to post a simple example. So I decided to look for a simpler problem that could be used to demonstrate the technique

Re: extracting numbers from a file, excluding fixed words

2005-10-29 Thread dawenliu
Thanks Kent. The code looks reasonable, but the result is that, the output file comes out identical as the input file, with all the and remaining inside. -- http://mail.python.org/mailman/listinfo/python-list

Re: py.log using decorators for DRY

2005-10-29 Thread yoda
I feel so stupid... lol... now why didn't I think of that? Thanks Alex. -- http://mail.python.org/mailman/listinfo/python-list

Re: Scanning a file

2005-10-29 Thread netvaibhav
I think implementing a finite state automaton would be a good (best?) solution. I have drawn a FSM for you (try viewing the following in fixed width font). Just increment the count when you reach state 5. <---| || 0 0

Re: Automatic binding of **kwargs to variables

2005-10-29 Thread Steve Holden
Peter Otten wrote: > Steve Holden wrote: > > >>>Why don't you just change the method signature to foo(self, x, y, z, >>>whatever, **kwargs)? > > >>Probably because values are then required for those arguments. Plus it's >>a lot of work to specify "a very long list", and the list will also need

Re: Scanning a file

2005-10-29 Thread Paul Watson
"Mike Meyer" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Paul Watson" <[EMAIL PROTECTED]> writes: ... > Did you do timings on it vs. mmap? Having to copy the data multiple > times to deal with the overlap - thanks to strings being immutable - > would seem to be a lose, and makes

Re: extracting numbers from a file, excluding fixed words

2005-10-29 Thread Daniel Bowett
dawenliu wrote: > Hi, I have a file with this content: > xxx xx x xxx > 1 > 0 > 0 > 0 > 1 > 1 > 0 > (many more 1's and 0's to follow) > y yy yyy yy y yyy > > The x's and y's are FIXED and known words which I will ignore, such as > "This is the start of the file"

Re: extracting numbers from a file, excluding fixed words

2005-10-29 Thread Kent Johnson
dawenliu wrote: > Hi, I have a file with this content: > xxx xx x xxx > 1 > 0 > 0 > 0 > 1 > 1 > 0 > (many more 1's and 0's to follow) > y yy yyy yy y yyy > > The x's and y's are FIXED and known words which I will ignore, such as > "This is the start of the file"

Re: Hi All - Newby

2005-10-29 Thread Tim Roberts
"Ask" <[EMAIL PROTECTED]> wrote: > >Hi TIm, > >Ahh I see.. (Told you I was a newby!) ;-) > >Tkinter is what I'm using as that was loaded by default with the >installation of Python I am using. Now your question makes good sense, especially if you were coming from something like the Win32 API. I

Re: Any Pythonic GTK Undo library?

2005-10-29 Thread Dave Cook
On 2005-10-29, Tony Nelson <[EMAIL PROTECTED]> wrote: > I'm looking for a "pythonic" GTK Undo library/class. It would have a You might ask the authors of Kiwi if they plan to add undo/redo. Or help them add it if you can. http://www.async.com.br/projects/kiwi/ It would be great to have this

Re: Scanning a file

2005-10-29 Thread Peter Otten
Bengt Richter wrote: > What struck me was > > >>> gen = byblocks(StringIO.StringIO('no'),1024,len('end?')-1) > >>> [gen.next() for i in xrange(10)] > ['no', 'no', 'no', 'no', 'no', 'no', 'no', 'no', 'no', 'no'] Ouch. Seems like I spotted the subtle cornercase error and missed the big one. Peter

Re: Microsoft Hatred FAQ

2005-10-29 Thread Tim Roberts
"David Schwartz" <[EMAIL PROTECTED]> wrote: >Paul Rubin wrote: > >> "David Schwartz" <[EMAIL PROTECTED]> writes: > >>> To call it an "established legal fact" is to grossly distort the >>> circumstances under which it was determined and upheld. > >> Who is paying you to post such nonsense? > >

Re: Scanning a file

2005-10-29 Thread Alex Martelli
Bengt Richter <[EMAIL PROTECTED]> wrote: ... > >>>while block: > >>>block = block[-overlap:] + f.read(blocksize-overlap) > >>>if block: yield block ... > I was thinking this was an example a la Alex's previous discussion > of interviewee code challenges ;-) > > What struc

Re: popen2

2005-10-29 Thread Piet van Oostrum
> Grant Edwards <[EMAIL PROTECTED]> (GE) wrote: >GE> On 2005-10-29, Piet van Oostrum <[EMAIL PROTECTED]> wrote: "g.franzkowiak" <[EMAIL PROTECTED]> (gf) wrote: >>> >gf> If starts a process with popen2.popen3('myprogram') and myprogram.exe is >gf> running before, I've a connection to

Re: Automatic binding of **kwargs to variables

2005-10-29 Thread Peter Otten
Steve Holden wrote: >> Why don't you just change the method signature to foo(self, x, y, z, >> whatever, **kwargs)? > Probably because values are then required for those arguments. Plus it's > a lot of work to specify "a very long list", and the list will also need > maintaining. Note that I ke

Re: Scanning a file

2005-10-29 Thread Bengt Richter
On Sat, 29 Oct 2005 10:34:24 +0200, Peter Otten <[EMAIL PROTECTED]> wrote: >Bengt Richter wrote: > >> On Fri, 28 Oct 2005 20:03:17 -0700, [EMAIL PROTECTED] (Alex Martelli) >> wrote: >> >>>Mike Meyer <[EMAIL PROTECTED]> wrote: >>> ... Except if you can't read the file into memory because it

Re: Understanding the arguments for SubElement factory in ElementTree

2005-10-29 Thread B Mahoney
Your SubElement call is lacking the attrib argument, but you can't set text, anyway. The elementtree source makes it clear, you can only set element attrib attributes with SubElement def SubElement(parent, tag, attrib={}, **extra): attrib = attrib.copy() attrib.update(extra) element =

Re: Automatic binding of **kwargs to variables

2005-10-29 Thread [EMAIL PROTECTED]
Mike Meyer wrote: [snip] >for name, value in kwargs.items(): >if name in ('a', 'list', 'of', 'valid', 'keywords'): > exec "%s = %s" % (name, value) >else: > raise ValueError, "Unrecognized keyword " + name > > Others will probably tell you that you really sho

Re: py.log using decorators for DRY

2005-10-29 Thread Alex Martelli
yoda <[EMAIL PROTECTED]> wrote: > I'm using py.log for logging and I find that I end up having the following > pattern emerge within my code (influenced by > http://agiletesting.blogspot.com/2005/06/keyword-based-logging-with-py-lib > rary.html): > > def foo(**kwargs): > log.foo(kwargs) >

extracting numbers from a file, excluding fixed words

2005-10-29 Thread dawenliu
Hi, I have a file with this content: xxx xx x xxx 1 0 0 0 1 1 0 (many more 1's and 0's to follow) y yy yyy yy y yyy The x's and y's are FIXED and known words which I will ignore, such as "This is the start of the file" and "This is the end of the file". The dig

Any Pythonic GTK Undo library?

2005-10-29 Thread Tony Nelson
I'm looking for a "pythonic" GTK Undo library/class. It would have a framework for Undo/Redo, and would provide Undo/Redo for TextView, Entry, and containers and other classes. In a "batteries included" fashion, just instantiating a "UndoableTextView" or "UndoableEntry" or "UndoableContainer"

Re: Expanding Python as a macro language

2005-10-29 Thread Mike Meyer
[EMAIL PROTECTED] (Alex Martelli) writes: >... >> But the problem is that in Linux you can't even send a keystroke to >> a running GUI application! > Actually, if the app is running under X11 you may try to fake out a > keystroke event (with low level calls, but ctypes might let you use it > f

py.log using decorators for DRY

2005-10-29 Thread yoda
I'm using py.log for logging and I find that I end up having the following pattern emerge within my code (influenced by http://agiletesting.blogspot.com/2005/06/keyword-based-logging-with-py-library.html): def foo(**kwargs): log.foo(kwargs) #body form This led me to believe that I could

Re: Automatic binding of **kwargs to variables

2005-10-29 Thread Steve Holden
Peter Otten wrote: > [EMAIL PROTECTED] wrote: > > >>I have a very long list of parameters coming from a web form to my >>method foo(self, **kwargs) >> >>I would like to avoid manually binding the variables to the values >>coming through the **kwargs dictionary, just to keep the code cleaner, >>I'

Re: Building 2.4.2 on OpenBSD 3.8

2005-10-29 Thread Martin v. Löwis
Dan M wrote: > /usr/include/sys/event.h:53: error: syntax error before "u_int" > /usr/include/sys/event.h:55: error: syntax error before "u_short" > *** Error code 1 > > Stop in /usr/local/src/Python-2.4.2. > > immediately upon running "make". I took at look at event.h to see if I > could find an

Re: Automatically creating a HOME environ variable on Windows?

2005-10-29 Thread Maciej Dziardziel
[EMAIL PROTECTED] wrote: > Cool, even better. So what's best, having code to add HOME > (=USERPROFILE) to os.environ, or change the various places that HOME is > used to check for USERPROFILE? Best solution would be to have portable function that returns user home directory and knows about all pl

Building 2.4.2 on OpenBSD 3.8

2005-10-29 Thread Dan M
I've been working with python 2.2.3 for the last couple of weeks, but would like to move up to 2.4. I grabbed the 2.4.2 tarball and attempted to install, but I get: gcc -pthread -c -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DPy_BUILD_CORE -o Modules/python.o

Re: Expanding Python as a macro language

2005-10-29 Thread Alex Martelli
<[EMAIL PROTECTED]> wrote: ... > But the problem is that in Linux you can't even send a keystroke to > a running GUI application! Actually, if the app is running under X11 you may try to fake out a keystroke event (with low level calls, but ctypes might let you use it from Python). Of course,

Re: popen2

2005-10-29 Thread Donn Cave
Quoth Pierre Hanser <[EMAIL PROTECTED]>: | Grant Edwards a écrit : |> On 2005-10-29, Piet van Oostrum <[EMAIL PROTECTED]> wrote: |>>>"g.franzkowiak" <[EMAIL PROTECTED]> (gf) wrote: |>> |>>>gf> If starts a process with popen2.popen3('myprogram') and myprogram.exe is |>>>gf> running before, I've

Re: Expanding Python as a macro language

2005-10-29 Thread Michael
[EMAIL PROTECTED] wrote: > But then I changed idea... Also if it is already one year that I try > to find a solution in Linux (mainly with Python or DCOP and KDE), This doesn't express the question you have anywhere clearly enough. Linux can run perfectly happily without any form of windowing e

Re: XML Tree Discovery (script, tool, __?)

2005-10-29 Thread George Sakkis
<[EMAIL PROTECTED]> wrote: > """ > I was looking for something similar (XML to DTD inference) but I didn't > find anything related in python. Trang > (http://www.thaiopensource.com/relaxng/trang-manual.html#introduction), > on the other hand seems impressive after a few non-trivial tests. It > wou

Re: popen2

2005-10-29 Thread Pierre Hanser
Grant Edwards a écrit : > On 2005-10-29, Piet van Oostrum <[EMAIL PROTECTED]> wrote: > >>>"g.franzkowiak" <[EMAIL PROTECTED]> (gf) wrote: >> >>>gf> If starts a process with popen2.popen3('myprogram') and myprogram.exe is >>>gf> running before, I've a connection to the second process, not to t

Re: Generic utility class for passing data

2005-10-29 Thread Chris Smith
> "Gordon" == Gordon Airporte <[EMAIL PROTECTED]> writes: Gordon> I'm wondering if this is might be bad practice. Sometimes Gordon> when I need to pass around several pieces of datum I will Gordon> put them in a tuple, then when I need to use them in a Gordon> receiving functio

Re: Expanding Python as a macro language

2005-10-29 Thread qwweeeit
Thank you for your replays (both for WMI and AutoIt beta-release) but I would be satisfied if I had in Linux something similar to the standard version of AutoIt! Concerning WMI, a part the fact that it works only under Windows, from the examples I have seen, IMHO it is much less powerful than AutoI

Re: Expanding Python as a macro language

2005-10-29 Thread qwweeeit
Thank you for your replays (both for WMI and AutoIt beta-release) but I would be satisfied if I had in Linux something similar to the standard version of AutoIt! Concerning WMI, a part the fact that it works only under Windows, from the examples I have seen, IMHO it is much less powerful than AutoI

Re: popen2

2005-10-29 Thread Grant Edwards
On 2005-10-29, Piet van Oostrum <[EMAIL PROTECTED]> wrote: >> "g.franzkowiak" <[EMAIL PROTECTED]> (gf) wrote: > >>gf> If starts a process with popen2.popen3('myprogram') and myprogram.exe is >>gf> running before, I've a connection to the second process, not to the >>first. >>gf> I can find th

[help]problem with python thread

2005-10-29 Thread BaoYongjun
Hi,all: Could someone explan the python thread to me? When I use the python thread,I find some problems.If I run many (such as 100) python threads ,then all thread are blocked.Below is the code: import thread,time def f(): print 'f()'

Re: Debugging with SciTE

2005-10-29 Thread jim . eggleston
Based on information from Jarek Zgoda in another thread on the Windows USERPROFILE environment variable, debug.py should be: import sys from pdb import pm, set_trace from inspect import getmembers if sys.platform == 'win32': import os os.environ['HOME'] = os.environ['USERPROFILE'] del sys.

Re: tool for syntax coloring in html

2005-10-29 Thread vishnuvyas
I use htmlize for that. you can try that. http://fly.srk.fer.hr/~hniksic/emacs/htmlize.el -- http://mail.python.org/mailman/listinfo/python-list

Re: Automatically creating a HOME environ variable on Windows?

2005-10-29 Thread jim . eggleston
Cool, even better. So what's best, having code to add HOME (=USERPROFILE) to os.environ, or change the various places that HOME is used to check for USERPROFILE? -- http://mail.python.org/mailman/listinfo/python-list

Re: popen2

2005-10-29 Thread Piet van Oostrum
> "g.franzkowiak" <[EMAIL PROTECTED]> (gf) wrote: >gf> If starts a process with popen2.popen3('myprogram') and myprogram.exe is >gf> running before, I've a connection to the second process, not to the first. >gf> I can find the process by name before I start a process with popen2..., >gf> but

Re: how to associate files with application

2005-10-29 Thread Lasse Vågsæther Karlsen
Dennis Lee Bieber wrote: > On Fri, 28 Oct 2005 09:48:27 -0400, "Colin J. Williams" > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > >>I'm no Windows expert but I think that, using Windows Explorer, one can, >>with a right mouse click, select "Open With". There are seve

Re: Oh what a twisted thread we weave....

2005-10-29 Thread Tom Anderson
On Sat, 28 Oct 2005, GregM wrote: > ST_zeroMatch = 'You found 0 products' > ST_zeroMatch2 = 'There are no products matching your selection' > > # why does this always drop through even though the If should be true. > if (ST_zeroMatch or ST_zeroMatch2) in self.webpg: This code - i do

Re: How do I sort these?

2005-10-29 Thread Diez B. Roggisch
KraftDiner wrote: > unzip doesn't seem to work for me... Mrmpf, my bad. The operation is called unzip, but implpemented by using zip - so unzip(l) == zip(*l) So the exchange unzip with zip in my example. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Expanding Python as a macro language

2005-10-29 Thread Do Re Mi chel La Si Do
Hi ! Not the good answer, but, for information : AutoIt is very better in beta-release (many versions beta exist). AutoIt beta can use COM call, and can use COM-server writed in Python with win32all (PyWin). And, also, AutoIt exist like Active-X (in reality a COM server), who can to do used

Re: Automatically creating a HOME environ variable on Windows?

2005-10-29 Thread Jarek Zgoda
[EMAIL PROTECTED] napisał(a): > Windows doesn't have a HOME environment variable, but it does have > HOMEDRIVE and HOMEPATH. Could Windows versions of Python automatically > populate os.environ with HOME, where HOME = > os.path.join(os.environ['HOMEDRIVE'], os.environ['HOMEPATH'])? MS recommends

  1   2   >