[Tutor] handling a textfile

2009-08-19 Thread Olli Virta
Hi! I have a textfile (job.txt) that needs modifying. The structure of this file is like this: AAA1... BBB1... CCC1... AAA2... BBB2... CCC2... etc... Question is how can I turn this all to a textfile (done.txt) that is suppose to look like this: AAA1...BBB1...CCC1... AAA2...BBB2...CCC2... etc

Re: [Tutor] handling a textfile

2009-08-19 Thread Fidel Sanchez-Bueno
Olli Virta escribió: Hi! I have a textfile (job.txt) that needs modifying. The structure of this file is like this: AAA1... BBB1... CCC1... AAA2... BBB2... CCC2... etc... Question is how can I turn this all to a textfile (done.txt) that is suppose to look like this: AAA1...BBB1...C

Re: [Tutor] Setting PYTHONPATH and other env vars dynamically

2009-08-19 Thread Alan Gauld
"Jramak" wrote We have developed three custom applications in Python. Each one of these applications needs a different PYTHONPATH, in addition to different environment variables to work. Environment variables should control the users (or oprocess) environment and as such should really be fai

Re: [Tutor] Question if my reasoning is right

2009-08-19 Thread Alan Gauld
"Darth Kaboda" wrote cb = [[[0, None]] * (n + 1)] * (m + 1) cb[3][2][0] = 10 This last statement causes the every first element in the list to update. Is this becuase this method of initializing a list is just a copy Yes exactly. To get around this I'm now doing the folowing: cb = [[[0,N

Re: [Tutor] handling a textfile

2009-08-19 Thread Alan Gauld
"Olli Virta" wrote I have a textfile (job.txt) that needs modifying. The structure of this file is like this: AAA1... BBB1... CCC1... AAA2... BBB2... CCC2... etc... Question is how can I turn this all to a textfile (done.txt) that is suppose to look like this: AAA1...BBB1...CCC1... AAA2..

[Tutor] python telnet

2009-08-19 Thread Rayon
using python telnet lib to connect to a Nortel switch, and dump some tables. My problem is that every now and then the connection is reset by peer . Telnet Error : (10054, Connection reset by peer) I need to know why, I have it in a loop so it will download after a few tries but I need to know

Re: [Tutor] Setting PYTHONPATH and other env vars dynamically

2009-08-19 Thread Kent Johnson
On Tue, Aug 18, 2009 at 9:21 PM, Douglas Philips wrote: > I think you have five-ish general options: One more - put required packages and modules into the same directory as the executable, usually the current directory is on the Python search path. Kent __

Re: [Tutor] Setting PYTHONPATH and other env vars dynamically

2009-08-19 Thread Kent Johnson
On Tue, Aug 18, 2009 at 7:57 PM, Jramak wrote: > Hello > We have developed three custom applications in Python. Each one of > these applications needs a different PYTHONPATH, in addition to > different environment variables to work. Instead of manually setting > the environment variables for each a

Re: [Tutor] Question if my reasoning is right

2009-08-19 Thread Kent Johnson
On Wed, Aug 19, 2009 at 1:52 AM, Darth Kaboda wrote: > I'm questioning my reason for why the follwoing code doesn't behave as I > thought it would upon first coding a project. > > m = 8 > n = 10 > cb = [[[0, None]] * (n + 1)] * (m + 1) > cb[3][2][0] = 10 > > This last statement causes the every fir

Re: [Tutor] handling a textfile

2009-08-19 Thread Kent Johnson
On Wed, Aug 19, 2009 at 5:54 AM, Alan Gauld wrote: > Lots of ways to do it. The simplest is to read the variables line by line, > so, in pseudo code: > > while infile not empty >    a = f.readline() >    b = f.readline() >    c = f.readline() >    outfile.write("%s,%s,%s" % (a,b,c) ) You will nee

Re: [Tutor] handling a textfile

2009-08-19 Thread Dave Angel
Alan Gauld wrote: "Olli Virta" wrote I have a textfile (job.txt) that needs modifying. The structure of this file is like this: AAA1... BBB1... CCC1... AAA2... BBB2... CCC2... etc... Question is how can I turn this all to a textfile (done.txt) that is suppose to look like this: AAA1...BB

Re: [Tutor] python telnet

2009-08-19 Thread Luke Paireepinart
How are you running it?This usually happens when you have an error in your connection, and then you try to re-run it, and the previous connection attempt has not released the port yet. Are you having an error between subsequent runs, or do you have an error the first time you run it after a fresh r

Re: [Tutor] Setting PYTHONPATH and other env vars dynamically

2009-08-19 Thread Jramak
> > > One more - put required packages and modules into the same directory > as the executable, usually the current directory is on the Python > search path. > > Kent > Hi Kent, there is no executable. It is just a collection of python scripts. I assume you refer to the Python search path as PYTHO

Re: [Tutor] Setting PYTHONPATH and other env vars dynamically

