Re: newbie question structure of function

2008-03-13 Thread nodrogbrown
> > > resultname=""" > > > That starts a string literal. > > i am not sure if this is the right way..i used it in case > matchdistance < threshold return False.then the filename will not be > taken from the filenameslist and so returns as an empty string. >a one-tuple why not use None instea

Monitoring SSHd and web servers?

2008-03-13 Thread Gilles Ganault
Hello I'd like to monitor connections to a remote SSH and web server. Does someone have some code handy that would try to connect every 5mn, and print an error if the script can't connect? Thank you. -- http://mail.python.org/mailman/listinfo/python-list

Re: getattr/setattr still ASCII-only, not Unicode - blows up SGMLlib from BeautifulSoup

2008-03-13 Thread Carl Banks
On Mar 14, 1:53 am, John Nagle <[EMAIL PROTECTED]> wrote: > John Machin wrote: > > On Mar 14, 5:38 am, John Nagle <[EMAIL PROTECTED]> wrote: > >>Just noticed, again, that getattr/setattr are ASCII-only, and don't > >> support > >> Unicode. > > >>SGMLlib blows up because of this when faced

Re: Need Script For read multiple files(.txt) from a folder

2008-03-13 Thread Chris
On Mar 14, 6:28 am, jai_python <[EMAIL PROTECTED]> wrote: > hi frenz I  Need a Python Script For read multiple files(.txt) from a > folder and write it in a single text file > > Thanks Take a look at the OS Module for the listdir funtion, you can use it to build a list of all files in the give

Re: newbie question structure of function

2008-03-13 Thread menosaint
Aaron thanx for the input > > resultname=""" > > That starts a string literal. i am not sure if this is the right way..i used it in case matchdistance < threshold return False.then the filename will not be taken from the filenameslist and so returns as an empty string. > > return (mat

Re: getattr/setattr still ASCII-only, not Unicode - blows up SGMLlib from BeautifulSoup

2008-03-13 Thread John Nagle
John Machin wrote: > On Mar 14, 5:38 am, John Nagle <[EMAIL PROTECTED]> wrote: >>Just noticed, again, that getattr/setattr are ASCII-only, and don't >> support >> Unicode. >> >>SGMLlib blows up because of this when faced with a Unicode end tag: >> >> File "/usr/local/lib/python2.5/

Re: Spaces in path name

2008-03-13 Thread David S
Hi, I get ERROR: ""C:\Program Files\apache-ant-1.7.0\bin\ant"" does not exist If I cut the path statement here and paste it next to a windows XP command prompt ant is invoked. The python code here is if not os.path.isfile(ANT_CMD): error('"%s" does not exist' % ANT_CMD) David "Me

Re: no more comparisons

2008-03-13 Thread Alan Isaac
Dan Bishop wrote: > Even assuming you meant (-x[0], int(x[1])), that sorts negative > numbers in the wrong order. You want > key = lambda x: (-1 if x[0] else 1) * int(x[1]) Sorry, was speed typing (very badly) and the question actually had two different problem descriptions. As you su

Need Script For read multiple files(.txt) from a folder

2008-03-13 Thread jai_python
hi frenz I Need a Python Script For read multiple files(.txt) from a folder and write it in a single text file Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with exec

2008-03-13 Thread alitosis
On Mar 14, 9:47 am, Justus Schwabedal <[EMAIL PROTECTED]> wrote: [snipped] > However when I do this: > > bash-3.2$ cat execBug2.py > #! /usr/bin/python > header=""" > from scipy import randn > def f(): > return randn() > """ > def g(): > exec header > return f() > print "

Re: sorting question

2008-03-13 Thread "Andrew Rekdal"
Seems 'KEYBOARDS' works nicely -- -- Andrew "jcnbp8k" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Hi Patty, > > That's easy solved, the word is keyboards. > > I just did a google search for 'anagram solver' and got lucky with Andy's > free online anagram solver at http://www

Re: escape string to store in a database?

2008-03-13 Thread andrei . avk
On Mar 12, 8:32 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Wed, 2008-03-12 at 18:18 -0700, [EMAIL PROTECTED] wrote: > > These pieces of text may have single and double quotes in > > them, I tried escaping them using re module and string module and > > either I did something wrong, or they e

Re: How do I iterate over items in a dict grouped by N number of elements?

2008-03-13 Thread [EMAIL PROTECTED]
On Mar 13, 6:34 pm, Noah <[EMAIL PROTECTED]> wrote: > What is the fastest way to select N items at a time from a dictionary? > I'm iterating over a dictionary of many thousands of items. > I want to operate on only 100 items at a time. > I want to avoid copying items using any sort of slicing. > Do

Re: sorting question

2008-03-13 Thread jcnbp8k
Hi Patty, That's easy solved, the word is keyboards. I just did a google search for 'anagram solver' and got lucky with Andy's free online anagram solver at http://www.ssynth.co.uk/~gay/anagram.html :) I know it's not a python script, though are you actually working on a python program to de

Re: How do I iterate over items in a dict grouped by N number of elements?

2008-03-13 Thread Paul Rubin
Noah <[EMAIL PROTECTED]> writes: > What is the fastest way to select N items at a time from a dictionary? > I'm iterating over a dictionary of many thousands of items. > I want to operate on only 100 items at a time. > I want to avoid copying items using any sort of slicing. I'd do something like

RE: Dispatch("Excel.Application") failed

2008-03-13 Thread lialie
On Behalf Of John Machin > > > '\xce\xde\xd0\xa7\xb5\xc4\xc0\xe0\xb1\xf0\xd7\xd6\xb7\xfb\xb4\xae', > > > None, None) > > > Googling for 2147221005 gives some clues. > > That string of hex stuff appears where an error message is > expected -- it'

