Re: Getting a Python program to run of off a flash drive?

2010-04-01 Thread timo verbeek
On Apr 1, 12:48 am, Abethebabe wrote: > I wanted to know if there was a way I could get a Python program to > run off of my flash drive as soon as the computer (Windows) detected > the device? > > For example I could have a a simple program that would create a text > document on the computers desk

String Formatting Operations for decimals.

2010-04-01 Thread Lacrima
Hello! I need to format a decimal (floating point) number in the following way: 10 results in '10' 10.5 results in '10.5' 10.50 results in '10.5' 10.5678 results in 10.57 How can I achieve this using standard Python string formatting operations? Something like '%.2f' works almost as expected: >>>

Re: String Formatting Operations for decimals.

2010-04-01 Thread Chris Rebert
On Thu, Apr 1, 2010 at 2:08 AM, Lacrima wrote: > Hello! > > I need to format a decimal (floating point) number in the following > way: > 10 results in '10' > 10.5 results in '10.5' > 10.50 results in '10.5' > 10.5678 results in 10.57 > > How can I achieve this using standard Python string formatti

Re: String Formatting Operations for decimals.

2010-04-01 Thread Xavier Ho
Hi Maxim, If it's the trailing zeroes you're concerned about, here's a work-around: >>> ('%.2f' % 10.5678).rstrip('0') '10.57 I'm sure there are better solutions. But this one works for your need, right? Cheers,' Ching-Yun Xavier Ho, Technical Artist Contact Information Mobile: (+61) 04 3335

Re: Generating text from a regular expression

2010-04-01 Thread Gabriel Genellina
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 expression and I want to generate all possible words that it can match (to compare performance of regex against an acora based matcher). T

Re: String Formatting Operations for decimals.

2010-04-01 Thread Maxim Lacrima
Hello, Chris! Thanks for your really quick reply! It works! On 1 April 2010 12:14, Chris Rebert wrote: > On Thu, Apr 1, 2010 at 2:08 AM, Lacrima wrote: > > Hello! > > > > I need to format a decimal (floating point) number in the following > > way: > > 10 results in '10' > > 10.5 results in '1

Re: Python + OpenOffice Calc

2010-04-01 Thread egl...@gmail.com
On Apr 1, 6:53 am, rantingrick wrote: > > 3 fields: quantity - description of the piece bought - price > > So what is your plan...? >   * Pop up a dialog with three entrys, >   * have him fill out the three entrys, >   * then have python insert the data into the spreadsheet? > ...Why bother messi

Q: We have *args and **kwargs. Woud ***allargs be useful?

2010-04-01 Thread Jonathan Fine
The idioms def f(*args, **kwargs): # Do something. and args = (1, 2, 3) kwargs = dict(a=4, b=5) g(*args, **kwargs) are often useful in Python. I'm finding myself picking up /all/ the arguments and storing them for later use (as part of a testing framework). So for me it

Developement Question?

2010-04-01 Thread Wayne
My town office uses Microsoft operating system. They have a proprietary accounting system that uses excel for their accounting reports. I would like to read these report and reproduce the report so that the report can be seen on the web. I was thinking about using xlrd and xlwt along with some sort

newbie with a encoding question, please help

2010-04-01 Thread Mister Yu
hi experts, i m new to python, i m writing crawlers to extract data from some chinese websites, and i run into a encoding problem. i have a unicode object, which looks like this u'\xd6\xd0\xce\xc4' which is encoded in "gb2312", but i have no idea of how to convert it back to utf-8 to re-create t

Re: associative array

2010-04-01 Thread Javier Montoya
On Mar 31, 7:36 pm, Gary Herron wrote: > JavierMontoyawrote: > > 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-dimensional associative > > array. I have for example a l

Re: associative array

2010-04-01 Thread Chris Rebert
On Thu, Apr 1, 2010 at 3:58 AM, Javier Montoya wrote: > On Mar 31, 7:36 pm, Gary Herron wrote: >> JavierMontoyawrote: >> > 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

