Re: [Tutor] question concerning Boolean operators

2008-03-20 Thread jim stockford
i'm guessing assignment, which actually associates a reference, will skip referencing an identifier to a null and will make the association (assignment) to the first non-null value in the expression, which is string2 in this case. that the identifier is non_null is immaterial; you could write

Re: [Tutor] question concerning Boolean operators

2008-03-20 Thread Steve Willoughby
On Thu, Mar 20, 2008 at 04:55:17PM -0700, jim stockford wrote: string1, string2, string3 = '', 'Trondheim', 'Hammer Dance' jackson = string1 or string2 or string3 jackson 'Trondheim' The key here is the or operator which, in an expression like a or b will return a if a is a True

Re: [Tutor] question concerning Boolean operators

2008-03-20 Thread Alan Gauld
Guba [EMAIL PROTECTED] wrote string1, string2, string3 = '', 'Trondheim', 'Hammer Dance' non_null = string1 or string2 or string3 non_null 'Trondheim' How does this work?? How does Python know that we are looking for non_null? After all, we don't provide this information here, right?

Re: [Tutor] [tutor] Question on multithreading

2008-02-26 Thread Kent Johnson
Varsha Purohit wrote: Hello, i have a gui program in wxpython where i am spawning two threads. one for the mainloop of gui and other for some background tasks. It is unusual to start a new thread for the GUI. Usually the GUI is run in the main application thread. I have to stop the

Re: [Tutor] Question on multithreading

2008-02-24 Thread Thomas Pani
Hi, Here are some thoughts: From the Python Library Reference: If the subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread. You'll have to do that for your GuiScript class. You can't just stop

[Tutor] [tutor] Question on multithreading

2008-02-23 Thread Varsha Purohit
Hello, i have a gui program in wxpython where i am spawning two threads. one for the mainloop of gui and other for some background tasks. I have to stop the background running thread once its work is done. I am trying to use the join method but it is giving me an error saying threads cannot be

Re: [Tutor] Question regarding list editing (in place)

2008-02-14 Thread David J. Weller-Fahy
Sorry for the delayed reply - the list software was helping me by not sending me the list copy. Heh. * Kent Johnson [EMAIL PROTECTED] [2008-02-05 13:43]: bob gailer wrote: dirs = [dir for dir in dirs if not dir.startswith(u'.')] Except to filter the directory list for os.walk() you have to

[Tutor] Question regarding list editing (in place)

2008-02-05 Thread David J. Weller-Fahy
Let me know if this should be on the general python list. I'm playing with some python to iterate over a directory structure. Part of the directory structure should be ignored, and will have a period (.) as the first character of the directory name. My solution was to use the following code.

Re: [Tutor] Question regarding list editing (in place)

2008-02-05 Thread bob gailer
David J. Weller-Fahy wrote: Let me know if this should be on the general python list. I'm playing with some python to iterate over a directory structure. Part of the directory structure should be ignored, and will have a period (.) as the first character of the directory name. My

Re: [Tutor] Question regarding list editing (in place)

2008-02-05 Thread Kent Johnson
bob gailer wrote: dirs = [dir for dir in dirs if not dir.startswith(u'.')] Except to filter the directory list for os.walk() you have to modify the list in place. Use this: dirs[:] = [dir for dir in dirs if not dir.startswith(u'.')] Kent ___ Tutor

Re: [Tutor] question about a number and bytes.

2008-01-29 Thread Michael Langford
Use pyserial: http://pyserial.sourceforge.net/ Use struct.pack: http://docs.python.org/lib/module-struct.html The format string will depend whether you need little or big endian. --Michael On Jan 29, 2008 4:13 PM, shawn bright [EMAIL PROTECTED] wrote: Thanks for your reply. i need

Re: [Tutor] question about a number and bytes.

2008-01-29 Thread shawn bright
Thanks for your reply. i need to do this in python because python is what scripting language our data I/O system is written in. i am writing a command out over a serial port that tells an RTU to change part of it's program. I am not sure what you mean by using it in any other python context, this

Re: [Tutor] question about a number and bytes.