Re: image matching algorithms

2008-03-13 Thread Daniel Fetchinson
> > Since you seem to know quite a bit about this topic, what is your > > opinion on the apparently 'generic' algorithm described here: > > http://grail.cs.washington.edu/projects/query/ ? > > So far it seems to me that it does what I'm asking for, it does even > > more because it can take a hand d

Re: no more comparisons

2008-03-13 Thread Mark Dickinson
On Mar 13, 8:38 pm, Alan Isaac <[EMAIL PROTECTED]> wrote: > Does this do it? :: > >     key= lambda x: (-x[1],int(x2)) > > Here I am depending on the lexicographic sorting of tuples. > Without that there would be real trouble. Close. :-) I think it needs to be something like: key = lambda x: (-x

How do I iterate over items in a dict grouped by N number of elements?

2008-03-13 Thread Noah
What is the fastest way to select N items at a time from a dictionary? I'm iterating over a dictionary of many thousands of items. I want to operate on only 100 items at a time. I want to avoid copying items using any sort of slicing. Does itertools copy items? This works, but is ugly: >>> from i

Re: no more comparisons

2008-03-13 Thread Dan Bishop
On Mar 13, 7:38 pm, Alan Isaac <[EMAIL PROTECTED]> wrote: > Mark Dickinson wrote: > > Sorting tuples, where the second item in the tuple should > > have the opposite ordering to the first is going to be > > a bit of a pain. Or even worse, where the ordering of the > > second item depends on the va

Re: getattr(foo, 'foobar') not the same as foo.foobar?

2008-03-13 Thread castironpi
On Mar 13, 8:15 pm, [EMAIL PROTECTED] wrote: > On Mar 13, 7:45 pm, [EMAIL PROTECTED] wrote: > > > > > > > On Mar 13, 7:18 pm, Mel <[EMAIL PROTECTED]> wrote: > > > > Diez B. Roggisch wrote: > > > >> My understanding is that foo.bar does *not* create a new object. > > > > > Your understanding is not

Re: getattr(foo, 'foobar') not the same as foo.foobar?

2008-03-13 Thread castironpi
On Mar 13, 7:45 pm, [EMAIL PROTECTED] wrote: > On Mar 13, 7:18 pm, Mel <[EMAIL PROTECTED]> wrote: > > > > > > > Diez B. Roggisch wrote: > > >> My understanding is that foo.bar does *not* create a new object. > > > > Your understanding is not correct. > > > >>  All it > > >> does is return the value

Re: getattr(foo, 'foobar') not the same as foo.foobar?

2008-03-13 Thread castironpi
On Mar 13, 7:18 pm, Mel <[EMAIL PROTECTED]> wrote: > Diez B. Roggisch wrote: > >> My understanding is that foo.bar does *not* create a new object. > > > Your understanding is not correct. > > >>  All it > >> does is return the value of the bar attribute of object foo.  What new > >> object is being

Re: no more comparisons

2008-03-13 Thread Alan Isaac
Mark Dickinson wrote: > Sorting tuples, where the second item in the tuple should > have the opposite ordering to the first is going to be > a bit of a pain. Or even worse, where the ordering of the > second item depends on the value of the first item in the > tuple. This is like some

EuroPython 2008: A Call for Theme and Talk Suggestions

2008-03-13 Thread Paul Boddie
This year, the EuroPython conference will take up residence for the second time in Vilnius, Lithuania with the main programme of talks and events taking place on Monday 7th, Tuesday 8th and Wednesday 9th July, and with sprints continuing after the main programme until and including Saturday 12th Ju

Re: Python-PHP bridge?

2008-03-13 Thread M�ta-MCI (MVP)
Hi! Only under Windows, you can use PHPscript. It's the "active-scripting" release of PHP. With it, you can send PHP's functions (source), and call these functions (with parameters). With the same method, you can also use, from Python, VBscript, Jscript, PerlScript, RubyScript. @-salutations

Advantage of the array module over lists?

2008-03-13 Thread Tobiah
I checked out the array module today. It claims that arrays are 'efficient'. I figured that this must mean that they are faster than lists, but this doesn't seem to be the case: one.py ## import array a = array.array('i') for x in xrange(1000): a.append

Re: getattr(foo, 'foobar') not the same as foo.foobar?

2008-03-13 Thread Mel
Diez B. Roggisch wrote: >> My understanding is that foo.bar does *not* create a new object. > > Your understanding is not correct. > >> All it >> does is return the value of the bar attribute of object foo. What new >> object is being created? > > A bound method. This happens through the descr

Re: Python regex

2008-03-13 Thread Adonis Vargas
Andrew Rekdal < wrote: > I hope posting is ok here for this question... > > I am attempting to extract the text from a CSS comment using 're' such as... > > string = "/* CSS comment /*" > exp = "[^(/*)].*[^(*/)] " > > p = re.compile(exp) > q = p.search(string) > r = q.group() > > print r > >>>

Re: getattr(foo, 'foobar') not the same as foo.foobar?

2008-03-13 Thread Arnaud Delobelle
On Mar 13, 11:29 pm, Dave Kuhlman <[EMAIL PROTECTED]> wrote: > Arnaud Delobelle wrote: > > > 4.  Both points above follow from the fact that foo.bar is really a > > function call that returns a (potentially) new object: in fact what > > really happens is something like > > Arnaud and Imri, too - >

Re: getattr(foo, 'foobar') not the same as foo.foobar?

2008-03-13 Thread castironpi
> > Basically, the above code is saying that foo.foobar is not the same as > > getattr(foo, 'foobar'). > > > What gives?  This breaks my understanding of id(), the is operator, and > > getattr(). > > 4.  Both points above follow from the fact that foo.bar is really a > function call that returns a

Re: getattr(foo, 'foobar') not the same as foo.foobar?

2008-03-13 Thread Diez B. Roggisch
> My understanding is that foo.bar does *not* create a new object. Your understanding is not correct. > All it > does is return the value of the bar attribute of object foo. What new > object is being created? A bound method. This happens through the descriptor-protocol. Please see this examp

sorting question

2008-03-13 Thread Patty Sutcliffe
The website you list regarding 9-letter scrambled words doesn't exist any longer. Is there another way that I can access it to see your program you designed? I have a nine letter work I need to unscramble. I will send it just in case you can figure it out for me and let me know. KAEOSYBR

Re: Spaces in path name

2008-03-13 Thread Mensanator
On Mar 13, 5:16 pm, "David S" <[EMAIL PROTECTED]> wrote: > Hi, > > I have some code in which I have to change some path names to get it to > work. The original code seems to have assumed that path names would not have > any embedded spaces. > > I am not sure how to write the following line so when

Re: getattr(foo, 'foobar') not the same as foo.foobar?

2008-03-13 Thread Erik Max Francis
Dave Kuhlman wrote: > Basically, the above code is saying that foo.foobar is not the same as > getattr(foo, 'foobar'). Python promises that the behavior is the same. It does not promise that the _objects_ will be the same, which is what `is` determines. That is, you're not doing a useful test

Re: getattr(foo, 'foobar') not the same as foo.foobar?

2008-03-13 Thread Dave Kuhlman
Arnaud Delobelle wrote: > > 4. Both points above follow from the fact that foo.bar is really a > function call that returns a (potentially) new object: in fact what > really happens is something like Arnaud and Imri, too - No. foo.bar is *not* really a function/method call. > > Foo.__di

Re: List mutation method gotcha - How well known?

2008-03-13 Thread Erik Max Francis
Chris wrote: > No output because x is a NoneType... That's behavior of the interactive interpreter when printing results of expressions, not of print. It will print None. -- Erik Max Francis && [EMAIL PROTECTED] && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!

RE: Dispatch("Excel.Application") failed

2008-03-13 Thread Ryan Ginstrom
> On Behalf Of John Machin > > '\xce\xde\xd0\xa7\xb5\xc4\xc0\xe0\xb1\xf0\xd7\xd6\xb7\xfb\xb4\xae', > > None, None) > > Googling for 2147221005 gives some clues. > > That string of hex stuff appears where an error message is > expected -- it's not utf8, and makes no sense when I attempt > to dec