Re: newbie with a encoding question, please help

2010-04-01 Thread Chris Rebert
2010/4/1 Mister Yu : > hi experts, > > i m new to python, i m writing crawlers to extract data from some > chinese websites, and i run into a encoding problem. > > i have a unicode object, which looks like this u'\xd6\xd0\xce\xc4' > which is encoded in "gb2312", No! Instances of type 'unicode' (i.

Re: associative array

2010-04-01 Thread Peter Otten
Javier Montoya wrote: > Is it possible to sort the dictionary by the student's grades in > descending order? You cannot sort dictionaries, but you can put dictionary items into a list and then sort that. Assumming that you have a dictionary student_dict that maps student IDs to Student instanc

Re: newbie with a encoding question, please help

2010-04-01 Thread Mister Yu
On Apr 1, 7:22 pm, Chris Rebert wrote: > 2010/4/1 Mister Yu : > > > hi experts, > > > i m new to python, i m writing crawlers to extract data from some > > chinese websites, and i run into a encoding problem. > > > i have a unicode object, which looks like this u'\xd6\xd0\xce\xc4' > > which is enc

Re: associative array

2010-04-01 Thread Harishankar
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-dimensional associative > array. I have for example a list of stude

Re: newbie with a encoding question, please help

2010-04-01 Thread Chris Rebert
On Thu, Apr 1, 2010 at 4:38 AM, Mister Yu wrote: > On Apr 1, 7:22 pm, Chris Rebert wrote: >> 2010/4/1 Mister Yu : >> > hi experts, >> >> > i m new to python, i m writing crawlers to extract data from some >> > chinese websites, and i run into a encoding problem. >> >> > i have a unicode object, w

Re: newbie with a encoding question, please help

2010-04-01 Thread Stefan Behnel
Mister Yu, 01.04.2010 13:38: i m still not very sure how to convert a unicode object ** u'\xd6\xd0\xce\xc4 ** back to "中文" the string it supposed to be? You are confused. '\xd6\xd0\xce\xc4' is an encoded byte string, not a unicode string. The fact that you have it stored in a unicode string

Re: newbie with a encoding question, please help

2010-04-01 Thread Mister Yu
On Apr 1, 8:13 pm, Chris Rebert wrote: > On Thu, Apr 1, 2010 at 4:38 AM, Mister Yu wrote: > > On Apr 1, 7:22 pm, Chris Rebert wrote: > >> 2010/4/1 Mister Yu : > >> > hi experts, > > >> > i m new to python, i m writing crawlers to extract data from some > >> > chinese websites, and i run into a e

Re: decorators only when __debug__ == True

2010-04-01 Thread MRAB
Steven D'Aprano wrote: On Thu, 01 Apr 2010 00:27:51 +0100, MRAB wrote: A decorator shouldn't call the function it's decorating. *raises eyebrow* Surely, in the general case, a decorator SHOULD call the function it is decorating? I'm sure you know that, but your wording is funny and could conf

Re: Developement Question?

2010-04-01 Thread MRAB
Wayne wrote: My town office uses Microsoft operating system. They have a proprietary accounting system that uses excel for their accounting reports. I would like to read these report and reproduce the report so that the report can be seen on the web. I was thinking about using xlrd and xlwt along

Re: decorators only when __debug__ == True

2010-04-01 Thread Steve Holden
MRAB wrote: > Steven D'Aprano wrote: >> On Thu, 01 Apr 2010 00:27:51 +0100, MRAB wrote: >> > A decorator shouldn't call the function it's decorating. *raises eyebrow* Surely, in the general case, a decorator SHOULD call the function it is decorating? I'm sure you know that,

Re: newbie with a encoding question, please help

2010-04-01 Thread Stefan Behnel
Mister Yu, 01.04.2010 14:26: On Apr 1, 8:13 pm, Chris Rebert wrote: gb2312_bytes = ''.join([chr(ord(c)) for c in u'\xd6\xd0\xce\xc4']) unicode_string = gb2312_bytes.decode('gb2312') utf8_bytes = unicode_string.encode('utf-8') #as you wanted Simplifying this hack a bit: gb2312_bytes = u'\x

Python 3.1, object, and setattr()

2010-04-01 Thread Ethan Furman
Greetings! Perhaps I woke up too early this morning, but this behaviour has me baffled: Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. --> test = object() --> setattr(test, 'example'

Re: sorting ascending/descending with operator.attrgetter

2010-04-01 Thread Patrick Maupin
On Apr 1, 1:54 am, Steven D'Aprano wrote: > At the risk of offending you further, I will suggest that I'm not the > only one who needs to apply some introspection here. If your skin is so > thin that you react so explosively to such a minor slight, how are you > going to react to some of the more

Re: decorators only when __debug__ == True

2010-04-01 Thread Steve Howell
On Apr 1, 6:16 am, Steve Holden wrote: > MRAB wrote: > > > I had the following idea: define the terms 'decorator', 'decoration' and > > 'decoratee'. The decorator applies the decoration to the decoratee. The > > decoratee is the function defined locally in the decorator. > > It would make more sen

Re: Python 3.1, object, and setattr()

2010-04-01 Thread Steve Howell
On Apr 1, 6:46 am, Ethan Furman wrote: > Greetings! > > Perhaps I woke up too early this morning, but this behaviour has me baffled: > > Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit > (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information.

Re: Python 3.1, object, and setattr()

2010-04-01 Thread Steve Holden
Ethan Furman wrote: > Greetings! > > Perhaps I woke up too early this morning, but this behaviour has me > baffled: > > Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit > (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > > --> test =

Re: sorting ascending/descending with operator.attrgetter

2010-04-01 Thread Patrick Maupin
On Apr 1, 12:50 am, Steve Holden wrote: > > I can well imagine that everybody who has to work with you thoroughly > >  enjoys proving you wrong as often as possible. > > I am glad I wasn't drinking when I read this. Liquid in one's nose is so > uncomfortable. Well, in that case, I'm glad you enjo

Re: Python 3.1, object, and setattr()

2010-04-01 Thread Steve Holden
Ethan Furman wrote: > Greetings! > > Perhaps I woke up too early this morning, but this behaviour has me > baffled: > > Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit > (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > > --> test =

Re: CGI templating with python

2010-04-01 Thread Someone Something
Cheetah would work, but it would be a major pain to debug (I hate those 500 Server Error pages) something django (as mentioned above) or turbogears (with Kid) would get you rolling quickly. On Wed, Mar 31, 2010 at 8:38 PM, KB wrote: > Hi there, > > Years ago I wrote a LAMP app using python. I fi

Re: newbie with a encoding question, please help

2010-04-01 Thread Mister Yu
On Apr 1, 9:31 pm, Stefan Behnel wrote: > Mister Yu, 01.04.2010 14:26: > > > On Apr 1, 8:13 pm, Chris Rebert wrote: > >> gb2312_bytes = ''.join([chr(ord(c)) for c in u'\xd6\xd0\xce\xc4']) > >> unicode_string = gb2312_bytes.decode('gb2312') > >> utf8_bytes = unicode_string.encode('utf-8') #as you w

Re: sort array, apply rearrangement to second

2010-04-01 Thread Steve Howell
On Mar 31, 1:09 pm, Raymond Hettinger wrote: > On Mar 30, 4:25 pm, s...@sig.for.address (Victor Eijkhout) wrote: > > > I have two arrays, made with numpy. The first one has values that I want > > to use as sorting keys; the second one needs to be sorted by those keys. > > Obviously I could turn th

Re: CGI templating with python

2010-04-01 Thread KB
> 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. Robert, Thank you very very much. I had a

Re: Developement Question?

2010-04-01 Thread KB
On Apr 1, 3:34 am, Wayne wrote: > My town office uses Microsoft operating system. They have a proprietary > accounting system that uses excel for their accounting reports. > I would like to read these report and reproduce the report so that > the report can be seen on the web. I was thinking about

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

2010-04-01 Thread Den
On Mar 30, 10:56 am, Steve Holden wrote: > 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: >

Re: Q: We have *args and **kwargs. Woud ***allargs be useful?

2010-04-01 Thread Jon Clements
On 1 Apr, 10:57, Jonathan Fine wrote: > The idioms >      def f(*args, **kwargs): >          # Do something. > and >      args = (1, 2, 3) >      kwargs = dict(a=4, b=5) >      g(*args, **kwargs) > are often useful in Python. > > I'm finding myself picking up /all/ the arguments and storing them f

Re: subprocess only good for win32?

2010-04-01 Thread wukong
On Mar 31, 3:47 pm, "Martin v. Loewis" wrote: > > WindowsError: [Error 14001] The application has failed to start > > because its side-by-side configuration is incorrect. Please see the > > application event log for more detail > > This is a configuration error on your system. The application you

Re: subprocess only good for win32?

2010-04-01 Thread wukong
On Mar 31, 3:47 pm, "Martin v. Loewis" wrote: > > WindowsError: [Error 14001] The application has failed to start > > because its side-by-side configuration is incorrect. Please see the > > application event log for more detail > > This is a configuration error on your system. The application you

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

2010-04-01 Thread Steve Holden
Den wrote: [...] > I've been following this thread for a few days now. My thoughts are > that, in view of a long known widely used syntax for this operator, > python's syntax seems like change for change sake. If current > programing paradigm provides that particular trinary operator, why > shoul

Re: Q: We have *args and **kwargs. Woud ***allargs be useful?

2010-04-01 Thread Jonathan Fine
Jon Clements wrote: I'm not sure this'll catch on, it'll be interesting to see other comments. However, I believe you can get the behaviour you desire something like: import inspect class AllArgs(object): def __init__(self, func): self._func = func self._spec = inspect.geta

Re: subprocess only good for win32?

2010-04-01 Thread Steve Holden
wukong wrote: > On Mar 31, 3:47 pm, "Martin v. Loewis" wrote: >>> WindowsError: [Error 14001] The application has failed to start >>> because its side-by-side configuration is incorrect. Please see the >>> application event log for more detail >> This is a configuration error on your system. The a

Re: decorators only when __debug__ == True

2010-04-01 Thread MRAB
Steve Holden wrote: MRAB wrote: Steven D'Aprano wrote: On Thu, 01 Apr 2010 00:27:51 +0100, MRAB wrote: A decorator shouldn't call the function it's decorating. *raises eyebrow* Surely, in the general case, a decorator SHOULD call the function it is decorating? I'm sure you know that, but yo

Re: subprocess only good for win32?

2010-04-01 Thread Michel Claveau - MVP
Hi! > side-by-side configuration is incorrect Others have given you an explanation. A possibility: you use a DLL directly, without having installed. That is OK with some DLL, and no OK with others DLL. @-salutations -- Michel Claveau -- http://mail.python.org/mailman/listinfo/python-list

"jobs in canada" "jobs in canada for pakistanis" "jobs in canada for foreigners" "jobs in canada hotels" "jobs in canada for accountants" "canada jobs" "canada job bank" on http://jobsincanada-net.

2010-04-01 Thread saima81
"jobs in canada" "jobs in canada for pakistanis" "jobs in canada for foreigners" "jobs in canada hotels" "jobs in canada for accountants" "canada jobs" "canada job bank" on http://jobsincanada-net.blogspot.com/ "jobs in canada" "jobs in canada for pakistanis" "jobs in canada for foreigners" "jobs

no module named exceptions?

2010-04-01 Thread Joaquin Abian
In python 3.1, >>> import exceptions Traceback (most recent call last): File "", line 1, in import exceptions ImportError: No module named exceptions in 2.6 no exception is raised It should be the same in 3.1, isnt it? Joaquin -- http://mail.python.org/mailman/listinfo/python-list

Re: no module named exceptions?

2010-04-01 Thread Shashwat Anand
There i no module named 'exceptions' in python 2.6 as well as python 3.1 What are you expecting ? On Thu, Apr 1, 2010 at 10:42 PM, Joaquin Abian wrote: > In python 3.1, > > >>> import exceptions > Traceback (most recent call last): > File "", line 1, in >import exceptions > ImportError: No

Re: no module named exceptions?

2010-04-01 Thread Tommy Grav
This is what he is expecting. Importing exceptions works fine in 2.6.4, not so in python 3.1. Python 2.6.4 (r264:75706, Nov 3 2009, 18:12:54) [GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import exceptions >>>

Re: Python 3.1, object, and setattr()

2010-04-01 Thread Terry Reedy
On 4/1/2010 10:16 AM, Steve Howell wrote: On Apr 1, 6:46 am, Ethan Furman wrote: On 2.6.2 the error seems to be limited to instances of object. If you subclass object, you are fine. I do not know why that is so; As the other Steve said, object is a built-in class; user-defined subclasses o

question on namedtuple

2010-04-01 Thread hetchkay
Hi, For purposes I don't want to go into here, I have the following code: def handleObj(obj): if isinstance(obj, MyType): return obj.handle() elif isinstance(obj, (list, tuple, set)): return obj.__class__(map (handleObj, obj)) elif isinstance(obj, dict): return obj.__class__((h

folks, what's wrong with this?

2010-04-01 Thread Ani
Hi All: I am just a beginner in python. Can anyone please tell me what is wrong with this piece of code? import copy class BaseDummyObject(object): def __init__(self): pass def __getattr__(self, item): try: return self.__dict__.__getitem__(item) excep

Re: Python 3.1, object, and setattr()

2010-04-01 Thread Ethan Furman
Many thanks for the replies, and especially for the very detailed explanation. Makes much more sense now. ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list

Re: folks, what's wrong with this?

2010-04-01 Thread Robert Kern
On 2010-04-01 13:56 PM, Ani wrote: Hi All: I am just a beginner in python. Can anyone please tell me what is wrong with this piece of code? import copy class BaseDummyObject(object): def __init__(self): pass def __getattr__(self, item): try: return sel

Re: no module named exceptions?

2010-04-01 Thread Chris Rebert
> On Thu, Apr 1, 2010 at 10:42 PM, Joaquin Abian wrote: >> In python 3.1, >> >> >>> import exceptions >> Traceback (most recent call last): >> File "", line 1, in >>import exceptions >> ImportError: No module named exceptions >> >> in 2.6 no exception is raised >> It should be the same in 3.

Re: question on namedtuple

2010-04-01 Thread Chris Rebert
On Thu, Apr 1, 2010 at 11:35 AM, hetchkay wrote: > Hi, > For purposes I don't want to go into here, I have the following code: > def handleObj(obj): >  if isinstance(obj, MyType): >     return obj.handle() >  elif isinstance(obj, (list, tuple, set)): >     return obj.__class__(map (handleObj, obj)

Re: no module named exceptions?

2010-04-01 Thread Gary Herron
Joaquin Abian wrote: In python 3.1, import exceptions Traceback (most recent call last): File "", line 1, in import exceptions ImportError: No module named exceptions in 2.6 no exception is raised It should be the same in 3.1, isnt it? Joaquin In 2.x, the exceptions m

Re: no module named exceptions?

2010-04-01 Thread Ned Deily
In article , Chris Rebert wrote: > > On Thu, Apr 1, 2010 at 10:42 PM, Joaquin Abian wrote: > >> In python 3.1, > >> > >> >>> import exceptions > >> Traceback (most recent call last): > >> File "", line 1, in > >>import exceptions > >> ImportError: No module named exceptions > >> > >> in

Re: question on namedtuple

2010-04-01 Thread Peter Otten
hetchkay wrote: > For purposes I don't want to go into here, I have the following code: > def handleObj(obj): > if isinstance(obj, MyType): > return obj.handle() > elif isinstance(obj, (list, tuple, set)): > return obj.__class__(map (handleObj, obj)) > elif isinstance(obj, dict): >

off topic but please forgive me me and answer

2010-04-01 Thread superpollo
how much is one half times one half? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python + OpenOffice Calc

2010-04-01 Thread rantingrick
On Apr 1, 4:38 am, "egl...@gmail.com" wrote: > Actually, a spreadsheet based solution isn't best fit for such a task. > I'd recommend to store the data in sqlite3 (also 100% pure python as > the module is in the stdlib). CSV is good for making invoices or > something like that. +1 -- http://mai

Re: subprocess only good for win32?

2010-04-01 Thread Piet van Oostrum
> wukong (w) wrote: >w> also subprocess.py clearly says >w> """ >w> import sys >w> mswindows = (sys.platform == "win32") >w> """ It may sound strange, but even in 64-bit Python on Win64, sys.plattform=="win32". You can check that subprocess is working, e.g. with subprocess.call('dir', she

Re: off topic but please forgive me me and answer

2010-04-01 Thread Tim Chase
superpollo wrote: how much is one half times one half? Uh, did you try it at the python prompt? If not, here's the answer: 0.1b * 0.1b = 0.01b Now all you need is to find the recent thread that converts binary floats to decimal floats ;-) -tkc -- http://mail.python.org/mailman/listinf

Re: folks, what's wrong with this?

2010-04-01 Thread Ani
On Apr 1, 12:10 pm, Robert Kern wrote: > On 2010-04-01 13:56 PM, Ani wrote: > > > > > Hi All: > > > I am just a beginner in python. Can anyone please tell me what is > > wrong with this piece of code? > > > import copy > > class BaseDummyObject(object): > > >      def __init__(self): > >          

Re: folks, what's wrong with this?

2010-04-01 Thread Robert Kern
On 2010-04-01 16:52 PM, Ani wrote: On Apr 1, 12:10 pm, Robert Kern wrote: On 2010-04-01 13:56 PM, Ani wrote: Hi All: I am just a beginner in python. Can anyone please tell me what is wrong with this piece of code? import copy class BaseDummyObject(object): def __init__(self):

C-style static variables in Python?

2010-04-01 Thread kj
When coding C I have often found static local variables useful for doing once-only run-time initializations. For example: int foo(int x, int y, int z) { static int first_time = TRUE; static Mongo *mongo; if (first_time) { mongo = heavy_lifting_at_runtime(); first_time = FALSE;

Re: C-style static variables in Python?

2010-04-01 Thread Chris Rebert
On Thu, Apr 1, 2010 at 3:34 PM, kj wrote: > When coding C I have often found static local variables useful for > doing once-only run-time initializations. > Another approach would be to stuff the static values in the function's > __dict__.  This is less satisfactory than the closure approach > be

Pydev 1.5.6 Released (Django Integration)

2010-04-01 Thread Fabio Zadrozny
Hi All, Pydev 1.5.6 has been released Details on Pydev: http://pydev.org Details on its development: http://pydev.blogspot.com Release Highlights: --- * Django integration: * New Django project can be created through wizards * Can set an existing project as

Re: C-style static variables in Python?

2010-04-01 Thread Steve Holden
Chris Rebert wrote: > On Thu, Apr 1, 2010 at 3:34 PM, kj wrote: >> When coding C I have often found static local variables useful for >> doing once-only run-time initializations. > >> Another approach would be to stuff the static values in the function's >> __dict__. This is less satisfactory th

Re: C-style static variables in Python?

2010-04-01 Thread Terry Reedy
On 4/1/2010 6:34 PM, kj wrote: When coding C I have often found static local variables useful for doing once-only run-time initializations. For example: int foo(int x, int y, int z) { static int first_time = TRUE; static Mongo *mongo; if (first_time) { mongo = heavy_lifting_at_

Re: C-style static variables in Python?

2010-04-01 Thread Patrick Maupin
On Apr 1, 6:10 pm, Steve Holden wrote: > Chris Rebert wrote: > > Personally, I hate such abuse with a passion; I think a global > > variable is clearest. > > But the real problem is that the OP is insisting on using purely > procedural Python when the problem is screaming for an object-oriented >

Re: off topic but please forgive me me and answer

2010-04-01 Thread Patrick Maupin
On Apr 1, 4:42 pm, Tim Chase wrote: > superpollo wrote: > > how much is one half times one half? > > Uh, did you try it at the python prompt?  If not, here's the answer: > >   0.1b * 0.1b = 0.01b > > Now all you need is to find the recent thread that converts > binary floats to decimal floats ;-)

How to run python without python

2010-04-01 Thread Spencer
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 without installing python? Wayne -- http://mail.python.org/mailman/listinfo/python-list

Re: How to run python without python

2010-04-01 Thread Krister Svanlund
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 > without installing python? > > Wayne > > -- > http://mail.python.org/mailman/listinfo/python-list > Short answer: No. --

Re: C-style static variables in Python?

2010-04-01 Thread Steve Holden
Terry Reedy wrote: > On 4/1/2010 6:34 PM, kj wrote: >> >> >> When coding C I have often found static local variables useful for >> doing once-only run-time initializations. For example: >> >> int foo(int x, int y, int z) { >> >>static int first_time = TRUE; >>static Mongo *mongo; >>if

Re: How to run python without python

2010-04-01 Thread Chris Rebert
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 >> without installing python? > > Short answer: No. Long answe

Re: off topic but please forgive me me and answer

2010-04-01 Thread David Robinow
On Thu, Apr 1, 2010 at 7:34 PM, Patrick Maupin wrote: > On Apr 1, 4:42 pm, Tim Chase wrote: >> superpollo wrote: >> > how much is one half times one half? >> >> Uh, did you try it at the python prompt?  If not, here's the answer: >> >>   0.1b * 0.1b = 0.01b >> >> Now all you need is to find the r

Good Intermediate Tutorials

2010-04-01 Thread Abethebabe
I've recently finished reading A Byte Of Python and have the basics of Python down. I want to continue practice but I'm unsure what I can do. So I started looking for tutorials to open my mind a little, but everything I come across are beginner tutorials that cover the same topics...over and over.

Re: off topic but please forgive me me and answer

2010-04-01 Thread Tim Chase
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 one of them to a float so you get a floating-point result: >>> 1/2 * 1/2 0 >>> 1/2 * 1/2.0 0.0 Oh...wait ;-) -tk

Browser-based MMOG web framework

2010-04-01 Thread Steve
Hi, I could use some advice on my project. It's a browser-based MMOG: "The High Seas" (working title) Basically it is a trading game set in 1600s or 1700s ... inspirations: Patrician 3, Mine Things, Space Rangers 2, ... Travel between cities takes several days: game updates trading ship position

Re: Good Intermediate Tutorials

2010-04-01 Thread rantingrick
On Apr 1, 7:25 pm, Abethebabe wrote: > I've recently finished reading A Byte Of Python and have the basics of > Python down. I want to continue practice but I'm unsure what I can do. > So I started looking for tutorials to open my mind a little, but > everything I come across are beginner tutorial

Re: C-style static variables in Python?

2010-04-01 Thread Alf P. Steinbach
* kj: When coding C I have often found static local variables useful for doing once-only run-time initializations. For example: int foo(int x, int y, int z) { static int first_time = TRUE; static Mongo *mongo; if (first_time) { mongo = heavy_lifting_at_runtime(); first_time = FAL

Re: off topic but please forgive me me and answer

2010-04-01 Thread Patrick Maupin
On Apr 1, 7:49 pm, 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 one of them to a float so you > get a floating-point result: > >    >

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

2010-04-01 Thread Steven D'Aprano
On Thu, 01 Apr 2010 08:27:53 -0700, Den wrote about Python's ternary operator: > I've been following this thread for a few days now. My thoughts are > that, in view of a long known widely used syntax for this operator, > python's syntax seems like change for change sake. If current > programing

Re: off topic but please forgive me me and answer

2010-04-01 Thread Steven D'Aprano
On Thu, 01 Apr 2010 19:55:27 -0400, David Robinow wrote: >>> superpollo wrote: >>> > how much is one half times one half? [...] > Well, my python says: > > $ 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?) Python 2.x defaul

Re: off topic but please forgive me me and answer

2010-04-01 Thread Steven D'Aprano
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 one of them to a float so you get a > floating-point

Re: off topic but please forgive me me and answer

2010-04-01 Thread Lie Ryan
On 04/02/10 13:01, Patrick Maupin wrote: > On Apr 1, 7:49 pm, 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 one of them to a float

Re: Browser-based MMOG web framework

2010-04-01 Thread exarkun
On 01:14 am, srosbo...@gmail.com wrote: Hi, I could use some advice on my project. It's a browser-based MMOG: "The High Seas" (working title) Basically it is a trading game set in 1600s or 1700s ... inspirations: Patrician 3, Mine Things, Space Rangers 2, ... Travel between cities takes severa

Re: off topic but please forgive me me and answer

2010-04-01 Thread Patrick Maupin
On Apr 1, 9:50 pm, Lie Ryan wrote: > On 04/02/10 13:01, Patrick Maupin wrote: > > > > > On Apr 1, 7:49 pm, 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?) > > >> T

Re: off topic but please forgive me me and answer

2010-04-01 Thread David Robinow
On Thu, Apr 1, 2010 at 10: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 nee

Re: off topic but please forgive me me and answer

2010-04-01 Thread Tim Chase
Steven D'Aprano wrote: That's because you need to promote one of them to a float so you get a floating-point result: >>> 1/2 * 1/2 0 >>> 1/2 * 1/2.0 0.0 Oh...wait ;-) Tim, I'm sure you know the answer to this, but for the benefit of the Original Poster, the problem is that you ne

Re: C-style static variables in Python?

2010-04-01 Thread Paul Rubin
kj writes: > When coding C I have often found static local variables useful for > doing once-only run-time initializations. For example: > > int foo(int x, int y, int z) { > static int first_time = TRUE; > static Mongo *mongo; > if (first_time) { ... Here are some cheesy ways. 1. Put an

Re: Good Intermediate Tutorials

2010-04-01 Thread Lie Ryan
On 04/02/10 11:25, Abethebabe wrote: > I've recently finished reading A Byte Of Python and have the basics of > Python down. I want to continue practice but I'm unsure what I can do. > So I started looking for tutorials to open my mind a little, but > everything I come across are beginner tutorials

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

2010-04-01 Thread Steve Howell
On Mar 30, 8:40 am, gentlestone wrote: > Hi, how can I write the popular C/JAVA syntax in Python? > > Java example: >     return (a==b) ? 'Yes' : 'No' > > ; first idea is: >     return ('No','Yes')[bool(a==b)] > > Is there a more elegant/common python expression for this? The ironic thing about

Re: Good Intermediate Tutorials

2010-04-01 Thread Ray Allen
In my opinion, the python official documents, include the tutorial, language reference, library reference, distributing python modules, also extending and embedding, Python/C API, are all what you need to learn python and use it, as long as you can read into it. Also you can read other python progr

Re: off topic but please forgive me me and answer

2010-04-01 Thread Patrick Maupin
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)) >                                  + (math.

Re: off topic but please forgive me me and answer

2010-04-01 Thread Steven D'Aprano
On Thu, 01 Apr 2010 22:34:46 -0500, Tim Chase wrote: >> Tim, I'm sure you know the answer to this, but for the benefit of the >> Original Poster, the problem is that you need to promote *both* >> divisions to floating point. Otherwise one of them will give int 0, >> which gives 0.0 when multiplied

Re: Developement Question?

2010-04-01 Thread Tim Roberts
Wayne wrote: > >My town office uses Microsoft operating system. They have a proprietary >accounting system that uses excel for their accounting reports. >I would like to read these report and reproduce the report so that >the report can be seen on the web. If it were me, I'd just have Excel print