Re: text file reformatting

2010-10-31 Thread iwawi
On 31 loka, 21:48, Tim Chase wrote: > > PRJ01001 4 00100END > > PRJ01002 3 00110END > > > I would like to pick only some columns to a new file and put them to a > > certain places (to match previous data) - definition file (def.csv) > > could be something like this: > > > VARIABLE   FIELDSTARTS  

python script to read google spreadsheet

2010-10-31 Thread charu gangal
import gdata.spreadsheet.service username= 'prakhil.purch...@gmail.com' passwd = 'purchase' doc_name= 'googleapps_spreadsheet' gd_client = gdata.spreadsheet.service.SpreadsheetsService() gd_client.email = username gd_client.password =passwd #gd_client.source = 'pythonsample

Allowing comments after the line continuation backslash

2010-10-31 Thread Yingjie Lan
Hi, Sorry if I am baking too many ideas today. I am just having trouble with the backslashes I would like to have comments after the line continuation backslash. >>> if a > 0 \ #comments for this condition and b > 0: #do something here This is currently not OK, but this might be a

Re: with block for multiple files

2010-10-31 Thread Yingjie Lan
> Guido's time machine strikes again! It's already in Python > 3; your > example would be spelled: > > with open('scores.csv') as f, open('grades.csv', wt) as g: >     g.write(f.read()) > Indeed! Thanks, Chris and James. Yingjie -- http://mail.python.org/mailman/listinfo/python-list

Allow multiline conditions and the like

