Re: C-style static variables in Python?

2010-04-02 Thread Ethan Furman
Steven D'Aprano wrote: On Fri, 02 Apr 2010 19:48:59 -0700, Ethan Furman wrote: The heuristic I use is, if I expect the try block to raise an exception more than about one time in ten, I change to an explicit test. In this case, since the exception should only be raised once, and then never aga

Re: Getting Local MAC Address

2010-04-02 Thread Frank Millman
"Booter" wrote in message news:ec6d247c-a6b0-4f33-a36b-1d33eace6...@k19g2000yqn.googlegroups.com... Hello all, I am new to python ans was wondering if there was a way to get the mac address from the local NIC? Thanks for your help. Gerad This is what I use - def

Re: C-style static variables in Python?

2010-04-02 Thread Steven D'Aprano
On Fri, 02 Apr 2010 19:48:59 -0700, Ethan Furman wrote: >> The heuristic I use is, if I expect the try block to raise an exception >> more than about one time in ten, I change to an explicit test. In this >> case, since the exception should only be raised once, and then never >> again, I would use

"jobs in alaska" "jobs in alaska for foreigners" "jobs in alaska oil" "jobs in alaska for women" "alaska jobs" "alaska jobs north slope" "alaska jobs pipeline" "alaska jobs for foreigners" ON http://j

2010-04-02 Thread Naeem
"jobs in alaska" "jobs in alaska for foreigners" "jobs in alaska oil" "jobs in alaska for women" "alaska jobs" "alaska jobs north slope" "alaska jobs pipeline" "alaska jobs for foreigners" ON http://jobsinalaska-usa.blogspot.com/ "jobs in alaska" "jobs in alaska for foreigners" "job

Re: C-style static variables in Python?

2010-04-02 Thread Patrick Maupin
On Apr 2, 10:11 pm, Stephen Hansen wrote: > > I don't know if properties are really faster or slower then a > __getattr__, but I find them a lot cleaner if I want to delay some > calculation until needed like that. Well, the relative speed of properties vs. __getattr__ can become irrelevant in at

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

2010-04-02 Thread Steve Howell
On Apr 2, 5:53 pm, Steven D'Aprano wrote: > > As I've pointed out before, it is natural syntax in English. Not > necessarily the most common, but common enough to be completely > unexceptional: > > "I'll be there in ten minutes, if I can find a parking space close by, > otherwise you should start

Traits implementation for Python 3

2010-04-02 Thread Ethan Furman
Well, it's been said than imitation is the sincerest form of flattery, so be flattered, Michele! In order to gain a better understanding of the whole metaclass issue, I decided to make my own implementation, targeting Python 3. I figured I could leave out a bunch of the complexity required to

Re: C-style static variables in Python?

2010-04-02 Thread Stephen Hansen
On 2010-04-02 19:42:29 -0700, Ethan Furman said: Terry Reedy wrote: In Duncan Booth writes: class Spam(object): mongo = None def __call__(self, x, y, z): if self.mongo is None: self.mongo = heavy_lifting_at_runtime() return frobnicate(x, y, z, self.mongo) Unless one wants the intializat

Re: C-style static variables in Python?

2010-04-02 Thread Ethan Furman
Steven D'Aprano wrote: On Fri, 02 Apr 2010 12:39:16 -0700, Patrick Maupin wrote: On Apr 2, 2:38 pm, Ethan Furman wrote: [...] Sounds like a personal preference issue, rather than a necessary / unnecessary issue -- after all, if you call that function a thousand times, only once is mongo n

Re: C-style static variables in Python?

2010-04-02 Thread Ethan Furman
Terry Reedy wrote: In Duncan Booth writes: class Spam(object): mongo = None def __call__(self, x, y, z): if self.mongo is None: self.mongo = heavy_lifting_at_runtime() return frobnicate(x, y, z, self.mongo) Unless one wants the intialization of mongo delayed

Re: psycopg2 / psycopg2.ProgrammingError: syntax error at or near "E'mytable'"

2010-04-02 Thread Steve Holden
mrdrew wrote: > Hey all, > > Right now I'm completely unable to pass parameters to queries under > any circumstances. I've got a fairly trivial query as a test... > > c.execute('SELECT * FROM %(table_name)s LIMIT 1', > {'table_name':"mytable"}) > > It fails, giving the error message... > > Tra

Re: off topic but please forgive me me and answer

2010-04-02 Thread Patrick Maupin
On Apr 2, 8:29 pm, Mensanator wrote: > Don't you know how Usenet works? No, but my cat does. -- http://mail.python.org/mailman/listinfo/python-list

Re: psycopg2 / psycopg2.ProgrammingError: syntax error at or near "E'mytable'"

2010-04-02 Thread Tim Chase
MRAB wrote: I think that you're confusing Python's string formatting with SQL placeholders. The "%(table_name)s" works only with Python's '%' operator. You should use only the "%s" form (or possibly "?", I'm not sure which!) It varies depending on your DB driver. Check out the .paramstyle

