pickle

2005-10-24 Thread Shi Mu
I got a sample code and tested it but really can not understand the use of pickle and dump: >>> import pickle >>> f = open("try.txt", "w") >>> pickle.dump(3.14, f) >>> pickle.dump([1,2,3,4], f) >>> f.close() -- http://mail.python.org/mailman/listinfo/python-list

Re: calling matlab

2005-10-24 Thread David Isaac
"hrh1818" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > There is a module named pymat avvailable from > http://sourceforge.net/projects/pymat that provides a limited set of > functions for intertfacing Python to Matlab. I think that pymat was superceded by mlabwrap http://mlabwrap

grep

2005-10-24 Thread David Isaac
What's the standard replacement for the obsolete grep module? Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: Tricky Areas in Python

2005-10-24 Thread Tim Roberts
"PyPK" <[EMAIL PROTECTED]> wrote: > >What possible tricky areas/questions could be asked in Python based >Technical Interviews? What's the point of asking "tricky" questions? Aren't you really more interested in what applications they have worked on and whether they were successful? I don't know

Re: Syntax across languages

2005-10-24 Thread Tim Roberts
[EMAIL PROTECTED] wrote: >This post comes from a boring morning, if you are busy ignore this. >This post is only for relaxed people. > >I've found this page, "Syntax Across Languages", it contains many >errors and omissions, but it's interesting. >http://merd.sourceforge.net/pixel/language-study/s

Re: namespace dictionaries ok?

2005-10-24 Thread Ron Adam
James Stroud wrote: > Oops. Answered before I finished reading the question. > > James Well, the one bad side effect (or feature depending on the circumstance), is it makes a copy. I wonder if there is a way to modify the dictionary in place with a function to do the same thing instead of cre

Re: Importing at runtime

2005-10-24 Thread David Poundall
> Imports happen at run time. Beware starting threads in the code run at > import time in each module, though - there are some nasty bugs lurking > there. Instead, start the threads in functions invoked from the main > routine. I have run into trouble trying to do that before. Thanks for the remi

Re: Importing at runtime

2005-10-24 Thread David Poundall
Devan, would ... __import__(name) for name in module_names have worked just as well - without the equate to modules? or is the modules list required as a hook for the imports ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Importing at runtime

2005-10-24 Thread Mike Meyer
"David Poundall" <[EMAIL PROTECTED]> writes: > I have several .py files in a directory that I would like to import at > run time. Each file contains a state machine that requires to be run > in its own thread. Imports happen at run time. Beware starting threads in the code run at import time in e

Re: Importing at runtime

2005-10-24 Thread Devan L
http://www.python.org/doc/2.4.2/lib/built-in-funcs.html or, if you want an answer in code now and don't want to read the docs def my_import(name): module = __import__(name) globals()[name] = module #not a good idea Or, seeing as how you won't be directly accessing them by name, anyways

Re: namespace dictionaries ok?

2005-10-24 Thread Bengt Richter
On Tue, 25 Oct 2005 03:10:17 GMT, Ron Adam <[EMAIL PROTECTED]> wrote: >Simon Burton wrote: > >> Yes! >> >> I do this a lot when i have deeply nested function calls >> a->b->c->d->e >> and need to pass args to the deep function without changing the >> middle functions. > >Yes, :-) Which is somet

Re: Importing at runtime

2005-10-24 Thread David Poundall
Thanks James, just after I posted I stumbled across the execfile command. Looks like with 'exec' and 'execfile' I should be able to do what I want. What an elegant language. -- http://mail.python.org/mailman/listinfo/python-list

Re: namespace dictionaries ok?

2005-10-24 Thread James Stroud
Oops. Answered before I finished reading the question. James On Monday 24 October 2005 19:53, Ron Adam wrote: > James Stroud wrote: > > Here it goes with a little less overhead: > > > > > > py> class namespace: > > ... def __init__(self, adict): > > ... self.__dict__.update(adict) > > ... >

Re: Importing at runtime

2005-10-24 Thread James Stroud
exec "import something" On Monday 24 October 2005 21:53, David Poundall wrote: > I have several .py files in a directory that I would like to import at > run time. Each file contains a state machine that requires to be run > in its own thread. > > The first problem I have is how can I import the

