Re: [Tutor] xml parsing

2007-10-02 Thread Alan Gauld
"chinni" <[EMAIL PROTECTED]> wrote > I am working on MAC and my App was based on Xml file.If any updates > r any > changes in the xml file my app will load that changes. > as i am new to python.i want to automate that one. > details snipped > Here the size is in KB's.Now plz tell me how to

Re: [Tutor] creating the equivalent of string.strip()

2007-10-02 Thread Alan Gauld
"Ricardo Aráoz" <[EMAIL PROTECTED]> wrote >sorry, forgot a piece of the code : > >s = list(s) >while s[0].isspace() : > while s[-1].isspace() : > del s[-1] > del s[0] > s = ''.join(s) It still won't work. Strings are immutable, you can't use del to delete a character. Try it. >>

Re: [Tutor] for a given file, how to find file size?

2007-10-02 Thread Kamal
never mind found my answer here http://docs.python.org/lib/os-file-dir.html On 10/2/07, Kamal <[EMAIL PROTECTED]> wrote: > > would appreciate any pointers. > > -- > Thanks, > Kamal -- Thanks, Kamal ___ Tutor maillist - Tutor@python.org http://ma

[Tutor] for a given file, how to find file size?

2007-10-02 Thread Kamal
would appreciate any pointers. -- Thanks, Kamal ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] xml parsing

2007-10-02 Thread chinni
Hi, I am working on MAC and my App was based on Xml file.If any updates r any changes in the xml file my app will load that changes. as i am new to python.i want to automate that one. there will be one URL and size will mention in that Xml file.i want to write a script so that it will download the

Re: [Tutor] newbie: Django suited for database driven web application?

2007-10-02 Thread Kent Johnson
cuongvt wrote: > Hello > I'm new to both Django and Python. I'm mainly developing on PHP. > I tend to move to Django. But I want to confirm as below: > I heard that Django is mainly used for something like content management, > CMS or something > like that and Rails is mainly for web applicatio

[Tutor] newbie: Django suited for database driven web application?

2007-10-02 Thread cuongvt
Hello I'm new to both Django and Python. I'm mainly developing on PHP. I tend to move to Django. But I want to confirm as below: I heard that Django is mainly used for something like content management, CMS or something like that and Rails is mainly for web applications. So my question: is it

Re: [Tutor] creating the equivalent of string.strip()

2007-10-02 Thread Ricardo Aráoz
Alan Gauld wrote: > "Ricardo Aráoz" <[EMAIL PROTECTED]> wrote > >> So as not to copy strings many times : >> >> while s[0].isspace() : >>while s[-1].isspace() : >>del s[-1] >>del s[0] > > Sorry, it won;t work. Strings are immutable. > However you can keep a track of the indexes of

Re: [Tutor] creating the equivalent of string.strip()

2007-10-02 Thread Alan Gauld
"Ricardo Aráoz" <[EMAIL PROTECTED]> wrote > > So as not to copy strings many times : > > while s[0].isspace() : >while s[-1].isspace() : >del s[-1] >del s[0] Sorry, it won;t work. Strings are immutable. However you can keep a track of the indexes of the first and last non space c

Re: [Tutor] creating the equivalent of string.strip()

2007-10-02 Thread Ricardo Aráoz
Andrew James wrote: > *headbang* > > I'm an idiot. s=s[:-2] should be s=s[:-1]. > > Andrew James wrote: >> And as soon as I send it again I realise a pretty stupid error. The >> two loops shouldn't be nested. >> >> Andrew James wrote: >>> Helps if I send it to the group... >>> >>> And Kent, I di

Re: [Tutor] Update values stored as a list in a dictionary with values from another dictionary

2007-10-02 Thread Ricardo Aráoz
John Fouhy wrote: > On 02/10/2007, GTXY20 <[EMAIL PROTECTED]> wrote: >> Hello all, >> >> Let's say I have the following dictionary: >> >> {1:(a,b,c), 2:(a,c), 3:(b,c), 4:(a,d)} >> >> I also have another dictionary for new value association: >> >> {a:1, b:2, c:3} >> >> How should I approach if I wan

Re: [Tutor] Need help speeding up algorithm.

2007-10-02 Thread Terry Carroll
Ian, thanks for cleaning this up and submitting it. I was curious what its performance would be. On Wed, 26 Sep 2007, Ian Witham wrote: > while count > 0: > fivecount += count > count /= 5 This is a great improvement, and I'm embarrased that I didn't think of it myself!

Re: [Tutor] Update values stored as a list in a dictionary with values from another dictionary

2007-10-02 Thread Kent Johnson
GTXY20 wrote: > > I have the transFn function as follows: > > def transFn(translatefile): > transfile = open(translatefile, 'r') > records = transfile.read() > transfile.close() > lines = records.split() > transDict = {} > for line in lines: > key, value = line.spl

