PyGame migrating to JavaScript

2010-04-02 Thread Peter Billam
Startling news from http://pygame.org/news.html : pygame rewritten for javascript - Apr 1, 2010 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. Please prepare

Re: PyGame migrating to JavaScript

2010-04-02 Thread Xavier Ho
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 convince me why that is a good idea at all? Any rationales? Cheers, -Xav -- http:/

Re: PyGame migrating to JavaScript

2010-04-02 Thread Gary Herron
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 convince me why that is a good idea at all? Any rationales? C

Re: PyGame migrating to JavaScript

2010-04-02 Thread Xavier Ho
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) Cheers, Xav

Re: folks, what's wrong with this?

2010-04-02 Thread Bruno Desthuilliers
Ani a écrit : Hi All: I am just a beginner in python. Can anyone please tell me what is wrong with this piece of code? Robert already addressed your problem, so I'll just comment on a couple other points: import copy class BaseDummyObject(object): def __init__(self): pass Th

Python and read archives?

2010-04-02 Thread durumdara
Hi!I want to make a multios (Win/Lin) Python based media catalog program, but I have a little problem with reading archives.Ok, Python supports zip and tar, but the world have more archives, like "rar", "7z", "tar.gz", "gz", etc.First I was happy with 7z.exe, because it is knows many formats, an

idle 2.x and unicode literals

2010-04-02 Thread Joe P. Cool
Hi, I'm working with Python 2.6.4 on Ubuntu 9.10 and noticed a difference between IDLE and command line python. If I enter an é (accented e, LATIN SMALL LETTER E WITH ACUTE) as a unicode string in command line python I get this: >>> u'é' u'\xe9' In IDLE 2.6.4 I get this: >>> u'é' u'\xc3\xa9'

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

2010-04-02 Thread Steven D'Aprano
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. > > There is a principle of programming that I would lik

pynotify for python 3.1.. Help Please..

2010-04-02 Thread Jebagnana Das
Hello all, I'm trying to display system notifications in ubuntu.. I've tested pynotify in python 2.6 and it's working fine.. I want to know if i can do the same with python 3? I tried but there is no module named pynotify error is displayed.. Any of your help would be much appreciated.. -

Splitting a string

2010-04-02 Thread Thomas Heller
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, '_', 0, '.ita') Thanks for ideas, Thomas -- http://mail.python.org/mailman/listinfo/python-li

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

2010-04-02 Thread Xavier Ho
Hi Jebamnana, You'll probably have to copy the pynotify contents to the Python 3.1 folder. (under Libs\site-packages). You should be able to find the folder in the Python 2.6 paths. Once you do that, you can try to use it. But I don't know if pynotify will be able to run with Python 3.1. For inst

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

2010-04-02 Thread Xavier Ho
On Fri, Apr 2, 2010 at 8:13 PM, Xavier Ho wrote: > Hi Jebamnana, > Jebagnana* Sorry. -Xav -- http://mail.python.org/mailman/listinfo/python-list

Hey Sci.Math, Musatov here. I know I've posted a lot of weird stuff trying to figure things out, but I really think I am onto something here and need some bright minds to have a look at this, comput

2010-04-02 Thread A Serious Moment
SPARSE COMPLETE SETS FOR NP: SOLUTION OF A CONJECTURE BY MARTIN MICHAEL MUSATOV * for llP: Sparse Comp1ete Sets Solution of a Conjecture In this paper we show if NP has a sparse complete set under many-one reductions, then ? NP. The result is extended to show NP is sparse reducible, then P = ip

subprocess.Popen objects: how to ensure that stdin is closed

2010-04-02 Thread Harishankar
I am writing a small app which requires input using stdin to the subprocess. I use the following technique: proc = subprocess.Popen (cmdargs, stdin=subprocess.PIPE) proc.stdin.write ("Something") proc.stdin.flush () ... proc.stdin.write ("something else") proc.stdin.flush () ... and so on. I c