Re: C-style static variables in Python?

2010-04-02 Thread Terry Reedy
On 4/2/2010 1:28 PM, Paul McGuire wrote: On Apr 1, 5:34 pm, kj wrote: When coding C I have often found static local variables useful for doing once-only run-time initializations. For example: Here is a decorator to make a function self-aware, giving it a "this" variable that points to itsel

Re: C-style static variables in Python?

2010-04-02 Thread Terry Reedy
On 4/2/2010 6:59 PM, kj wrote: In Duncan Booth writes: class Spam(object): mongo = None def __call__(self, x, y, z): if self.mongo is None: self.mongo = heavy_lifting_at_runtime() return frobnicate(x, y, z, self.mongo) Unless one wants the intialization of mo

Re: off topic but please forgive me me and answer

2010-04-02 Thread Mensanator
On Apr 2, 7:32 pm, Patrick Maupin wrote: > On Apr 2, 6:50 pm, Mensanator wrote: > > > On Apr 2, 2:34 pm, Patrick Maupin wrote: > > > > Methinks the OP is fluent in the way of choosing newsgroups. > > > According to google, he has posted 6855 messages in 213 groups. > > > Does that really mean an

Re: psycopg2 / psycopg2.ProgrammingError: syntax error at or near "E'mytable'"