Re: [Tutor] Update values stored as a list in a dictionary with values from another dictionary

2007-10-02 Thread GTXY20
I have the transFn function as follows: def transFn(translatefile): transfile = open(translatefile, 'r') records = transfile.read() transfile.close() lines = records.split() transDict = {} for line in lines: key, value = line.split(',') transDict[key] = valu

Re: [Tutor] A simple Question...

2007-10-02 Thread Noufal Ibrahim
bhaaluu wrote: > On 10/2/07, Kent Johnson <[EMAIL PROTECTED]> wrote: >> traceback.print_stack() prints the stack trace to the current point of >> execution. No forced error or drama needed :-) >> >> Kent > > Exactly how is this used, please? > > Traceback (most recent call last): > File "print_

Re: [Tutor] Cython/Pyrex

2007-10-02 Thread Kent Johnson
Dave Kuhlman wrote: > Question: Someday will all the Python built-ins be implemented in > Cython/Pyrex. I would bet on RPython against Pyrex: http://codespeak.net/pypy/dist/pypy/doc/extcompiler.html Kent ___ Tutor maillist - Tutor@python.org http://ma

Re: [Tutor] Update values stored as a list in a dictionary with values from another dictionary

2007-10-02 Thread Kent Johnson
GTXY20 wrote: > Here's an interesting question: > > Can I use the transFn function to remove items in the value list. > > Can this be done by simple assigning the current value a value of null > in the translate file? No, that will make the translated value be None (I guess that is what you mea

Re: [Tutor] Update values stored as a list in a dictionary with values from another dictionary

2007-10-02 Thread GTXY20
Here's an interesting question: Can I use the transFn function to remove items in the value list. Can this be done by simple assigning the current value a value of null in the translate file? M. On 10/2/07, GTXY20 <[EMAIL PROTECTED]> wrote: > I adjusted so that I get the following so if I do

Re: [Tutor] creating the equivalent of string.strip()

2007-10-02 Thread Dave Kuhlman
On Tue, Oct 02, 2007 at 06:48:13AM -0400, Kent Johnson wrote: > Christopher Spears wrote: > > I was looking for the source code for the strip > > functions at python.org. I didn't find anything. Do > > you or someone else know where the source code is > > posted? I tried to find python on my wor

Re: [Tutor] Update values stored as a list in a dictionary with values from another dictionary

2007-10-02 Thread GTXY20
I adjusted so that I get the following so if I do not need to translate a dictionary I do not call the function transFn: def transFn(translatefile): transfile = open(translatefile, 'r') records = transfile.read() transfile.close() lines = records.split() transDict = {} for

Re: [Tutor] A simple Question...

2007-10-02 Thread Kent Johnson
bhaaluu wrote: > On 10/2/07, Kent Johnson <[EMAIL PROTECTED]> wrote: >> traceback.print_stack() prints the stack trace to the current point of >> execution. No forced error or drama needed :-) >> >> Kent > > Exactly how is this used, please? > > Traceback (most recent call last): > File "print_

Re: [Tutor] A simple Question...

2007-10-02 Thread bhaaluu
On 10/2/07, Kent Johnson <[EMAIL PROTECTED]> wrote: > > traceback.print_stack() prints the stack trace to the current point of > execution. No forced error or drama needed :-) > > Kent Exactly how is this used, please? Traceback (most recent call last): File "print_stack.py", line 160, in ?

Re: [Tutor] A simple Question...

2007-10-02 Thread Kent Johnson
Suzanne Peel wrote: > > Thankyou for your help, > > However both suggestions will only give me that name of the 1st file > executed eg when I use *execfile('EA_Owner.py')* the name returned > when the __file__ or sys.argv[0] is executed always EA_Owner.py . > > The Traceback feature is an ex

Re: [Tutor] Update values stored as a list in a dictionary with values from another dictionary

