Re: [Tutor] When to use def __init__ when making a class?

2011-08-03 Thread brandon w
On 08/02/2011 09:25 PM, Steven D'Aprano wrote: brandon w wrote: I have two questions: 1) When should I use "def __init__(self):" when I create a class? Whenever you need something to happen when you create an instance. 2) Would these two classes have the same effect? Technically, no, b

Re: [Tutor] When to use def __init__ when making a class?

2011-08-03 Thread brandon w
On 08/02/2011 09:09 PM, Brett Ritter wrote: On Tue, Aug 2, 2011 at 8:47 PM, brandon w wrote: 1) When should I use "def __init__(self):" when I create a class? When you have any initialization to do. (in other words, when you want class instantiation to do more than simply give you

Re: [Tutor] calculation in string operations

2011-08-03 Thread Sander Sweers
On 4 August 2011 01:16, David wrote: > I got an error message that surprises me. I know how to solve the > problem (couple of parentheses will do), but I would expect Python to > run as the code is presented below. > After all, my_weight is a number that can be multiplied by a float. > I would exp

Re: [Tutor] calculation in string operations

2011-08-03 Thread Alan Gauld
On 04/08/11 00:16, David wrote: After all, my_weight is a number that can be multiplied by a float. I would expect Python to evaluate the expression after the (final) operator and then having it inserted into the string. But it doesn't because the % format operator has a higher precedence. So

[Tutor] calculation in string operations

2011-08-03 Thread David
Hello everybody, I got an error message that surprises me. I know how to solve the problem (couple of parentheses will do), but I would expect Python to run as the code is presented below. After all, my_weight is a number that can be multiplied by a float. I would expect Python to evaluate the exp

Re: [Tutor] Indexing a list with nested tuples

2011-08-03 Thread Alexander Quest
Hi Bob- thanks for the reply again. I apologize about not "replying all" last time- still getting in the habit of doing this. I am using Python version 3.1. As far as tuples are concerned, I don't NEED to use them, but I am trying to get some practice with them. This is because I am following an i

Re: [Tutor] Indexing a list with nested tuples

2011-08-03 Thread Alexander Quest
Thanks Peter- I tried the replacement method where the entire tuple is replaced with a new one and that worked. Changing the "attribute_index" (or "selection" variable, as I called it) to an integer removed the int/str errors. -Alex On Wed, Aug 3, 2011 at 12:12 AM, Peter Otten <__pete...@web.de>

Re: [Tutor] Puzzled again

2011-08-03 Thread Richard D. Moores
On Wed, Aug 3, 2011 at 12:10, Peter Otten <__pete...@web.de> wrote: > Richard D. Moores wrote: > >> On Wed, Aug 3, 2011 at 10:11, Peter Otten <__pete...@web.de> wrote: >>> Richard D. Moores wrote: >>> I wrote before that I had pasted the function (convertPath()) from my initial post into

Re: [Tutor] Puzzled again

2011-08-03 Thread Richard D. Moores
On Wed, Aug 3, 2011 at 12:16, Steven D'Aprano wrote: > Richard D. Moores wrote: >> >> I wrote before that I had pasted the function (convertPath()) from my >> initial post into mycalc.py because I had accidentally deleted it from >> mycalc.py. And that there was no problem importing it from mycalc

Re: [Tutor] Puzzled again

2011-08-03 Thread Steven D'Aprano
Richard D. Moores wrote: I wrote before that I had pasted the function (convertPath()) from my initial post into mycalc.py because I had accidentally deleted it from mycalc.py. And that there was no problem importing it from mycalc. Well, I was mistaken (for a reason too tedious to go into). Ther

Re: [Tutor] Puzzled again

2011-08-03 Thread Peter Otten
Richard D. Moores wrote: > On Wed, Aug 3, 2011 at 10:11, Peter Otten <__pete...@web.de> wrote: >> Richard D. Moores wrote: >> >>> I wrote before that I had pasted the function (convertPath()) from my >>> initial post into mycalc.py because I had accidentally deleted it from >>> mycalc.py. And that

Re: [Tutor] Puzzled again

2011-08-03 Thread Dave Angel
On 08/03/2011 01:48 PM, Richard D. Moores wrote: On Wed, Aug 3, 2011 at 10:11, Peter Otten<__pete...@web.de> wrote: Dave was close, but Steven hit the nail: the string r"C:\Users\Dick\..." is fine, but when you put it into the docstring it is not a raw string within another string, it becomes

Re: [Tutor] Puzzled again

2011-08-03 Thread Richard D. Moores
On Wed, Aug 3, 2011 at 10:11, Peter Otten <__pete...@web.de> wrote: > Richard D. Moores wrote: > >> I wrote before that I had pasted the function (convertPath()) from my >> initial post into mycalc.py because I had accidentally deleted it from >> mycalc.py. And that there was no problem importing i

Re: [Tutor] Puzzled again

2011-08-03 Thread Peter Otten
Richard D. Moores wrote: > I wrote before that I had pasted the function (convertPath()) from my > initial post into mycalc.py because I had accidentally deleted it from > mycalc.py. And that there was no problem importing it from mycalc. > Well, I was mistaken (for a reason too tedious to go into

Re: [Tutor] Puzzled again

2011-08-03 Thread Richard D. Moores
I wrote before that I had pasted the function (convertPath()) from my initial post into mycalc.py because I had accidentally deleted it from mycalc.py. And that there was no problem importing it from mycalc. Well, I was mistaken (for a reason too tedious to go into). There WAS a problem, the same o

Re: [Tutor] Indexing a list with nested tuples

2011-08-03 Thread bob gailer
On 8/2/2011 11:39 PM, Alexander Quest wrote: Hey Bob- thanks for the reply. Here is a more complete part of that code section (the ellipses are parts where I've deleted code because I don't think it's important for this question): Please always reply-all so a copy goes to the list. Thanks for

Re: [Tutor] Dynamically linking python into my vc project - help required

2011-08-03 Thread spawgi
+1 to Alan on this. Also, you may want to try stackoverflow.com for this question. Thanks and Regards, Sumod On Wed, Aug 3, 2011 at 1:41 PM, Alan Gauld wrote: > On 03/08/11 07:52, mrinal...@edss.co.in wrote: > >> Hi, >> >> I am trying to embed python into my MFC application. I have done this >>

Re: [Tutor] Using .po translation file

2011-08-03 Thread Григор Колев
Otherwise I can do translation system. But it will be in its own way with dictionaries and shelve. But it will be difficult if someone decides to translate. po has its own editor. В 19:22 +1000 на 03.08.2011 (ср), Steven D'Aprano написа: > Григор Колев wrote: > > Hi. > > Some one help me. > > Ha

Re: [Tutor] Using .po translation file

2011-08-03 Thread Григор Колев
I do not understand I have bg.po file And try the following. import gettext instance = gettext.GNUTranslations(open('bg.po')) IOError: [Errno 0] Bad magic number: 'bg.po' and this instance = gettext.Catalog('bg.po') IOError: [Errno 2] No translation file found for domain: 'bg.po' В 14:48 +05

Re: [Tutor] Using .po translation file

2011-08-03 Thread Steven D'Aprano
Григор Колев wrote: Hi. Some one help me. Haw can I use .po translation file for my program. This is not a standard part of Python. Is this a django thing? You should ask on a django forum. -- Steven ___ Tutor maillist - Tutor@python.org To

Re: [Tutor] Puzzled again

2011-08-03 Thread Steven D'Aprano
Richard D. Moores wrote: But here's a try using the regular command line: C:\Windows\System32>python Python 3.2.1 (default, Jul 10 2011, 20:02:51) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. from mycalc import convertPath Traceba

Re: [Tutor] Puzzled again

2011-08-03 Thread Richard D. Moores
Ops! I accidentally erased convertPath() from mycalc.py while trying out various things. It was my only copy of convertPath that had the docstring as posted, so I went to my initial post and copy-and-pasted it into mycalc.py. Now no problem: from Wing's shell: Python 3.2.1 (default, Jul 10 2

Re: [Tutor] Using .po translation file

2011-08-03 Thread vishwajeet singh
2011/8/3 Григор Колев > Hi. > Some one help me. > Haw can I use .po translation file for my program. > > cat = gettext.Catalog(domain, localedir) > what should be domain > Domain is usually the name of po file it defaults to django and djangojs in some cases. > >

[Tutor] Using .po translation file

2011-08-03 Thread Григор Колев
Hi. Some one help me. Haw can I use .po translation file for my program. cat = gettext.Catalog(domain, localedir) what should be domain ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/ma

Re: [Tutor] Puzzled again

2011-08-03 Thread Steven D'Aprano
Steven D'Aprano wrote: Richard D. Moores wrote: Puzzled again. Why the error. Line 36 is the line just above "import os.path". I have many other functions in mycalc.py with examples formatted exactly the same way. def convertPath(path): """ Given a path with backslashes, return that pat

Re: [Tutor] Puzzled again

2011-08-03 Thread Steven D'Aprano
Richard D. Moores wrote: Puzzled again. Why the error. Line 36 is the line just above "import os.path". I have many other functions in mycalc.py with examples formatted exactly the same way. def convertPath(path): """ Given a path with backslashes, return that path with forward slashes.

Re: [Tutor] Dynamically linking python into my vc project - help required

2011-08-03 Thread Alan Gauld
On 03/08/11 07:52, mrinal...@edss.co.in wrote: Hi, I am trying to embed python into my MFC application. I have done this before by statically linking to the python lib. But I want to change this now. Hi, this mailing list is really for people trying to learn Python. This question is way more a

[Tutor] Dynamically linking python into my vc project - help required

2011-08-03 Thread mrinalini
Hi, I am trying to embed python into my MFC application. I have done this before by statically linking to the python lib. But I want to change this now. The idea is to take the information from the registry for the installed version of python on the target machine. Then load python using load

Re: [Tutor] Python scripts into executable Windows programss

2011-08-03 Thread Emeka
Sumod, Thanks so much ... I was also looking for something like Inno. Emeka On Wed, Aug 3, 2011 at 8:04 AM, wrote: > For a seamless application development experience, you may want to consider > these steps. > 1. Use Eclipse-pydev to write your scripts > 2. Use py2exe to convert into executa

Re: [Tutor] Puzzled again

2011-08-03 Thread Dave Angel
On 08/03/2011 02:07 AM, Richard D. Moores wrote: On Tue, Aug 2, 2011 at 21:59, Dave Angel wrote: When I paste that from your email into a file and run Python 2.7 on it, it behaves fine with no errors. That's in Linux. I should have said that I'm using Wing IDE Professional 4.0.3-1 (rev 2472

Re: [Tutor] Indexing a list with nested tuples

2011-08-03 Thread Peter Otten
Alexander Quest wrote: > Hi guys- I'm having a problem with a list that has nested tuples: > > attributes = [("strength", 0), ("health ", 0), ("wisdom ", 0), > ("dexterity", 0)] > > I've defined the list above with 4 items, each starting with a value of 0. > The player > enters how many points

Re: [Tutor] Python scripts into executable Windows programss

2011-08-03 Thread spawgi
For a seamless application development experience, you may want to consider these steps. 1. Use Eclipse-pydev to write your scripts 2. Use py2exe to convert into executable programs 3. Use Inno setup to create installers There is support for 2.6 and 2.7 with Python. Please see the news page - http