Re: This actually works.

2008-03-13 Thread Dotan Cohen
On 14/03/2008, Dustan <[EMAIL PROTECTED]> wrote: > you.screw() Ah, you are pushing sex pills. > self.thank(God, encapsulation) And bibles? Interesting combination. > not self.want_to_know(you.screw.func_code) Unsubscribe? I know better... Dotan Cohen http://what-is-what.com http://gibberi

Re: newbie question structure of function

2008-03-13 Thread castironpi
Just some FYI options. >     if not matchfilename: May return positive if you someday return an object that holds a 'not' value. >     resultname=""" That starts a string literal. > if (matchdistance < threshold): Parentheses optional. >     return (matchdistance,resultname) Parentheses opt

Re: getattr(foo, 'foobar') not the same as foo.foobar?

2008-03-13 Thread Arnaud Delobelle
On Mar 13, 10:06 pm, Dave Kuhlman <[EMAIL PROTECTED]> wrote: > The following code has me mystified: > > In [4]: class A(object): >    ...:     def show(self): >    ...:         print 'hello' >    ...: >    ...: > In [5]: a = A() > In [6]: > In [7]: x = a.show > In [8]: y = getattr(a, 'show') > In [

Problem with exec

2008-03-13 Thread Justus Schwabedal
I'm trying to parallise with python. Specifically I'm sending code to the processes and let them exec this code (in ascii form). However I ran into a problem with Namespaces (I think) which I do not understand. Here's what I do first: --- bash-3.2$ cat execB

Re: This actually works.

2008-03-13 Thread Dustan
On Mar 13, 3:16 pm, [EMAIL PROTECTED] wrote: > not self.believe > programming.screw() > > self.serious; this.works > > make_money(EASY) > anyone.can_do(this) you.screw() self.thank(God, encapsulation) not self.want_to_know(you.screw.func_code) programming.is_good -- http://mail.python.org/mailma

newbie question structure of function

2008-03-13 Thread menosaint
hi I am new to python programming..I would like to call a function that returns an integer value and a filename string as a tuple.I coded it like this below...I want to know if this can be coded more compactly and efficiently..(i am from java background and thus code often becomes bulky ..) de

Re: getattr(foo, 'foobar') not the same as foo.foobar?

2008-03-13 Thread Imri Goldberg
Dave Kuhlman wrote: > The following code has me mystified: > > In [4]: class A(object): >...: def show(self): >...: print 'hello' >...: >...: > In [5]: a = A() > In [6]: > In [7]: x = a.show > In [8]: y = getattr(a, 'show') > In [9]: x > Out[9]: > > In [10]: y > Out[10

Spaces in path name

2008-03-13 Thread David S
Hi, I have some code in which I have to change some path names to get it to work. The original code seems to have assumed that path names would not have any embedded spaces. I am not sure how to write the following line so when used in my script the path will be found. ANT_CMD = r'C:\Program

getattr(foo, 'foobar') not the same as foo.foobar?

2008-03-13 Thread Dave Kuhlman
The following code has me mystified: In [4]: class A(object): ...: def show(self): ...: print 'hello' ...: ...: In [5]: a = A() In [6]: In [7]: x = a.show In [8]: y = getattr(a, 'show') In [9]: x Out[9]: > In [10]: y Out[10]: > In [11]: In [12]: id(x) Out[12]: 12419552 In [

Re: image matching algorithms

2008-03-13 Thread Yu-Xi Lim
Daniel Fetchinson wrote: > Since you seem to know quite a bit about this topic, what is your > opinion on the apparently 'generic' algorithm described here: > http://grail.cs.washington.edu/projects/query/ ? > So far it seems to me that it does what I'm asking for, it does even > more because it ca

Re: [pysqlite] [ANN] pysqlite and APSW projects moved

2008-03-13 Thread Gerhard Häring
Colin Mcphail wrote: > On 2008-03-09 18:57:00 +, Gerhard Häring <[EMAIL PROTECTED]> said: > > Gerhard Häring wrote: [...] APSW web:http://oss.itsystementwicklung.de/trac/apsw/ scm:Subversion: http://initd.org/svn/pysqlite/apsw/trunk/ > > That should have

Re: Dispatch("Excel.Application") failed

2008-03-13 Thread John Machin
On Mar 13, 5:02 pm, lialie <[EMAIL PROTECTED]> wrote: > Hi, > Maybe it 's quite simple, but I can't fix it. Do I make some mistakes in > my env setting? My excel version is 2003. > any suggestion? Thanks. > > Traceback (most recent call last): > File "testexcel.py", line 3, in ? > excel = Dispatch(

Re: getattr/setattr still ASCII-only, not Unicode - blows up SGMLlib from BeautifulSoup

2008-03-13 Thread John Machin
On Mar 14, 5:38 am, John Nagle <[EMAIL PROTECTED]> wrote: >Just noticed, again, that getattr/setattr are ASCII-only, and don't support > Unicode. > >SGMLlib blows up because of this when faced with a Unicode end tag: > > File "/usr/local/lib/python2.5/sgmllib.py", line 353, in finis

Re: getattr/setattr still ASCII-only, not Unicode - blows up SGMLlibfrom BeautifulSoup

2008-03-13 Thread Terry Reedy
"John Nagle" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Just noticed, again, that getattr/setattr are ASCII-only, and don't support | Unicode. | | SGMLlib blows up because of this when faced with a Unicode end tag: | | File "/usr/local/lib/python2.5/sgmllib.py", line 353,

Re: call by reference howto????

2008-03-13 Thread Steven D'Aprano
On Thu, 13 Mar 2008 08:54:43 +, Paul Rudin wrote: >> Whatever python has for a calling convention, it is close enough that >> naming it "call by reference" gives people a reasonable idea of what is >> going on. > > Quite. The thing is not to get hung up with the label - but to > understand wh

Re: call by reference howto????

2008-03-13 Thread Terry Reedy
"Antoon Pardon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | On 2008-02-28, Steven D'Aprano <[EMAIL PROTECTED]> wrote: | > On Thu, 28 Feb 2008 02:02:19 +0200, Tamer Higazi wrote: | > | >> Hi! | >> Can somebody of you make me a sample how to define a function based on | >> "call

Re: [pysqlite] [ANN] pysqlite and APSW projects moved

2008-03-13 Thread Colin Mcphail
On 2008-03-09 18:57:00 +, Gerhard Häring <[EMAIL PROTECTED]> said: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Gerhard Häring wrote: >> [...] APSW >> >> >> web:http://oss.itsystementwicklung.de/trac/apsw/ >> scm:Subversion: http://initd.org/svn/pysqlite/apsw/trunk/ >

Re: [pysqlite] [ANN] pysqlite and APSW projects moved

2008-03-13 Thread CMcP
In article <[EMAIL PROTECTED]>Gerhard Häring <[EMAIL PROTECTED]> wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > Gerhard Häring wrote: >> [...] APSW >> >> >> web:http://oss.itsystementwicklung.de/trac/apsw/ >> scm:Subversion: http://initd.org/svn/pysqlite/apsw

Re: no more comparisons

2008-03-13 Thread Mark Dickinson
On Mar 13, 5:10 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: > (1, '14') represents 14 should be -14, of course. -- http://mail.python.org/mailman/listinfo/python-list

Re: no more comparisons

2008-03-13 Thread Mark Dickinson
On Mar 13, 3:48 pm, Alan Isaac <[EMAIL PROTECTED]> wrote: > So maybe this is not as bad as I feared.  What are some use > > cases that will clearly be harder (i.e., at least require > > a slightly elaborate wrapper) after this change? Sorting tuples, where the second item in the tuple should have

Re: subprocess.Popen pipeline bug?

2008-03-13 Thread Douglas Wells
In article <[EMAIL PROTECTED]>, Marko Rauhamaa <[EMAIL PROTECTED]> writes: > > This tiny program hangs: > > > #!/usr/bin/env python > import subprocess > a = subprocess.Popen('cat',shell = True,stdin = subprocess.PIPE, >

Re: List mutation method gotcha - How well known?

2008-03-13 Thread John Machin
On Mar 14, 6:13 am, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > On Mar 13, 10:42 am, Paul Rubin wrote: > [...] > > > By Python convention, methods that mutate the object return None, and > > also stuff that returns None doesn't generate output at the > > interactive pro

Python-PHP bridge?

2008-03-13 Thread erikcw
Hi all, I'm starting to translate a large legacy php app to python (django), and was wondering if anyone knew of a bridge between the 2 languages. (access php objects from python and vice versa). Some of the solutions I've come across so far include using php's passthru() ( http://us3.php.net/pas

Re: subprocess.Popen pipeline bug?

2008-03-13 Thread Marko Rauhamaa
[EMAIL PROTECTED]: > Not sure. I think what's happening is that the second cat subprocess > never gets EOF on its stdin, because there are still processes with an > open file descriptor for the other end of the pipe. You are right. However, the close_fds technique seems a bit heavy-handed. Well,

Update pytz timezone definitions

2008-03-13 Thread _robby
I am looking at using pytz in a scheduling application which will be used internationally. I would like to be able to update the definition files that pytz uses monthly or bi-monthly. As far as I can tell, pytz seems to be updated (fairly) regularly to the newest tzdata, but I don't want to have t

Re: how to pass the workspace ?

2008-03-13 Thread Stef Mientki
Gary Herron wrote: > Stef Mientki wrote: >> hello, >> >> I've GUI tree with drag and drop nodes, >> where each nodes contains a code snippet. >> Now I want to run one or more branches in that tree, >> so I enumerate over the nodes and have to run something like this: >> >> execfile ( node1 ) >> exe

Re: Python regex

2008-03-13 Thread Arnaud Delobelle
On Mar 13, 8:22 pm, "Andrew Rekdal" <@comcast.net> wrote: [...] > in your expression above.. > > >>> r = re.compile(r'/\*(.*?)\*/') > > what does the 'r' do? It means the literal is a 'raw string' : >>> print 'Hi\nthere!' Hi there! >>> print r'Hi\nthere!' Hi\nthere! >>> If you haven't done so al

Re: This actually works.

2008-03-13 Thread Grant Edwards
On 2008-03-13, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I couldn't believe it. Screw programming Python anymore! OMG, IT'S FREE MONEY! I guess you've got to give the wanker credit for actually mention Python programming. :) -- Grant -- http://mail.python.org/mailman/listinfo/python-lis

Re: Python regex

2008-03-13 Thread "Andrew Rekdal"
-- -- Andrew "Arnaud Delobelle" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] On Mar 13, 8:03 pm, "Andrew Rekdal" <@comcast.net> wrote: > I hope posting is ok here for this question... > > I am attempting to extract the text from a CSS comment using 're' such > as... > > string

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-13 Thread Aahz
In article <[EMAIL PROTECTED]>, Jeff Schwab <[EMAIL PROTECTED]> wrote: > >I write maybe a dozen one-liners a day. It's not practical to do this >with Python, or at least it's not nearly as convenient as Perl. That is a defensible position, but my take is that writing the one-liners in Python

This actually works.

2008-03-13 Thread troyj1978
I couldn't believe it. Screw programming Python anymore! I'm totally serious. This actually works! It is SO EASY to make money this way. Anyone, and I mean ANYONE can do it. You should start seeing returns within a day or two. Do yourself a favour and at least check it out: http://agentb.af

Re: Python regex

2008-03-13 Thread Arnaud Delobelle
On Mar 13, 8:03 pm, "Andrew Rekdal" <@comcast.net> wrote: > I hope posting is ok here for this question... > > I am attempting to extract the text from a CSS comment using 're' such as... > > string = "/* CSS comment /*" > exp = "[^(/*)].*[^(*/)] " > > p = re.compile(exp) > q = p.search(string) > r

Ping and ARP on both Win and Linux in Python

2008-03-13 Thread Mauro "Baba" Mascia
Hi, this is my question: I want to know if several switch (about 50) in a big lan are up and then know their MAC addresses to do a list that contains host name, ip and mac. I know only the range of their IP addresses (the host name it's simply to know using socket.gethostn. The first idea it's

Re: Python regex

2008-03-13 Thread "Andrew Rekdal"
made error on last line... read as... > I would be saying if forward-slash AND asterisk appear in this order... > negate -- -- Andrew "Andrew Rekdal @comcast.net>" < wrote in message news:[EMAIL PROTECTED] >I hope posting is ok here for this question... > > I am attempting to extract the tex

Python regex

2008-03-13 Thread "Andrew Rekdal"
I hope posting is ok here for this question... I am attempting to extract the text from a CSS comment using 're' such as... string = "/* CSS comment /*" exp = "[^(/*)].*[^(*/)] " p = re.compile(exp) q = p.search(string) r = q.group() print r >>CSS comment although this works to a degree... I

Re: no more comparisons

2008-03-13 Thread Alan Isaac
>> Dan Bishop wrote: >>> def cmp_key(cmp_fn): >>>class CmpWrapper(object): >>>def __init__(self, obj): >>>self.obj = obj >>>def __cmp__(self, other): >>>return cmp_fn(self.obj, other.obj) >>>return CmpWrapper > On Mar 13, 12:38 pm, Alan

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-13 Thread Jeff Schwab
Paddy wrote: > On Mar 13, 7:03 pm, Jonathan Gardner <[EMAIL PROTECTED]> > wrote: >> On Mar 12, 6:37 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > > <> >> And leave out the magical -p and -n. If you want to iterate through a >> file, "for line in sys.stdin:". > > Or better still: > > import fil

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-13 Thread Paddy
On Mar 13, 7:03 pm, Jonathan Gardner <[EMAIL PROTECTED]> wrote: > On Mar 12, 6:37 pm, Carl Banks <[EMAIL PROTECTED]> wrote: <> > > And leave out the magical -p and -n. If you want to iterate through a > file, "for line in sys.stdin:". Or better still: import fileinput for line in fileinp

Re: List mutation method gotcha - How well known?

2008-03-13 Thread Arnaud Delobelle
On Mar 13, 10:42 am, Paul Rubin wrote: [...] > By Python convention, methods that mutate the object return None, and > also stuff that returns None doesn't generate output at the > interactive prompt. A convention that does not always hold: >>> l = [1, 2, 3] >>> l.pop()

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-13 Thread Jonathan Gardner
On Mar 12, 6:37 pm, Carl Banks <[EMAIL PROTECTED]> wrote: > On Mar 12, 8:11 pm, Justus Schwabedal <[EMAIL PROTECTED]> > wrote: > > > What do you need it for anyway? I just read about it and I think it's > > useless > > in python. > > Perl, like Python, has a separate compilation and run times.  One

Re: List mutation method gotcha - How well known?

2008-03-13 Thread yoz
Dustan wrote: > On Mar 13, 2:36 am, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: >> Hi, >> >> I am surprised that it took me so long to bloody my nose on this one. >> >> It must be well known - and I would like to find out how well known. >> >> So here is a CLOSED BOOK multiple choice question -

Re: subprocess.Popen pipeline bug?

2008-03-13 Thread bryanjugglercryptographer
Marko Rauhamaa wrote: > This tiny program hangs: > > > #!/usr/bin/env python > import subprocess > a = subprocess.Popen('cat',shell = True,stdin = subprocess.PIPE, > stdout = subprocess.PIPE) > b = subproc

Re: frequency count or number of occurences of a number in an array

2008-03-13 Thread Bernard
d'oh! On 12 mar, 07:58, John Machin <[EMAIL PROTECTED]> wrote: > On Mar 12, 10:29 pm, Bernard <[EMAIL PROTECTED]> wrote: > > > > > Hey Larry, > > > that one is fairly easy: > > > >>> from array import array > > >>> array('i', [1, 2, 3, 4, 5, 1, 2]) > > >>> def count(x, arr): > > >         cpt = 0

Re: app runs fine with interpreter, but not under py2exe

2008-03-13 Thread GHUM
Doug, > Precision.py is part of the Numeric package. AFAIKT, the problem is during > the module initialization. The first lines of Precision.py are: > > from multiarray import zeros > import string > [.] and your program is crashing on the lst.append( (zeros( (1,), t ).itemsize()*8, t) )

Re: List mutation method gotcha - How well known?

2008-03-13 Thread Lie
On Mar 13, 2:36 pm, "Hendrik van Rooyen" <[EMAIL PROTECTED]> wrote: > Hi, > > I am surprised that it took me so long to bloody my nose on this one. > > It must be well known - and I would like to find out how well known. > > So here is a CLOSED BOOK multiple choice question - no RTFM, > no playing

Re: Socket Performance

2008-03-13 Thread Grant Edwards
On 2008-03-13, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> > For example: try creating a local client/server (running on the same >> > computer) where the server sends the client a fixed amount of data. >> > Using method A, recv(8192) and sendall( ) with 8192 bytes >> > worth of data. Do this

getattr/setattr still ASCII-only, not Unicode - blows up SGMLlib from BeautifulSoup

2008-03-13 Thread John Nagle
Just noticed, again, that getattr/setattr are ASCII-only, and don't support Unicode. SGMLlib blows up because of this when faced with a Unicode end tag: File "/usr/local/lib/python2.5/sgmllib.py", line 353, in finish_endtag method = getattr(self, 'end_' + tag) Unicod

Re: wx and pil conversion

2008-03-13 Thread azrael
On Mar 13, 6:57 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > azrael wrote: > > I thought of using Temp files but I am afraid of the JPG destorsion > > while saving because of the compresion.I am looking for a way to > > directly transform it. > > Then don't use JPEG, use PNG. It's lossless.

Re: wx and pil conversion

2008-03-13 Thread Diez B. Roggisch
azrael wrote: > I thought of using Temp files but I am afraid of the JPG destorsion > while saving because of the compresion.I am looking for a way to > directly transform it. Then don't use JPEG, use PNG. It's lossless. Diez -- http://mail.python.org/mailman/listinfo/python-list

RE: "Attribute Doesnt Exist" ... but.... it does :-s

2008-03-13 Thread Robert Rawlins
Haha, I could use a stiff whisky myself after the stress that caused me :-) Robert -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robert Bossy Sent: 13 March 2008 16:10 To: python-list@python.org Subject: Re: "Attribute Doesnt Exist" ... but it does

Re: Socket Performance

2008-03-13 Thread sleddd
On Mar 13, 9:33 am, "Brian Smith" <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Sent: Wednesday, March 12, 2008 9:47 PM > > To: [EMAIL PROTECTED] > > Subject: Socket Performance > > > Can anyone explain why socket performance (throughput) varies > > depending on the amount of data send

Re: How to send a var to stdin of an external software

2008-03-13 Thread Bryan Olson
I wrote: > [...] Pipe loops are tricky business. > > Popular solutions are to make either the input or output stream > a disk file, or to create another thread (or process) to be an > active reader or writer. Or asynchronous I/O. On Unix-like systems, you can select() on the underlying file descr

Re: no more comparisons

2008-03-13 Thread Carl Banks
On Mar 13, 12:38 pm, Alan Isaac <[EMAIL PROTECTED]> wrote: > Dan Bishop wrote: > > def cmp_key(cmp_fn): > > class CmpWrapper(object): > > def __init__(self, obj): > > self.obj = obj > > def __cmp__(self, other): > > return cmp_fn(self.obj, other.obj) > >

Re: no more comparisons

2008-03-13 Thread Alan Isaac
Dan Bishop wrote: > def cmp_key(cmp_fn): > class CmpWrapper(object): > def __init__(self, obj): > self.obj = obj > def __cmp__(self, other): > return cmp_fn(self.obj, other.obj) > return CmpWrapper Apparently I'm overlooking something obviou

Re: How to send a var to stdin of an external software

2008-03-13 Thread Bryan Olson
Benjamin Watine wrote: > And if somebody need it : to get the stdout in a var (myNewVar), not in > the shell : > > cat = subprocess.Popen('cat', shell = True, stdin = subprocess.PIPE, > stdout=subprocess.PIPE) > cat.stdin.write(myVar) > cat.stdin.close() > cat.wait() > myNewVar = cat.stdout.read

Re: wx and pil conversion

2008-03-13 Thread azrael
I thought of using Temp files but I am afraid of the JPG destorsion while saving because of the compresion.I am looking for a way to directly transform it. On Mar 13, 5:09 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > azrael wrote: > > A little problem. > > > Can I directly show Pil object

Re: "Attribute Doesnt Exist" ... but.... it does :-s

2008-03-13 Thread Robert Bossy
Robert Rawlins wrote: > Hi Guys, > > Well thanks for the response, I followed your advice and chopped out all the > crap from my class, right down to the bare __init__ and the setter method, > however, the problem continued to persist. > > However, Robert mentioned something about unindented lines

Re: Is there Python equivalent to Perl BEGIN{} block?

2008-03-13 Thread Carl Banks
On Mar 13, 7:02 am, Bruno Desthuilliers wrote: > Alex a écrit : > (sni) > > > First of all thanks all for answering! > > > I have some environment check and setup in the beginning of the code. > > I would like to move it to the end of the script. > > Why ? (if I may ask...) > > > But I want it to

Re: "Attribute Doesnt Exist" ... but.... it does :-s

2008-03-13 Thread Michael Wieher
2008/3/13, Robert Rawlins <[EMAIL PROTECTED]>: > > Hi Guys, > > Well thanks for the response, I followed your advice and chopped out all > the > crap from my class, right down to the bare __init__ and the setter method, > however, the problem continued to persist. > > However, Robert mentioned some

Re: wx and pil conversion

2008-03-13 Thread Diez B. Roggisch
azrael wrote: > A little problem. > > Can I directly show Pil objects "image.open("bla.jpg") in Wx or do I > have to transform them. > > If I have to transofm them How can I do it. Pixel by pixel or is there > somethin built in in pil or wx or python. > pilj->wx and wx->pil. PIL doesn't depend

Re: What's Going On?

2008-03-13 Thread castironpi
On Mar 13, 6:12 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > (Accompanied by Marvin Gaye) > > def f(list=[0]): > > ...list[0]+=1 > > ...return list[0] > > ... > f() > > 1 > f() > > 2 > f() # 'list' is a name bound to a list (mutable) s

RE: "Attribute Doesnt Exist" ... but.... it does :-s

2008-03-13 Thread Robert Rawlins
Hi Guys, Well thanks for the response, I followed your advice and chopped out all the crap from my class, right down to the bare __init__ and the setter method, however, the problem continued to persist. However, Robert mentioned something about unindented lines which got me thinking so I deleted

  1   2   >