2007-10-02 Thread Kent Johnson
GTXY20 wrote: > > This seemed to work: > > def transFn(c): > transfile = open('translate.txt', 'r') > records = transfile.read() > transfile.close() > lines = records.split() > transDict = {} > for line in lines: > key, value = line.split(',') > transDict[k

Re: [Tutor] Update values stored as a list in a dictionary with values from another dictionary

2007-10-02 Thread Kent Johnson
John Fouhy wrote: > You could use the map function... > > Let's say we have something like: > > transDict = { 'a':1, 'b':2, 'c':3 } > > We could define a function that mirrors this: > > def transFn(c): > try: > return transDict[c] > except KeyError: > return c This coul

Re: [Tutor] creating the equivalent of string.strip()

2007-10-02 Thread Kent Johnson
Andrew James wrote: > Helps if I send it to the group... > > And Kent, I didn't post it originally because I figured the other guy > was still working on his script. Besides, I didn't think it'd be that > far fetched for you to assume I was using something like "while s[0] == > ' ':" Actually

Re: [Tutor] creating the equivalent of string.strip()

2007-10-02 Thread Kent Johnson
Christopher Spears wrote: > I was looking for the source code for the strip > functions at python.org. I didn't find anything. Do > you or someone else know where the source code is > posted? I tried to find python on my workstation, but > I'm not sure where the sys admin installed it. The sour

Re: [Tutor] Update values stored as a list in a dictionary with valuesfrom another dictionary

2007-10-02 Thread Alan Gauld
"GTXY20" <[EMAIL PROTECTED]> wrote > Let's say I have the following dictionary: > > {1:(a,b,c), 2:(a,c), 3:(b,c), 4:(a,d)} > > I also have another dictionary for new value association: > > {a:1, b:2, c:3} I assume the keys should be strings: 'a','b','c'? Not the variable names a,b,c? > How shou

Re: [Tutor] A simple Question...

2007-10-02 Thread Eric Brunson
Alan Gauld wrote: > "Suzanne Peel" <[EMAIL PROTECTED]> wrote > > >> However both suggestions will only give me that name of the 1st file >> executed eg when I use execfile('EA_Owner.py') the name returned >> when >> the __file__ or sys.argv[0] is executed always EA_Owner.py . >> > > You

Re: [Tutor] Update values stored as a list in a dictionary with values from another dictionary

2007-10-02 Thread GTXY20
This seemed to work: def transFn(c): transfile = open('translate.txt', 'r') records = transfile.read() transfile.close() lines = records.split() transDict = {} for line in lines: key, value = line.split(',') transDict[key] = value try: return tran

Re: [Tutor] A simple Question...

2007-10-02 Thread Alan Gauld
"Suzanne Peel" <[EMAIL PROTECTED]> wrote > However both suggestions will only give me that name of the 1st file > executed eg when I use execfile('EA_Owner.py') the name returned > when > the __file__ or sys.argv[0] is executed always EA_Owner.py . You didn't mention you were doing wacky stuf

Re: [Tutor] creating the equivalent of string.strip()

2007-10-02 Thread Alan Gauld
"Christopher Spears" <[EMAIL PROTECTED]> wrote >I was looking for the source code for the strip > functions at python.org. I didn't find anything. Do > you or someone else know where the source code is > posted? I tried to find python on my workstation, but > I'm not sure where the sys admin i

Re: [Tutor] creating the equivalent of string.strip()

2007-10-02 Thread Alan Gauld
"Andrew James" <[EMAIL PROTECTED]> wrote > *headbang* > > I'm an idiot. s=s[:-2] should be s=s[:-1]. > > Andrew James wrote: >> And as soon as I send it again I realise a pretty stupid error. The >> two loops shouldn't be nested. >> >> Andrew James wrote: >>> Helps if I send it to the group... S

Re: [Tutor] Update values stored as a list in a dictionary with values from another dictionary

2007-10-02 Thread GTXY20
Sorry - solved my own problem - it was the way I was creating my dictionary and assigning the value as a list. I will post my final working code shortly. M. On 10/2/07, GTXY20 <[EMAIL PROTECTED]> wrote: > > I seem to be encountering a problem and I think it is because I actually > have my data a

Re: [Tutor] Update values stored as a list in a dictionary with values from another dictionary

2007-10-02 Thread GTXY20
I seem to be encountering a problem and I think it is because I actually have my data as follows: data = {1:[a,b,c], 2:[a,c], 3:[b,c], 4:[a,d]} not as previously mentioned: data = {1:(a,b,c), 2:(a,c), 3:(b,c), 4:(a,d)} So the values are actually stored as a list. I am trying to adjust so that

Re: [Tutor] creating the equivalent of string.strip()

2007-10-02 Thread Andrew James
*headbang* I'm an idiot. s=s[:-2] should be s=s[:-1]. Andrew James wrote: > And as soon as I send it again I realise a pretty stupid error. The > two loops shouldn't be nested. > > Andrew James wrote: >> Helps if I send it to the group... >> >> And Kent, I didn't post it originally because I fig

Re: [Tutor] creating the equivalent of string.strip()

2007-10-02 Thread Andrew James
And as soon as I send it again I realise a pretty stupid error. The two loops shouldn't be nested. Andrew James wrote: > Helps if I send it to the group... > > And Kent, I didn't post it originally because I figured the other guy > was still working on his script. Besides, I didn't think it'd be

Re: [Tutor] creating the equivalent of string.strip()

2007-10-02 Thread Andrew James
Helps if I send it to the group... And Kent, I didn't post it originally because I figured the other guy was still working on his script. Besides, I didn't think it'd be that far fetched for you to assume I was using something like "while s[0] == ' ':" Andrew James wrote: > I'm always nervous