Importing at runtime

2005-10-24 Thread David Poundall
I have several .py files in a directory that I would like to import at run time. Each file contains a state machine that requires to be run in its own thread. The first problem I have is how can I import the code in all of the .py files without knowing the file names in advance. Can this be done

Re: Microsoft Hatred FAQ

2005-10-24 Thread David Schwartz
"Roedy Green" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Mon, 24 Oct 2005 12:59:33 -0700, "David Schwartz" > <[EMAIL PROTECTED]> wrote, quoted or indirectly quoted someone who > said : >>I think you need to look up "extortion" in a dictionary. > In the days prior to W

Re: [OT] Re: output from external commands

2005-10-24 Thread Tony Meyer
On 25/10/2005, at 3:36 PM, Steven Bethard wrote: > I wouldn't fret too much about a sharp remark from Fredrik Lundh. > They're pretty much all that way. ;) [...] It takes a little > training to get used to > him, but if you can look past the nasty bite, he's really a valuable > resource around h

Re: namespace dictionaries ok?

2005-10-24 Thread Ron Adam
Simon Burton wrote: > Yes! > > I do this a lot when i have deeply nested function calls > a->b->c->d->e > and need to pass args to the deep function without changing the > middle functions. Yes, :-) Which is something like what I'm doing also. Get the dictionary, modify it or validate it som

Re: namespace dictionaries ok?

2005-10-24 Thread Ron Adam
James Stroud wrote: > Here it goes with a little less overhead: > > > py> class namespace: > ... def __init__(self, adict): > ... self.__dict__.update(adict) > ... > py> n = namespace({'bob':1, 'carol':2, 'ted':3, 'alice':4}) > py> n.bob > 1 > py> n.ted > 3 > > James But it's not a dictio

Re: Tricky Areas in Python

2005-10-24 Thread Alex Martelli
beza1e1 <[EMAIL PROTECTED]> wrote: > let me try. > > 1) ''.join(lots_of_pieces) Yep. > 2) This doesn't even work, if something is removed, the list is too > short. So: > [x for x in somelist if not isbad(x)] > well, list comprehension is Python 2.4 and 2.3 is the standard in many > OSes, so it

Re: Python vs Ruby

2005-10-24 Thread Alex Martelli
Jorge Godoy <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] (Alex Martelli) writes: > > > forwards a lot to Python 3.0!-). But -- the "dream" solution would be > > to work closely with customers from the start, XP-style, so features go > > into the code in descending order of urgence and importan

Re: [OT] Re: output from external commands

2005-10-24 Thread Steven Bethard
darren kirby wrote: > quoth the Fredrik Lundh: > >>(using either on the output from glob.glob is just plain silly, of course) > [snip] > > It is things like this that make me wary of posting to this list, either to > help another, or with my own q's. All I usually want is help with a specific

wxPython import error