2009-08-19 Thread Jramak
> > > > > Don't edit site.py, it is part of the std lib. If you do want to > customize it, add a site-customize.py in your site-packages folder and > put your customizations there. > > Kent > There is no site-customize.py in Python25, how does Python know that site-customize.py needs to be loaded

Re: [Tutor] Setting PYTHONPATH and other env vars dynamically

2009-08-19 Thread Jramak
> > >> >> Don't edit site.py, it is part of the std lib. If you do want to >> customize it, add a site-customize.py in your site-packages folder and >> put your customizations there. > > > >> There is no site-customize.py in Python25, how does Python know that > site-customize.py needs to be loade

Re: [Tutor] Setting PYTHONPATH and other env vars dynamically

2009-08-19 Thread Kent Johnson
On Wed, Aug 19, 2009 at 3:56 PM, Jramak wrote: >> >> >> Don't edit site.py, it is part of the std lib. If you do want to >> customize it, add a site-customize.py in your site-packages folder and >> put your customizations there. > > There is no site-customize.py in Python25, how does Python know th

Re: [Tutor] Setting PYTHONPATH and other env vars dynamically

2009-08-19 Thread Kent Johnson
On Wed, Aug 19, 2009 at 4:00 PM, Jramak wrote: >> One more - put required packages and modules into the same directory >> as the executable, usually the current directory is on the Python >> search path. >> >> Kent > > > Hi Kent, there is no executable. It is just a collection of python scripts. >

Re: [Tutor] Setting PYTHONPATH and other env vars dynamically

2009-08-19 Thread Jramak
Thanks for all the insight, everyone. I was originally thinking of writing a bash or bat script that would set the PYTHONPATH and other environment variables before running the specific application code. It seemed to be the most simplest solution. There are no other applications that rely on the

Re: [Tutor] Setting PYTHONPATH and other env vars dynamically

2009-08-19 Thread Jramak
> > > Sorry, I mean put the packages in the same directory as the python > script that needs them. The search path is sys.path which is affected > by PYTHONPATH among other things... > > > sys.path is affected by PYTHONPATH ? how could it be affected by the PYTHONPATH ? Could you pls enlighten me

Re: [Tutor] Setting PYTHONPATH and other env vars dynamically

2009-08-19 Thread Kent Johnson
On Wed, Aug 19, 2009 at 4:41 PM, Jramak wrote: >> >> Sorry, I mean put the packages in the same directory as the python >> script that needs them. The search path is sys.path which is affected >> by PYTHONPATH among other things... >> >> > > > sys.path is affected by PYTHONPATH ? how could it be af

Re: [Tutor] Setting PYTHONPATH and other env vars dynamically

2009-08-19 Thread Kent Johnson
On Wed, Aug 19, 2009 at 4:37 PM, Jramak wrote: > I > also looked at virtualenv http://pypi.python.org/pypi/virtualenv . Each > virtual env takes up 2.3 MB. To me this seems a bit of overkill, but this > will enable you to run Python24, Python25, Python26 etc specific code on one > computer. You do

[Tutor] Possible bug in django models when assigning model attribute

2009-08-19 Thread Glen Zangirolami
I ran into something weird in Django and i'm completely stumped. I got it to work but i'm trying to understand the logic behind it. *I have the following data model:* from django.db import models class Setting(models.Model): name = models.CharField(max_length=200) value = models.TextFiel

[Tutor] Help on input error

2009-08-19 Thread David Shunick
I'm trying to learn Python, but keep running into the erroor message ImportError: no module named area. I created a file area.py in IDLE. I'm using Python 3.1 and Window XP. After saving the file in c:/Python31/Lib/Python Modules/area.py I can run the program using F5. But when I start a new s

Re: [Tutor] Help on input error

2009-08-19 Thread Luke Paireepinart
Can you import other (Standard library) modules? or can you not import anything? On Wed, Aug 19, 2009 at 6:14 PM, David Shunick wrote: > I'm trying to learn Python, but keep running into the erroor message > ImportError: no module named area. > > I created a file area.py in IDLE. I'm using Pyt

Re: [Tutor] Help on input error

2009-08-19 Thread Kent Johnson
On Wed, Aug 19, 2009 at 7:14 PM, David Shunick wrote: > I'm trying to learn Python, but keep running into the erroor message > ImportError: no module named area. > > I created a file area.py in IDLE. I'm using Python 3.1 and Window XP. After > saving the file in c:/Python31/Lib/Python  Modules/area

Re: [Tutor] Help on input error

2009-08-19 Thread Luke Paireepinart
Please reply to the whole list, using Reply All, rather than directly to me or anyone else, unless you want the conversation to take place off-list (unless you have a good reason to do so, we discourage this, because then future people cannot benefit from our advice.) Kent has already indicated th

[Tutor] handling a textfile continued

2009-08-19 Thread Olli Virta
Hi! Sorry. OK I admit I might have been confusing. Although I got some good ideas from the messages. Thanks. Let me try again: So I got this big textfile. It's full of data from a database. About 200 or more rows or lines in a textfile. There's three first rows that belong to the same subject. A