2008-01-29 Thread Tiger12506
Hello there all. I have a need to make a hi byte and lo byte out of a number. so, lets say i have a number 300, and need this number to be represented in two bytes, how do i go about that? First question. Why would you need to do this in python? Second question. If you could do that, how

[Tutor] question about a number and bytes.

2008-01-29 Thread shawn bright
Hello there all. I have a need to make a hi byte and lo byte out of a number. so, lets say i have a number 300, and need this number to be represented in two bytes, how do i go about that? thanks for any tips, sk ___ Tutor maillist -

[Tutor] [tutor] Question on multithreading

2008-01-29 Thread Varsha Purohit
Hello friends, I hve a GUI where i have start button and stop button. When i press start button one thread is created and it is executing some background task and when i press stop button that thread is stopped/killed. These two things are working properly. But i have to implement pause

Re: [Tutor] [tutor] Question on multithreading

2008-01-29 Thread John Fouhy
On 30/01/2008, Varsha Purohit [EMAIL PROTECTED] wrote: Hello friends, I hve a GUI where i have start button and stop button. When i press start button one thread is created and it is executing some background task and when i press stop button that thread is stopped/killed. These two

Re: [Tutor] [tutor] Question on multithreading

2008-01-29 Thread bob gailer
Varsha Purohit wrote: Hello friends, I hve a GUI where i have start button and stop button. When i press start button one thread is created and it is executing some background task and when i press stop button that thread is stopped/killed. These two things are working properly.

Re: [Tutor] question re type()

2007-10-31 Thread Kent Johnson
Aditya Lal wrote: On 10/29/07, *Kent Johnson* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: - Common Python practice is to prefer the least restrictive type check possible. I completely agree that the check type(n) == int is very intuitive and simple. Its just that there

Re: [Tutor] question re type()

2007-10-31 Thread Aditya Lal
On 10/31/07, Kent Johnson [EMAIL PROTECTED] wrote: Aditya Lal wrote: On 10/29/07, *Kent Johnson* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: - Common Python practice is to prefer the least restrictive type check possible. I completely agree that the check type(n) ==

Re: [Tutor] question re type()

2007-10-30 Thread Aditya Lal
On 10/29/07, Kent Johnson [EMAIL PROTECTED] wrote: Aditya Lal wrote: or use types module import types if type(n) == types.IntType or type(n) == types.LongType : blah! A few notes: - If you look at types.py, you find IntType = int LongType = long and so on for all the

Re: [Tutor] question re type()

2007-10-29 Thread Kent Johnson
Aditya Lal wrote: or use types module import types if type(n) == types.IntType or type(n) == types.LongType : blah! A few notes: - If you look at types.py, you find IntType = int LongType = long and so on for all the built-in types, so there is no need or advantage to importing

[Tutor] question re type()

2007-10-27 Thread Dick Moores
I can't figure out how to test a variable n for its type. An example that is the wrong syntax, but shows what I want to do: if type(n) == 'int' or type(n) == 'long': do something elif type(n) == 'float': do something else elif type(n) == 'str': do something different What's the

Re: [Tutor] question re type()

2007-10-27 Thread Ricardo Aráoz
Dick Moores wrote: I can't figure out how to test a variable n for its type. An example that is the wrong syntax, but shows what I want to do: if type(n) == 'int' or type(n) == 'long': do something elif type(n) == 'float': do something else elif type(n) == 'str': do

Re: [Tutor] question re type()

2007-10-27 Thread Dick Moores
At 04:34 AM 10/27/2007, Ricardo Aráoz wrote: Just take the quotes off : if type(n) == int or type(n) == long : Thanks. I tried a lot of things, but not that one! Dick HTH Oh, yeah! ___ Tutor maillist - Tutor@python.org

Re: [Tutor] question re type()

2007-10-27 Thread Alan Gauld
Dick Moores [EMAIL PROTECTED] wrote if type(n) == 'int' or type(n) == 'long': do something don't use strings if type(n) == int Or just use an instance of the same type: if type(n) == type(42) Alan G. ___ Tutor maillist - Tutor@python.org

Re: [Tutor] question re type()