2005-10-24 Thread contact
I have tried several times to install wxPython on Fedora Core 2. The installation seems to go fine (from sources), but when I try to import the wx module I keep getting the following error: = Python 2.4.2 (#1, Sep 29 2005

Re: namespace dictionaries ok?

2005-10-24 Thread Simon Burton
Yes! I do this a lot when i have deeply nested function calls a->b->c->d->e and need to pass args to the deep function without changing the middle functions. In this situation I think i would prefer this variation: class Context(dict): def __init__(self,**kwds): dict.__init__(self,kwds)

Re: namespace dictionaries ok?

2005-10-24 Thread James Stroud
Here it goes with a little less overhead: py> class namespace: ... def __init__(self, adict): ... self.__dict__.update(adict) ... py> n = namespace({'bob':1, 'carol':2, 'ted':3, 'alice':4}) py> n.bob 1 py> n.ted 3 James On Monday 24 October 2005 19:06, Ron Adam wrote: > Hi, I found the fo

namespace dictionaries ok?

2005-10-24 Thread Ron Adam
Hi, I found the following to be a useful way to access arguments after they are passed to a function that collects them with **kwds. class namespace(dict): def __getattr__(self, name): return self.__getitem__(name) def __setattr__(self, name, value):

[OT] Re: output from external commands

2005-10-24 Thread darren kirby
quoth the Fredrik Lundh: > (using either on the output from glob.glob is just plain silly, of course) Silly? Sure. os.listdir() is more on point. Never said I was the smartest. However, I will defend my post by pointing out that at the time it was the only one that actually included code that di

Re: Microsoft Hatred FAQ

2005-10-24 Thread entropy
[EMAIL PROTECTED] wrote... > > Also may I remind you that these newsgroups are international. > > So what? We are talking about a United States' company's actions with > respect to United States laws. There is no reason to make this about > philosophy, politics, law, international relation

Re: Microsoft Hatred FAQ

2005-10-24 Thread Roedy Green
On Mon, 24 Oct 2005 12:59:33 -0700, "David Schwartz" <[EMAIL PROTECTED]> wrote, quoted or indirectly quoted someone who said : >I think you need to look up "extortion" in a dictionary. In the days prior to Win95, Microsoft said "Co-operate with us is this immoral scheme to screw OS/2 or go ou

Re: Simple server/client application

2005-10-24 Thread MBW
thanks both of you, I should have realized what was gonig on Cheers, Matt -- http://mail.python.org/mailman/listinfo/python-list

how to use new AST goodies

2005-10-24 Thread Simon Burton
Hello, i've just found out that the ast-branch has been merged into the main python cvs. ** Woohoo ! ** I'd like to experiment with this, does anyone know where to start ? It seems that the parser module still produces the same junk as before. So where do we find these nice high level AST objects

Re: Simple server/client application

2005-10-24 Thread jmdeschamps
Simon Percivall wrote: > You're calling the grid() method on the Entry object you're > instanciating. Are you sure that the grid() method returns the Entry > object so that you're actually binding it to self.myAddress? The widget maker should do it in two steps instead of one. So instead of: sel

Re: Python/Apache Oddness On OSX

2005-10-24 Thread grahamd
John Abel wrote: > Hi, > > I'm running Python 2.3.5/2.4.2 on OSX 10.4.2, and am trying to run CGI > scripts using the builtin Apache. For ease, I've symlinked my custom > modules into the /Library/Python/2.3/site-packages directory, and they > import OK via command line python. However, when I pe

Re: need some advice on x y plot

2005-10-24 Thread nephish
ok, i am stuck a bit here with this line gp('set xtics (%s)' % ','.join(ticstrings)) the error code says that it is looking for a closing parenthesis. that and i am kinda new enough not to really get what %s is all about. i know it formats a string. can you simply pass a list to 'set xtics' ? i

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

2005-10-24 Thread [EMAIL PROTECTED]
The output I was contemplating was a DOM "DNA" - that is the DOM without the instances of the elements or their data, a bare tree, a prototype tree based on what is in the document (rather than what is legal to include in the document). Just enough data that for an arbitrary element I would know:

Re: Microsoft Hatred FAQ

2005-10-24 Thread David Schwartz
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "David Schwartz" <[EMAIL PROTECTED]> writes: >> I think you need to look up "extortion" in a dictionary. I can >> walk up to you and say "if you want me to mow your lawn, you must >> pay me $1 every time you smoke a cigarette". S

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

2005-10-24 Thread uche . ogbuji
"inally diving into XML programmatically. Does anyone have a best practice recommendation for programmatically discovering the structure of an arbitrary XML document via Python?" You can do this with DOM or SAX, or any of the many more friendly XML processing libraries out there. You might want

Re: Microsoft Hatred FAQ

2005-10-24 Thread joe
"David Schwartz" <[EMAIL PROTECTED]> writes: > "Antoon Pardon" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > >> Microsoft had something you need so badly that you could not go into > >> business without it. So they demanded from you that you pay them what > >> their > >>

Re: output from external commands

2005-10-24 Thread Fredrik Lundh
Terry Hancock wrote: > Note also that for those who count, "str(f)" is exactly as long > (in keystrokes) as "'%s'%f", making the "just" a matter of opinion. the % implementation still has to create an overallocated output buffer, parse the format string, call str() on the argument, verify the res

Re: win32 process information, using win32 extension

2005-10-24 Thread Chris Lambacher
I started down the win32process path trying to solve the same problem. That only ended in misery for me. Try this recipie instead: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/442477 -Chris On Fri, Oct 21, 2005 at 07:12:34AM -0700, Java and Swing wrote: > i need to get information ab

Re: Microsoft Hatred FAQ

2005-10-24 Thread David Schwartz
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Not that I care much since eggs bring on a rather strong reaction > within me, but his arguments were totally false. So you maintain that the United States government owns its economy? It might be instructive to google for "

Re: Simple server/client application

2005-10-24 Thread Simon Percivall
You're calling the grid() method on the Entry object you're instanciating. Are you sure that the grid() method returns the Entry object so that you're actually binding it to self.myAddress? -- http://mail.python.org/mailman/listinfo/python-list

Re: Extention String returning

2005-10-24 Thread Tuvas
Thanks for the help! -- http://mail.python.org/mailman/listinfo/python-list

Re: python cgi script not understood as html

2005-10-24 Thread Philippe C. Martin
It is, thanks. Philippe Peter Hansen wrote: > Philippe C. Martin wrote: >> The following code outputs the actual HTML text to the browser, not the >> interpreted text. >> >> html_ok = """ >> Content-Type: text/html\n >> > "http://www.w3.org/TR/html4/loose.dtd";>\n > > HTTP header lines must

Re: Microsoft Hatred FAQ

2005-10-24 Thread axel
In comp.lang.perl.misc Roedy Green <[EMAIL PROTECTED]> wrote: > On Mon, 24 Oct 2005 12:35:13 GMT, [EMAIL PROTECTED] wrote, > quoted or indirectly quoted someone who said : >>I see that you cannot make a reasoned argument against the fact that >>property in the form of houses is taxed in America.

Re: Setting a Limit to the Maximum Size of an Upload

2005-10-24 Thread Joey C.
Here is a basic overview of the variables included there. params = cgi.FieldStorage() I accidentally made a mistake when typing what the "thefile" variable is. thefile = params["upfile"].file "upfile" is the CGI field that contains the file that I'm uploading. As you can see, the if statement just

Re: python cgi script not understood as html

2005-10-24 Thread Philippe C. Martin
Many thanks !! Regards, Philippe Mitja Trampus wrote: > Philippe C. Martin wrote: >> Hi, >> >> The following code outputs the actual HTML text to the browser, not the >> interpreted text. >> >> Any idea ? >> >> html_ok = """ >> Content-Type: text/html\n > > > > ... > > """ > > Avoid t

Re: python cgi script not understood as html

2005-10-24 Thread Peter Hansen
Philippe C. Martin wrote: > The following code outputs the actual HTML text to the browser, not the > interpreted text. > > html_ok = """ > Content-Type: text/html\n > "http://www.w3.org/TR/html4/loose.dtd";>\n HTTP header lines must end with \r\n, not just with \n. Not sure this is the soluti

Re: Tricky Areas in Python

2005-10-24 Thread Peter Hansen
beza1e1 wrote: > well, list comprehension is Python 2.4 and 2.3 is the standard in many > OSes, so it is possibly not the most portable solution You're probably remembering "generator expressions", which were added in Python 2.4 and aren't available in earlier versions. They fit in a similar pl

Re: python cgi script not understood as html

2005-10-24 Thread Mitja Trampus
Philippe C. Martin wrote: > Hi, > > The following code outputs the actual HTML text to the browser, not the > interpreted text. > > Any idea ? > > html_ok = """ > Content-Type: text/html\n > > ... > """ Avoid the starting newline (before content-type). Add at least TWO newlines after conten

Simple server/client application

2005-10-24 Thread MBW
The following code is for a simple server/client asplication that allows the user to toggle between serve and or client modes and send/recieve a message however i am getting an Attribute error on my entry widgets when I try and call get() to get the port and ip address from those fields, I'm sure i

Re: Microsoft Hatred FAQ

2005-10-24 Thread David Schwartz
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >>His comments are not applicable to America. They are applicable to a >> country where the government owns the economy. >>No reply is needed to his comments except to point out that they only >> apply to a communist or totalit

Re: Microsoft Hatred FAQ

2005-10-24 Thread David Schwartz
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > In comp.lang.perl.misc David Schwartz <[EMAIL PROTECTED]> wrote: > >>This is about whether we're talking *ABOUT* America, you idiot. It's >> as >> if he said the press has no freedom, and I replied, "if you want to talk >> about s

Re: Microsoft Hatred FAQ

2005-10-24 Thread David Schwartz
"Antoon Pardon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >> Microsoft had something you need so badly that you could not go into >> business without it. So they demanded from you that you pay them what >> their >> software was actually worth to you. That is not extortion.

Re: python cgi script not understood as html

2005-10-24 Thread Philippe C. Martin
the title should say "python cgi script html output not understood as html" Philippe C. Martin wrote: > Hi, > > The following code outputs the actual HTML text to the browser, not the > interpreted text. > > Any idea ? > > Regards, > > Philippe > import cgi > import logging > import auth #th

python cgi script not understood as html

2005-10-24 Thread Philippe C. Martin
Hi, The following code outputs the actual HTML text to the browser, not the interpreted text. Any idea ? Regards, Philippe import cgi import logging import auth #this is the one you must implement (or use SCF ;-) html_ok = """ Content-Type: text/html\n http://www.w3.org/TR/html4/loose.dtd";>\n

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

2005-10-24 Thread Erik Max Francis
[EMAIL PROTECTED] wrote: > Finally diving into XML programmatically. Does anyone have a best > practice recommendation for programmatically discovering the structure > of an arbitrary XML document via Python? > > It seems like it is a common wheel I'd be re-inventing. It is. Look up XML DOM.

XML Tree Discovery (script, tool, __?)

2005-10-24 Thread [EMAIL PROTECTED]
Hi all, Finally diving into XML programmatically. Does anyone have a best practice recommendation for programmatically discovering the structure of an arbitrary XML document via Python? It seems like it is a common wheel I'd be re-inventing. Thanks and cheers EP -- http://mail.python.org/ma

Re: Would there be support for a more general cmp/__cmp__

2005-10-24 Thread Steve Holden
James Stroud wrote: > On Monday 24 October 2005 04:33, Steve Holden wrote: > >>Well in that case it's time to declare Principia Mathematica obsolete. >>The real numbers are a two-dimensional field, and you are proposing to >>define an ordering for it. > > > I wasn't a math major, but don't you m

Re: output from external commands

2005-10-24 Thread Terry Hancock
On Monday 24 October 2005 11:24 am, Peter Hansen wrote: > Answering narrowly, the difference is that using "%s" calls str() on the > items in the result list, while your suggestion does not. ("Why not > just use str(f) instead of the less clear '%s' % f?" would be a valid > question too though.

Re: Python/Apache Oddness On OSX

2005-10-24 Thread Diez B. Roggisch
John Abel wrote: > Hi, > > I'm running Python 2.3.5/2.4.2 on OSX 10.4.2, and am trying to run CGI > scripts using the builtin Apache. For ease, I've symlinked my custom > modules into the /Library/Python/2.3/site-packages directory, and they > import OK via command line python. However, when

Re: difference after remove

2005-10-24 Thread Peter
Shi Mu wrote: >Is there any difference if I remove the '/' > > I will assume you mean "\", not "/". ;) >from the following statement? >intMatrix2 = [[1,1,2,4,1,7,1,7,6,9],\ > [1,2,5,3,9,1,1,1,9,1],\ > [0,0,5,1,1,1,9,7,7,7]] >print intMatrix2 > > >I removed one '\' and

Re: Would there be support for a more general cmp/__cmp__

2005-10-24 Thread James Stroud
On Monday 24 October 2005 04:33, Steve Holden wrote: > Well in that case it's time to declare Principia Mathematica obsolete. > The real numbers are a two-dimensional field, and you are proposing to > define an ordering for it. I wasn't a math major, but don't you mean "the complex numbers are a t

Re: Tricky Areas in Python

2005-10-24 Thread Steve Holden
beza1e1 wrote: > let me try. > > 1) ''.join(lots_of_pieces) > > 2) This doesn't even work, if something is removed, the list is too > short. So: > [x for x in somelist if not isbad(x)] > well, list comprehension is Python 2.4 and 2.3 is the standard in many > OSes, so it is possibly not the most

