Re: simple string question

2009-09-06 Thread Chris Rebert
On Sun, Sep 6, 2009 at 10:29 PM, jwither wrote: > Given a string (read from a file) which contains raw escape sequences, > (specifically, slash n), what is the best way to convert that to a parsed > string, where the escape sequence has been replaced (specifically, by a > NEWLINE token)? There's p

Re: simple string question

2009-09-06 Thread 7stud
On Sep 6, 11:29 pm, "jwither" wrote: > Given a string (read from a file) which contains raw escape sequences, > (specifically, slash n), what is the best way to convert that to a parsed > string, where the escape sequence has been replaced (specifically, by a > NEWLINE token)? > > James Withers 1

Re: using python interpreters per thread in C++ program

2009-09-06 Thread sturlamolden
On 7 Sep, 07:59, ganesh wrote: > No, I did not use GIL. > -- For using GIL, do we need to initialize GIL at startup and destroy/ > finalize it at end? > -- Are there any configuration & build related flags that I need to > use to make this work? > > Please guide. Thanks. I just showed you how...

Re: using python interpreters per thread in C++ program

2009-09-06 Thread ganesh
> Did you remeber to acquire the GIL? The GIL is global to the process > (hence the name). No, I did not use GIL. -- For using GIL, do we need to initialize GIL at startup and destroy/ finalize it at end? -- Are there any configuration & build related flags that I need to use to make this work? P

Re: simple string question

2009-09-06 Thread Sean DiZazzo
On Sep 6, 10:29 pm, "jwither" wrote: > Given a string (read from a file) which contains raw escape sequences, > (specifically, slash n), what is the best way to convert that to a parsed > string, where the escape sequence has been replaced (specifically, by a > NEWLINE token)? > > James Withers I

Re: using python interpreters per thread in C++ program

2009-09-06 Thread ganesh
> Did you remeber to acquire the GIL? The GIL is global to the process No, I did not use GIL. -- Why do we need to use GIL even though python is private to each thread? -- For using GIL, do we need to initialize GIL at startup and destroy/ finalize it at end? -- With GIL, we are not achieiving co

Re: using python interpreters per thread in C++ program

2009-09-06 Thread sturlamolden
On 7 Sep, 07:17, grbgooglefan wrote: > Can we not use python interpreters even private to each multiple > thread? You can use multiple interpreters, but they share GIL. For example, Python extension modules are DLLs and will be loaded only once for each process - the OS makes sure of that. Since

Re: The future of Python immutability

2009-09-06 Thread Terry Reedy
Dennis Lee Bieber wrote: On Sun, 06 Sep 2009 20:29:47 -0700, John Nagle declaimed the following in gmane.comp.python.general: Python has the advantage that a sizable fraction of its objects, especially the very common ones like numbers and strings, are immutable. Immutable objects

Re: Multiple inheritance - How to call method_x in InheritedBaseB from method_x in InheritedBaseA?

2009-09-06 Thread The Music Guy
Sorry, that last code had a typo in it: #!/usr/bin/python def main(): foox = FooX() fooy = FooY() fooz = FooZ() foox.method_x("I", "AM", "X") print fooy.method_x("ESTOY", "Y", "!") print fooz.method_x(100, 200, 300) class MyMixin(object): def method_x(self,

Re: Multiple inheritance - How to call method_x in InheritedBaseB from method_x in InheritedBaseA?

2009-09-06 Thread The Music Guy
On Sat, Sep 5, 2009 at 8:41 PM, Carl Banks wrote: > Out of curiosity, did you try this and are reporting that it resulted > in an AttributeError, or did you merely deduce that it would raise > AttributeError based on your knowledge of Python's inheritance? > > I ask this rhetorically.  I know that

Re: using python interpreters per thread in C++ program

