ANN: Intro+Intermediate Python course, SF, May 10-12

2010-04-01 Thread wesley chun
Need to get up-to-speed with Python as quickly as possible? Come join me, Wesley Chun, author of Prentice-Hall's bestseller Core Python Programming, for a comprehensive intro course coming up this May in beautiful Northern California! Please pass on this note to whomever you think may be

Google Summer of Code 2010 -- call for participation

2010-04-01 Thread C. Titus Brown
Hello everynoe, The Python Software Foundation is once again participating in the Google Summer of Code (GSoC), and we invite student applications from all who wish to participate. This year we'll be focusing on the transition to Python 3, so please bring your porting and extension issues our

Re: sorting ascending/descending with operator.attrgetter

2010-04-01 Thread Steve Holden
Steven D'Aprano wrote: On Wed, 31 Mar 2010 22:19:27 -0400, Steve Holden wrote: I'm the same myself, and I know from personal experience that while I am (simply?) seeking accuracy and truth it sometimes bugs the hell out of people ... By the way, why are we acting as if seeking accuracy

Re: sorting ascending/descending with operator.attrgetter

2010-04-01 Thread Rami Chowdhury
On Wednesday 31 March 2010 22:50:02 Steve Holden wrote: When I say 'use soap' *use* soap? Sounds awfully Perlish to me, perhaps you meant import soap ;-)? Rami Chowdhury Ninety percent of everything is crap. -- Sturgeon's Law 408-597-7068 (US) / 07875-841-046 (UK) / 01819-245544 (BD) --

jobs in australia jobs in australia for pakistanis jobs in australia melbourne jobs in australia for immigrants jobs in australia for international students jobs in australia for foreigne

2010-04-01 Thread Naeem
jobs in australia jobs in australia for pakistanis jobs in australia melbourne jobs in australia for immigrants jobs in australia for international students jobs in australia for foreigners ON http://jobsinaustralia-net.blogspot.com/ jobs in australia jobs in australia for pakistanis jobs in

Re: sorting ascending/descending with operator.attrgetter

2010-04-01 Thread Steven D'Aprano
On Wed, 31 Mar 2010 21:54:40 -0700, Patrick Maupin wrote: There is a (not very subtle) difference between saying Oh, you meant a list, not a string (especially when the context was a discussion of list processing), and printing a traceback for something that nobody was discussing, based on a

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 abrahamalra...@gmail.com 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

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 lacrima.ma...@gmail.com 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

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 pt...@austin.rr.com escribió: On Mar 31, 5:49 am, Nathan Harmston iwanttobeabad...@googlemail.com wrote: I have a slightly complicated/medium sized regular expression and I want to generate all possible words that it can match (to compare

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 c...@rebertia.com wrote: On Thu, Apr 1, 2010 at 2:08 AM, Lacrima lacrima.ma...@gmail.com wrote: Hello! I need to format a decimal (floating point) number in the following way: 10 results

Re: Python + OpenOffice Calc

2010-04-01 Thread egl...@gmail.com
On Apr 1, 6:53 am, rantingrick rantingr...@gmail.com 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?

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

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

Re: associative array

2010-04-01 Thread Javier Montoya
On Mar 31, 7:36 pm, Gary Herron gher...@digipen.edu 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

Re: associative array

2010-04-01 Thread Chris Rebert
On Thu, Apr 1, 2010 at 3:58 AM, Javier Montoya jmonto...@gmail.com wrote: On Mar 31, 7:36 pm, Gary Herron gher...@digipen.edu 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

Re: newbie with a encoding question, please help

2010-04-01 Thread Chris Rebert
2010/4/1 Mister Yu eryan...@gmail.com: 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

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

Re: newbie with a encoding question, please help

2010-04-01 Thread Mister Yu
On Apr 1, 7:22 pm, Chris Rebert c...@rebertia.com wrote: 2010/4/1 Mister Yu eryan...@gmail.com: 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

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 students

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 eryan...@gmail.com wrote: On Apr 1, 7:22 pm, Chris Rebert c...@rebertia.com wrote: 2010/4/1 Mister Yu eryan...@gmail.com: hi experts, i m new to python, i m writing crawlers to extract data from some chinese websites, and i run into a encoding

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 c...@rebertia.com wrote: On Thu, Apr 1, 2010 at 4:38 AM, Mister Yu eryan...@gmail.com wrote: On Apr 1, 7:22 pm, Chris Rebert c...@rebertia.com wrote: 2010/4/1 Mister Yu eryan...@gmail.com: hi experts, i m new to python, i m writing crawlers to extract

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

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

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, but your wording is funny

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 =

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', 123)

Re: sorting ascending/descending with operator.attrgetter

2010-04-01 Thread Patrick Maupin
On Apr 1, 1:54 am, Steven D'Aprano ste...@remove.this.cybersource.com.au 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

Re: decorators only when __debug__ == True

2010-04-01 Thread Steve Howell
On Apr 1, 6:16 am, Steve Holden st...@holdenweb.com 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

Re: Python 3.1, object, and setattr()

2010-04-01 Thread Steve Howell
On Apr 1, 6:46 am, Ethan Furman et...@stoneleaf.us 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

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 = object() --

Re: sorting ascending/descending with operator.attrgetter

2010-04-01 Thread Patrick Maupin
On Apr 1, 12:50 am, Steve Holden st...@holdenweb.com 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

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 = object() --

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 ke...@nekotaku.com wrote: Hi there, Years ago I wrote a LAMP app

Re: newbie with a encoding question, please help

2010-04-01 Thread Mister Yu
On Apr 1, 9:31 pm, Stefan Behnel stefan...@behnel.de 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')

Re: sort array, apply rearrangement to second

2010-04-01 Thread Steve Howell
On Mar 31, 1:09 pm, Raymond Hettinger pyt...@rcn.com 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

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 brief

Re: Developement Question?

2010-04-01 Thread KB
On Apr 1, 3:34 am, Wayne infotech...@fairpoint.net 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

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

2010-04-01 Thread Den
On Mar 30, 10:56 am, Steve Holden st...@holdenweb.com wrote: John Nagle wrote: Chris Rebert wrote: On Tue, Mar 30, 2010 at 8:40 AM, gentlestone tibor.b...@hotmail.com wrote: Hi, how can I write the popular C/JAVA syntax in Python? Java example:    return (a==b) ? 'Yes' : 'No' My

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

2010-04-01 Thread Jon Clements
On 1 Apr, 10:57, Jonathan Fine j.f...@open.ac.uk 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

Re: subprocess only good for win32?

2010-04-01 Thread wukong
On Mar 31, 3:47 pm, Martin v. Loewis mar...@v.loewis.de 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

Re: subprocess only good for win32?

2010-04-01 Thread wukong
On Mar 31, 3:47 pm, Martin v. Loewis mar...@v.loewis.de 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

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 should

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 =

Re: subprocess only good for win32?

2010-04-01 Thread Steve Holden
wukong wrote: On Mar 31, 3:47 pm, Martin v. Loewis mar...@v.loewis.de 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.

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

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 in canada hotels

no module named exceptions?

2010-04-01 Thread Joaquin Abian
In python 3.1, import exceptions Traceback (most recent call last): File pyshell#6, line 1, in module 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 --

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 gatoyga...@gmail.com wrote: In python 3.1, import exceptions Traceback (most recent call last): File pyshell#6, line 1, in module import

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

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 Furmanet...@stoneleaf.us 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;

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

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)

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