Re: Extention String returning

2005-10-24 Thread Fredrik Lundh
"Tuvas" wrote: > I have been writing a program that is designed to return an 8 byte > string from C to Python. Occasionally one or more of these bytes will > be null, but the size of it will always be known. How can I write an > extention module that will return the correct bytes, and not just unt

Re: Extention String returning

2005-10-24 Thread Jp Calderone
On 24 Oct 2005 11:28:23 -0700, Tuvas <[EMAIL PROTECTED]> wrote: >I have been writing a program that is designed to return an 8 byte >string from C to Python. Occasionally one or more of these bytes will >be null, but the size of it will always be known. How can I write an >extention module that wil

Re: Extention String returning

2005-10-24 Thread jepler
I think that you want to use return PyString_FromStringAndSize(buf, 8); Jeff pgp3nNxegNjmk.pgp Description: PGP signature -- http://mail.python.org/mailman/listinfo/python-list

Extention String returning

2005-10-24 Thread Tuvas
I have been writing a program that is designed to return an 8 byte string from C to Python. Occasionally one or more of these bytes will be null, but the size of it will always be known. How can I write an extention module that will return the correct bytes, and not just until the null? I would thi

Re: python gc performance in large apps

2005-10-24 Thread Chris Lambacher
A couple of strategic gc.collect() calls can be useful. You can also tweak how the garbage collector gets run by changing settings in the gc module. -Chris On Fri, Oct 21, 2005 at 04:13:09PM -0400, Robby Dermody wrote: > > Hey guys (thus begins a book of a post :), > > I'm in the process of wri