2010-04-02 Thread MRAB
mrdrew wrote: Hey all, Right now I'm completely unable to pass parameters to queries under any circumstances. I've got a fairly trivial query as a test... c.execute('SELECT * FROM %(table_name)s LIMIT 1', {'table_name':"mytable"}) It fails, giving the error message... Traceback (most recent

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

2010-04-02 Thread Steven D'Aprano
On Fri, 02 Apr 2010 20:12:59 +, kj wrote: > In Steve Holden > writes: [...] >>Yes, that's deliberately awful syntax. Guido designed it that way to >>ensure that people didn't aver-use it, thereby reducing the readability >>of Python applications. > > Is that for real??? It's the QWERTY rat

Re: off topic but please forgive me me and answer

2010-04-02 Thread Patrick Maupin
On Apr 2, 6:50 pm, Mensanator wrote: > On Apr 2, 2:34 pm, Patrick Maupin wrote: > > > Methinks the OP is fluent in the way of choosing newsgroups. > > According to google, he has posted 6855 messages in 213 groups. > > Does that really mean anything? Hell, I have 12765 messages > posted to 332 gr

psycopg2 / psycopg2.ProgrammingError: syntax error at or near "E'mytable'"

2010-04-02 Thread mrdrew
Hey all, Right now I'm completely unable to pass parameters to queries under any circumstances. I've got a fairly trivial query as a test... c.execute('SELECT * FROM %(table_name)s LIMIT 1', {'table_name':"mytable"}) It fails, giving the error message... Traceback (most recent call last): Fi

Re: C-style static variables in Python?

2010-04-02 Thread Patrick Maupin
On Apr 2, 6:57 pm, Steven D'Aprano wrote: > On Fri, 02 Apr 2010 12:39:16 -0700, Patrick Maupin wrote: > > On Apr 2, 2:38 pm, Ethan Furman wrote: > [...] > >> Sounds like a personal preference issue, rather than a necessary / > >> unnecessary issue -- after all, if you call that function a thousan

Re: C-style static variables in Python?

2010-04-02 Thread Steven D'Aprano
On Fri, 02 Apr 2010 12:39:16 -0700, Patrick Maupin wrote: > On Apr 2, 2:38 pm, Ethan Furman wrote: [...] >> Sounds like a personal preference issue, rather than a necessary / >> unnecessary issue -- after all, if you call that function a thousand >> times, only once is mongo not defined... clearl

Re: off topic but please forgive me me and answer

2010-04-02 Thread Mensanator
On Apr 2, 2:34 pm, Patrick Maupin wrote: > On Apr 2, 2:41 pm, Andreas Waldenburger > wrote: > > > While everyone else is mocking you: Can you please elaborate on why you > > want to know and what kind of problem you're trying to solve with this? > > Also, don't you think you should have picked a

Re: off topic but please forgive me me and answer

2010-04-02 Thread Mensanator
On Apr 2, 6:07 pm, Steven D'Aprano wrote: > On Fri, 02 Apr 2010 12:35:55 -0700, Mensanator wrote: > >> If you want an exact result when multiplying arbitrary fractions, you > >> need to avoid floats and decimals and use Fractions: > > >> >>> Fraction(1, 2)**2 > > >> Fraction(1, 4) > > > Where do y

Re: Generating text from a regular expression

2010-04-02 Thread Nathan Harmston
Thanks everyone, the invRegexInf is perfect. Thanks again, Nathan On 1 April 2010 10:17, Gabriel Genellina wrote: > En Wed, 31 Mar 2010 12:23:48 -0300, Paul McGuire > escribió: >> >> On Mar 31, 5:49 am, Nathan Harmston >> wrote: >>> >>> I have a slightly complicated/medium sized regular expre

Re: off topic but please forgive me me and answer

2010-04-02 Thread Steven D'Aprano
On Fri, 02 Apr 2010 12:35:55 -0700, Mensanator wrote: >> If you want an exact result when multiplying arbitrary fractions, you >> need to avoid floats and decimals and use Fractions: >> >> >>> Fraction(1, 2)**2 >> >> Fraction(1, 4) > > Where do you get that from? Where do I get what from? Fracti

Re: C-style static variables in Python?

2010-04-02 Thread kj
In Duncan Booth writes: >class Spam(object): > mongo = None > def __call__(self, x, y, z): > if self.mongo is None: > self.mongo = heavy_lifting_at_runtime() > return frobnicate(x, y, z, self.mongo) >spam = Spam() >ham = spam(1, 2, 3) I really like this. Thanks. >T

Re: Splitting a string

2010-04-02 Thread Patrick Maupin
On Apr 2, 4:32 pm, Peter Otten <__pete...@web.de> wrote: > _split = re.compile(r"(\d+)").split > def split(s): >     if not s: >         return () >     parts = _split(s) >     parts[1::2] = map(int, parts[1::2]) >     if parts[-1] == "": >         del parts[-1] >     if parts[0] == "": >        

Re: Getting Local MAC Address

2010-04-02 Thread Steve Holden
Booter wrote: > Hello all, > > I am new to python ans was wondering if there was a way to get the mac > address from the local NIC? > > Thanks for your help. > >>> import uuid >>> uuid.getnode() 246090452741227L >>> This is supposed to return the MAC address, but I am not sure it does. The docu

Re: off topic but please forgive me me and answer

2010-04-02 Thread Dave Angel
Mensanator wrote: On Apr 1, 9:44 pm, Steven D'Aprano wrote: 1/2.0 0.25 If you want an exact result when multiplying arbitrary fractions, you need to avoid floats and decimals and use Fractions: Fraction(1, 2)**2 Fraction(1, 4) Where do you get that

Re: Getting Local MAC Address

2010-04-02 Thread Michael Torrie
On 04/02/2010 02:14 PM, Booter wrote: > I am new to python ans was wondering if there was a way to get the mac > address from the local NIC? As Dan has indicated, you have to Popen an external command to get this information. Every OS has different commands and syntaxes for this. You'll have to h

Re: Getting Local MAC Address

2010-04-02 Thread Michael Torrie
On 04/02/2010 03:30 PM, Dan McLeran wrote: > i'm running python 2.6 on win xp sp3 and i get: Your code isn't portable to non-Windows OS's. On my Mac and on my Linux workstations it simply doesn't work. Using '/usr/sbin/ifconfig' as the executable name in Popen does work, however. The OP didn't

Re: Splitting a string

2010-04-02 Thread Peter Otten
Thomas Heller wrote: > Thanks to all for these code snippets. Peter's solution is the winner - > most elegant and also the fastest. With an additional list comprehension > to remove the possible empty strings at the start and at the end I get > 16 us. Interesting is that Xavier's solution (whic

Re: Getting Local MAC Address

2010-04-02 Thread danmcle...@yahoo.com
On Apr 2, 2:52 pm, "danmcle...@yahoo.com" wrote: > On Apr 2, 2:14 pm, Booter wrote: > > > Hello all, > > > I am new to python ans was wondering if there was a way to get the mac > > address from the local NIC? > > > Thanks for your help. > > > Gerad > > for windows parse p.stdout.read(): > > impo

Re: Getting Local MAC Address

2010-04-02 Thread Irmen de Jong
On 2-4-2010 22:55, danmcle...@yahoo.com wrote: On Apr 2, 2:52 pm, "danmcle...@yahoo.com" wrote: On Apr 2, 2:14 pm, Booter wrote: Hello all, I am new to python ans was wondering if there was a way to get the mac address from the local NIC? Thanks for your help. Gerad for windows par

Re: Getting Local MAC Address

2010-04-02 Thread danmcle...@yahoo.com
On Apr 2, 2:52 pm, "danmcle...@yahoo.com" wrote: > On Apr 2, 2:14 pm, Booter wrote: > > > Hello all, > > > I am new to python ans was wondering if there was a way to get the mac > > address from the local NIC? > > > Thanks for your help. > > > Gerad > > for windows parse p.stdout.read(): > > impo

Re: Getting Local MAC Address

2010-04-02 Thread danmcle...@yahoo.com
On Apr 2, 2:14 pm, Booter wrote: > Hello all, > > I am new to python ans was wondering if there was a way to get the mac > address from the local NIC? > > Thanks for your help. > > Gerad for windows parse p.stdout.read(): import subprocess p = subprocess.Popen('ipconfig', shell = True, stdout =

Re: Is it possible to store data in a Python file in a way similar to Ruby's __END__ section?

2010-04-02 Thread Stephen Hansen
On 2010-04-02 13:08:00 -0700, Christopher Roach said: I have a script that I am working on to process a bunch of data. A good portion of the Tk-based GUI is driven by a large set of YAML data and I'd love to store that data inside of the script so that I can send just a single file to my colleag

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

2010-04-02 Thread Patrick Maupin
On Apr 2, 3:12 pm, kj wrote: > Is that for real???  It's the QWERTY rationale all over again.  Swell. Well, bearing in mind that everybody seems to have an agenda, so you can't (or shouldn't, anyway) take all your news from a single source, it may be that the common wisdom about the QWERTY thing

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

2010-04-02 Thread Ethan Furman
kj wrote: In Steve Holden writes: John Nagle wrote: Chris Rebert wrote: On Tue, Mar 30, 2010 at 8:40 AM, gentlestone wrote: Hi, how can I write the popular C/JAVA syntax in Python? Java example: return (a==b) ? 'Yes' : 'No' My first idea is: return ('No','Yes')[bool(a==b)] Is th

Re: Is it possible to store data in a Python file in a way similar to Ruby's __END__ section?

2010-04-02 Thread Martin v. Loewis
Christopher Roach wrote: > I have a script that I am working on to process a bunch of data. A > good portion of the Tk-based GUI is driven by a large set of YAML data > and I'd love to store that data inside of the script so that I can > send just a single file to my colleague. Ruby has a mechanism

Re: C-style static variables in Python?

2010-04-02 Thread Patrick Maupin
On Apr 2, 3:33 pm, Ethan Furman wrote: > My main point, though, was using __call__, and not some weird _ method.  ;) Yes, __call__ is good. In general, not naming things that don't need to be named is good (but if you have too many of them to keep track of, then, obviously, they need to be named

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

2010-04-02 Thread Steve Holden
kj wrote: > In Steve Holden > writes: > >> John Nagle wrote: >>> Chris Rebert wrote: On Tue, Mar 30, 2010 at 8:40 AM, gentlestone wrote: > Hi, how can I write the popular C/JAVA syntax in Python? > > Java example: >return (a==b) ? 'Yes' : 'No' > > My first

Re: C-style static variables in Python?

2010-04-02 Thread Ethan Furman
Patrick Maupin wrote: [snippage] Well, I think the whole discussion has basically been about personal preference. OTOH, but if you call the function a few million times, you might find the cost of try/except to be something that you would rather not incur -- it might become a performance issue

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

2010-04-02 Thread John Bokma
kj writes: > Anyway, I don't know of any other language that puts the test > between the alternatives. No doubt there's one out there, with > emphasis on "out there"... Perl has something that has IMO somewhat the same problem: print "Hello, world!\n" if $some_condition; I prefer most of the

Getting Local MAC Address

2010-04-02 Thread Booter
Hello all, I am new to python ans was wondering if there was a way to get the mac address from the local NIC? Thanks for your help. Gerad -- http://mail.python.org/mailman/listinfo/python-list

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

2010-04-02 Thread kj
In Steve Holden writes: >John Nagle wrote: >> Chris Rebert wrote: >>> On Tue, Mar 30, 2010 at 8:40 AM, gentlestone >>> wrote: Hi, how can I write the popular C/JAVA syntax in Python? Java example: return (a==b) ? 'Yes' : 'No' My first idea is: return ('

Is it possible to store data in a Python file in a way similar to Ruby's __END__ section?

2010-04-02 Thread Christopher Roach
I have a script that I am working on to process a bunch of data. A good portion of the Tk-based GUI is driven by a large set of YAML data and I'd love to store that data inside of the script so that I can send just a single file to my colleague. Ruby has a mechanism for doing this whereby I can loa

Re: Splitting a string

2010-04-02 Thread Thomas Heller
Patrick Maupin schrieb: > On Apr 2, 6:24 am, Peter Otten <__pete...@web.de> wrote: >> Thomas Heller wrote: >> > Maybe I'm just lazy, but what is the fastest way to convert a string >> > into a tuple containing character sequences and integer numbers, like >> > this: >> >> > 'si_pos_99_rep_1_0.ita'

Re: C-style static variables in Python?

2010-04-02 Thread Patrick Maupin
On Apr 2, 2:38 pm, Ethan Furman wrote: > Patrick Maupin wrote: > > On Apr 2, 1:21 pm, Ethan Furman wrote: > >> For this type of situation, my preference would be: > > >> class spam(object): > >>      def __call__(self, x, y, z): > >>          try: > >>              mongo = self.mongo > >>        

Re: off topic but please forgive me me and answer

2010-04-02 Thread Mensanator
On Apr 1, 9:44 pm, Steven D'Aprano wrote: > On Thu, 01 Apr 2010 19:49:43 -0500, Tim Chase wrote: > > David Robinow wrote: > >> $ python -c "print 1/2 * 1/2" > >> 0 > > >>  But that's not what I learned in grade school. > >> (Maybe I should upgrade to 3.1?) > > > That's because you need to promote

Re: off topic but please forgive me me and answer

2010-04-02 Thread Patrick Maupin
On Apr 2, 2:41 pm, Andreas Waldenburger wrote: > While everyone else is mocking you: Can you please elaborate on why you > want to know and what kind of problem you're trying to solve with this? > Also, don't you think you should have picked a maths forum for this > kind of question? Methinks th

Re: C-style static variables in Python?

2010-04-02 Thread Ethan Furman
Patrick Maupin wrote: On Apr 2, 1:21 pm, Ethan Furman wrote: For this type of situation, my preference would be: class spam(object): def __call__(self, x, y, z): try: mongo = self.mongo except AttributeError: mongo = self.mongo = heavy_lifting_a

Re: How to run python without python

2010-04-02 Thread John Bokma
"danmcle...@yahoo.com" writes: > On Apr 2, 11:23 am, Chris Rebert wrote: >> On Fri, Apr 2, 2010 at 10:09 AM, danmcle...@yahoo.com >> >> wrote: >> > On Apr 1, 5:54 pm, Chris Rebert wrote: >> >> On Thu, Apr 1, 2010 at 4:46 PM, Krister Svanlund >> >> wrote: >> >> > On Fri, Apr 2, 2010 at 1:36 AM

Re: folks, what's wrong with this?

2010-04-02 Thread John Nagle
Bruno Desthuilliers wrote: And now for the most import point: __getattr__ is only called as a *last* resort. That is, after the attribute lookup mechanism will have tried *and failed* to find the name in the instance's __dict__. In general, "getattr" is for unusual situations only. If you w

Re: plagiarism, no follow-ups please

2010-04-02 Thread Steve Holden
purple wrote: > On 4/2/2010 7:36 AM, Chip Eastham wrote: >> On Apr 2, 6:14 am, A Serious Moment >> cross-posted >> an OCR'd version of a 1980 paper >> by SR Mahaney, mutilating the text >> further to remove its attribution >> and create the false impression of >> authorship by the (im)poster. >

Re: off topic but please forgive me me and answer

2010-04-02 Thread Andreas Waldenburger
On Thu, 01 Apr 2010 22:44:51 +0200 superpollo wrote: > how much is one half times one half? While everyone else is mocking you: Can you please elaborate on why you want to know and what kind of problem you're trying to solve with this? Also, don't you think you should have picked a maths forum f

Re: C-style static variables in Python?

2010-04-02 Thread Steven D'Aprano
On Fri, 02 Apr 2010 16:08:42 +, kj wrote: > Other responses advocated for global variables. I avoid them in > general, In general this is wise, but remember that because Python globals are not globally global, but local to a single module, they're safer than globals in other languages. St

Re: C-style static variables in Python?

2010-04-02 Thread Patrick Maupin
On Apr 2, 1:21 pm, Ethan Furman wrote: > For this type of situation, my preference would be: > > class spam(object): >      def __call__(self, x, y, z): >          try: >              mongo = self.mongo >          except AttributeError: >              mongo = self.mongo = heavy_lifting_at_runtime(

Re: subclass of object

2010-04-02 Thread Ethan Furman
Steve Holden wrote: Alf P. Steinbach wrote: * Jason Friedman: Hi, what is the difference between: def MyClass(object): pass and def MyClass(): pass If you really meant 'def', then the first is a routine taking one argument, and the second is a routine of no arguments. If you meant

6th Int. Conf. on Technology and Medical Sciences – Announce & Call for Papers

2010-04-02 Thread tava...@fe.up.pt
Dear Colleague, We are pleased to announce the TMSi2010 – 6th International Conference on Technology and Medical Sciences (www.fe.up.pt/tmsi2010) that will be held at the Faculty of Engineering of University of Porto, Porto, Portugal, on October 21-23, 2010. Possible Topics (but not limited to)

Re: C-style static variables in Python?

2010-04-02 Thread Ethan Furman
kj wrote: class _Spam(object): @classmethod def _(cls, x, y, z): try: mongo = cls.mongo except AttributeError: mongo = cls.mongo = heavy_lifting_at_runtime() return frobnicate(x, y, z, mongo) ham = _Spam._(1, 2, 3) Is this really more n

"JOBS IN ALABAMA" "ALABAMA JOBS" "ACCOUNTS JOBS IN ALABAMA" "FINANCE JOBS IN ALABAMA" ON http://jobsinalabama-usa.blogspot.com/ "USA JOBS" "JOBS IN USA" "JOBS IN USA STATES" "MEDICAL JOBS IN ALABAMA"

2010-04-02 Thread saima81
"JOBS IN ALABAMA" "ALABAMA JOBS" "ACCOUNTS JOBS IN ALABAMA" "FINANCE JOBS IN ALABAMA" ON http://jobsinalabama-usa.blogspot.com/ "USA JOBS" "JOBS IN USA" "JOBS IN USA STATES" "MEDICAL JOBS IN ALABAMA""JOBS IN ALABAMA" "ALABAMA JOBS" "ACCOUNTS JOBS IN ALABAMA" "FINANCE JOBS IN ALABAMA" ON http://

Re: C-style static variables in Python?

2010-04-02 Thread Duncan Booth
kj wrote: > I suppose one could refactor this: > > > def spam(x, y, z): > try: > mongo = spam.mongo > except AttributeError: > mongo = spam.mongo = heavy_lifting_at_runtime() > return frobnicate(x, y, z, mongo) > > ham = spam(3, 4, 5) > > > into this: > > > class

Re: C-style static variables in Python?

2010-04-02 Thread Mel
kj wrote: > In Steve Holden > writes: > >>But the real problem is that the OP is insisting on using purely >>procedural Python when the problem is screaming for an object-oriented >>answer. > > My initial reaction to this comment was something like "What? switch > from procedural to OO just to

Re: C-style static variables in Python?

2010-04-02 Thread Paul McGuire
On Apr 1, 5:34 pm, kj wrote: > When coding C I have often found static local variables useful for > doing once-only run-time initializations.  For example: > Here is a decorator to make a function self-aware, giving it a "this" variable that points to itself, which you could then initialize from

Re: How to run python without python

2010-04-02 Thread danmcle...@yahoo.com
On Apr 2, 11:23 am, Chris Rebert wrote: > On Fri, Apr 2, 2010 at 10:09 AM, danmcle...@yahoo.com > > wrote: > > On Apr 1, 5:54 pm, Chris Rebert wrote: > >> On Thu, Apr 1, 2010 at 4:46 PM, Krister Svanlund > >> wrote: > >> > On Fri, Apr 2, 2010 at 1:36 AM, Spencer > >> > wrote: > >> >> Is there

Re: How to run python without python

2010-04-02 Thread Chris Rebert
On Fri, Apr 2, 2010 at 10:09 AM, danmcle...@yahoo.com wrote: > On Apr 1, 5:54 pm, Chris Rebert wrote: >> On Thu, Apr 1, 2010 at 4:46 PM, Krister Svanlund >> wrote: >> > On Fri, Apr 2, 2010 at 1:36 AM, Spencer wrote: >> >> Is there a way to developing a script on linux and give it >> >> to someo

Re: How to run python without python

2010-04-02 Thread danmcle...@yahoo.com
On Apr 2, 11:09 am, "danmcle...@yahoo.com" wrote: > On Apr 1, 5:54 pm, Chris Rebert wrote: > > > > > On Thu, Apr 1, 2010 at 4:46 PM, Krister Svanlund > > > wrote: > > > On Fri, Apr 2, 2010 at 1:36 AM, Spencer wrote: > > >> Is there a way to developing a script on linux and give it > > >> to som

Re: How to run python without python

2010-04-02 Thread danmcle...@yahoo.com
On Apr 1, 5:54 pm, Chris Rebert wrote: > On Thu, Apr 1, 2010 at 4:46 PM, Krister Svanlund > > wrote: > > On Fri, Apr 2, 2010 at 1:36 AM, Spencer wrote: > >> Is there a way to developing a script on linux and give it > >> to someone on microsoft, so that they could run it on microsoft > >> withou

Re: PyGame migrating to JavaScript

2010-04-02 Thread Jose Manuel
On Apr 2, 3:19 am, Gary Herron wrote: > Xavier Ho wrote: > >  Javascript in recent years has been getting better and better, and > > >      now is a way better language than python. So to keep up with the > >      times pygame has been rewritten for javascript. > > > *shudders* > > > Can someone c

Re: PyGame migrating to JavaScript

2010-04-02 Thread Chris Rebert
On Fri, Apr 2, 2010 at 1:23 AM, Xavier Ho wrote: > On Fri, Apr 2, 2010 at 6:19 PM, Gary Herron wrote: >> It's a joke -- see http://en.wikipedia.org/wiki/April_Fools%27_Da > > D'oh! > > Can't believe that got me. > > (It's already 2nd of April... you're not supposed to make that joke now! =p) He'

Re: C-style static variables in Python?

2010-04-02 Thread kj
In Steve Holden writes: >But the real problem is that the OP is insisting on using purely >procedural Python when the problem is screaming for an object-oriented >answer. My initial reaction to this comment was something like "What? switch from procedural to OO just to be able to do some one-t

Re: I'm not sure you understand

2010-04-02 Thread Chris Colbert
On Fri, Apr 2, 2010 at 11:35 AM, A Serious Moment wrote: > Do you really not see the complete absurdity of posting an entire paper in this forum as plain text? Not only are you completely off-topic for this group, but the paper as you posted it is completely unreadable; regardless of whether i

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

2010-04-02 Thread Steven D'Aprano
On Fri, 02 Apr 2010 07:05:49 -0700, Steve Howell wrote: >> How is the ternary operator "not really ternary, it's binary"? It >> requires three arguments, not two, which makes it ternary. In Python >> syntax: >> > Of course, I understand that the ternary operator has three arguments, > but it only

Re: plagiarism, no follow-ups please

2010-04-02 Thread purple
On 4/2/2010 7:36 AM, Chip Eastham wrote: On Apr 2, 6:14 am, A Serious Moment cross-posted an OCR'd version of a 1980 paper by SR Mahaney, mutilating the text further to remove its attribution and create the false impression of authorship by the (im)poster. You report, we decide? Fox News has

Re: Splitting a string

2010-04-02 Thread Bearophile
I don't know how fast this is (Python 2.x): >>> from itertools import groupby >>> t = 'si_pos_99_rep_1_0.ita' >>> tuple(int("".join(g)) if h else "".join(g) for h,g in groupby(t, >>> str.isdigit)) ('si_pos_', 99, '_rep_', 1, '_', 0, '.ita') It doesn't work with unicode strings. Bye, bearophile

I'm not sure you understand

2010-04-02 Thread A Serious Moment
On Apr 2, 5:36 am, Chip Eastham wrote: > On Apr 2, 6:14 am, A Serious Moment > cross-posted > an OCR'd version of a 1980 paper > by SR Mahaney, mutilating the text > further to remove its attribution > and create the false impression of > authorship by the (im)poster. I'm afraid you misunderstan

Re: off topic but please forgive me me and answer

2010-04-02 Thread Stefan Behnel
Patrick Maupin, 02.04.2010 07:25: On Apr 1, 11:52 pm, Dennis Lee Bieber wrote: On Thu, 01 Apr 2010 22:44:51 +0200, superpollo declaimed the following in gmane.comp.python.general: how much is one half times one half? import math print math.exp((math.log(1) - math.log(2))

Re: Splitting a string

2010-04-02 Thread Terry Reedy
On 4/2/2010 6:21 AM, Shashwat Anand wrote: >>> s = 'si_pos_99_rep_1_0.ita' >>> res = tuple(re.split(r'(\d+)', s)) >>> res ('si_pos_', '99', '_rep_', '1', '_', '0', '.ita') This solves the core of the problem, but is not quite there ;-). Thomas requested conversion of int literals to ints, wh

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

2010-04-02 Thread Steve Howell
On Apr 2, 7:52 am, Tim Chase wrote: > Steve Howell wrote: > > I forgot this one: > > > def obfuscated_triager(rolls, pins, > >         lookup = ['normal'] * 10 + ['strike'] + [None] * 9 + ['spare'] > >         ): > >     return lookup[rolls * pins] > > Bah...no need to be _quite_ so obscure: >    

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

2010-04-02 Thread Tim Chase
Steve Howell wrote: I forgot this one: def obfuscated_triager(rolls, pins, lookup = ['normal'] * 10 + ['strike'] + [None] * 9 + ['spare'] ): return lookup[rolls * pins] Bah...no need to be _quite_ so obscure: def triager(rolls, pins): return { (1, 10):'strike',

Re: Dynamic Class Creation

2010-04-02 Thread Aahz
In article <8d79f0cb-9c5b-4243-8891-a15fb311f...@z18g2000prh.googlegroups.com>, Josh English wrote: > > >Analog Science Fiction and Fact >Analog >Science Fiction >First Contact >Hard Science Fiction > >Stanley Schmidt, Editor >267 Broadway, 4th Floor >

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

2010-04-02 Thread Steve Howell
On Apr 2, 7:21 am, Steve Holden wrote: > Steve Howell wrote: > > On Apr 2, 2:04 am, Steven D'Aprano > cybersource.com.au> wrote: > [...] > >> How is the ternary operator "not really ternary, it's binary"? It > >> requires three arguments, not two, which makes it ternary. In Python > >> syntax: >

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

2010-04-02 Thread Steve Howell
On Apr 2, 7:05 am, Steve Howell wrote: > On Apr 2, 2:04 am, Steven D'Aprano > > > cybersource.com.au> wrote: > > On Thu, 01 Apr 2010 21:16:18 -0700, Steve Howell wrote: > > > The ironic thing about the ternary operator is that it is not really > > > ternary; it's binary.  Even just making an expr

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

2010-04-02 Thread Steve Holden
Steve Howell wrote: > On Apr 2, 2:04 am, Steven D'Aprano cybersource.com.au> wrote: [...] >> How is the ternary operator "not really ternary, it's binary"? It >> requires three arguments, not two, which makes it ternary. In Python >> syntax: >> > > Of course, I understand that the ternary operato

Re: off topic but please forgive me me and answer

2010-04-02 Thread Wanderer
On Apr 1, 7:34 pm, Patrick Maupin wrote: > On Apr 1, 4:42 pm, Tim Chase wrote: > > Uh, did you try it at the python prompt?   When I try it at the IPython prompt, I get Object 'how much is one half times one half' not found. -- http://mail.python.org/mailman/listinfo/python-list

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

2010-04-02 Thread Steve Howell
On Apr 2, 2:04 am, Steven D'Aprano wrote: > On Thu, 01 Apr 2010 21:16:18 -0700, Steve Howell wrote: > > The ironic thing about the ternary operator is that it is not really > > ternary; it's binary.  Even just making an expression from a binary > > operator inevitably leads to syntax hell. > > > T

Re: Splitting a string

2010-04-02 Thread Patrick Maupin
On Apr 2, 6:24 am, Peter Otten <__pete...@web.de> wrote: > Thomas Heller wrote: > > Maybe I'm just lazy, but what is the fastest way to convert a string > > into a tuple containing character sequences and integer numbers, like > > this: > > > 'si_pos_99_rep_1_0.ita'  -> ('si_pos_', 99, '_rep_', 1,

Re: CGI templating with python

2010-04-02 Thread Aaron Watters
On Apr 1, 11:19 am, KB wrote: > > Django will probably get you where you want to go the fastest: > > >    http://www.djangoproject.com/ > > > In particular, its admin interface will probably automatically generate a > > usable > > UI for you without your having to write many templates at all. > >

plagiarism, no follow-ups please

2010-04-02 Thread Chip Eastham
On Apr 2, 8:27 am, A Serious Moment cross-posted a 1980 paper by J. Hartmanis and S.R. Mahaney, falsely taking credit for their work. -- http://mail.python.org/mailman/listinfo/python-list

plagiarism, no follow-ups please

2010-04-02 Thread Chip Eastham
On Apr 2, 6:14 am, A Serious Moment cross-posted an OCR'd version of a 1980 paper by SR Mahaney, mutilating the text further to remove its attribution and create the false impression of authorship by the (im)poster. -- http://mail.python.org/mailman/listinfo/python-list

Re: subclass of object

2010-04-02 Thread Alf P. Steinbach
* Steve Holden: Alf P. Steinbach wrote: * Jason Friedman: Hi, what is the difference between: def MyClass(object): pass and def MyClass(): pass If you really meant 'def', then the first is a routine taking one argument, and the second is a routine of no arguments. If you meant 'cla

JSONBOT 0.1 released

2010-04-02 Thread Bart Thate
Introducing JSONBOT JSONBOT is a bot that stores all its data in json format. It runs on the Google Application Engine and can thus support wave, web and xmpp. Standalone programms are provided for IRC and console, the goal is to let both clientside and GAE side communicate through JSON either ove

For Peer Review

2010-04-02 Thread A Serious Moment
AN ESSAY ABOUT RESEARCH (fl) ON SPARSE NP COMPLETE SETS By M. Musatov The purpose of this paper is to review the origins and motivation for the conjecture sparse NP complete sets do not exist (unless ? NP) and to describe the development of the ideas and techniques leading to the recent solution of

Re: subclass of object

2010-04-02 Thread Steve Holden
Alf P. Steinbach wrote: > * Jason Friedman: >> Hi, what is the difference between: >> >> def MyClass(object): >> pass >> >> and >> >> def MyClass(): >> pass > > If you really meant 'def', then the first is a routine taking one > argument, and the second is a routine of no arguments. > > I

Re: associative array

2010-04-02 Thread Bernard Czenkusz
On Thu, 01 Apr 2010 11:57:11 +, Harishankar wrote: > On Wed, 31 Mar 2010 09:40:30 -0700, Javier Montoya wrote: > >> Dear all, >> >> I'm a newbie in python and would be acknowledge if somebody could shed >> some light on associative arrays. >> More precisely, I would like to create a multi-di

Re: subclass of object

2010-04-02 Thread Steve Holden
Jason Friedman wrote: > Hi, what is the difference between: > > def MyClass(object): > pass > > and > > def MyClass(): > pass In Python 3, nothing. In Python 2, the former gets you a subclass of object whereas the latter gets you an instance of , for compatibility with pre-2.2 versions.

Re: subclass of object

2010-04-02 Thread Alf P. Steinbach
* Jason Friedman: Hi, what is the difference between: def MyClass(object): pass and def MyClass(): pass If you really meant 'def', then the first is a routine taking one argument, and the second is a routine of no arguments. If you meant 'class' instead of 'def', then it depends o

Re: pynotify for python 3.1.. Help Please..

2010-04-02 Thread Jebagnana Das
Thank you for your reply. Unfortunately pynotify is not available as a .py file but as an .so (shared library) file. In both python 2.5 and 2.6 installations it can be found at /var/lib/python-support/python2.x/gtk-2.0/pynotify/__init__.py , _pynotify.so. I think it was written in native

  1   2   >