[Tutor] Question if my reasoning is right

2009-08-18 Thread Darth Kaboda
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 first element in the list to update. Is this becuase this metho

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

2009-08-18 Thread Douglas Philips
On 2009 Aug 18, 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 application, w

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

2009-08-18 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

[Tutor] Setting PYTHONPATH and other env vars dynamically

2009-08-18 Thread Jramak
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 application, what would be the best way to set PYTHONPATH

Re: [Tutor] yet another question on OO inheritance

2009-08-18 Thread Dave Angel
Serdar Tumgoren wrote: Thanks to you both for the suggestions. I think I'll try the approach below. But just one follow-up: should I be setting "self.tablename", or is a static attribute ("tablename") the correct approach? A nice way to do this is with a class attribute. For example: class C

Re: [Tutor] yet another question on OO inheritance

2009-08-18 Thread Serdar Tumgoren
> ..The atttribute is created in the class definition > (not in any method) as just "tablename". This creates an attribute of > the class, rather than of the instance. It is accessed as > "self.tablename". The attribute lookup rules will look first in the > instance, fail to find 'tablename', then

Re: [Tutor] yet another question on OO inheritance

2009-08-18 Thread Kent Johnson
On Tue, Aug 18, 2009 at 3:16 PM, Serdar Tumgoren wrote: > On Tue, Aug 18, 2009 at 2:51 PM, Serdar Tumgoren wrote: >> Thanks to you both for the suggestions. I think I'll try the approach >> below. But just one follow-up: should I be setting "self.tablename", >> or is a static attribute ("tablename"

Re: [Tutor] yet another question on OO inheritance

2009-08-18 Thread Serdar Tumgoren
On Tue, Aug 18, 2009 at 2:51 PM, Serdar Tumgoren wrote: > Thanks to you both for the suggestions. I think I'll try the approach > below. But just one follow-up: should I be setting "self.tablename", > or is a static attribute ("tablename") the correct approach? > Looks like it's the former (i.e. "s

Re: [Tutor] yet another question on OO inheritance

2009-08-18 Thread Serdar Tumgoren
Thanks to you both for the suggestions. I think I'll try the approach below. But just one follow-up: should I be setting "self.tablename", or is a static attribute ("tablename") the correct approach? > A nice way to do this is with a class attribute. For example: > class Committee(object): > >   d

Re: [Tutor] yet another question on OO inheritance

2009-08-18 Thread Kent Johnson
On Tue, Aug 18, 2009 at 1:47 PM, Serdar Tumgoren wrote: > Hi all, > > I've hit another gray area for an application I'm working on. > Specifically, I have a campaign Committee object, and then subclasses > called CandidateCommittee and PresidentialCommittee. Depending on the > type of committee, I

[Tutor] yet another question on OO inheritance

2009-08-18 Thread Serdar Tumgoren
Hi all, I've hit another gray area for an application I'm working on. Specifically, I have a campaign Committee object, and then subclasses called CandidateCommittee and PresidentialCommittee. Depending on the type of committee, I have to execute a series of SQL statements to pull data (used to po

Re: [Tutor] Problems with encoding in BeautifulSoup

2009-08-18 Thread Eduardo Vieira
On Tue, Aug 18, 2009 at 5:59 AM, Kent Johnson wrote: > On Tue, Aug 18, 2009 at 12:18 AM, Mal Wanstall wrote: >> On Tue, Aug 18, 2009 at 9:00 AM, Eduardo Vieira >> wrote: > >>> Here is the Error output: >>> utf-8 >>> Traceback (most recent call last): >>>  File "C:\myscripts\encondingproblem.py", l

Re: [Tutor] Problems with encoding in BeautifulSoup

2009-08-18 Thread Serdar Tumgoren
> Setting sys.setdefaultencoding() affects all scripts you run and will > make scripts that you write non-portable. A better solution is to > properly encode the output, for example > for company in companies[:4]: # assuming companies is a list >  print company.encode('cp437') > Kent's suggestion a

Re: [Tutor] Problems with encoding in BeautifulSoup

2009-08-18 Thread Kent Johnson
On Tue, Aug 18, 2009 at 12:18 AM, Mal Wanstall wrote: > On Tue, Aug 18, 2009 at 9:00 AM, Eduardo Vieira > wrote: >> Here is the Error output: >> utf-8 >> Traceback (most recent call last): >>  File "C:\myscripts\encondingproblem.py", line 13, in >>    print companies[:4] >> UnicodeEncodeError: '