Re: no module named exceptions?

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

Re: question on namedtuple

2010-04-01 Thread Chris Rebert
On Thu, Apr 1, 2010 at 11:35 AM, hetchkay hetch...@gmail.com 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

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 pyshell#6, line 1, in module 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,

Re: no module named exceptions?

2010-04-01 Thread Ned Deily
In article l2g50697b2c1004011245l80c169e6k5be038e8ca75b...@mail.gmail.com, Chris Rebert c...@rebertia.com wrote: On Thu, Apr 1, 2010 at 10:42 PM, Joaquin Abian gatoyga...@gmail.com wrote: In python 3.1, import exceptions Traceback (most recent call last): File pyshell#6, line 1,

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

Re: subprocess only good for win32?

2010-04-01 Thread Piet van Oostrum
wukong novacomp...@gmail.com (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',

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

Re: folks, what's wrong with this?

2010-04-01 Thread Ani
On Apr 1, 12:10 pm, Robert Kern robert.k...@gmail.com 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 Kernrobert.k...@gmail.com 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):

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 no.em...@please.post wrote: When coding C I have often found static local variables useful for doing once-only run-time initializations. snip Another approach would be to stuff the static values in the function's __dict__.  This is less satisfactory than the

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 no.em...@please.post wrote: When coding C I have often found static local variables useful for doing once-only run-time initializations. snip Another approach would be to stuff the static values in the function's __dict__. This is less

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 =

Re: C-style static variables in Python?

2010-04-01 Thread Patrick Maupin
On Apr 1, 6:10 pm, Steve Holden st...@holdenweb.com 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

Re: off topic but please forgive me me and answer

2010-04-01 Thread Patrick Maupin
On Apr 1, 4:42 pm, Tim Chase python.l...@tim.thechases.com 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

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 infotech...@fairpoint.net 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

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 (first_time) {

Re: How to run python without python

2010-04-01 Thread Chris Rebert
On Thu, Apr 1, 2010 at 4:46 PM, Krister Svanlund krister.svanl...@gmail.com wrote: On Fri, Apr 2, 2010 at 1:36 AM, Spencer infotech...@fairpoint.net 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

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 pmau...@gmail.com wrote: On Apr 1, 4:42 pm, Tim Chase python.l...@tim.thechases.com 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

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 ;-) -tkc --

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 positions

Re: Good Intermediate Tutorials

2010-04-01 Thread rantingrick
On Apr 1, 7:25 pm, Abethebabe abrahamalra...@gmail.com 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

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 =

Re: off topic but please forgive me me and answer

2010-04-01 Thread Patrick Maupin
On Apr 1, 7:49 pm, Tim Chase python.l...@tim.thechases.com 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: (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 defaults to integer

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

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 python.l...@tim.thechases.com 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

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 several

Re: off topic but please forgive me me and answer

2010-04-01 Thread Patrick Maupin
On Apr 1, 9:50 pm, Lie Ryan lie.1...@gmail.com wrote: On 04/02/10 13:01, Patrick Maupin wrote: On Apr 1, 7:49 pm, Tim Chase python.l...@tim.thechases.com 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

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 st...@remove-this-cybersource.com.au 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

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

Re: C-style static variables in Python?

2010-04-01 Thread Paul Rubin
kj no.em...@please.post 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

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 tibor.b...@hotmail.com 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

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

  1   2   3   >