Re: Tricky Areas in Python

2005-10-24 Thread beza1e1
let me try. 1) ''.join(lots_of_pieces) 2) This doesn't even work, if something is removed, the list is too short. So: [x for x in somelist if not isbad(x)] well, list comprehension is Python 2.4 and 2.3 is the standard in many OSes, so it is possibly not the most portable solution I had to look u

Re: Read/Write from/to a process

2005-10-24 Thread jas
What about having a thread which reads from subprocess.Popen()'s stdout...instead of read/write, read/write. just always read, and write when needed? any comments on that idea? jas wrote: > actually, i can't check for ">" only because if you a dir, a line can > end with a > but is not the end of

Re: output from external commands

2005-10-24 Thread James Colannino
Kent Johnson wrote: >import os >files = os.listdir('.') > Thanks, that's good to know. I still need to use os.popen() for a few things, but I'll be needing filenames also, so when I try to get filenames I'll use the above. James -- My blog: http://www.crazydrclaw.com/ My homepage: http://ja

Re: Read/Write from/to a process

2005-10-24 Thread jas
actually, i can't check for ">" only because if you a dir, a line can end with a > but is not the end of the output jas wrote: > Thanks, that is certainly a start. As you mentioned, the "cd" could is > an issue. > > Perhaps checking to see if the line ends with ">" is sufficient? > > Dennis Lee B