Re: Splitting a string

2010-04-02 Thread Shashwat Anand
>>> s = 'si_pos_99_rep_1_0.ita' >>> res = tuple(re.split(r'(\d+)', s)) >>> res ('si_pos_', '99', '_rep_', '1', '_', '0', '.ita') >>> On Fri, Apr 2, 2010 at 3:42 PM, Thomas Heller wrote: > Maybe I'm just lazy, but what is the fastest way to convert a string > into a tuple containing character se

Re: Splitting a string

2010-04-02 Thread Xavier Ho
Best I can come up with: >>> def split_number(string): ... output = [string[0]] ... for character in string[1:]: ... if character.isdigit() != output[-1].isdigit(): ... output.append('') ... output[-1] += character ... return tuple(output) ... >>> split_numb

Re: subprocess.Popen objects: how to ensure that stdin is closed

2010-04-02 Thread Harishankar
On Fri, 02 Apr 2010 10:17:55 +, Harishankar wrote: > I am writing a small app which requires input using stdin to the > subprocess. > > I use the following technique: > > proc = subprocess.Popen (cmdargs, stdin=subprocess.PIPE) > > proc.stdin.write ("Something") > proc.stdin.flush () > ...

Re: Hey Sci.Math, Musatov here. I know I've posted a lot of weird stuff trying to figure things out, but I really think I am onto something here and need some bright minds to have a look at this, co

2010-04-02 Thread Xavier Ho
On Fri, Apr 2, 2010 at 8:14 PM, A Serious Moment wrote: > SPARSE COMPLETE SETS FOR NP: > SOLUTION OF A CONJECTURE > BY MARTIN MICHAEL MUSATOV * > > for llP: > > Sparse Comp1ete Sets > Solution of a Conjecture > Hi, If you're serious about this posting, could you please: 1) Provide a link to a P

Re: Splitting a string

2010-04-02 Thread Xavier Ho
Oops, minor update: >>> def split_number(string): ... output = [string[0]] ... for character in string[1:]: ... if character.isdigit() != output[-1].isdigit(): ... if output[-1].isdigit() is True: ... output[-1] = int(output[-1]) ... output.a

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

2010-04-02 Thread Shashwat Anand
I guess it is a 3rd party module. Run setup.py with python3.1, however it can happen that the module is not python3 compatible. In that case try using 2to3 if you can. On Fri, Apr 2, 2010 at 3:43 PM, Xavier Ho wrote: > On Fri, Apr 2, 2010 at 8:13 PM, Xavier Ho wrote: > >> Hi Jebamnana, >> > > J

Re: Splitting a string

2010-04-02 Thread Alex Willmer
On Apr 2, 11:12 am, 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, '_', 0, '.ita') > This is very probably not the

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

2010-04-02 Thread Duncan Booth
Steven D'Aprano wrote: > Yes, I agree, we should be using the previously well known syntax: > > condition -> value_if_true, value_if_false > > which was introduced by BCPL in 1966. > What, not this? VALOF TEST condition THEN RESULTIS value_if_true ELSE RESULTIS value_if_false which was also

Re: Splitting a string

2010-04-02 Thread Peter Otten
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, '_', 0, '.ita') >>> parts = re.compile("([+-]?\d+)").split('s

subclass of object

2010-04-02 Thread Jason Friedman
Hi, what is the difference between: def MyClass(object): pass and def MyClass(): pass -- http://mail.python.org/mailman/listinfo/python-list

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

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: 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: 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
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

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

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

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

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

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

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. > >

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: (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: 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 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: (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 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: 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 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: (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: 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: 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))

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: 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

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: (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: 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: 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: 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: 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: 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: 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 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: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: 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: 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 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

"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 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

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: 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

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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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'

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: (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 ('

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 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

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 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 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: 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: (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: (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: 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: 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: 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: 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 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: 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: 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 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: 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: 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: 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: 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

  1   2   >