2007-10-27 Thread Aditya Lal
On 10/27/07, Alan Gauld [EMAIL PROTECTED] wrote: Dick Moores [EMAIL PROTECTED] wrote if type(n) == 'int' or type(n) == 'long': do something don't use strings if type(n) == int Or just use an instance of the same type: if type(n) == type(42) Alan G.

Re: [Tutor] question re type()

2007-10-27 Thread Alan Gauld
Dave Kuhlman [EMAIL PROTECTED] wrote Calling type(n) for any integer seems to return the same object. I checked with id(). I would hope so since they are all of the same type. It thus makes sense that they all return a reference to the same type object. So, should we be using: if

Re: [Tutor] question re type()

2007-10-27 Thread Dick Moores
At 11:34 AM 10/27/2007, Dave Kuhlman wrote: On Sat, Oct 27, 2007 at 01:03:18PM +0100, Alan Gauld wrote: if type(n) == int Or just use an instance of the same type: if type(n) == type(42) Calling type(n) for any integer seems to return the same object. I checked with id(). So, should

Re: [Tutor] Question about default values for arguments

2007-10-11 Thread Kent Johnson
Roy Chen wrote: Hi everyone, been looking at the following functions, but can't figure out how they work. def f(a, L=[]): L.append(a) return L def g(a, L=None): if L == None: L = [] L.append(a) return L

[Tutor] Question about default values for arguments

2007-10-11 Thread Roy Chen
Hi everyone, been looking at the following functions, but can't figure out how they work. def f(a, L=[]): L.append(a) return L def g(a, L=None): if L == None: L = [] L.append(a) return L print f(1) print f(2) print f(3) print g(1) print

Re: [Tutor] Question about default values for arguments

2007-10-11 Thread Alan Gauld
Roy Chen [EMAIL PROTECTED] wrote def f(a, L=[]): L.append(a) return L This creates a single list object L used for all calls to f() that don;t provide an explicit L. Thus each call appends to the same object. def g(a, L=None): if L == None: L = [] L.append(a)

[Tutor] Question about installing 2.51

2007-08-27 Thread Dick Moores
XP, Python 2.5 I just downloaded python-2.5.1.msi from python.org. During the installation process (which I aborted), I was told, This Update will replace your existing Python25 installation. What exactly does this mean? What will happen, for example, to all my scripts that are in

Re: [Tutor] Question about installing 2.51

2007-08-27 Thread Kent Johnson
Dick Moores wrote: XP, Python 2.5 I just downloaded python-2.5.1.msi from python.org. During the installation process (which I aborted), I was told, This Update will replace your existing Python25 installation. What exactly does this mean? What will happen, for example, to all my

Re: [Tutor] Question about installing 2.51

2007-08-27 Thread Alan Gauld
Dick Moores [EMAIL PROTECTED] wrote installation process (which I aborted), I was told, This Update will replace your existing Python25 installation. What exactly does this mean? What will happen, for example, to all my scripts that are in E:\Python25\dev? Or to the packages I've put

Re: [Tutor] Question about installing 2.51

2007-08-27 Thread Dick Moores
At 02:00 PM 8/27/2007, Alan Gauld wrote: Dick Moores [EMAIL PROTECTED] wrote installation process (which I aborted), I was told, This Update will replace your existing Python25 installation. What exactly does this mean? What will happen, for example, to all my scripts that are in

[Tutor] Question about calling functions

2007-08-26 Thread Ara Kooser
Hello, After taking some suggestions from bhaaluu my program for generating a character works except for one part. You have a choice of excepting a set of numbers. If you choose n then the program dumps you into: def navy() instead of going back to def upp(). I am guessing this has to do with

Re: [Tutor] Question about calling functions

2007-08-26 Thread Alan Gauld
Ara Kooser [EMAIL PROTECTED] wrote a character works except for one part. You have a choice of excepting a set of numbers. If you choose n then the program dumps you into: def navy() instead of going back to def upp(). print upp() print You have a chance to reroll if needed. reroll()

Re: [Tutor] Question about classes