Re: Read/Write from/to a process

2005-10-24 Thread jas
Thanks, that is certainly a start. As you mentioned, the "cd" could is an issue. Perhaps checking to see if the line ends with ">" is sufficient? Dennis Lee Bieber wrote: > On 24 Oct 2005 07:20:42 -0700, "jas" <[EMAIL PROTECTED]> declaimed the > following in comp.lang.python: > > > Hi, > > I w

Re: Python variables are bound to types when used?

2005-10-24 Thread [EMAIL PROTECTED]
Fredrik Lundh wrote: > the page was written before the "type/class unification" in Python 2.2, > at a time where the word "type" had a stricter meaning (referring to C- > level types, not user-level classes). Gotcha. Thanks. That writeup is definitely on my required reading list for new Python p

Re: output from external commands

2005-10-24 Thread Peter Hansen
Mike Meyer wrote: > darren kirby <[EMAIL PROTECTED]> writes: > >>If all you want is filenames this will work: >> >import glob >files = ["%s" % f for f in glob.glob("*")] > > > What's the point of doing "%s" % f? How is this different from just > file = [f for f in glob.glob("*")]? Answe

Re: Redirect os.system output

2005-10-24 Thread jas
Kent, Yes, your example does work. So did os.popen...however, the problem is specific to "cmd.exe". Have you tried that yet? Thanks! Kent Johnson wrote: > jas wrote: > > Ok, I tried this... > > > > C:\>python > > Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] > > on w