2010-10-31 Thread Yingjie Lan
Hi, This is a mini-proposal I piggy-tailed in the other topic: Allow the conditions in the if-, elif-, while-, for-, and with-clauses to span multiple lines without using a backlalsh at the end of a line, just like when you specify literal lists, tuples, dicts, etc. across multiple lines (simila

Re: with block for multiple files

2010-10-31 Thread James Mills
On Mon, Nov 1, 2010 at 3:03 PM, Yingjie Lan wrote: > with open('scores.csv'), open('grades.csv', wt) as f,g: >     g.write(f.read()) One could write their own ContextManager here... cheers James -- -- James Mills -- -- "Problems are solved by method" -- http://mail.python.org/mailman/listinfo

Re: with block for multiple files

2010-10-31 Thread Chris Rebert
On Sun, Oct 31, 2010 at 10:03 PM, Yingjie Lan wrote: > Hi, > > Suppose I am working with two files simultaneously, > it might make sense to do this: > > with open('scores.csv'), open('grades.csv', wt) as f,g: >     g.write(f.read()) > > sure, you can do this with nested with-blocks, > but the one

with block for multiple files

2010-10-31 Thread Yingjie Lan
Hi, Suppose I am working with two files simultaneously, it might make sense to do this: with open('scores.csv'), open('grades.csv', wt) as f,g: g.write(f.read()) sure, you can do this with nested with-blocks, but the one above does not seem too complicated, it is like having a multiple as

Re: [Beginer Question] I heard about python needing some sort of_VariableName_ boiler plate?

2010-10-31 Thread Ben Finney
brad...@hotmail.com writes: > Sorry, to clarify I heard that when you declare a variable in python > you have to use some sort of standard boiler plate _variable_ however > this has not been my experience using IDLE so is this even true? I don't know what “some sort of boiler plate _variable_” mi

Re: [Beginer Question] I heard about python needing some sort of_VariableName_ boiler plate?

2010-10-31 Thread James Mills
On Mon, Nov 1, 2010 at 1:37 PM, wrote: > Sorry, to clarify I heard that when you declare a variable in python you have > to use some sort of standard boiler plate _variable_ however this has not > been my experience using IDLE so is this even true? Boilerplate, what boilerplate ? To define va

Re: A bug for raw string literals in Py3k?

2010-10-31 Thread Yingjie Lan
> According to msg56377, the behaviour is "optimal" for regular > expressions. Well, I use regular expressions a lot, and I > still think it's a nuisance! Thanks for bringing that up. Using an otherwise 'dead' backlash to escape quotes in raw strings seems like the black magic of necromancy to

Re: I heard about python needing some sort of_VariableName_ boiler plate?

2010-10-31 Thread rantingrick
Brad, Serously, i have never heard of any boilerplate variables in Python. Could you show us an example using Python code that compiles? Of could you even show us some puesdo that resembles any thing that you are suggesting? I am perplexed! Is this a troll or are you really serious? -- http://ma

Re: I heard about python needing some sort of_VariableName_ boiler plate?

2010-10-31 Thread rantingrick
On Oct 31, 10:37 pm, brad...@hotmail.com wrote: > Sorry, to clarify I heard that when you declare a variable in python you have > to use some sort of standard boiler plate _variable_ however this has not > been my experience using IDLE so is this even true? Halloween night and i am bored... hmm.

Re: I heard about python needing some sort of _VariableName_ boiler plate?

2010-10-31 Thread rantingrick
On Oct 31, 10:18 pm, Chris Rebert wrote: > On Sun, Oct 31, 2010 at 7:09 PM, Braden Faulkner wrote: > > I heard about python needing some sort of _VariableName_ boiler plate? > > Can anyone explain to me how this works, I don't seem to have to do it in > > IDLE? Oh thats just more FUD and spin fr

Re: A bug for raw string literals in Py3k?

2010-10-31 Thread MRAB
On 01/11/2010 03:30, Yingjie Lan wrote: All backslashes in raw string literals are interpreted literally. (seehttp://docs.python.org/release/3.0.1/whatsnew/3.0.html): All backslashes in syntactically-correct raw string literals are interpreted literally. That's a good way of putting it.

Re: [Beginer Question] I heard about python needing some sort of_VariableName_ boiler plate?

2010-10-31 Thread bradenf
Sorry, to clarify I heard that when you declare a variable in python you have to use some sort of standard boiler plate _variable_ however this has not been my experience using IDLE so is this even true? Thanks! --Original Message-- From: Chris Rebert Sender: ch...@rebertia.com To: Brad

Re: A bug for raw string literals in Py3k?

2010-10-31 Thread Yingjie Lan
> > > All backslashes in raw string literals are > interpreted literally. > > > (seehttp://docs.python.org/release/3.0.1/whatsnew/3.0.html): > > > > All backslashes in syntactically-correct raw string > literals are interpreted literally. > > That's a good way of putting it. > Syntactical correc

Re: [Beginer Question] I heard about python needing some sort of _VariableName_ boiler plate?

2010-10-31 Thread Chris Rebert
On Sun, Oct 31, 2010 at 7:09 PM, Braden Faulkner wrote: > I heard about python needing some sort of _VariableName_ boiler plate? > Can anyone explain to me how this works, I don't seem to have to do it in > IDLE? Your question is extremely vague. Please give more details. Regards, Chris -- http

[Beginer Question] I heard about python needing some sort of _VariableName_ boiler plate?

2010-10-31 Thread Braden Faulkner
Can anyone explain to me how this works, I don't seem to have to do it in IDLE? Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-31 Thread cbr...@cbrownsystems.com
On Oct 31, 4:27 pm, Lawrence D'Oliveiro wrote: > In message > <687bcb76-0093-4d68-ba56-0390a3e1e...@30g2000yql.googlegroups.com>, > > cbr...@cbrownsystems.com wrote: > > I should note that efficiency is not an issue to me here; this is for > > when you have, say, a list user_options of at most aro

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-31 Thread Lawrence D'Oliveiro
In message <687bcb76-0093-4d68-ba56-0390a3e1e...@30g2000yql.googlegroups.com>, cbr...@cbrownsystems.com wrote: > I should note that efficiency is not an issue to me here; this is for > when you have, say, a list user_options of at most around 15 options > or so, and you want to perform some actio

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-31 Thread Lawrence D'Oliveiro
In message <4cca5aaf$0$1600$742ec...@news.sonic.net>, John Nagle wrote: > This is cheaper than intersection ... All together now: “PREMATURE OPTIMIZATION IS THE ROOT OF ALL EVIL!” -- http://mail.python.org/mailman/listinfo/python-list

Re: Exception Handling in Python 3

2010-10-31 Thread Lawrence D'Oliveiro
In message , Antoine Pitrou wrote: > If you want to present exceptions to users in a different way ... sys.stderr.write \ ( "Traceback (most recent call last):\n" ... "AttributeError: blah blah blah ...\n" ) -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.7 or 3.1

2010-10-31 Thread Lawrence D'Oliveiro
In message , Jorge Biquez wrote: > Would you consider a "not so intelligent move" for a newsbie to > Python to have maybe version 2.7 and 3.x (if that's possible to be > running together on the same machine) to have them run and be > learning mainly in 2.7 and see differences in 3.x? Sure, why n

Re: Compare source code

2010-10-31 Thread Lawrence D'Oliveiro
In message <4ccd5ad9$0$19151$426a7...@news.free.fr>, jf wrote: > I edit each file to remove tabs ... expand -i newfile > Do you know a tools to compare the initial file with the cleaned one to > know if the algorithms are the same ? diff -b oldfile newfile -- http://mail.python.org/ma

Re: A bug for raw string literals in Py3k?

2010-10-31 Thread Ben Finney
John Machin writes: > On Oct 31, 11:23 pm, Yingjie Lan wrote: > > Thanks! That looks weird to me ... doesn't this contradict with: > > > > All backslashes in raw string literals are interpreted literally. > > (seehttp://docs.python.org/release/3.0.1/whatsnew/3.0.html): > > All backslashes in syn

Re: Compare source code

2010-10-31 Thread Martin v. Loewis
> Should I be worry about this comment in reindent.py "So long as the > input files get a clean bill of health from tabnanny.py, reindent should > do a good job." ? I don't think so: IIUC, this is about comments that are not reasonably aligned with preceding or following code lines, most likely, y

Re: no line breaks in xml file with elementTree

2010-10-31 Thread Diez B. Roggisch
hackingKK writes: > On Sunday 31 October 2010 01:58 PM, Lawrence D'Oliveiro wrote: >> In message, hackingKK >> wrote: >> >> >>> I want to know if there is a way to have the ElementTree module write to >>> an xml file with line breaks? >>> >> Why does it matter? The XML files you generat

Re: text file reformatting

2010-10-31 Thread cbr...@cbrownsystems.com
On Oct 31, 12:48 pm, Tim Chase wrote: > > PRJ01001 4 00100END > > PRJ01002 3 00110END > > > I would like to pick only some columns to a new file and put them to a > > certain places (to match previous data) - definition file (def.csv) > > could be something like this: > > > VARIABLE   FIELDSTARTS

Re: A bug for raw string literals in Py3k?

2010-10-31 Thread John Machin
On Oct 31, 11:23 pm, Yingjie Lan wrote: > > > So I suppose this is a bug? > > > It's not, see > > >http://docs.python.org/py3k/reference/lexical_analysis.html#literals > > > # Specifically, a raw string cannot end in a single backslash > > Thanks! That looks weird to me ... doesn't this contradict

RE: text file reformatting

2010-10-31 Thread Braden Faulkner
Sorry to clarify, I was having issues getting this to work. I'm relatively new to Python. Sorry for the miscommunication. > Date: Sun, 31 Oct 2010 16:13:42 -0500 > From: python.l...@tim.thechases.com > To: brad...@hotmail.com > CC: python-list@python.org > Subject: Re: text file reformatting >

Re: Eclipse/PyDev - BOM Lexical Error

2010-10-31 Thread Fabio Zadrozny
On Mon, Oct 4, 2010 at 5:03 AM, TheOne wrote: > Hi. > > I installed eclipse/pydev today. > I created a pydev project and added python source files with utf-8 > BOM. > Eclipse/Pydev reports lexical error : >  Lexical error at line 1, column 1. Encountered: "\ufeff" (65279), > after : "" > > I want

Re: text file reformatting

2010-10-31 Thread Tim Chase
On 10/31/10 14:52, Braden Faulkner wrote: import csv f = file('def.csv', 'rb') f.next() # discard the header row r = csv.reader(f, delimiter=';') fields = [ (varname, slice(int(start), int(start)+int(size)), width) for varname, start, size, width in r ]

Re: Compare source code

2010-10-31 Thread Alan Harris-Reid
Hi jf, I use Beyond Compare (by Scooter Software) for comparing text files and find it an indespensible tool. You can configure it so that it ignores tabs/whitespace, or treats spaces and tabs as different characters. Not sure if it will work with compiled .pyc files, though (but then you

RE: text file reformatting

2010-10-31 Thread Braden Faulkner
I also am having issues with this. > Date: Sun, 31 Oct 2010 14:48:09 -0500 > From: python.l...@tim.thechases.com > To: iwawi...@gmail.com > Subject: Re: text file reformatting > CC: python-list@python.org > > > PRJ01001 4 00100END > > PRJ01002 3 00110END > > > > I would like to pick only some co

Re: text file reformatting

2010-10-31 Thread Tim Chase
PRJ01001 4 00100END PRJ01002 3 00110END I would like to pick only some columns to a new file and put them to a certain places (to match previous data) - definition file (def.csv) could be something like this: VARIABLEFIELDSTARTS FIELD SIZE NEW PLACE IN NEW DATA FILE ProjID ;

Re: Is there a way to pring a list object in Python?

2010-10-31 Thread Benjamin Kaplan
On Sun, Oct 31, 2010 at 3:04 PM, Zeynel wrote: > >        Rep().replist = L >        Rep().put() >        query = Rep.all() >        for result in query: >            self.response.out.write(result.replist) > > The output of this is: > > [u'a', u'b'][u'a', u'b'][u'a', u'b']. . . > > So, these are

Re: Is there a way to pring a list object in Python?

2010-10-31 Thread Richard Thomas
On Oct 31, 7:04 pm, Zeynel wrote: > On Oct 31, 5:52 am, Dave Angel wrote: > > > > > > > > > > > On 2:59 PM, Zeynel wrote:> class Rep(db.Model): > > >      author = db.UserProperty() > > >      replist = db.ListProperty(str) > > >      unique = db.ListProperty(str) > > >      date = db.DateTimePro

Re: Is there a way to pring a list object in Python?

2010-10-31 Thread Zeynel
On Oct 31, 5:52 am, Dave Angel wrote: > On 2:59 PM, Zeynel wrote:> class Rep(db.Model): > >      author = db.UserProperty() > >      replist = db.ListProperty(str) > >      unique = db.ListProperty(str) > >      date = db.DateTimeProperty(auto_now_add=True) > > > > > > Rep().replist = L > > R

text file reformatting

2010-10-31 Thread iwawi
I have this fixed width data file (data.txt) which I would like to reformat. Data is something like this, with hundreds of rows and columns, every row finishes to END: PRJ01001 4 00100END PRJ01002 3 00110END PRJ01003 3 00120END PRJ01004 2 00130END PRJ01005 1 00140END PRJ01006 1 00150END PRJ01007 3

Re: Py3: Import relative path module

2010-10-31 Thread Дамјан Георгиевски
> I am loathe to duplicate programming in files that should just load a > copy from a module. I tried all kinds of tricks to import a module > from one level up. What's the secret? > > It works if I say: > > from Data import DumpHT > > but ONLY if the search path in sys.path. I want a relative

Re: import ImageGrab fails on Ubuntu 10.4

2010-10-31 Thread News123
On 10/31/2010 05:04 PM, News123 wrote: > importing ImageGrab un Ubuntu 10.4 fails as seen below: > > import _grabscreen > ImportError: No module named _grabscreen > Well I found a partial answer on http://www.pythonware.com/library/pil/handbook/imagegrab.htm > The ImageGrab module can be

import ImageGrab fails on Ubuntu 10.4

2010-10-31 Thread News123
Hi, It's the first time I wanted to use ImageGrab. importing ImageGrab fails as seen below: $ python -c "import ImageGrab" Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.6/dist-packages/PIL/ImageGrab.py", line 34, in import _grabscreen ImportError: No mo

Py3: Import relative path module

2010-10-31 Thread Gnarlodious
I am loathe to duplicate programming in files that should just load a copy from a module. I tried all kinds of tricks to import a module from one level up. What's the secret? It works if I say: from Data import DumpHT but ONLY if the search path in sys.path. I want a relative path import indepen

Re: Is there a way to pring a list object in Python?

2010-10-31 Thread Zeynel
On Oct 31, 3:00 am, Richard Thomas wrote: > On Oct 31, 5:42 am, Zeynel wrote: > > > class Rep(db.Model): > >     author = db.UserProperty() > >     replist = db.ListProperty(str) > >     unique = db.ListProperty(str) > >     date = db.DateTimeProperty(auto_now_add=True) > > > > > > Rep().rep

Re: Compare source code

2010-10-31 Thread jf
Le 31/10/2010 13:10, Martin v. Loewis a écrit : I've a project with tabs and spaces mixed (yes I know it's bad). I edit each file to remove tabs, but it's so easy to make a mistake. Do you know a tools to compare the initial file with the cleaned one to know if the algorithms are the same ? To

Re: no line breaks in xml file with elementTree

2010-10-31 Thread Stefan Behnel
hackingKK, 31.10.2010 10:04: On Sunday 31 October 2010 01:58 PM, Lawrence D'Oliveiro wrote: hackingKK wrote: Further more, I just was curious why elementtree is not having the namespace facility? ElementTree handles namespaces just fine. So is there a function to generate tags with namespac

Re: A bug for raw string literals in Py3k?

2010-10-31 Thread Yingjie Lan
> > So I suppose this is a bug? > > It's not, see > > http://docs.python.org/py3k/reference/lexical_analysis.html#literals > > # Specifically, a raw string cannot end in a single backslash Thanks! That looks weird to me ... doesn't this contradict with: All backslashes in raw string literals a

Re: Compare source code

2010-10-31 Thread Martin v. Loewis
> I've a project with tabs and spaces mixed (yes I know it's bad). > > I edit each file to remove tabs, but it's so easy to make a mistake. > Do you know a tools to compare the initial file with the cleaned one to > know if the algorithms are the same ? > By comparing pyc files for example. Tools

Compare source code

2010-10-31 Thread jf
Hi, I've a project with tabs and spaces mixed (yes I know it's bad). I edit each file to remove tabs, but it's so easy to make a mistake. Do you know a tools to compare the initial file with the cleaned one to know if the algorithms are the same ? By comparing pyc files for example. Thanks. -

Re: A bug for raw string literals in Py3k?

2010-10-31 Thread Martin v. Loewis
> So I suppose this is a bug? It's not, see http://docs.python.org/py3k/reference/lexical_analysis.html#literals # Specifically, a raw string cannot end in a single backslash Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list

A bug for raw string literals in Py3k?

2010-10-31 Thread Yingjie Lan
Hi, I tried this in the IDLE (version 3.1.2) shell: >>> r'\' SyntaxError: EOL while scanning string literal But according to the py3k docs (http://docs.python.org/release/3.0.1/whatsnew/3.0.html): All backslashes in raw string literals are interpreted literally. So I suppose this is a bug? Y

Re: Is there a way to pring a list object in Python?

2010-10-31 Thread Dave Angel
On 2:59 PM, Zeynel wrote: class Rep(db.Model): author = db.UserProperty() replist = db.ListProperty(str) unique = db.ListProperty(str) date = db.DateTimeProperty(auto_now_add=True) Rep().replist = L Rep().put() mylist = Rep().all().fetch(10) I am trying to display myli

Re: no line breaks in xml file with elementTree

2010-10-31 Thread hackingKK
On Sunday 31 October 2010 01:58 PM, Lawrence D'Oliveiro wrote: In message, hackingKK wrote: I want to know if there is a way to have the ElementTree module write to an xml file with line breaks? Why does it matter? The XML files you generate are not for humans to look at, are they?

Re: no line breaks in xml file with elementTree

2010-10-31 Thread Lawrence D'Oliveiro
In message , hackingKK wrote: > I want to know if there is a way to have the ElementTree module write to > an xml file with line breaks? Why does it matter? The XML files you generate are not for humans to look at, are they? > Further more, I just was curious why elementtree is not having the

playing with berp: python3 to haskell compiler in haskell

2010-10-31 Thread Alia Khouri
In case anyone finds this worthwhile: there is a pretty impressive python3 to haskell compiler written in haskell called berp that looks very interesting: http://github.com/bjpop/berp/wiki I highly recommend reading through the berp implementation code for a fascinating (but currently incomplete)

no line breaks in xml file with elementTree

2010-10-31 Thread hackingKK
Hello all. I want to know if there is a way to have the ElementTree module write to an xml file with line breaks? I find that when I use the write function from the module on a tree object, the resulting file has no line breaks. I don't want to use prittyprint because it is adding extra tabs t

Re: Is there a way to pring a list object in Python?

2010-10-31 Thread Richard Thomas
On Oct 31, 5:42 am, Zeynel wrote: > class Rep(db.Model): >     author = db.UserProperty() >     replist = db.ListProperty(str) >     unique = db.ListProperty(str) >     date = db.DateTimeProperty(auto_now_add=True) > > > > Rep().replist = L > Rep().put() > mylist = Rep().all().fetch(10) > > I