2009-09-06 Thread sturlamolden
On 7 Sep, 07:17, grbgooglefan wrote: > What is best way to embed python in multi-threaded C++ application? Did you remeber to acquire the GIL? The GIL is global to the process (hence the name). void foobar(void) { PyGILState_STATE state = PyGILState_Ensure(); /* Safe to use Python C A

simple string question

2009-09-06 Thread jwither
Given a string (read from a file) which contains raw escape sequences, (specifically, slash n), what is the best way to convert that to a parsed string, where the escape sequence has been replaced (specifically, by a NEWLINE token)? James Withers -- http://mail.python.org/mailman/listinfo/p

using python interpreters per thread in C++ program

2009-09-06 Thread grbgooglefan
Hi I've a multi-threaded C++ program, in which I want to use embedded python interpreter for each thread. I am using Python 2.6.2 on Linux for this. When I tried to embed python interpreter per thread, I got crash when the threads were calling Python's C APIs. Can we not use python interpreters

Re: The future of Python immutability

2009-09-06 Thread Steven D'Aprano
On Sun, 06 Sep 2009 10:12:56 -0400, Terry Reedy wrote: > Adam Skutt wrote: >> There's nothing inappropriate about using a lambda for a function I >> don't care to give a name. That's the entire reason they exist. > > But you did give a name -- 'b' -- and that is when a lambda expression > is in

Re: The future of Python immutability

2009-09-06 Thread Steven D'Aprano
On Sun, 06 Sep 2009 06:18:23 -0700, Adam Skutt wrote: > On Sep 5, 7:38 pm, Steven D'Aprano > No. Lambdas are a *syntactical construct*, not an object. You wouldn't >> talk about "while objects" and "if objects" and "comment objects" >> *because they're not objects*. > This rhetoric precludes funct

Re: Something confusing about non-greedy reg exp match

2009-09-06 Thread Ben Finney
George Burdell writes: > I want to find every occurrence of "money," and for each occurrence, I > want to scan back to the first occurrence of "hello." How can this be > done? By recognising the task: not expression matching, but lexing and parsing. For which you might find the ‘pyparsing’ libra

Re: Something confusing about non-greedy reg exp match

2009-09-06 Thread Gary Herron
George Burdell wrote: On Sep 6, 10:06 pm, "Mark Tolonen" wrote: wrote in message news:f98a6057-c35f-4843-9efb-7f36b05b6...@g19g2000yqo.googlegroups.com... If I do this: import re a=re.search(r'hello.*?money', 'hello how are you hello funny money') I would expect a.gr

Re: Something confusing about non-greedy reg exp match

2009-09-06 Thread George Burdell
On Sep 6, 10:06 pm, "Mark Tolonen" wrote: > wrote in message > > news:f98a6057-c35f-4843-9efb-7f36b05b6...@g19g2000yqo.googlegroups.com... > > > If I do this: > > > import re > > a=re.search(r'hello.*?money',  'hello how are you hello funny money') > > > I would expect a.group(0) to be "hello fun

Re: The future of Python immutability

2009-09-06 Thread John Nagle
Bearophile wrote: John Nagle: The concept here is that objects have an "owner", which is either a thread or some synchronized object. Locking is at the "owner" level. This is simple until "ownership" needs to be transferred. Can this be made to work in a Pythonic way, without explicit syntax?

Re: Something confusing about non-greedy reg exp match

2009-09-06 Thread George Burdell
On Sep 6, 10:22 pm, George Burdell wrote: > On Sep 6, 10:06 pm, "Mark Tolonen" wrote: > > > > > > > wrote in message > > >news:f98a6057-c35f-4843-9efb-7f36b05b6...@g19g2000yqo.googlegroups.com... > > > > If I do this: > > > > import re > > > a=re.search(r'hello.*?money',  'hello how are you hell

Re: Something confusing about non-greedy reg exp match

2009-09-06 Thread George Burdell
On Sep 6, 10:06 pm, "Mark Tolonen" wrote: > wrote in message > > news:f98a6057-c35f-4843-9efb-7f36b05b6...@g19g2000yqo.googlegroups.com... > > > If I do this: > > > import re > > a=re.search(r'hello.*?money',  'hello how are you hello funny money') > > > I would expect a.group(0) to be "hello fun

Re: Something confusing about non-greedy reg exp match

2009-09-06 Thread r
EDIT: your regex matches the whole string because it means... "hello" followed by any number of *anythings* up to the first occurrence of "money") you see? -- http://mail.python.org/mailman/listinfo/python-list

Re: Something confusing about non-greedy reg exp match

2009-09-06 Thread Mark Tolonen
wrote in message news:f98a6057-c35f-4843-9efb-7f36b05b6...@g19g2000yqo.googlegroups.com... If I do this: import re a=re.search(r'hello.*?money', 'hello how are you hello funny money') I would expect a.group(0) to be "hello funny money", since .*? is a non-greedy match. But instead, I get th

Re: Something confusing about non-greedy reg exp match

2009-09-06 Thread r
On Sep 6, 9:46 pm, "gburde...@gmail.com" wrote: > If I do this: > > import re > a=re.search(r'hello.*?money',  'hello how are you hello funny money') > > I would expect a.group(0) to be "hello funny money", since .*? is a > non-greedy match. But instead, I get the whole sentence, "hello how > are

Re: Evil trend report - cancelled

2009-09-06 Thread John Nagle
Steven D'Aprano wrote: On Sat, 05 Sep 2009 22:43:17 -0700, John Nagle wrote: [snip] Test complete: Evil trend report Accidentally posted a private e-mail. Cancelled. Sorry. John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Module for Fisher's exact test?

2009-09-06 Thread gb345
Before I roll my own, is there a good Python module for computing the Fisher's exact test stastics on 2 x 2 contingency tables? Many thanks in advance, Gabe -- http://mail.python.org/mailman/listinfo/python-list

Something confusing about non-greedy reg exp match

2009-09-06 Thread gburde...@gmail.com
If I do this: import re a=re.search(r'hello.*?money', 'hello how are you hello funny money') I would expect a.group(0) to be "hello funny money", since .*? is a non-greedy match. But instead, I get the whole sentence, "hello how are you hello funny money". Is this expected behavior? How can I s

Re: Q on explicitly calling file.close

2009-09-06 Thread Stephen Hansen
On Sun, Sep 6, 2009 at 4:31 PM, r wrote: > On Sep 6, 1:14 pm, "Jan Kaliszewski" wrote: > > 05-09-2009 r wrote: > > > i find the with statement (while quite useful in general > > > practice) is not a "cure all" for situations that need and exception > > > caught. > > > > In what sense? > > *ahem

Re: Is "#!/usr/bin/env python" the better shebang line ?

2009-09-06 Thread Timothy Madden
Ned Deily wrote: In article <4aa3bfdf$0$282$14726...@news.sunsite.dk>, Timothy Madden wrote: My questions is if I should use #!/usr/bin/env python as the shebang line in a portable and open python script and if it does help with portability and usage. This question came up recently on st

Re: Evil trend report

2009-09-06 Thread Che M
On Sep 6, 8:50 am, Grant Edwards wrote: > On 2009-09-06, John Nagle wrote: > > > > > Bing > >    A     3    2.4%  () > >    A     1    0.8%  (non_commercial) > >    Q    50   40.0%  () > >    Q    15   12.0%  (no_location) > >    U     5    4.0%  (no_website) > >    U    33   26.4%  (non_commerci

Re: possible attribute-oriented class

2009-09-06 Thread Jan Kaliszewski
06-09-2009 o 20:20:21 Ethan Furman wrote: In the dbf module I wrote, I use both the attribute access and the key lookup. The attribute access is great for interactive use, and for all the routines that play with the tables we have at work, where all the field names are indeed known at com

Re: Q on explicitly calling file.close

2009-09-06 Thread r
On Sep 6, 1:14 pm, "Jan Kaliszewski" wrote: > 05-09-2009 r wrote: > > i find the with statement (while quite useful in general > > practice) is not a "cure all" for situations that need and exception > > caught. > > In what sense? *ahem*! in the sense that the with statement (while quite useful

xlutils 1.4.1 released!

2009-09-06 Thread Chris Withers
Hi All, I'm pleased to announce a new release of xlutils. This package is a small collection of utilities that make use of both xlrd and xlwt to process Microsoft Excel files. This release includes memory and speed enhancements for xlutils.filter and xlutils.copy. To find out more, please

Re: possible attribute-oriented class

2009-09-06 Thread Ethan Furman
Steven D'Aprano wrote: On Fri, 04 Sep 2009 22:51:39 -0700, Ken Newton wrote: I would think this is much more than just copy from other language styles or 'just' a syntax change -- the apparent widespread use would hint at a deeper need. "Apparent" is the key word there. There are lots of peo

TestFixtures 1.6.1 released!

2009-09-06 Thread Chris Withers
Hi All, I'm pleased to announce a new release of TestFixtures. This package is a collection of helpers and mock objects that are useful when writing unit tests or doc tests. This release sees the following changes: - @replace and Replacer.replace can now replace attributes that may not be p

Re: Is "#!/usr/bin/env python" the better shebang line ?

2009-09-06 Thread Ned Deily
In article <4aa3bfdf$0$282$14726...@news.sunsite.dk>, Timothy Madden wrote: > My questions is if I should use >#!/usr/bin/env python > as the shebang line in a portable and open python script and if it does > help with portability and usage. This question came up recently on stackoverflow (

standard way to search through pdf-documents

2009-09-06 Thread krystian stodola
Hi there, I'm interested in searching through a number of pdf-documents by script. I found in the internet one project named PdfSearchGui-0.3 which should be ready for this task. But I always fail because of the following error: Traceback (most recent call last): File "main.py", line 3, in

Re: Q on explicitly calling file.close

2009-09-06 Thread Jan Kaliszewski
05-09-2009 r wrote: i find the with statement (while quite useful in general practice) is not a "cure all" for situations that need and exception caught. In what sense? I think that: with open(...) as f: foo... is equivalent to: f = open(...) try: foo... finally:

Re: platform-specific overrides of functions and class methods (expanding on imputils demo code)

2009-09-06 Thread Terry Reedy
lkcl wrote: On Aug 21, 12:58 am, a...@pythoncraft.com (Aahz) wrote: In article <77715735-2668-43e7-95da-c91d175b3...@z31g2000yqd.googlegroups.com>, lkcl wrote: if somebody would like to add this to the python bugtracker, as a contribution, that would be great. alternatively, you might like

Re: Q on explicitly calling file.close

2009-09-06 Thread Stephen Hansen
> > It's just too bad that 'with' doesn't support multiple separate "x as y" >> clauses. >> > > The developers already agreed with you ;-). > > "With more than one item, the context managers are processed as if multiple > with statements were nested: > > with A() as a, B() as b: >suite > is equ

How to debug a forked process with pdb ?

2009-09-06 Thread Timothy Madden
Hello I am trying to write a daemon and I call os.fork() twice to detach from the terminal and other staff. Problem is after the second fork() the child immediately gives an exception and although I get a traceback displayed the process should terminate, the child proces is still live, and its p

Re: Support for Windows 7 ?

2009-09-06 Thread jkn
On Sep 5, 4:45 pm, Pascale Mourier wrote: > YES IT IS! Sorry for the inconvenience. I usually start from this > assumption. Yesterday this new student was really agressive, and I > assumed he was right! > I suggest that (in general) you don't allow the first clause of this last sentence to lead

Re: platform-specific overrides of functions and class methods (expanding on imputils demo code)

2009-09-06 Thread lkcl
On Aug 21, 12:58 am, a...@pythoncraft.com (Aahz) wrote: > In article > <77715735-2668-43e7-95da-c91d175b3...@z31g2000yqd.googlegroups.com>, > > lkcl wrote: > > >if somebody would like to add this to the python bugtracker, as a > >contribution, that would be great. alternatively, you might like

Re: Python or ActionScript 3.0

2009-09-06 Thread lkcl
On Sep 6, 3:19 pm, lkcl wrote: > On Aug 16, 1:29 am, Douglas Alan wrote: > > I think the future of client-side browser programming is > > actuallyJavaScript, not ActionScript, though that future may morph into one > > that mostly usesJavaScriptas a virtual machine. This is the approach > > that

Re: Python or ActionScript 3.0

2009-09-06 Thread lkcl
On Aug 15, 9:32 pm, Jaseem wrote: > Hi, > > Is python similar to actionscript 3.0 > Which is better to create a rich gui internet application? can i suggest that you read this: http://www.javalobby.org/articles/ajax-ria-overview/ and then take a look at this: http://pyjs.org pyjamas pu

Re: Python or ActionScript 3.0

2009-09-06 Thread lkcl
On Aug 16, 1:29 am, Douglas Alan wrote: > > But both python and AS 3.0 is almost identical. > > No, Python and ActionScript are not "almost identical". the AS 3.0 implementation is entirely missing declarative style of programming: it is purely event-driven. i.e. you cannot get an AS 3.0 "comma

Re: Python or ActionScript 3.0

2009-09-06 Thread lkcl
On Aug 16, 5:43 am, "Michel Claveau - MVP" wrote: > Hi! > > > Python doesn't run in your typical web browser > > Yes, Python can do it... on Windows. and linux. pyxpcomext. it's a bit of a pig, but perfectly doable: http://pyxpcomext.mozdev.org/tutorials.html > Two (examples) ways: > - Act

Re: Python- javascript

2009-09-06 Thread lkcl
On Aug 16, 12:02 am, Mike Paul wrote: > I'm trying to scrap a dynamic page with lot ofjavascriptin it. > Inorder to get all the data from the page i need to access thejavascript. But > i've no idea how to do it. > > Say I'm scraping some site htttp://www.xyz.com/xyz > > request=urllib2.Request("h

HTTPS on Twisted

2009-09-06 Thread koranthala
Hi, For a financial application, I am creating a python tool which uses HTTPS to transfer the data from client to server. Now, everything works perfectly, since the SSL support comes free with Twisted. I have one problem though. As an upgrade, now, I have to send many requests as the same cl

Re: Is "#!/usr/bin/env python" the better shebang line ?

2009-09-06 Thread Benjamin Kaplan
On Sun, Sep 6, 2009 at 10:01 AM, Timothy Madden wrote: > Hello > > Sorry if this has been discussed before, my search did not find it. > My questions is if I should use >  #!/usr/bin/env python > as the shebang line in a portable and open python script and if it does help > with portability and usa

Re: How to access ODBC databases ?

2009-09-06 Thread Timothy Madden
Martin P. Hellwig wrote: Timothy Madden wrote: [...] It has been a couple of years, but I remember vaguely that back in the days of PossgreSQL 6, if you want ODBC support you needed to compile PG a bit different then normal, I am not really sure what options those where and if this still ap

Re: The future of Python immutability

2009-09-06 Thread Terry Reedy
Adam Skutt wrote: On Sep 5, 10:34 pm, Terry Reedy wrote: Adam Skutt wrote: On Sep 5, 11:29 am, Terry Reedy wrote: This is a pointless replacement for 'def b(x): return x+a' And? That has nothing to do with anything I was saying whatsoever. Agreed. However, posts are read by newbies. Post

Re: Q on explicitly calling file.close

2009-09-06 Thread Terry Reedy
Stephen Hansen wrote: This is precisely why the with statement exists; to provide a cleaner way to wrap a block in setup and teardown functions. Closing is one. Yeah, you get some extra indentation-- but you sorta have to live with it if you're worried about correct code. I think it's a good c

Is "#!/usr/bin/env python" the better shebang line ?

2009-09-06 Thread Timothy Madden
Hello Sorry if this has been discussed before, my search did not find it. My questions is if I should use #!/usr/bin/env python as the shebang line in a portable and open python script and if it does help with portability and usage. First, can one not find /usr/bin/python in any standard sys

Re: beginner's python help

2009-09-06 Thread Terry Reedy
Maggie wrote: code practice: test = open ("test.txt", "r") readData = test.readlines() #set up a sum sum = 0; for item in readData: sum += int(item) print sum test file looks something like this: 34 23 124 432 12 when i am trying to compile this it gives me the error: invalid literal

Re: Support for Windows 7 ? Thread closed please

2009-09-06 Thread Pascale Mourier
Many thanks to all contributors! I learnt sth I never realized before: Windows indeed maintains a "current directory" for each drive! As you may guess, I'm not very fond of DOS / Windows. My training with those OS started with "hands-on" experience on a machine w/ a single "C:" drive (namely a

Re: How to refer to data files without hardcoding paths?

2009-09-06 Thread Timothy Madden
Matthew Wilson wrote: When a python package includes data files like templates or images, what is the orthodox way of referring to these in code? I'm working on an application installable through the Python package index. Most of the app is just python code, but I use a few jinja2 templates. T

Re: The future of Python immutability

2009-09-06 Thread Bearophile
John Nagle: > The concept here is that objects have an "owner", which is either > a thread or some synchronized object.   Locking is at the "owner" > level.  This is simple until "ownership" needs to be transferred. > Can this be made to work in a Pythonic way, without explicit > syntax? > > What w

Re: beginner's python help

2009-09-06 Thread MRAB
Chris Rebert wrote: On Sun, Sep 6, 2009 at 1:28 AM, Maggie wrote: On Sep 6, 4:19 am, Chris Rebert wrote: On Sun, Sep 6, 2009 at 1:10 AM, Maggie wrote: On Sep 6, 3:58 am, Chris Rebert wrote: On Sun, Sep 6, 2009 at 12:54 AM, hrishy wrote: Hi sum = 0 for item in readData: try: su

Re: The future of Python immutability

2009-09-06 Thread Adam Skutt
On Sep 5, 10:34 pm, Terry Reedy wrote: > Adam Skutt wrote: > > On Sep 5, 11:29 am, Terry Reedy wrote: > >> This is a pointless replacement for 'def b(x): return x+a' > > > And?  That has nothing to do with anything I was saying whatsoever. > > Agreed.  However, posts are read by newbies. > Posts

Re: The future of Python immutability

2009-09-06 Thread Adam Skutt
On Sep 5, 7:38 pm, Steven D'Aprano No. Lambdas are a *syntactical construct*, not an object. You wouldn't > talk about "while objects" and "if objects" and "comment objects" > *because they're not objects*. This rhetoric precludes functions objects as well and is entirely non- compelling. > Funct

Re: beginner's python help

2009-09-06 Thread Benjamin Kaplan
On Sun, Sep 6, 2009 at 4:28 AM, Maggie wrote: > On Sep 6, 4:19 am, Chris Rebert wrote: >> On Sun, Sep 6, 2009 at 1:10 AM, Maggie wrote: >> > On Sep 6, 3:58 am, Chris Rebert wrote: >> >> On Sun, Sep 6, 2009 at 12:54 AM, hrishy wrote: >> >> > Hi >> >> >> > sum = 0 >> >> >  for item in readData: >>

Managing a Sub-Process

2009-09-06 Thread Greg Lindstrom
I am using Python 2.6 on Gentoo Linux and have a routine that gets/puts files to other servers via sftp. We have an ongoing problem with various sftp processes "hanging"; that is, it no longer transfers any data but does not shutdown/timeout. I would like to design a routine that will kick off th

Re: How to access ODBC databases ?

2009-09-06 Thread Martin P. Hellwig
Timothy Madden wrote: Thank you. The precompiled psqlodbca.so driver from apt-get worked on one of the Ubuntu machines that I tried. I would still like o use the Unicode driver if possible. Do you know what the problem could be ? Or where ? pyodbc/unixODBC/psqlodbcw.so ? Thank you, Timot

Evil trend report

2009-09-06 Thread John Nagle
Bing A 32.4% () A 10.8% (non_commercial) Q50 40.0% () Q15 12.0% (no_location) U 54.0% (no_website) U33 26.4% (non_commercial) X 10.8% (negative_info) X17 13.6% (no_location) Google A 10.8% () A 43

Re: Support for Windows 7 ?

2009-09-06 Thread Michel Claveau - MVP
Bonjour ! Plusieurs points : - Python (ainsi que Pywin32) fonctionne TRÈS bien sous Windows-7 (je l'utilise depuis plus d'un an, sur Win-7 beta, RC, RTM, en 32 bits et en 64 bits). Résultats : AUCUN problème. - Il existe des sources françaises (newsgroups, sites, forums, etc.) qui peuvent

Re: Why does this group have so much spam?

2009-09-06 Thread Steven D'Aprano
On Thu, 03 Sep 2009 23:07:48 -0400, Terry Reedy wrote: > Suppose that all over the world, people coordinated so that one in three > households paid ISPs while a neighbor on each side piggybacked (and > perhaps paid the paying househould their one-third share). Do you > really think that would hav

Re: Support for Windows 7 ?

2009-09-06 Thread Pascale Mourier
Michel Claveau - MVP a écrit : Bonjour ! Plusieurs points : - Python (ainsi que Pywin32) fonctionne TRÈS bien sous Windows-7 (je l'utilise depuis plus d'un an, sur Win-7 beta, RC, RTM, en 32 bits et en 64 bits). Résultats : AUCUN problème. - Il existe des sources françaises (newsgroups, si

zip a huge file into multiple small ones

2009-09-06 Thread krishna chaitanya
I am new to dealing with zip files in python. I have a huge file which i need to zip and send as an attachment through email. My email restrictions are not allowing me to send it in one go. Is there a way to split this file into multiple zip files, so that i can mail them separately. All the indivi

subclassing Scientific.IO.NetCDFFile

2009-09-06 Thread Jon Beezley
Hi all, I have come across a problem that I am unsure how to get around. What I want to do is create a subclass of Scientific.IO.NetCDFFile, but despite what the docstrings say isn't really a class at all, but a function that returns some sort of data structure from the netcdf C api. I am aware

Re: Turn-based game - experimental economics

2009-09-06 Thread Paolo Crosetto
Dennis, thanks. > Do the clients have to do anything between turns? If not, the > simplest thing is to just have these clients block on a read request > waiting for data to be returned from the server. the only thing that the clients do is receiving information on the action of other pla

Re: Question on File Input and AST

2009-09-06 Thread Steven D'Aprano
On Sun, 06 Sep 2009 00:53:43 -0700, joy99 wrote: > Dear Group, > > I have a file "test1.txt". Now, as I do the file handling, i try to do > any one of the following operations. > > 1. open_file=open("/python26/test1.txt","r") # FOR READING 2. > open_file=open("/python26/test1.txt","r+") # FOR RE

Re: beginner's python help

2009-09-06 Thread Chris Rebert
On Sun, Sep 6, 2009 at 1:28 AM, Maggie wrote: > On Sep 6, 4:19 am, Chris Rebert wrote: >> On Sun, Sep 6, 2009 at 1:10 AM, Maggie wrote: >> > On Sep 6, 3:58 am, Chris Rebert wrote: >> >> On Sun, Sep 6, 2009 at 12:54 AM, hrishy wrote: >> >> > Hi >> >> >> > sum = 0 >> >> >  for item in readData: >>

Re: beginner's python help

2009-09-06 Thread Maggie
On Sep 6, 4:19 am, Chris Rebert wrote: > On Sun, Sep 6, 2009 at 1:10 AM, Maggie wrote: > > On Sep 6, 3:58 am, Chris Rebert wrote: > >> On Sun, Sep 6, 2009 at 12:54 AM, hrishy wrote: > >> > Hi > > >> > sum = 0 > >> >  for item in readData: > >> >     try: > >> >         sum += int(item) > >> >    

Re: Evil trend report

2009-09-06 Thread Steven D'Aprano
On Sat, 05 Sep 2009 22:43:17 -0700, John Nagle wrote: [snip] > Test complete: Evil trend report > > Right now, Google is winning slightly. It changes from minute to > minute, because it's based on the current list of hot search topics from > Google. More on this later. What does this mean? Wha

Re: beginner's python help

2009-09-06 Thread Chris Rebert
On Sun, Sep 6, 2009 at 1:10 AM, Maggie wrote: > On Sep 6, 3:58 am, Chris Rebert wrote: >> On Sun, Sep 6, 2009 at 12:54 AM, hrishy wrote: >> > Hi >> >> > sum = 0 >> >  for item in readData: >> >     try: >> >         sum += int(item) >> >     except ValueError: >> >         print "Oops!  That was n

Re: beginner's python help

2009-09-06 Thread Maggie
On Sep 6, 3:58 am, Chris Rebert wrote: > On Sun, Sep 6, 2009 at 12:54 AM, hrishy wrote: > > Hi > > > sum = 0 > >  for item in readData: > >     try: > >         sum += int(item) > >     except ValueError: > >         print "Oops!  That was no valid number. Instead it was:", item > > > So you mean

Re: beginner's python help

2009-09-06 Thread Chris Rebert
On Sun, Sep 6, 2009 at 12:54 AM, hrishy wrote: > Hi > > sum = 0 >  for item in readData: >     try: >         sum += int(item) >     except ValueError: >         print "Oops!  That was no valid number. Instead it was:", item > > So you mean to say this would ignore the bad data and continue process

Question on File Input and AST

2009-09-06 Thread joy99
Dear Group, I have a file "test1.txt". Now, as I do the file handling, i try to do any one of the following operations. 1. open_file=open("/python26/test1.txt","r") # FOR READING 2. open_file=open("/python26/test1.txt","r+") # FOR READING AND WRITING BOTH [Either of 1 or 2 to open as the need be]

Re: beginner's python help

2009-09-06 Thread hrishy
Hi sum = 0 for item in readData: try: sum += int(item) except ValueError: print "Oops! That was no valid number. Instead it was:", item So you mean to say this would ignore the bad data and continue processing ? regards -- http://mail.python.org/mailman/li

Re: beginner's python help

2009-09-06 Thread Chris Rebert
On Sun, Sep 6, 2009 at 12:46 AM, hrishy wrote: > Hi Chris > > What if i want to log that bad data and continue processing is there a way to > do that ? Tighten the area included in the try...except: sum = 0 for item in readData: try: sum += int(item) except ValueError: pr

Re: efficiently splitting up strings based on substrings

2009-09-06 Thread 7stud
On Sep 6, 1:23 am, 7stud wrote: > On Sep 6, 1:14 am, 7stud wrote: > > > > > On Sep 5, 5:29 pm, per wrote: > > > > On Sep 5, 7:07 pm, "Rhodri James" wrote: > > > > > On Sat, 05 Sep 2009 23:54:08 +0100, per wrote: > > > > > On Sep 5, 6:42 pm, "Rhodri James" wrote: > > > > >> On Sat, 05 Sep 2009

Re: File Handling Problem

2009-09-06 Thread joy99
On Sep 5, 11:49 am, Chris Rebert wrote: > On Fri, Sep 4, 2009 at 11:39 PM, > SUBHABRATABANERJEE wrote: > > > > > And one small question does Python has any increment operator like ++ in C. > > No. We do  x += 1  instead. > > Cheers, > Chris > --http://blog.rebertia.com Thanx for your kind reply

Re: beginner's python help

2009-09-06 Thread hrishy
Hi Chris What if i want to log that bad data and continue processing is there a way to do that ? regards --- On Sun, 6/9/09, Chris Rebert wrote: > From: Chris Rebert > Subject: Re: beginner's python help > To: "Maggie" > Cc: python-list@python.org > Date: Sunday, 6 September, 2009, 8:15 AM

Re: efficiently splitting up strings based on substrings

2009-09-06 Thread 7stud
On Sep 6, 1:14 am, 7stud wrote: > On Sep 5, 5:29 pm, per wrote: > > > > > On Sep 5, 7:07 pm, "Rhodri James" wrote: > > > > On Sat, 05 Sep 2009 23:54:08 +0100, per wrote: > > > > On Sep 5, 6:42 pm, "Rhodri James" wrote: > > > >> On Sat, 05 Sep 2009 22:54:41 +0100, per wrote: > > > >> > I'm try

Re: beginner's python help

2009-09-06 Thread hrishy
Hi I am just a python beginner What you need is exceptions http://docs.python.org/tutorial/errors.html something on the lines of since you expect a integer and you wnat to catch the exception ... try: ... sum = 0; ... for item in readData: ...sum += int(item

Re: beginner's python help

2009-09-06 Thread Chris Rebert
On Sun, Sep 6, 2009 at 12:00 AM, Maggie wrote: > code practice: > > test = open ("test.txt", "r") > readData = test.readlines() > #set up a sum > sum = 0; > for item in readData: >        sum += int(item) > print sum A slightly better way to write this: test = open("test.txt", "r") #set up a sum

Re: efficiently splitting up strings based on substrings

2009-09-06 Thread 7stud
On Sep 5, 5:29 pm, per wrote: > On Sep 5, 7:07 pm, "Rhodri James" wrote: > > > > > On Sat, 05 Sep 2009 23:54:08 +0100, per wrote: > > > On Sep 5, 6:42 pm, "Rhodri James" wrote: > > >> On Sat, 05 Sep 2009 22:54:41 +0100, per wrote: > > >> > I'm trying to efficiently "split" strings based on wha

beginner's python help

2009-09-06 Thread Maggie
code practice: test = open ("test.txt", "r") readData = test.readlines() #set up a sum sum = 0; for item in readData: sum += int(item) print sum test file looks something like this: 34 23 124 432 12 when i am trying to compile this it gives me the error: invalid literal for int() with b