Re: Redirect os.system output

2005-10-24 Thread Kent Johnson
jas wrote: > Ok, I tried this... > > C:\>python > Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] > on win32 > Type "help", "copyright", "credits" or "license" for more information. > import subprocess as sp p = sp.Popen("cmd", stdout=sp.PIPE) result = p.com

Re: Python vs Ruby

2005-10-24 Thread Michele Simionato
Alex Martelli: > Michele Simionato: >> cutting off non-essential features (and you can discover that a feature >> is non essential only after having implemented it) > This one is difficult if you have RELEASED the program with the feature > you now want to remove, sigh. Yeah, but I used the wrong

Re: Tricky Areas in Python

2005-10-24 Thread Steven Bethard
Alex Martelli wrote: > >>>class Base(object) >>>def getFoo(self): ... >>>def setFoo(self): ... >>>foo = property(getFoo, setFoo) >>> >>>class Derived(Base): >>>def getFoo(self): >> [snip] > the solution, in Python 2.4 and earlier, is to use > one extra

Re: Python vs Ruby

2005-10-24 Thread Jorge Godoy
[EMAIL PROTECTED] (Alex Martelli) writes: > forwards a lot to Python 3.0!-). But -- the "dream" solution would be > to work closely with customers from the start, XP-style, so features go > into the code in descending order of urgence and importance and it's > hardly ever necessary to remove them

Re: Microsoft Hatred FAQ

2005-10-24 Thread Terry Hancock
On Monday 24 October 2005 08:19 am, Roedy Green wrote: > On Mon, 24 Oct 2005 12:35:13 GMT, [EMAIL PROTECTED] wrote, > quoted or indirectly quoted someone who said : > > >I see that you cannot make a reasoned argument against the fact that > >property in the form of houses is taxed in America. > >

Re: testing '192.168.1.4' is in '192.168.1.0/24' ?

2005-10-24 Thread gry
There was just recently announced -- iplib-0.9: http://groups.google.com/group/comp.lang.python.announce/browse_frm/thread/e289a42714213fb1/ec53921d1545bf69#ec53921d1545bf69 It appears to be pure python and has facilities for dealing with netmasks. (v4 only). -- George -- http://mail.python.or

Re: more than 100 capturing groups in a regex

2005-10-24 Thread skip
Joerg> Or is there a way to circumvent [capturing groups limitation]? Sure, submit a patch to SourceForge that removes the restriction. I've never come anywhere close to creating regular expressions that need to capture 100 groups even though I generate regular expressions from a higher-level

Re: Python vs Ruby

2005-10-24 Thread Alex Martelli
Michele Simionato <[EMAIL PROTECTED]> wrote: > Alex Martelli wrote: > > ... remember Pascal's "Lettres Provinciales", > > and the famous apology about "I am sorry that this letter is so long, > > but I did not have the time to write a shorter one"!-) > > This observation applies to code too. I us

Re: Tricky Areas in Python

2005-10-24 Thread Alex Martelli
Steven D'Aprano <[EMAIL PROTECTED]> wrote: ... > my hard-won ignorance, and admit that I don't see the > problem with the property examples: > > > class Sic: > > def getFoo(self): ... > > def setFoo(self): ... > > foo = property(getFoo, setFoo) Sorry for skipping t

Re: Microsoft Hatred FAQ

2005-10-24 Thread Terry Hancock
On Saturday 22 October 2005 05:44 pm, Tim Tyler wrote: > Microsoft still comes in at number 2 - on: > http://dmoz.org/Society/Issues/Business/Allegedly_Unethical_Firms/ > Few companies are more despised than Microsoft. Wrong URL? No such list appears at that site, although it does link to several

Re: High Order Messages in Python

2005-10-24 Thread Alex Martelli
Kent Johnson <[EMAIL PROTECTED]> wrote: ... > For example to open a file and read from it uses two closures, one to wrap > a block with the file open/close, one to iterate lines (from the pickaxe > book): > > File.open("testfile") do |file| > file.each_line { |line| puts line } > end Good ex

Re: importing pickle modlue execute the code twice ??

