Re: Getting Local MAC Address

2010-04-07 Thread Rebelo
Lawrence D'Oliveiro wrote: In message , Booter wrote: I am new to python ans was wondering if there was a way to get the mac address from the local NIC? What if you have more than one? you can try with netifaces : http://pypi.python.org/pypi/netifaces/0.3 I use them on both Windows and L

Re: (a==b) ? 'Yes' : 'No'

2010-04-07 Thread Duncan Booth
Steven D'Aprano wrote: > On Tue, 06 Apr 2010 16:54:18 +, Duncan Booth wrote: > >> Albert van der Horst wrote: >> >>> Old hands would have ... >>> stamp =( weight>=1000 and 120 or >>> weight>=500 and 100 or >>> weight>=250 and 80 or >>> weigh

Re: pass object or use self.object?

2010-04-07 Thread Bruno Desthuilliers
Lie Ryan a écrit : (snip) Since in function in python is a first-class object, you can instead do something like: def process(document): # note: document should encapsulate its own logic document.do_one_thing() Obvious case of encapsulation abuse here. Should a file object encapsulat

Python and Regular Expressions

2010-04-07 Thread Richard Lamboj
Hello, i want to parse this String: version 3.5.1 { $pid_dir = /opt/samba-3.5.1/var/locks/ $bin_dir = /opt/samba-3.5.1/bin/ service smbd { bin = ${bin_dir}smbd -D pid = ${pid_dir}smbd.pid } service nmbd { b

Re: plotting in python 3

2010-04-07 Thread egl...@gmail.com
On Apr 6, 11:52 pm, Rolf Camps wrote: > Op dinsdag 06-04-2010 om 14:55 uur [tijdzone -0500], schreef Christopher > Choi: > It was after the homework I asked my question. All plot solutions i > found where for python2.x. gnuplot_py states on its homepage you need a > 'working copy of numpy'. I don

Re: Python and Regular Expressions

2010-04-07 Thread Chris Rebert
On Wed, Apr 7, 2010 at 1:37 AM, Richard Lamboj wrote: > i want to parse this String: > > version 3.5.1 { > >        $pid_dir = /opt/samba-3.5.1/var/locks/ >        $bin_dir = /opt/samba-3.5.1/bin/ > >        service smbd { >                bin = ${bin_dir}smbd -D >                pid = ${pid_dir}s

Re: converting a timezone-less datetime to seconds since the epoch

2010-04-07 Thread Chris Withers
Hi Chris, Chris Rebert wrote: from calendar import timegm def timestamp(dttm): return timegm(dttm.utctimetuple()) #the *utc*timetuple change is just for extra consistency #it shouldn't actually make a difference here And problem solved. As for what the problem was: Paraphrasing the table

Re: Python and Regular Expressions

2010-04-07 Thread Bruno Desthuilliers
Richard Lamboj a écrit : Hello, i want to parse this String: version 3.5.1 { $pid_dir = /opt/samba-3.5.1/var/locks/ $bin_dir = /opt/samba-3.5.1/bin/ service smbd { bin = ${bin_dir}smbd -D pid = ${pid_dir}smbd.pid } servic

Re: Python and Regular Expressions

2010-04-07 Thread Richard Lamboj
Am Wednesday 07 April 2010 10:52:14 schrieb Chris Rebert: > On Wed, Apr 7, 2010 at 1:37 AM, Richard Lamboj wrote: > > i want to parse this String: > > > > version 3.5.1 { > > > >        $pid_dir = /opt/samba-3.5.1/var/locks/ > >        $bin_dir = /opt/samba-3.5.1/bin/ > > > >        service smbd

Re: Q about assignment and references

2010-04-07 Thread jdbosmaus
Thanks to all for the informative answers. You made me realize this is a wxPython issue. I have to say, wxPython seems useful, and I'm glad it is available - but it doesn't have the gentlest of learning curves. -- http://mail.python.org/mailman/listinfo/python-list

PyCon Australia Call For Proposals

2010-04-07 Thread Richard Jones
Hi everyone, I'm happy to announce that on the 26th and 27th of June we are running PyCon Australia in Sydney! http://pycon-au.org/ We are looking for proposals for Talks on all aspects of Python programming from novice to advanced levels; applications and frameworks, or how you have been invol

Re: staticmethod and namespaces

2010-04-07 Thread Дамјан Георгиевски
> Having an odd problem that I solved, but wondering if its the best > solution (seems like a bit of a hack). > > First off, I'm using an external DLL that requires static callbacks, > but because of this, I'm losing instance info. It could be import > related? It will make more sense after I di

Re: converting a timezone-less datetime to seconds since the epoch

2010-04-07 Thread Floris Bruynooghe
On Apr 7, 9:57 am, Chris Withers wrote: > Chris Rebert wrote: > > To convert from struct_time in ***UTC*** > > to seconds since the epoch > > use calendar.timegm() > > ...and really, wtf is timegm doing in calendar rather than in time? ;-) You're not alone in finding this strange: http://bugs.pyt

"jobs in california" "jobs in california los angeles" "jobs in california for uk residents" "jobs in california san diego" "jobs in california orange county" "jobs in california for british" http

2010-04-07 Thread Naeem
"jobs in california" "jobs in california los angeles" "jobs in california for uk residents" "jobs in california san diego" "jobs in california orange county" "jobs in california for british" http://jobsincalifornia-usa.blogspot.com/ "jobs in california" "jobs in california los angeles"

Re: Impersonating a Different Logon

2010-04-07 Thread Kevin Holleran
On Tue, Apr 6, 2010 at 4:11 PM, Tim Golden wrote: > On 06/04/2010 20:26, Kevin Holleran wrote: >> >> Hello, >> >> I am sweeping some of our networks to find devices.  When I find a >> device I try to connect to the registry using _winreg and then query a >> specific key that I am interested in.  T

Striving for PEP-8 compliance

2010-04-07 Thread Tom Evans
[ Please keep me cc'ed, I'm not subscribed ] Hi all I've written a bunch of internal libraries for my company, and they all use two space indents, and I'd like to be more consistent and conform to PEP-8 as much as I can. My problem is I would like to be certain that any changes do not alter the

Re: Striving for PEP-8 compliance

2010-04-07 Thread geremy condra
On Wed, Apr 7, 2010 at 10:53 AM, Tom Evans wrote: > [ Please keep me cc'ed, I'm not subscribed ] > > Hi all > > I've written a bunch of internal libraries for my company, and they > all use two space indents, and I'd like to be more consistent and > conform to PEP-8 as much as I can. > > My proble

Re: imports again

2010-04-07 Thread Gabriel Genellina
En Tue, 06 Apr 2010 14:25:38 -0300, Alex Hall escribió: Sorry this is a forward (long story involving a braille notetaker's bad copy/paste and GMail's annoying mobile site). Basically, I am getting errors when I run the project at http://www.gateway2somewhere.com/sw.zip Error 404 -- Gabriel

Re: Impersonating a Different Logon

2010-04-07 Thread Tim Golden
On 07/04/2010 14:57, Kevin Holleran wrote: Thanks, I was able to connect to the remote machine. However, how do I query for a very specific key value? I have to scan hundreds of machines and need want to reduce what I am querying. I would like to be able to scan a very specific key and report

Re: Striving for PEP-8 compliance

2010-04-07 Thread Grant Edwards
On 2010-04-07, Tom Evans wrote: > [ Please keep me cc'ed, I'm not subscribed ] Sorry. I post via gmane.org, so cc'ing you would require some extra work, and I'm too lazy. > I've written a bunch of internal libraries for my company, and they > all use two space indents, and I'd like to be more c

Re: Simplify Python

2010-04-07 Thread AlienBaby
On 6 Apr, 20:04, ja1lbr3ak wrote: > I'm trying to teach myself Python, and so have been simplifying a > calculator program that I wrote. The original was 77 lines for the > same functionality. Problem is, I've hit a wall. Can anyone help? > > loop = input("Enter 1 for the calculator, 2 for the Fib

Re: Striving for PEP-8 compliance

2010-04-07 Thread Gabriel Genellina
En Wed, 07 Apr 2010 11:53:58 -0300, Tom Evans escribió: [ Please keep me cc'ed, I'm not subscribed ] Sorry; you may read this at http://groups.google.com/group/comp.lang.python/ I've written a bunch of internal libraries for my company, and they all use two space indents, and I'd like

Re: Striving for PEP-8 compliance

2010-04-07 Thread Gabriel Genellina
En Wed, 07 Apr 2010 11:53:58 -0300, Tom Evans escribió: [ Please keep me cc'ed, I'm not subscribed ] Sorry; you may read this at http://groups.google.com/group/comp.lang.python/ I've written a bunch of internal libraries for my company, and they all use two space indents, and I'd like

Re: Striving for PEP-8 compliance

2010-04-07 Thread Tom Evans
On Wed, Apr 7, 2010 at 4:10 PM, geremy condra wrote: > On Wed, Apr 7, 2010 at 10:53 AM, Tom Evans wrote: >> [ Please keep me cc'ed, I'm not subscribed ] >> >> Hi all >> >> I've written a bunch of internal libraries for my company, and they >> all use two space indents, and I'd like to be more con

Re: Striving for PEP-8 compliance

2010-04-07 Thread Robert Kern
On 2010-04-07 11:06 AM, Tom Evans wrote: On Wed, Apr 7, 2010 at 4:10 PM, geremy condra wrote: On Wed, Apr 7, 2010 at 10:53 AM, Tom Evans wrote: [ Please keep me cc'ed, I'm not subscribed ] Hi all I've written a bunch of internal libraries for my company, and they all use two space indents,

"jobs in newyork " "hotel jobs in newyork city" "jobs in newyork newyork" "jobs in newyork usa" "newyork jobs" "newyork jobbank" "newyork job exchange" http://jobsinnewyork-usa.blogspot.com/

2010-04-07 Thread saima81
"jobs in newyork " "hotel jobs in newyork city" "jobs in newyork newyork" "jobs in newyork usa" "newyork jobs" "newyork jobbank" "newyork job exchange" http://jobsinnewyork-usa.blogspot.com/ "jobs in newyork " "hotel jobs in newyork city" "jobs in newyork newyork" "jobs in newyork usa" "newyork job

Re: (a==b) ? 'Yes' : 'No'

2010-04-07 Thread Emile van Sebille
On 4/6/2010 9:20 PM Steven D'Aprano said... On Tue, 06 Apr 2010 16:54:18 +, Duncan Booth wrote: Most old hands would (IMHO) write the if statements out in full, though some might remember that Python comes 'batteries included': from bisect import bisect WEIGHTS = [100, 250, 500, 1000]

Re: pass object or use self.object?

2010-04-07 Thread Tim Arnold
On Apr 6, 11:19 am, Jean-Michel Pichavant wrote: > Tim Arnold wrote: > > Hi, > > I have a few classes that manipulate documents. One is really a > > process that I use a class for just to bundle a bunch of functions > > together (and to keep my call signatures the same for each of my > > manipulat

[2.5.1/cookielib] How to display specific cookie?

2010-04-07 Thread Gilles Ganault
Hello I'm using ActivePython 2.5.1 and the cookielib package to retrieve web pages. I'd like to display a given cookie from the cookiejar instead of the whole thing: #OK for index, cookie in enumerate(cj): print index, ' : ', cookie #How to display just PHPSESSID?

Re: lambda with floats

2010-04-07 Thread Peter Pearson
On Tue, 06 Apr 2010 23:16:18 -0400, monkeys paw wrote: > I have the following acre meter which works for integers, > how do i convert this to float? I tried > > return float ((208.0 * 208.0) * n) > > >>> def s(n): > ... return lambda x: (208 * 208) * n > ... > >>> f = s(1) > >>> f(1) > 43264 > >

Re: python as pen and paper substitute

2010-04-07 Thread Manuel Graune
Hello Johan, thanks to you (and everyone else who answered) for your effort. Johan Grönqvist writes: > Manuel Graune skrev: >> Manuel Graune writes: >> >> Just as an additional example, let's assume I'd want to add the area of >> to circles. >> [...] >> which can be explained to anyone who kno

Re: Performance of list vs. set equality operations

2010-04-07 Thread Raymond Hettinger
[Gustavo Nare] > In other words: The more different elements two collections have, the > faster it is to compare them as sets. And as a consequence, the more > equivalent elements two collections have, the faster it is to compare > them as lists. > > Is this correct? If two collections are equal,

Re: python as pen and paper substitute

2010-04-07 Thread Manuel Graune
Hello Johan, thanks to you (and everyone else who answered) for your effort. Johan Grönqvist writes: > Manuel Graune skrev: >> Manuel Graune writes: >> >> Just as an additional example, let's assume I'd want to add the area of >> to circles. >> [...] >> which can be explained to anyone who kno

+Hi+

2010-04-07 Thread Matt Burson
http://sites.google.com/site/fgu45ythjg/rfea8i -- Matt -- http://mail.python.org/mailman/listinfo/python-list

[Q] raise exception with fake filename and linenumber

2010-04-07 Thread kwatch
Hi all, Is it possible to raise exception with custom traceback to specify file and line? Situation = I'm creating a certain parser. I want to report syntax error with the same format as other exception. Example === parser.py: - 1: def parse(filename): 2:

fcntl, serial ports and serial signals on RS232.

2010-04-07 Thread Max Kotasek
Hello to all out there, I'm trying to figure out how to parse the responses from fcntl.ioctl() calls that modify the serial lines in a way that asserts that the line is now changed. For example I may want to drop RTS explicitly, and assert that the line has been dropped before returning. Here is

Re: Recommend Commercial graphing library

2010-04-07 Thread David Bolen
AlienBaby writes: > I'd be grateful for any suggestions / pointers to something useful, Ignoring the commercial vs. open source discussion, although it was a few years ago, I found Chart Director (http://www.advsofteng.com/) to work very well, with plenty of platform and language support, includ

Re: Impersonating a Different Logon

2010-04-07 Thread David Bolen
Kevin Holleran writes: > Thanks, I was able to connect to the remote machine. However, how do > I query for a very specific key value? I have to scan hundreds of > machines and need want to reduce what I am querying. I would like to > be able to scan a very specific key and report on its value

remote multiprocessing, shared object

2010-04-07 Thread Norm Matloff
Should be a simple question, but I can't seem to make it work from my understanding of the docs. I want to use the multiprocessing module with remote clients, accessing shared lists. I gather one is supposed to use register(), but I don't see exactly how. I'd like to have the clients read and wr

Regex driving me crazy...

2010-04-07 Thread J
Can someone make me un-crazy? I have a bit of code that right now, looks like this: status = getoutput('smartctl -l selftest /dev/sda').splitlines()[6] status = re.sub(' (?= )(?=([^"]*"[^"]*")*[^"]*$)', ":",status) print status Basically, it pulls the first actual line of data fr

Re: Regex driving me crazy...

2010-04-07 Thread Grant Edwards
On 2010-04-07, J wrote: > Can someone make me un-crazy? Definitely. Regex is driving you crazy, so don't use a regex. inputString = "# 1 Short offline Completed without error 00% 679 -" print ' '.join(inputString.split()[4:-3]) > So any ideas on what the best

Re: python as pen and paper substitute

2010-04-07 Thread Michael Torrie
On 04/06/2010 12:40 PM, Manuel Graune wrote: > Hello everyone, > > I am looking for ways to use a python file as a substitute for simple > pen and paper calculations. At the moment I mainly use a combination > of triple-quoted strings, exec and print (Yes, I know it's not exactly > elegant). Thi

order that destructors get called?

2010-04-07 Thread Brendan Miller
I'm used to C++ where destrcutors get called in reverse order of construction like this: { Foo foo; Bar bar; // calls Bar::~Bar() // calls Foo::~Foo() } I'm writing a ctypes wrapper for some native code, and I need to manage some memory. I'm wrapping the memory in a python class

Re: order that destructors get called?

2010-04-07 Thread Stephen Hansen
On 2010-04-07 15:08:14 -0700, Brendan Miller said: When doing this, I noticed some odd behaviour. I had code like this: def delete_my_resource(res): # deletes res class MyClass(object): def __del__(self): delete_my_resource(self.res) o = MyClass() What happens is that as the p

Profiling: Interpreting tottime

2010-04-07 Thread Nikolaus Rath
Hello, Consider the following function: def check_s3_refcounts(): """Check s3 object reference counts""" global found_errors log.info('Checking S3 object reference counts...') for (key, refcount) in conn.query("SELECT id, refcount FROM s3_objects"): refcount2 = conn.get

Re: pass object or use self.object?

2010-04-07 Thread Lie Ryan
On 04/07/10 18:34, Bruno Desthuilliers wrote: > Lie Ryan a écrit : > (snip) > >> Since in function in python is a first-class object, you can instead do >> something like: >> >> def process(document): >> # note: document should encapsulate its own logic >> document.do_one_thing() > > Obvi

help req: installing debugging symbols

2010-04-07 Thread sanam singh
Hi,I am using ununtu 9.10. I want to install a version of Python that was compiled with debug symbols.But if I delete python from ubuntu it would definitely stop working . And python comes preintalled in ubuntu without debugging symbols.How can i install python with debugging symbols ?Thanks

ftp and python

2010-04-07 Thread Matjaz Pfefferer
Hi, I'm Py newbie and I have some beginners problems with ftp handling. What would be the easiest way to copy files from one ftp folder to another without downloading them to local system? Are there any snippets for this task (I couldnt find example like this) Thx

Re: Striving for PEP-8 compliance

2010-04-07 Thread Lawrence D'Oliveiro
In message , Tom Evans wrote: > I've written a bunch of internal libraries for my company, and they > all use two space indents, and I'd like to be more consistent and > conform to PEP-8 as much as I can. “A foolish consistency is the hobgoblin of little minds” — Ralph Waldo Emerson -- http

Re: Striving for PEP-8 compliance

2010-04-07 Thread Lawrence D'Oliveiro
In message , Gabriel Genellina wrote: > If you only reindent the code (without adding/removing lines) then you can > compare the compiled .pyc files (excluding the first 8 bytes that contain > a magic number and the source file timestamp). Remember that code objects > contain line number informat

Re: Regex driving me crazy...

2010-04-07 Thread Patrick Maupin
On Apr 7, 4:40 pm, J wrote: > Can someone make me un-crazy? > > I have a bit of code that right now, looks like this: > > status = getoutput('smartctl -l selftest /dev/sda').splitlines()[6] >         status = re.sub(' (?= )(?=([^"]*"[^"]*")*[^"]*$)', ":",status) >         print status > > Basicall

Re: Regex driving me crazy...

2010-04-07 Thread Patrick Maupin
On Apr 7, 4:47 pm, Grant Edwards wrote: > On 2010-04-07, J wrote: > > > Can someone make me un-crazy? > > Definitely.  Regex is driving you crazy, so don't use a regex. > >   inputString = "# 1  Short offline       Completed without error     00%     >   679         -" > >   print ' '.join(input

Re: help req: installing debugging symbols

2010-04-07 Thread Shashwat Anand
Install python in a different directory, use $prefix for that. Change PATH value accordingly 2010/4/5 sanam singh > Hi, > > I am using ununtu 9.10. I want to install a version of Python that was > compiled with debug symbols. > > But if I delete python from ubuntu it would definitely stop wo

Re: Regex driving me crazy...

2010-04-07 Thread Patrick Maupin
On Apr 7, 7:49 pm, Patrick Maupin wrote: > On Apr 7, 4:40 pm, J wrote: > > > > > Can someone make me un-crazy? > > > I have a bit of code that right now, looks like this: > > > status = getoutput('smartctl -l selftest /dev/sda').splitlines()[6] > >         status = re.sub(' (?= )(?=([^"]*"[^"]*")

Re: Striving for PEP-8 compliance

2010-04-07 Thread Chris Rebert
On Wed, Apr 7, 2010 at 5:35 PM, Lawrence D'Oliveiro <@> wrote: > In message , Gabriel > Genellina wrote: > >> If you only reindent the code (without adding/removing lines) then you can >> compare the compiled .pyc files (excluding the first 8 bytes that contain >> a magic number and the source file

Re: ftp and python

2010-04-07 Thread Tim Chase
Matjaz Pfefferer wrote: What would be the easiest way to copy files from one ftp folder to another without downloading them to local system? As best I can tell, this isn't well-supported by FTP[1] which doesn't seem to have a native "copy this file from server-location to server-location bypa

Re: Python and Regular Expressions

2010-04-07 Thread Patrick Maupin
On Apr 7, 3:52 am, Chris Rebert wrote: > Regular expressions != Parsers True, but lots of parsers *use* regular expressions in their tokenizers. In fact, if you have a pure Python parser, you can often get huge performance gains by rearranging your code slightly so that you can use regular expr

Re: Performance of list vs. set equality operations

2010-04-07 Thread Steven D'Aprano
On Wed, 07 Apr 2010 10:55:10 -0700, Raymond Hettinger wrote: > [Gustavo Nare] >> In other words: The more different elements two collections have, the >> faster it is to compare them as sets. And as a consequence, the more >> equivalent elements two collections have, the faster it is to compare >>

Re: Performance of list vs. set equality operations

2010-04-07 Thread Patrick Maupin
On Apr 7, 8:41 pm, Steven D'Aprano wrote: > On Wed, 07 Apr 2010 10:55:10 -0700, Raymond Hettinger wrote: > > [Gustavo Nare] > >> In other words: The more different elements two collections have, the > >> faster it is to compare them as sets. And as a consequence, the more > >> equivalent elements

Re: Regex driving me crazy...

2010-04-07 Thread James Stroud
Patrick Maupin wrote: BTW, although I find it annoying when people say "don't do that" when "that" is a perfectly good thing to do, and although I also find it annoying when people tell you what not to do without telling you what *to* do, and although I find the regex solution to this problem to

Re: Regex driving me crazy...

2010-04-07 Thread Patrick Maupin
On Apr 7, 9:02 pm, James Stroud wrote: > Patrick Maupin wrote: > > BTW, although I find it annoying when people say "don't do that" when > > "that" is a perfectly good thing to do, and although I also find it > > annoying when people tell you what not to do without telling you what > > *to* do, an

Re: Regex driving me crazy...

2010-04-07 Thread Grant Edwards
On 2010-04-08, Patrick Maupin wrote: > On Apr 7, 4:47?pm, Grant Edwards wrote: >> On 2010-04-07, J wrote: >> >> > Can someone make me un-crazy? >> >> Definitely. ?Regex is driving you crazy, so don't use a regex. >> >> ? inputString = "# 1 ?Short offline ? ? ? Completed without error ? ? 00% ?

Re: Regex driving me crazy...

2010-04-07 Thread Grant Edwards
On 2010-04-08, James Stroud wrote: > Patrick Maupin wrote: >> BTW, although I find it annoying when people say "don't do that" when >> "that" is a perfectly good thing to do, and although I also find it >> annoying when people tell you what not to do without telling you what >> *to* do, and althou

Re: Regex driving me crazy...

2010-04-07 Thread Patrick Maupin
On Apr 7, 9:36 pm, Grant Edwards wrote: > On 2010-04-08, Patrick Maupin wrote:> On Apr 7, 4:47?pm, > Grant Edwards wrote: > >> On 2010-04-07, J wrote: > > >> > Can someone make me un-crazy? > > >> Definitely. ?Regex is driving you crazy, so don't use a regex. > > >> ? inputString = "# 1 ?Short

Re: Regex driving me crazy...

2010-04-07 Thread Steven D'Aprano
On Wed, 07 Apr 2010 18:03:47 -0700, Patrick Maupin wrote: > BTW, although I find it annoying when people say "don't do that" when > "that" is a perfectly good thing to do, and although I also find it > annoying when people tell you what not to do without telling you what > *to* do, Grant did giv

Re: Regex driving me crazy...

2010-04-07 Thread J
On Wed, Apr 7, 2010 at 22:45, Patrick Maupin wrote: > When I saw "And I am interested in the string that appears in the > third column, which changes as the test runs and then completes" I > assumed that, not only could that string change, but so could the one > before it. > > I guess my base ass

Re: Regex driving me crazy...

2010-04-07 Thread Patrick Maupin
On Apr 7, 9:51 pm, Steven D'Aprano wrote: > On Wed, 07 Apr 2010 18:03:47 -0700, Patrick Maupin wrote: > > BTW, although I find it annoying when people say "don't do that" when > > "that" is a perfectly good thing to do, and although I also find it > > annoying when people tell you what not to do w

Re: Tkinter inheritance mess?

2010-04-07 Thread ejetzer
On 5 avr, 22:32, Lie Ryan wrote: > On 04/06/10 02:38, ejetzer wrote: > > > > > On 5 avr, 12:36, ejetzer wrote: > >> For a school project, I'm trying to make a minimalist web browser, and > >> I chose to use Tk as the rendering toolkit. I made my parser classes > >> into Tkinter canvases, so that

Re: Regex driving me crazy...

2010-04-07 Thread Grant Edwards
On 2010-04-08, Patrick Maupin wrote: > Sorry, my eyes completely missed your one-liner, so my criticism about > not posting a solution was unwarranted. I don't think you and I read > the problem the same way (which is probably why I didn't notice your > solution -- because it wasn't solving the

Re: Performance of list vs. set equality operations

2010-04-07 Thread Raymond Hettinger
[Raymond Hettinger] > > If the two collections have unequal sizes, then both ways immediately > > return unequal. [Steven D'Aprano] > Perhaps I'm misinterpreting what you are saying, but I can't confirm that > behaviour, at least not for subclasses of list: For doubters, see list_richcompare() in

Re: Regex driving me crazy...

2010-04-07 Thread Patrick Maupin
On Apr 7, 9:51 pm, Steven D'Aprano wrote: > This is one of the reasons we're so often suspicious of re solutions: > > >>> s = '# 1  Short offline       Completed without error       00%' > >>> tre = Timer("re.split(' {2,}', s)", > > ... "import re; from __main__ import s")>>> tsplit = Timer("[x f

Re: [Q] raise exception with fake filename and linenumber

2010-04-07 Thread Gabriel Genellina
En Wed, 07 Apr 2010 17:23:22 -0300, kwatch escribió: Is it possible to raise exception with custom traceback to specify file and line? I'm creating a certain parser. I want to report syntax error with the same format as other exception. - 1: def parse(filename): 2: i

Re: Profiling: Interpreting tottime

2010-04-07 Thread Gabriel Genellina
En Wed, 07 Apr 2010 18:44:39 -0300, Nikolaus Rath escribió: def check_s3_refcounts(): """Check s3 object reference counts""" global found_errors log.info('Checking S3 object reference counts...') for (key, refcount) in conn.query("SELECT id, refcount FROM s3_objects"):

Re: Profiling: Interpreting tottime

2010-04-07 Thread Gabriel Genellina
En Wed, 07 Apr 2010 18:44:39 -0300, Nikolaus Rath escribió: def check_s3_refcounts(): """Check s3 object reference counts""" global found_errors log.info('Checking S3 object reference counts...') for (key, refcount) in conn.query("SELECT id, refcount FROM s3_objects"):

The Regex Story

2010-04-07 Thread Lie Ryan
On 04/08/10 12:45, Patrick Maupin wrote: > (And I got testy because of seeing other IMO unwarranted denigration > of re on the list lately.) Why am I seeing a lot of this pattern lately: OP: Got problem with string +- A: Suggested a regex-based solution +- B: Quoted "Some people ... r

Re: Regex driving me crazy...

2010-04-07 Thread Patrick Maupin
On Apr 7, 9:51 pm, Steven D'Aprano wrote: BTW, I don't know how you got 'True' here. > >>> re.split(' {2,}', s) == [x for x in s.split('  ') if x.strip()] > True You must not have s set up to be the string given by the OP. I just realized there was an error in my non-regexp example, that actua

Re: order that destructors get called?

2010-04-07 Thread Gabriel Genellina
En Wed, 07 Apr 2010 19:08:14 -0300, Brendan Miller escribió: I'm used to C++ where destrcutors get called in reverse order of construction like this: { Foo foo; Bar bar; // calls Bar::~Bar() // calls Foo::~Foo() } That behavior is explicitly guaranteed by the C++ languag

Simple Cookie Script: Not recognising Cookie

2010-04-07 Thread Jimbo
Hi I have a simple Python program that assigns a cookie to a web user when they open the script the 1st time(in an internet browser). If they open the script a second time the script should display the line " You have been here 2 times." , if they open the script agai it should show on the webpage

Re: ftp and python

2010-04-07 Thread John Nagle
Tim Chase wrote: Matjaz Pfefferer wrote: What would be the easiest way to copy files from one ftp folder to another without downloading them to local system? As best I can tell, this isn't well-supported by FTP[1] which doesn't seem to have a native "copy this file from server-location to se

Re: remote multiprocessing, shared object

2010-04-07 Thread Kushal Kumaran
On Thu, Apr 8, 2010 at 3:04 AM, Norm Matloff wrote: > Should be a simple question, but I can't seem to make it work from my > understanding of the docs. > > I want to use the multiprocessing module with remote clients, accessing > shared lists.  I gather one is supposed to use register(), but I do

Re: Regex driving me crazy...

2010-04-07 Thread Kushal Kumaran
On Thu, Apr 8, 2010 at 3:10 AM, J wrote: > Can someone make me un-crazy? > > I have a bit of code that right now, looks like this: > > status = getoutput('smartctl -l selftest /dev/sda').splitlines()[6] >        status = re.sub(' (?= )(?=([^"]*"[^"]*")*[^"]*$)', ":",status) >        print status >

Re: remote multiprocessing, shared object

2010-04-07 Thread Norm Matloff
Thanks very much, Kushal. But it seems to me that it doesn't quite work. After your first client below creates l and calls append() on it, it would seem that one could not then assign to it, e.g. do l[1] = 8 What I'd like is to write remote multiprocessing code just like threads code (or for

Re: remote multiprocessing, shared object

2010-04-07 Thread Kushal Kumaran
On Thu, Apr 8, 2010 at 11:30 AM, Norm Matloff wrote: > Thanks very much, Kushal. > > But it seems to me that it doesn't quite work.  After your first client > below creates l and calls append() on it, it would seem that one could > not then assign to it, e.g. do > >   l[1] = 8 > > What I'd like is