2007-08-25 Thread Noufal Ibrahim
Ara Kooser wrote: Hello all, I am working on trying to understand classes by creating a character generator for a rpg. I know I am doing something silly but I am not sure what. When I run the program I and type no when prompted I get the following message: Traceback (most recent call

Re: [Tutor] Question about classes

2007-08-25 Thread Alan Gauld
Ara Kooser [EMAIL PROTECTED] wrote I am working on trying to understand classes by creating a character generator for a rpg. You are so ar off base at the moment that I suggest you go back to basics and try a much simpler class. Your MAIN is not really a class at all, it's a function.

Re: [Tutor] Question about classes

2007-08-25 Thread Eric Abrahamsen
On Aug 25, 2007, at 12:59 PM, Ara Kooser wrote: Hello all, I am working on trying to understand classes by creating a character generator for a rpg. I know I am doing something silly but I am not sure what. When I run the program I and type no when prompted I get the following message:

Re: [Tutor] Question about classes

2007-08-25 Thread Alan Gauld
Eric Abrahamsen [EMAIL PROTECTED] wrote The new problem is the while loop inside __upp. Every time I say no, and it generates a new set of attributes, it seems to add another layer of unfinished = True, so that once I've got attributes I like, I need to say yes as many times as I said no

Re: [Tutor] Question about classes

2007-08-25 Thread Eric Abrahamsen
Welcome to the wacky world of recursion. You call __upp from inside __upp so you do indeed generate a new layer, in fact you start a new while loop. You need to move the while loop out into init, something like this: So all those yess were actually backing out of multiple while loops...

Re: [Tutor] Question about classes

2007-08-25 Thread Alan Gauld
Eric Abrahamsen [EMAIL PROTECTED] wrote Welcome to the wacky world of recursion. You call __upp from inside __upp so you do indeed generate a new layer, in fact you start a new while loop. You need to So all those yess were actually backing out of multiple while loops... Should have guessed

Re: [Tutor] Question about classes

2007-08-25 Thread Kent Johnson
Ara Kooser wrote: Hello all, I am working on trying to understand classes by creating a character generator for a rpg. I know I am doing something silly but I am not sure what. This is a procedural program wrapped in a class declaration. Just get rid of class Main: and outdent

[Tutor] Question about classes

2007-08-24 Thread Ara Kooser
Hello all, I am working on trying to understand classes by creating a character generator for a rpg. I know I am doing something silly but I am not sure what. When I run the program I and type no when prompted I get the following message: Traceback (most recent call last): File

[Tutor] Question re Tutor List Etiquette

2007-08-14 Thread Dick Moores
When sending a reply to a post, to the list, should we also address the reply to the author of the post to which we are replying? (There's gotta be an easier way to say that..) If we do so, then the author gets a duplicate of our reply. I've run some statistics (but no more bar graphs ;-) ).

Re: [Tutor] Question re Tutor List Etiquette

2007-08-14 Thread Eric Brunson
Dick Moores wrote: When sending a reply to a post, to the list, should we also address the reply to the author of the post to which we are replying? (There's gotta be an easier way to say that..) If we do so, then the author gets a duplicate of our reply. I've run some statistics (but no

Re: [Tutor] Question re Tutor List Etiquette

2007-08-14 Thread Luke Paireepinart
Dick Moores wrote: When sending a reply to a post, to the list, should we also address the reply to the author of the post to which we are replying? (There's gotta be an easier way to say that..) If we do so, then the author gets a duplicate of our reply. I've run some statistics (but no

Re: [Tutor] Question re Tutor List Etiquette

2007-08-14 Thread Kent Johnson
Dick Moores wrote: When sending a reply to a post, to the list, should we also address the reply to the author of the post to which we are replying? (There's gotta be an easier way to say that..) If we do so, then the author gets a duplicate of our reply. This is configurable for each

Re: [Tutor] Question re Tutor List Etiquette

2007-08-14 Thread Tom Fitzhenry
On Tue, Aug 14, 2007 at 11:06:05AM -0700, Dick Moores wrote: Replying only to the list takes a bit of trouble. The default behavior seems to be that the Reply button addresses the author only and not the list; Reply to all addresses both the list, the author, and any others included in the

Re: [Tutor] Question re Tutor List Etiquette

2007-08-14 Thread Dick Moores
At 11:56 AM 8/14/2007, Kent Johnson wrote: Dick Moores wrote: When sending a reply to a post, to the list, should we also address the reply to the author of the post to which we are replying? (There's gotta be an easier way to say that..) If we do so, then the author gets a duplicate of

Re: [Tutor] Question re Tutor List Etiquette

2007-08-14 Thread Carroll, Barry
Date: Tue, 14 Aug 2007 12:33:16 -0700 From: Dick Moores [EMAIL PROTECTED] Subject: Re: [Tutor] Question re Tutor List Etiquette To: tutor@python.org Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=us-ascii; format=flowed At 11:56 AM 8/14/2007, Kent Johnson wrote: Dick

Re: [Tutor] Question re Tutor List Etiquette

2007-08-14 Thread William O'Higgins Witteman
On Tue, Aug 14, 2007 at 08:11:33PM +0100, Tom Fitzhenry wrote: On Tue, Aug 14, 2007 at 11:06:05AM -0700, Dick Moores wrote: Replying only to the list takes a bit of trouble. The default behavior seems to be that the Reply button addresses the author only and not the list; Reply to all

[Tutor] question about datetime object

2007-07-20 Thread shawn bright
Hello there, if i have a python datetime object, what is the easiest way to make it into epoch seconds ? thanks ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] question about datetime object

2007-07-20 Thread Kent Johnson
shawn bright wrote: Hello there, if i have a python datetime object, what is the easiest way to make it into epoch seconds ? impIn [1]: import datetime In [2]: now = datetime.datetime.now() In [4]: now.timetuple() Out[4]: (2007, 7, 20, 11, 56, 58, 4, 201, -1) In [5]: import calendar In [6]:

[Tutor] Question from a newbie

2007-07-18 Thread Junaid.Khan/Finance/Lahore
Hi I am totally new to Python. I downloaded it and I really like it as its very simple but I came across a small problem. My question is: How can I save something in Python. I tried to save it but it don't save it. Even I tried to add *.py as extension in the end of file name but still it

Re: [Tutor] Question from a newbie

2007-07-18 Thread Luke Paireepinart
Junaid.Khan/Finance/Lahore wrote: Hi I am totally new to Python. I downloaded it and I really like it as its very simple but I came across a small problem. My question is: How can I save something in Python. I tried to save it but it don’t save it. Even I tried to add *.py as extension

Re: [Tutor] Question from a newbie

2007-07-18 Thread Darren Williams
for testing lines of code up until then. - Original Message - From: Luke Paireepinart [EMAIL PROTECTED] To: Junaid.Khan/Finance/Lahore [EMAIL PROTECTED] Cc: tutor@python.org Sent: Wednesday, July 18, 2007 10:40 AM Subject: Re: [Tutor] Question from a newbie Junaid.Khan/Finance/Lahore wrote

Re: [Tutor] Question about lambda and new.instancemethod

2007-07-17 Thread Kent Johnson
Tino Dai wrote: Hi Everybody, I have been working on a parser for myself. I want to create methods on the fly with the information that I get from a file. Here is my question: class configure: .stuff deleted.. def

Re: [Tutor] Question about code reviews

2007-07-15 Thread Kent Johnson
Tino Dai wrote: Actually, I'm looking for two things: I can do stuff with python, but a) is there a better way to do it? b) What in python don't I know that I don't know. Does that make sense? Reading other people's code is another good way to learn both of these. I found reading the

Re: [Tutor] Question

2007-07-13 Thread ALAN GAULD
Including the list... - Original Message From: Que Prime [EMAIL PROTECTED] To: Alan Gauld [EMAIL PROTECTED] Thank you Alan, but I'm still having difficulty. I think you mean this but there must be something that I'm misunderstanding. print Creating txt file tfile =

Re: [Tutor] Question

2007-07-13 Thread Luke Paireepinart
Try tfile.write(str(i)+'\n') OR tfile.write( d\n % i) Alan meant tfile.write(%d\n % i) of course ;) -Luke ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Question about code reviews

2007-07-13 Thread Tino Dai
On 7/12/07, Tiger12506 [EMAIL PROTECTED] wrote: Do you know of any service or person that could do a code review for me? Perhaps if you were more specific about what you are looking for in the review? If you merely want something to check your code for possible errors and how well

Re: [Tutor] Question

2007-07-13 Thread Alan Gauld
Luke Paireepinart [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Try tfile.write(str(i)+'\n') OR tfile.write( d\n % i) Alan meant tfile.write(%d\n % i) of course ;) Which is why we should always include the list on replies! Thanks for catching that one Luke Alan G.

Re: [Tutor] Question about code reviews

2007-07-12 Thread Adam A. Zajac
Do you know of any service or person that could do a code review for me? Perhaps if you were more specific about what you are looking for in the review? If you merely want something to check your code for possible errors and how well you stick to standards, then look into pylint or

Re: [Tutor] Question about code reviews

2007-07-12 Thread Tiger12506
Do you know of any service or person that could do a code review for me? Perhaps if you were more specific about what you are looking for in the review? If you merely want something to check your code for possible errors and how well you stick to standards, then look into pylint or

[Tutor] Question

2007-07-12 Thread Que Prime
I'm trying to create a program that creates a file and write the number for each line. Here is what I have so far but can't seem to get the loop and write correct. Thanks in advance. print Creating txt file tfile = open(25.txt, w) for i in range(25): x = int(1) tfile.writelines(x\n)

Re: [Tutor] Question

2007-07-12 Thread Alan Gauld
Que Prime [EMAIL PROTECTED] wrote Here is what I have so far but can't seem to get the loop and write correct. I suspect you have used another language before and Python's for loop is foxing you. print Creating txt file tfile = open(25.txt, w) for i in range(25): x = int(1) You

Re: [Tutor] Question regarding syntax

2007-07-12 Thread John Morris
On 7/11/07, Andre Roberge [EMAIL PROTECTED] wrote: It is a standard convention. Lots of tools are built on the assumption that translatable strings are going to be enclosed in _(...) These tools extract the strings from programs, and put them in files (.po) that are easily editable by human

[Tutor] Question about code reviews

2007-07-11 Thread Tino Dai
Hi there, Do you know of any service or person that could do a code review for me? Thanks, -Tino ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] Question regarding syntax

2007-07-11 Thread John Morris
I'm editing some code from Mailman and seeing: legend = _(%(hostname)s Mailing Lists) Can anyone tell me what the _( means in that context? Thanks, John ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Question regarding syntax

2007-07-11 Thread Dave Kuhlman
On Wed, Jul 11, 2007 at 11:03:18AM -0400, John Morris wrote: I'm editing some code from Mailman and seeing: legend = _(%(hostname)s Mailing Lists) The outter parenthese are a function call. The underscore is a name that has a callable as a value, I suppose. I believe that the value of the

Re: [Tutor] Question regarding syntax

2007-07-11 Thread John Morris
On 7/11/07, Dave Kuhlman [EMAIL PROTECTED] wrote: On Wed, Jul 11, 2007 at 11:03:18AM -0400, John Morris wrote: I'm editing some code from Mailman and seeing: legend = _(%(hostname)s Mailing Lists) The outer parentheses are a function call. The underscore is a name that has a callable as a

Re: [Tutor] Question regarding syntax

2007-07-11 Thread Michael Klier
Dave Kuhlman wrote: On Wed, Jul 11, 2007 at 11:03:18AM -0400, John Morris wrote: I'm editing some code from Mailman and seeing: legend = _(%(hostname)s Mailing Lists) I am no python pro but I guess that funtction _() ist just a wrapper function around gettext.gettext from the gettext

Re: [Tutor] Question regarding syntax

2007-07-11 Thread Eric Brunson
Michael Klier wrote: Dave Kuhlman wrote: On Wed, Jul 11, 2007 at 11:03:18AM -0400, John Morris wrote: I'm editing some code from Mailman and seeing: legend = _(%(hostname)s Mailing Lists) I am no python pro but I guess that funtction _() ist just a wrapper function

Re: [Tutor] Question regarding syntax

2007-07-11 Thread Andre Roberge
On 7/11/07, Eric Brunson [EMAIL PROTECTED] wrote: Michael Klier wrote: Dave Kuhlman wrote: On Wed, Jul 11, 2007 at 11:03:18AM -0400, John Morris wrote: I'm editing some code from Mailman and seeing: legend = _(%(hostname)s Mailing Lists) I am no python pro but I guess that

[Tutor] Question about lambda and new.instancemethod

2007-07-10 Thread Tino Dai
Hi Everybody, I have been working on a parser for myself. I want to create methods on the fly with the information that I get from a file. Here is my question: class configure: .stuff deleted.. def parseGlobal(self,projectName,section,project): for

Re: [Tutor] question re: executing exe files with arguments

2007-05-20 Thread Martin Walsh
Hey Janani, Janani Krishnaswamy wrote: Hi! I am having trouble executing an exe file with 3 arguments within a python script. Right now I have something like this: os.system(r'1/2/3/program 1/2/3/argument1 1/2/3/argument2') Without an error message, or traceback, this is difficult to

[Tutor] question re: executing exe files with arguments

2007-05-18 Thread Janani Krishnaswamy
Hi! I am having trouble executing an exe file with 3 arguments within a python script. Right now I have something like this: os.system(r'1/2/3/program 1/2/3/argument1 1/2/3/argument2') I was trying it with a raw string because of the /'s within it. I'm not sure of any other approaches. Any

Re: [Tutor] question re: executing exe files with arguments

2007-05-18 Thread Luke Paireepinart
Janani Krishnaswamy wrote: Hi! I am having trouble executing an exe file with 3 arguments within a python script. Right now I have something like this: os.system(r'1/2/3/program 1/2/3/argument1 1/2/3/argument2') I was trying it with a raw string because of the /'s within it. I'm not sure

[Tutor] Question about formating string with dictionary

2007-04-26 Thread Shuai Jiang (Runiteking1)
Hello everyone, The program that I am working on right now have a template for string formatting. My question is that is it possible to use multiple dictionary to format the string. For example x = {'foo':1234, 'bar': 5678} y = {'spam':'hello','cheese':'good-bye'} is there any way to use his

[Tutor] Question on UserDict class - copy function

2007-04-24 Thread Ketan Joshi
Hello All, I am very new to Python scripting. I have just started learning about Python. I have a question regarding UserDict class. UserDict class has a copy function which is defined as follows: def copy(self): if self.__class__ is UserDict: return UserDict(self.data) import

Re: [Tutor] Question on UserDict class - copy function

2007-04-24 Thread Rikard Bosnjakovic
On 4/24/07, Ketan Joshi [EMAIL PROTECTED] wrote: If so, why isn't this function defined as: def copy(self): import copy return copy.copy(self) The if-case in your code makes sure that the property __class__ is of UserDict-inheritance. I believe it's there in case of multiple

[Tutor] Question about cgi module

2007-04-20 Thread Mike Hansen
Part of the web app that I'm writing will allow users to upload small images to be stored in a database. Is there a way to limit how big of a file that the user can upload? Is there some cgi setting that would prevent a user from upload a huge file, or stop at a certain size and error? Mike

Re: [Tutor] Question about cgi module

2007-04-20 Thread Andreas Kostyrka
* Mike Hansen [EMAIL PROTECTED] [070420 22:32]: Part of the web app that I'm writing will allow users to upload small images to be stored in a database. Is there a way to limit how big of a file that the user can upload? Is there some cgi setting that would prevent a user from upload a huge

[Tutor] Question about exception

2007-04-05 Thread Mike Hansen
When doing a try/except block, is it possible to return a list as part of the exception? try: check_someting() except CheckSomethingError, e: for each_error in e: # do something Can 'e' be a list of errors? If so, how do you construct your exception class? Is it better to do it

Re: [Tutor] Question about exception

2007-04-05 Thread Bill Campbell
On Thu, Apr 05, 2007, Mike Hansen wrote: When doing a try/except block, is it possible to return a list as part of the exception? try: check_someting() except CheckSomethingError, e: for each_error in e: # do something Can 'e' be a list of errors? If so, how do you construct your

Re: [Tutor] Question about exception

2007-04-05 Thread Mike Hansen
If the Exception is defined as a class, e will be an instance of that class so you can have pretty much anything available: class MyException(Exception): def __init__(self, msg, mylist) self.msg = msg self.mylist = mylist Exception.__init__(self, msg) try:

Re: [Tutor] Question about profile.run() and decorators

2007-02-27 Thread Thane.Frivold
: Monday, February 26, 2007 7:26 PM To: Frivold Thane (Nokia-M/SanFrancisco) Cc: tutor@python.org Subject: Re: [Tutor] Question about profile.run() and decorators [EMAIL PROTECTED] wrote: Is there a way to construct a string version (suitable to pass into profile.run()) from what

[Tutor] Question about profile.run() and decorators

2007-02-26 Thread Thane.Frivold
To whom it may concern, I was directed to this forum... I searched for 'decorator profile' in the Python tutorial archives, and had no hits, so I hope this is not a lame question. Is there a way to construct a string version (suitable to pass into profile.run()) from what is

Re: [Tutor] Question about profile.run() and decorators

2007-02-26 Thread Kent Johnson
[EMAIL PROTECTED] wrote: Is there a way to construct a string version (suitable to pass into profile.run()) from what is available inside a decorator function? I realize that what I am trying to do could probably be done otherwise, but this arose out of questions and problems possed in

[Tutor] Question about local scopes (namespaces)

2007-02-21 Thread Adam Pridgen
Sorry for the long email, and thanks in advance. In the below example, is the list foo supposed to retain the value after the function, Bar(), returns? Is the list foo supposed to reinitialized on each call to Bar(), meaning len(foo) == 0, and when Bar() returns len(foo) (when Bar() is called

Re: [Tutor] Question about local scopes (namespaces)

2007-02-21 Thread Kent Johnson
Adam Pridgen wrote: Sorry for the long email, and thanks in advance. In the below example, is the list foo supposed to retain the value after the function, Bar(), returns? Yes Is the list foo supposed to reinitialized on each call to Bar(), meaning len(foo) == 0, and when Bar() returns

[Tutor] question

2007-02-14 Thread Caicedo, Richard IT2 NSWC
I am trying to get the $ python promt I can't seem to get it. I can get the python shell but when I press enter I don't get the $ python? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] question

2007-02-14 Thread Luke Paireepinart
Alan Gauld wrote: Doug Potter [EMAIL PROTECTED] wrote I don't get the output I would expect from the following. a = open('arp.txt') file = a.read() file = file.split('\n') Easier to do file = open('arp.txt').readlines() But file is a bad name since its an

Re: [Tutor] question

2007-02-14 Thread Luke Paireepinart
Caicedo, Richard IT2 NSWC wrote: I am trying to get the $ python promt I can't seem to get it. I can get the python shell but when I press enter I don't get the $ python? I don't understand what you're asking. What is the $ prompt? If you have a python shell you mean you have a python

Re: [Tutor] question

2007-02-14 Thread William Allison
Caicedo, Richard IT2 NSWC wrote: I am trying to get the $ python promt I can't seem to get it. I can get the python shell but when I press enter I don't get the $ python?

Re: [Tutor] question about importing threads

2007-02-11 Thread shawn bright
Yes, Mr Gauld, this is a help. Even though i am still newbie enough to take some time digesting it. one last queston. if i have a class that i import as a module, say a script that emails me when something goes wrong. so i have a file called my_own_email.py and in it a class called MyOwnEmail.

Re: [Tutor] question about importing threads

2007-02-11 Thread Kent Johnson
shawn bright wrote: one last queston. if i have a class that i import as a module, say a script that emails me when something goes wrong. so i have a file called my_own_email.py and in it a class called MyOwnEmail. Now MyOwnEmail needs the smtplib module. Do i need to import it just for

Re: [Tutor] question about importing threads

2007-02-11 Thread shawn bright
great, saves me 15 lines. thanks sk On 2/11/07, Kent Johnson [EMAIL PROTECTED] wrote: shawn bright wrote: one last queston. if i have a class that i import as a module, say a script that emails me when something goes wrong. so i have a file called my_own_email.py and in it a class called

<    2   3   4   5   6   7   8   9   10   >