Re: Problem in accessing files with unicode fonts.

2009-02-23 Thread Mark Tolonen
Try os.walk for recursively walking directories. Also if you use a unicode parameter with os.walk or os.listdir you get unicode strings in the result. To run this successfully when you have non-ascii characters in your filenames, you will need to use an environment that supports the characters

Re: ANN: SuPy 1.6

2009-02-23 Thread Mike C. Fletcher
Greg Ewing wrote: ... What is SuPy? - SuPy is a plugin for the Sketchup 3D modelling application that lets you script it in Python. Hi Greg, Can you review the SuPy writeup on Py3D? I couldn't get through to your server this evening, so I couldn't check the license, if there's a

Re: Problem in accessing files with unicode fonts.

2009-02-23 Thread venu madhav
On Tue, Feb 24, 2009 at 12:16 PM, Chris Rebert wrote: > A. Your reason for emailing us off-list makes no sense. The list would > garner you more and about as quick responses, not to mention the value > it adds through public archiving. CC-ing us /might/ have made slight > sense. > B. This is your

Re: How to read columns in python

2009-02-23 Thread Dhananjay
Well, The three columns are tab separated and there are 200 such rows having these 3 columns in the file. First two columns are x and y coordinates and third column is the corresponding value. I want to read this file as a matrix in which column1 correspond to row, column2 corresponds to columns

Re: How to read columns in python

2009-02-23 Thread Chris Rebert
On Mon, Feb 23, 2009 at 10:41 PM, Dhananjay wrote: > I am bit new to python and programming and this might be a basic question: > > I have a file containing 3 columns. Your question is much too vague to answer. What defines a "column" for you? Tab-separated, comma-separated, or something else alt

Re: Problem in accessing files with unicode fonts.

2009-02-23 Thread Chris Rebert
A. Your reason for emailing us off-list makes no sense. The list would garner you more and about as quick responses, not to mention the value it adds through public archiving. CC-ing us /might/ have made slight sense. B. This is your problem: v = unicode(full_path,errors='skip') I'd advise you

How to read columns in python

2009-02-23 Thread Dhananjay
I am bit new to python and programming and this might be a basic question: I have a file containing 3 columns. first two columns are x and y axes and third column is their corresponding values in the graph. I want to read this in a matrix as well as plot in 2D. Could anyone tell me how to do so

ANN: SuPy 1.6

2009-02-23 Thread Greg Ewing
SuPy 1.6 Available -- http://www.cosc.canterbury.ac.nz/greg.ewing/SuPy/ Fixed some bugs in the Tool and Observer classes, and in the linetool example. What is SuPy? - SuPy is a plugin for the Sketchup 3D modelling application that lets you script it in Python.

Re: "Byte" type?