2005-10-24 Thread Fredrik Lundh
"ychaouche" wrote: > i am having a strange experience with the pickle module. I use > python2.4 and i really don't understand what is happening on ! > take a look at this : > > > import pickle > print "hello" > > > hello > hello > did you perhaps name your test program "pickle.py" ? --

Re: Execute C code through Python

2005-10-24 Thread Fredrik Lundh
Ernesto wrote: >> > Thanks. Can anyone provide an example of using *subprocess* to run >> > helloWorld.C through the python interpreter. >> >> compile helloWorld, and run: >> >> import subprocess >> subprocess.call("helloWorld") >> >> (any special reason why you couldn't figure this out y

Python/Apache Oddness On OSX

2005-10-24 Thread John Abel
Hi, I'm running Python 2.3.5/2.4.2 on OSX 10.4.2, and am trying to run CGI scripts using the builtin Apache. For ease, I've symlinked my custom modules into the /Library/Python/2.3/site-packages directory, and they import OK via command line python. However, when I perform the import from a

Re: Set an environment variable

2005-10-24 Thread Grant Edwards
On 2005-10-24, Eric Brunel <[EMAIL PROTECTED]> wrote: >> The only think you can export an environment variable to is a >> child process > > Well, you know that, and I know that too. From my experience, > many people don't... True. Using Unix for 20+ years probably warps one's perception of what'

importing pickle modlue execute the code twice ??

2005-10-24 Thread ychaouche
Hi ! i am having a strange experience with the pickle module. I use python2.4 and i really don't understand what is happening on ! take a look at this : import pickle print "hello" hello hello #import pickle print "hello" hello I just don't get it. Thank you for any advice or help !

Read/Write from/to a process

2005-10-24 Thread jas
Hi, I would like to start a new process and be able to read/write from/to it. I have tried things like... import subprocess as sp p = sp.Popen("cmd.exe", stdout=sp.PIPE) p.stdin.write("hostname\n") however, it doesn't seem to work. I think the cmd.exe is catching it. I also tried f = open("o

Re: Execute C code through Python

2005-10-24 Thread Ernesto
Fredrik Lundh wrote: > "Ernesto" wrote: > > > Thanks. Can anyone provide an example of using *subprocess* to run > > helloWorld.C through the python interpreter. > > compile helloWorld, and run: > > import subprocess > subprocess.call("helloWorld") > > (any special reason why you couldn't

Re: output from external commands

2005-10-24 Thread Mike Meyer
darren kirby <[EMAIL PROTECTED]> writes: > If all you want is filenames this will work: import glob files = ["%s" % f for f in glob.glob("*")] What's the point of doing "%s" % f? How is this different from just file = [f for f in glob.glob("*")]? http://www.mired.

Re: newbie question about SocketServer

2005-10-24 Thread [EMAIL PROTECTED]
After further playing - it seems that the server_close() just takes time to execute. I have found that if I wait a while (1-3 seconds) the second connection will fail as well. Locking is already built into my handler class - so I'll just use it to prevent further connections until server_close()

Re: write a loopin one line; process file paths

2005-10-24 Thread Graham Fawcett
Xah Lee wrote: > Dear Peter Hansen, > My messages speak themselfs. You and your cohorts's stamping of it does > not change its nature. And if this is done with repetitiousness, it > gives away your nature. Taunt not the cohorts of Peter Hansen! Graham -- http://mail.python.org/mailman/listinfo/

Re: write a loopin one line; process file paths

2005-10-24 Thread John Thingstad
On Wed, 19 Oct 2005 11:48:01 +0200, Xah Lee <[EMAIL PROTECTED]> wrote: > Thanks a lot for various notes. Bonono? > > I will have to look at the itertools module. Just went to the doc > http://www.python.org/doc/2.4.1/lib/module-itertools.html > looks interesting. > >> But I believe Python is desig

Re: Redirect os.system output

2005-10-24 Thread jas
doesn't sound to encouraging :) How about something with os.popen? in = os.popen("cmd", "w") in.write("hostname") I tried this, and I get "IOError: [Errno 22] Invalid Argument" I am not sure why this isnt working. Steve Holden wrote: > jas wrote: > > Ok, I tried this... > > > > C:\>python > >

  1   2   >