2009-02-23 Thread Martin v. Löwis
>> Depends on how you write your code. If you use the bytearray type >> (which John didn't, despite his apparent believe that he did), >> then no conversion additional conversion is needed. > > According to PEP 3137, there should be no distinction between > the two for read purposes. In 2.6,

Re: How do I count the distance between strings in a list?

2009-02-23 Thread Steven D'Aprano
On Mon, 23 Feb 2009 21:35:21 -0800, collin wrote: > For example, if I were to have the code > > randomlist = ["1", "2", "3", "4"] > > And I want to count the distance between strings "1" and "4" which is 3, > what command can I use to do this? This question is ambiguous. It could mean: int("4"

Re: How do I count the distance between strings in a list?

2009-02-23 Thread Jonathan Gardner
On Feb 23, 9:35 pm, collin wrote: > For example, if I were to have the code > > randomlist = ["1", "2", "3", "4"] > > And I want to count the distance between strings "1" and "4" which is > 3, what command can I use to do this? You'd have to get the indexes of the two items and subtract them. The

Re: code challenge: generate minimal expressions using only digits 1,2,3

2009-02-23 Thread Sambit Samal
test On Sat, Feb 21, 2009 at 3:31 AM, Trip Technician wrote: > anyone interested in looking at the following problem. > > we are trying to express numbers as minimal expressions using only the > digits one two and three, with conventional arithmetic. so for > instance > > 33 = 2^(3+2)+1 = 3^3+(3*

Re: getting at individual bits inside byte field: struct module : bitwise operator

2009-02-23 Thread harijay
Thanks Gabriel , MRAB and Mark Instead of using the bitwise operator on the unpacked data I was trying to do a bitwise operator directly after read. This was giving the unsupported operand error i.e # version in my code - wrong file.read(2) & 0x001f Instead of # version in my example and now i

How do I count the distance between strings in a list?

2009-02-23 Thread collin
For example, if I were to have the code randomlist = ["1", "2", "3", "4"] And I want to count the distance between strings "1" and "4" which is 3, what command can I use to do this? -- http://mail.python.org/mailman/listinfo/python-list

Re: how to conditionally add a dict in-line

2009-02-23 Thread Steven D'Aprano
On Mon, 23 Feb 2009 21:56:46 -0700, Wes James wrote: >> vars = {'_page': i} >> if request.vars._query is not None: >>    vars['_query'] = request.vars._query > > Could this be: > > vars = {'_page': i} > if request.vars._query: > vars['_query'] = request.vars._query Instead of typing "requ

Re: A tale of two execs

2009-02-23 Thread aha
Hello All, It occurred to me that I might just want to try copying the subprocess.py installed in a /usr/lib/python24 installation to the directory where I place the scripts that I need to launch my application...I know this was mentioned earlier. Anyway, my application worked under python 2.3 a

Re: How does one get from "ImportError: DLL load failed:..." to a culprit .dll and symbol?

2009-02-23 Thread John Machin
On Feb 24, 2:54 pm, Chris Cormie wrote: > Mark Hammond wrote: > > On 23/02/2009 11:41 PM, Chris Cormie wrote: > > >>> If that not-very-technical description [all I've ever needed] doesn't > >>> help, you'll need to read the DW help file (HTFF1K) or wait till > >>> someone who knows what they are d

Re: pysqlite smart search

2009-02-23 Thread klia
klia wrote: > > Hey guys; > > I am trying to develop a tiny program using python to search inside sqlite > database with file extension is .db in which the program will ask users to > enter their search query and base on that it will retrieve the results But > > I need the program to have so

tkinter icons as bytestrings, not files?

2009-02-23 Thread Peter Billam
Greetings, As a newbie, starting with Python3, I'm working my way through Mark Summerfield's tkinter examples. In the toolbar, there's lines like: for image, command in ( ('images/filenew.gif', self.fileNew), ('images/fileopen.gif', self.fileOpen), ('images/filesave.g

Re: how to conditionally add a dict in-line

2009-02-23 Thread Wes James
Steven. Thx (see my question below...) On Mon, Feb 23, 2009 at 9:47 PM, Steven D'Aprano wrote: > On Mon, 23 Feb 2009 21:35:38 -0700, Wes James wrote: > >> I have this line: >> >> navs.append(A(' '+str(i+1)+' >> ',_href=self.action(args=request.args,vars= > {'_page':i,'_query':request.vars._query

Re: Access from class variable to one on constructor

2009-02-23 Thread Steven D'Aprano
On Mon, 23 Feb 2009 08:02:17 -0200, Gabriel Genellina wrote: > En Mon, 23 Feb 2009 07:40:47 -0200, Kless > escribió: > >> How to access from a class variable to one that is initialized on the >> constructor? >> -- >> class Foo(): >> foo = bar # I want to access *from here* to vari

Re: Reference or Value?

2009-02-23 Thread Steven D'Aprano
On Mon, 23 Feb 2009 08:14:34 -0300, andrew cooke wrote: > Steven D'Aprano wrote: >> On Sun, 22 Feb 2009 13:37:27 -0300, andrew cooke wrote: >> >>> as far as i understand things, the best model is: >>> >>> 1 - everything is an object >>> 2 - everything is passed by reference >> >> Except that is wr

Re: how to conditionally add a dict in-line

2009-02-23 Thread Steven D'Aprano
On Mon, 23 Feb 2009 21:35:38 -0700, Wes James wrote: > I have this line: > > navs.append(A(' '+str(i+1)+' > ',_href=self.action(args=request.args,vars= {'_page':i,'_query':request.vars._query > or ''}))) What a mess. How can you read it? > How do I do something like this: > > vars={'_page':i,

Re: how to conditionally add a dict in-line

2009-02-23 Thread Wes James
On Mon, Feb 23, 2009 at 9:35 PM, Wes James wrote: > I have this line: > > navs.append(A(' '+str(i+1)+' > ',_href=self.action(args=request.args,vars={'_page':i,'_query':request.vars._query > or ''}))) > > How do I do something like this: > > vars={'_page':i, if request.vars._query not None then ins

how to conditionally add a dict in-line

2009-02-23 Thread Wes James
I have this line: navs.append(A(' '+str(i+1)+' ',_href=self.action(args=request.args,vars={'_page':i,'_query':request.vars._query or ''}))) How do I do something like this: vars={'_page':i, if request.vars._query not None then insert this key/value pair ('_query':request.vars._query) else insert

Re: getting at individual bits inside byte field: struct module : bitwise operator

2009-02-23 Thread Mark Tolonen
"harijay" wrote in message news:4c7d58a1-830f-4f02-ba07-aa4910f5f...@b16g2000yqb.googlegroups.com... In my last post I had asked about reading data from a binary file using the struct module. Thanks to some excellent help , I have managed to read in successfully most of the header of this bina

Re: opening files with names in non-english characters.

2009-02-23 Thread venutaurus...@gmail.com
On Feb 24, 8:29 am, "venutaurus...@gmail.com" wrote: > On Feb 23, 11:02 pm, Chris Rebert wrote: > > > > > On Mon, Feb 23, 2009 at 5:51 AM, venutaurus...@gmail.com > > > wrote: > > > Hi all, > > >          I am trying to find the attributes of afile whose name has > > > non english characters one

Re: getting tut. example to work

2009-02-23 Thread alex23
On Feb 24, 1:31 pm, John Forse wrote: > I'm trying some examples from the language ref sections on the site in   > the process of learning some python in 3.0.1. I've tried to run both   > of the samples below ,but the only printout is "generator object chain   > at 0x11f4dc8" whether I use print()

Re: How does one get from "ImportError: DLL load failed:..." to a culprit .dll and symbol?

2009-02-23 Thread Chris Cormie
Mark Hammond wrote: On 23/02/2009 11:41 PM, Chris Cormie wrote: If that not-very-technical description [all I've ever needed] doesn't help, you'll need to read the DW help file (HTFF1K) or wait till someone who knows what they are doing comes along :-) LOL, I am that person :p LOL sounds r

Re: "Byte" type?

2009-02-23 Thread John Nagle
Martin v. Löwis wrote: Please don't call something dumb that you don't fully understand. It's offenses the people who have spent lots of time developing Python -- personal, unpaid and voluntary time! Some of the people involved are on Google's payroll. Crying out; "Please do not criticise

getting tut. example to work

2009-02-23 Thread John Forse
I'm trying some examples from the language ref sections on the site in the process of learning some python in 3.0.1. I've tried to run both of the samples below ,but the only printout is "generator object chain at 0x11f4dc8" whether I use print() or not . How do I use the sample to produce

Re: opening files with names in non-english characters.

2009-02-23 Thread venutaurus...@gmail.com
On Feb 23, 11:02 pm, Chris Rebert wrote: > On Mon, Feb 23, 2009 at 5:51 AM, venutaurus...@gmail.com > > wrote: > > Hi all, > >          I am trying to find the attributes of afile whose name has > > non english characters one like given below. When I try to run my > > python scirpt, it fails givi

Re: How does one get from "ImportError: DLL load failed:..." to a culprit .dll and symbol?

2009-02-23 Thread Chris Cormie
John Machin wrote: On Feb 23, 11:41 pm, Chris Cormie wrote: If that not-very-technical description [all I've ever needed] doesn't help, you'll need to read the DW help file (HTFF1K) or wait till someone who knows what they are doing comes along :-) LOL, I am that person :p It wasn't apparent

Re: How does one get from "ImportError: DLL load failed:..." to a culprit .dll and symbol?

2009-02-23 Thread Chris Cormie
Gabriel Genellina wrote: En Mon, 23 Feb 2009 10:41:20 -0200, Chris Cormie escribió: If that not-very-technical description [all I've ever needed] doesn't help, you'll need to read the DW help file (HTFF1K) or wait till someone who knows what they are doing comes along :-) LOL, I am that per

Re: Code in __init__.py, is it bad form?

2009-02-23 Thread Carl Banks
On Feb 23, 5:41 pm, Michael Crute wrote: > Is it bad form (i.e. non-pythonic) to have code in your __init__.py > files? I know this is subjective so I'm just looking for the general > consensus. I've heard both sides of the story and I personally feel > its okay if the code pertains to the whole m

Re: How does one get from "ImportError: DLL load failed:..." to a culprit .dll and symbol?

2009-02-23 Thread Chris Cormie
Mark Hammond wrote: On 23/02/2009 11:41 PM, Chris Cormie wrote: If that not-very-technical description [all I've ever needed] doesn't help, you'll need to read the DW help file (HTFF1K) or wait till someone who knows what they are doing comes along :-) LOL, I am that person :p LOL sounds r

Re: Code in __init__.py, is it bad form?

2009-02-23 Thread Michael Crute
On Mon, Feb 23, 2009 at 9:41 PM, Benjamin Peterson wrote: > Michael Crute gmail.com> writes: >> On Mon, Feb 23, 2009 at 9:03 PM, Steve Holden holdenweb.com> >> wrote: >> > No, it's absolutely fine. One common usage is to import symbols from >> > sub-modules so that they are available from a sim

Re: Code in __init__.py, is it bad form?

2009-02-23 Thread alex23
On Feb 24, 12:21 pm, Michael Crute wrote: > Yeah, I use it often for that I'm talking more about stuff like > utility functions, main methods, etc... Personally, I use it only for those tasks related to 'initialising' the package, a la the importing of various modules for convenience sake (as men

Re: Code in __init__.py, is it bad form?

2009-02-23 Thread Ben Finney
Michael Crute writes: > Is it bad form (i.e. non-pythonic) to have code in your __init__.py > files? No, it's good form, but *only* for code that truly pertains to the entire package. Anything that can reasonably be in a module other than ‘__init__’, should be. That leaves the following things

Re: Code in __init__.py, is it bad form?

2009-02-23 Thread Benjamin Peterson
Michael Crute gmail.com> writes: > On Mon, Feb 23, 2009 at 9:03 PM, Steve Holden holdenweb.com> > wrote: > > No, it's absolutely fine. One common usage is to import symbols from > > sub-modules so that they are available from a simple import of the package. > > Yeah, I use it often for that I'm

Re: ZSI / MTOM

2009-02-23 Thread Cameron Simpson
On 23Feb2009 08:09, John Ionides wrote: | I have project for which I would like to have a python web service | including MTOM. It seems that ZSI is the most complete python web | service library but that it doesn't currently support MTOM - and | having worked through the code it looks as though it

Re: Code in __init__.py, is it bad form?

2009-02-23 Thread Michael Crute
On Mon, Feb 23, 2009 at 9:03 PM, Steve Holden wrote: > Michael Crute wrote: >> Is it bad form (i.e. non-pythonic) to have code in your __init__.py >> files? I know this is subjective so I'm just looking for the general >> consensus. I've heard both sides of the story and I personally feel >> its o

Re: more on unescaping escapes

2009-02-23 Thread bvdp
Gabriel Genellina wrote: En Mon, 23 Feb 2009 23:31:20 -0200, bvdp escribió: Gabriel Genellina wrote: En Mon, 23 Feb 2009 22:46:34 -0200, bvdp escribió: Chris Rebert wrote: On Mon, Feb 23, 2009 at 4:26 PM, bvdp wrote: [problem with Python and Windows paths using backslashes] Is there an

Re: Code in __init__.py, is it bad form?

2009-02-23 Thread Steve Holden
Michael Crute wrote: > Is it bad form (i.e. non-pythonic) to have code in your __init__.py > files? I know this is subjective so I'm just looking for the general > consensus. I've heard both sides of the story and I personally feel > its okay if the code pertains to the whole module but have an ope

Re: Peculiar swap behavior

2009-02-23 Thread Gabriel Genellina
En Mon, 23 Feb 2009 22:58:44 -0200, John Posner escribió: m,n = [1,2,3],[4,5,6] m[:],n[:] = n,m I believe this is an RTFM situation. In the Python 2.6.1 help topic "Simple Statements" > "Assignment Statements", see this para: Yes, the other relevant paragraph is: """An assign

Re: more on unescaping escapes

2009-02-23 Thread Gabriel Genellina
En Mon, 23 Feb 2009 23:31:20 -0200, bvdp escribió: Gabriel Genellina wrote: En Mon, 23 Feb 2009 22:46:34 -0200, bvdp escribió: Chris Rebert wrote: On Mon, Feb 23, 2009 at 4:26 PM, bvdp wrote: [problem with Python and Windows paths using backslashes] Is there any particular reason you ca

Re: Need to store dictionary in file

2009-02-23 Thread Gabriel Genellina
En Mon, 23 Feb 2009 18:38:56 -0200, S.Selvam Siva escribió: I have a dictionary in which each key is associated with a list as value. eg: *dic={'a':['aa','ant','all']}* The dictionary contains *1.5 lakh keys*. Now i want to store it to a file,and need to be loaded to python program during e

Code in __init__.py, is it bad form?

2009-02-23 Thread Michael Crute
Is it bad form (i.e. non-pythonic) to have code in your __init__.py files? I know this is subjective so I'm just looking for the general consensus. I've heard both sides of the story and I personally feel its okay if the code pertains to the whole module but have an open mind about the matter. If y

Re: can error messages be improved or can they be overridden ?

2009-02-23 Thread rdmurray
"andrew cooke" wrote: > rdmur...@bitdance.com wrote: > [...] > > (You know, I really ought to revisit that routine and make it part > > of my standard development toolbox.) > > please post it OK. I dug it up, cut out the stuff that was specific to the application, freshened it up a little,

Re: more on unescaping escapes

2009-02-23 Thread bvdp
Gabriel Genellina wrote: En Mon, 23 Feb 2009 22:46:34 -0200, bvdp escribió: Chris Rebert wrote: On Mon, Feb 23, 2009 at 4:26 PM, bvdp wrote: [problem with Python and Windows paths using backslashes] Is there any particular reason you can't just internally use regular forward-slashes for the

Re: thanks very much indeed for your help is there a better way to do this (python3) newby

2009-02-23 Thread Rhodri James
On Mon, 23 Feb 2009 23:33:31 -, Gary Wood wrote: '''exercise to complete and test this function''' import string def joinStrings(items): '''Join all the strings in stringList into one string, and return the result. For example: >>> print joinStrings(['very', 'hot', 'day']) '

Re: more on unescaping escapes

2009-02-23 Thread Gabriel Genellina
En Mon, 23 Feb 2009 22:46:34 -0200, bvdp escribió: Chris Rebert wrote: On Mon, Feb 23, 2009 at 4:26 PM, bvdp wrote: [problem with Python and Windows paths using backslashes] Is there any particular reason you can't just internally use regular forward-slashes for the paths? They work in Windo

Re: Peculiar swap behavior

2009-02-23 Thread John Posner
>> m,n = [1,2,3],[4,5,6] >> m[:],n[:] = n,m I believe this is an RTFM situation. In the Python 2.6.1 help topic "Simple Statements" > "Assignment Statements", see this para: If the target is a slicing: The primary expression in the reference is evaluated. It should yield a mutable seq

Re: more on unescaping escapes

2009-02-23 Thread Mel
bvdp wrote: > Not sure if it's more clear or not :) > > >>> a="c:\\Program\x20Files\\test" > >>> a > 'c:\\Program Files\\test' > >>> print a > c:\Program Files\test > > Which is all fine. And I didn't need to use decode(). > > So, in this case I'm assuming that the interpreter is converting t

Re: getting at individual bits inside byte field: struct module : bitwise operator

2009-02-23 Thread Gabriel Genellina
En Mon, 23 Feb 2009 22:18:31 -0200, harijay escribió: mentioned here : ( http://www.dataq.com/support/techinfo/ff.htm) I have a question about how to bitmask a bunch of bytes read in from such a binary formatted file . For eg the spec says the first two bytes have different parameters in diff

Re: Python AppStore / Marketplace

2009-02-23 Thread Rhodri James
On Mon, 23 Feb 2009 22:12:09 -, Steve Holden wrote: Michael Torrie wrote: Steve Holden wrote: Unfortunately I have no idea what a "souq" is, so I suspect this may be linguistically biased against English speakers. Or perhaps I'm just ignorant. Nah. Not biased against English speakers

Re: more on unescaping escapes

2009-02-23 Thread bvdp
Bear in mind that it's the string as it really is that is being operated on, not the representation of it that you displayed Yes, that is the confusion ... what is displayed and what's actually in the string. I think I understand it all now :) Thanks. -- http://mail.python.org/mailman/lis

Re: more on unescaping escapes

2009-02-23 Thread bvdp
Chris Rebert wrote: On Mon, Feb 23, 2009 at 4:26 PM, bvdp wrote: [problem with Python and Windows paths using backslashes] Is there any particular reason you can't just internally use regular forward-slashes for the paths? They work in Windows from Python in nearly all cases and you can easily

Re: more on unescaping escapes

2009-02-23 Thread Chris Rebert
On Mon, Feb 23, 2009 at 4:26 PM, bvdp wrote: [problem with Python and Windows paths using backslashes] Is there any particular reason you can't just internally use regular forward-slashes for the paths? They work in Windows from Python in nearly all cases and you can easily interconvert using os.

Re: getting at individual bits inside byte field: struct module : bitwise operator

2009-02-23 Thread MRAB
harijay wrote: In my last post I had asked about reading data from a binary file using the struct module. Thanks to some excellent help , I have managed to read in successfully most of the header of this binary format that I want to parse. These are some time-voltage traces from a digital to ana

Re: more on unescaping escapes

2009-02-23 Thread Rhodri James
On Tue, 24 Feb 2009 00:26:29 -, bvdp wrote: So, in this case I'm assuming that the interpreter is converting the escapes on assignment. The compiler converts the escapes on creating its internal representation of the string, before assignment ever gets involved. -- Rhodri James *-* Wild

Re: can error messages be improved or can they be overridden ?

2009-02-23 Thread python
Gabriel, > Have you seen the cgitb module? Despite its name, it's a general purpose > module. > > > import cgitb > cgitb.enable(format="txt") > > My vote for tip of the week, perhaps even month. I'm not part of this thread, but your post is a great

Re: Can someone tell me why i get None at the end please this has me stuck for ages

2009-02-23 Thread Gabriel Genellina
En Mon, 23 Feb 2009 17:22:16 -0200, Gary Wood escribió: '''exercise to complete and test this function''' import string def joinStrings(items): '''Join all the strings in stringList into one string, and return the result. For example: >>> print joinStrings(['very', 'hot', 'day'])

Re: intermediate python csv reader/writer question from a beginner

2009-02-23 Thread Chris Rebert
On Mon, Feb 23, 2009 at 1:33 PM, Learning Python wrote: > anything related to csv, I usually use VB within excel to manipulate > the data, nonetheless, i finally got the courage to take a dive into > python. i have viewed a lot of googled csv tutorials, but none of > them address everything i nee

Re: more on unescaping escapes

2009-02-23 Thread Rhodri James
On Mon, 23 Feb 2009 22:05:42 -, bvdp wrote: So, we think something is working and send of a bug fix to our client :) I'm not sure I understand this at all and wonder if there is bug? >>> a="c:\\Program\x20Files\\test" >>> a 'c:\\Program Files\\test' so far, so good. >>> a.decode("st

Re: more on unescaping escapes

2009-02-23 Thread bvdp
Tim Wintle wrote: On Mon, 2009-02-23 at 17:00 -0700, bvdp wrote: Let's see if this makes sense: >>> a='c:\\Program Files\\test' >>> a.decode('string-escape') 'c:\\Program Files\test' Hint: try running print a and see what's written - I think that the interpreter adds extra "\" character

Re: Can someone tell me why i get None at the end please this has me stuck for ages

2009-02-23 Thread Chris Rebert
On Mon, Feb 23, 2009 at 11:22 AM, Gary Wood wrote: > '''exercise to complete and test this function''' > import string > def joinStrings(items): > '''Join all the strings in stringList into one string, > and return the result. For example: > >>> print joinStrings(['very', 'hot', 'day']

getting at individual bits inside byte field: struct module : bitwise operator

2009-02-23 Thread harijay
In my last post I had asked about reading data from a binary file using the struct module. Thanks to some excellent help , I have managed to read in successfully most of the header of this binary format that I want to parse. These are some time-voltage traces from a digital to analog converter for

Re: more on unescaping escapes

2009-02-23 Thread bvdp
andrew cooke wrote: do you know that a string with the letter "r" in front doesn't escape slashes? it's intended for regular expressions, but would simplify things for you here too. just do a=r'c:\\Program Files\test' Yes, I knew that. Unfortunately in my program loop I really don't have

Re: Need to store dictionary in file

2009-02-23 Thread Chris Rebert
On Mon, Feb 23, 2009 at 12:38 PM, S.Selvam Siva wrote: > Hi all, > > I have a dictionary in which each key is associated with a list as value. > > eg: dic={'a':['aa','ant','all']} > > The dictionary contains 1.5 lakh keys. Tip: You might not want to use the "lakh" in international media such as i

Re: "import" not working?

2009-02-23 Thread Rhodri James
On Mon, 23 Feb 2009 19:24:46 -, Lionel wrote: sys.path.append("C:\DataFileTypes") Just so that we're clear, this is a *really* *bad* habit to get into. Not appending to sys.path, though that isn't often a good idea, but failing to escape your backslashes. This works because '\D' happens

Re: more on unescaping escapes

2009-02-23 Thread Tim Wintle
On Mon, 2009-02-23 at 17:00 -0700, bvdp wrote: > Let's see if this makes sense: > > >>> a='c:\\Program Files\\test' > >>> a.decode('string-escape') > 'c:\\Program Files\test' Hint: try running >>> print a and see what's written - I think that the interpreter adds extra "\" characters to escap

Re: can error messages be improved or can they be overridden ?

2009-02-23 Thread Gabriel Genellina
En Mon, 23 Feb 2009 15:54:03 -0200, escribió: Stef Mientki wrote: but I was looking for a more general solution, in which I don't change the program itself, and where the error messages (in general) become more informative than it is by default. No you are not the only one who wishes the er

Re: more on unescaping escapes

2009-02-23 Thread andrew cooke
do you know that a string with the letter "r" in front doesn't escape slashes? it's intended for regular expressions, but would simplify things for you here too. just do a=r'c:\\Program Files\test' andrew bvdp wrote: > > I'm getting hopelessly lost in a series of \\\ s :) > > Let's see

Re: read csv error question

2009-02-23 Thread MRAB
Benjamin Kaplan wrote: On Mon, Feb 23, 2009 at 6:43 PM, MRAB > wrote: Vincent Davis wrote: I am trying to read a csv file from excel on a mac. I get the following error. SystemExit: file some.csv, line 1: new-line character seen

Re: read csv error question

2009-02-23 Thread Vincent Davis
I just thought to look in the documentation for open() It seems this may contain the answers to my questions. I am just to new to python to know where my problem is, Thanks Vincent Davis 720-301-3003 On Mon, Feb 23, 2009 at 4:52 PM, Benjamin Kaplan wrote: > > > On Mon, Feb 23, 2009 at 6:43 PM, M

Re: more on unescaping escapes

2009-02-23 Thread bvdp
I'm getting hopelessly lost in a series of \\\ s :) Let's see if this makes sense: >>> a='c:\\Program Files\\test' >>> a.decode('string-escape') 'c:\\Program Files\test' In this case there are still 2 '\'s before the P; but only 1 before the 't'. Now, when it comes time to open the file w

Re: read csv error question

2009-02-23 Thread Vincent Davis
Thanks for the help the "U" was what I needed. I was reading the documentation here.http://docs.python.org/library/csv.html but I could not find the term universal-newline mode, In fact where do you find "U" I have not read it word for word but it is not obvious to me. I do even see anything about

Re: read csv error question

2009-02-23 Thread Benjamin Kaplan
On Mon, Feb 23, 2009 at 6:43 PM, MRAB wrote: > Vincent Davis wrote: > >> I am trying to read a csv file from excel on a mac. I get the following >> error. >> SystemExit: file some.csv, line 1: new-line character seen in unquoted >> field - do you need to open the file in universal-newline mode? >

Re: Reference or Value?

2009-02-23 Thread Gabriel Genellina
En Mon, 23 Feb 2009 17:17:04 -0200, Brian Blais escribió: On Feb 23, 2009, at 3:03 , Gabriel Genellina wrote: En Mon, 23 Feb 2009 03:54:16 -0200, Denis Kasak escribió: On Mon, Feb 23, 2009 at 5:09 AM, Steven D'Aprano wrote: On Sun, 22 Feb 2009 13:37:27 -0300, andrew cooke wrote: as far a

Re: read csv error question

2009-02-23 Thread MRAB
Vincent Davis wrote: I am trying to read a csv file from excel on a mac. I get the following error. SystemExit: file some.csv, line 1: new-line character seen in unquoted field - do you need to open the file in universal-newline mode? I was using the example code import csv, sys reader = csv.r

read csv error question

2009-02-23 Thread rdmurray
Vincent Davis wrote: > I am trying to read a csv file from excel on a mac. I get the following > error.SystemExit: file some.csv, line 1: new-line character seen in unquoted > field - do you need to open the file in universal-newline mode? > I was using the example code > import csv, sys > > read

RE: Peculiar swap behavior

2009-02-23 Thread andrew cooke
andrew cooke wrote: > Delaney, Timothy (Tim) wrote: >> Tim Chase wrote: >>> # swap list contents...not so much... >>> >>> m,n = [1,2,3],[4,5,6] >>> >>> m[:],n[:] = n,m >>> >>> m,n >>> ([4, 5, 6], [4, 5, 6]) > [...] >> For these types of things, it's best to expand the code out. The >> appropriat

Re: Reading a tab delimited text file.

2009-02-23 Thread harijay
You could also use the csv module import csv myfileobj = open("myfiletab.txt","read") csv_read = csv.reader(myfileobj,dialect=csv.excel_tab) myval1 = [] myval2 = [] myval3 = [] for line in csv_read: # filter header and stuff using some criterion if len(line) = 3: myval1.append(line[0])

Re: "import" not working?

2009-02-23 Thread Gabriel Genellina
En Mon, 23 Feb 2009 18:10:07 -0200, Lionel escribió: Taking "DataFileTypes.py" module out of the "...\site-packages \DataFileTypes" folder and placing it directly into the "site- packages" folder seems to have cleared it up. Some problem between package and module usage I suppose. You're ri

thanks very much indeed for your help is there a better way to do this (python3) newby

2009-02-23 Thread Gary Wood
'''exercise to complete and test this function''' import string def joinStrings(items): '''Join all the strings in stringList into one string, and return the result. For example: >>> print joinStrings(['very', 'hot', 'day']) 'veryhotday' ''' for i in items: return (''

Re: Peculiar swap behavior

2009-02-23 Thread Chris Rebert
On Mon, Feb 23, 2009 at 10:43 AM, Tim Chase wrote: > # swap list contents...not so much... m,n = [1,2,3],[4,5,6] m[:],n[:] = n,m m,n > ([4, 5, 6], [4, 5, 6]) Pseudo-C-Python expansion: #evaluate RHS. simply *take pointers* since the RHS is just plain variables ptr_n = &n ptr_m = &

Re: Challenge: Please break this! [Python Security]

2009-02-23 Thread Luis Zarrabeitia
On Monday 23 February 2009 03:50:57 pm tav wrote: > Hey all, > > As an attempt to convince Python-Dev of the merits of a > functions-based approach to security in Python, I've come up with a > simple challenge. > While I'm almost excited that you are tackling the problem of python's security, I f

read csv error question

2009-02-23 Thread Vincent Davis
I am trying to read a csv file from excel on a mac. I get the following error.SystemExit: file some.csv, line 1: new-line character seen in unquoted field - do you need to open the file in universal-newline mode? I was using the example code import csv, sys reader = csv.reader(open('/Volumes/vince

Re: Challenge: Please break this! [Python Security]

2009-02-23 Thread Tim Wintle
On Mon, 2009-02-23 at 13:20 -0800, Paul McNett wrote: > tav wrote: > > I'm keen to know your experiences even if you don't manage to write to > > the filesystem -- and especially if you do! > > Does it count when it breaks some standard libs that aren't even trying to > write to > the filesystem

Re: A tale of two execs

2009-02-23 Thread Steve Holden
aha wrote: > I've decided to change the runCmdLine method to Popen. > [...] So just exactly why was it necessary to follow this remark with about three hundred lines of quoted text? And can't you put your replies at the bottom rather than the top, please? And trim the stuff that isn't required. It

Re: Python won't run

2009-02-23 Thread Ned Deily
[Again, please reply-all to the list, don't send private email!] On Feb 23, 2009, at 14:03 , kevin hayes wrote: > Ned, system log didn't do anything when I tried to open IDLE. However, this > is what's in the console.log. does this tell you anything? > > Unhandled server exception! > Thread: Soc

Re: Peculiar swap behavior

2009-02-23 Thread Robert Kern
On 2009-02-23 16:17, andrew cooke wrote: Delaney, Timothy (Tim) wrote: Tim Chase wrote: # swap list contents...not so much... >>> m,n = [1,2,3],[4,5,6] >>> m[:],n[:] = n,m >>> m,n ([4, 5, 6], [4, 5, 6]) [...] For these types of things, it's best to expand the code out. The appropriat

Re: Reading a tab delimited text file.

2009-02-23 Thread Tim Chase
time_vec, ch1_vec, and_so_on = zip(*( map(float, line.split()) for line in file('in.txt'))) If this isn't homework, there are some less terse versions which are a bit easier on the eyes and less like some love-child between Perl and Python. haha, no this isn't homework. I'm a mecha

Re: more on unescaping escapes

2009-02-23 Thread MRAB
bvdp wrote: So, we think something is working and send of a bug fix to our client :) I'm not sure I understand this at all and wonder if there is bug? >>> a="c:\\Program\x20Files\\test" >>> a 'c:\\Program Files\\test' so far, so good. >>> a.decode("string-escape") 'c:\\Program Files\test'

Re: Reading a tab delimited text file.

2009-02-23 Thread Mel
Stephen wrote: > Hi, > > I would like to read a text file of numbers produced by a data > acquisition system into three vectors of doubles. The contents of the > file are: > > +0.000e+0 +2.7645134e+1 +2.7745625e+1 > > +0.4100041e-1 +2.7637787e+1 +2.7731047e+1 > > +0.0820008e+0 +2.76451

Re: A tale of two execs

2009-02-23 Thread aha
I've decided to change the runCmdLine method to Popen. On Feb 23, 4:54 pm, aha wrote: > Hello All, >   So below is my naive attempt at the wrapper, it is only half baked > since I am no master at Interprocess communication... I know that it > is lacking a lot of things comment greatly appreciated:

Re: Top posting

2009-02-23 Thread Steve Holden
Stef Mientki wrote: > >>> btw, it's also polite (in some cultures) to sign your messages ;-) >>> >> >> Hmm. I appreciate that you took the time to remove my signature from >> your reply but I don't think that you should then claim that I never >> included one. >> >> > Sorry for that. > >

Re: Reading a tab delimited text file.

2009-02-23 Thread Stephen
On Feb 23, 4:06 pm, Tim Chase wrote: > > I would like to read a text file of numbers produced by a data > > acquisition system into three vectors of doubles. The contents of the > > file are: > > > +0.000e+0      +2.7645134e+1   +2.7745625e+1 > > +0.4100041e-1      +2.7637787e+1   +2.7731047e+

RE: Peculiar swap behavior

2009-02-23 Thread andrew cooke
Delaney, Timothy (Tim) wrote: > Tim Chase wrote: >> # swap list contents...not so much... >> >>> m,n = [1,2,3],[4,5,6] >> >>> m[:],n[:] = n,m >> >>> m,n >> ([4, 5, 6], [4, 5, 6]) [...] > For these types of things, it's best to expand the code out. The > appropriate expansion of: > m,n = [1,2

  1   2   3   >