Re: [Tutor] how to wirte code In python :str = (a>b?"Yes":"NO")

2007-02-16 Thread Michael P. Reilly
On 2/16/07, Wolfram Kraus <[EMAIL PROTECTED]> wrote: On 16.02.2007 08:01, xiufeng liu wrote: > Hi, all, > > In python if there is any similar way like in Java, or C++ to express > the following: > str = (a>b?"Yes":"NO") > > > thanks! In Python 2.5 you can do the following (untested): str = "Ye

Re: [Tutor] Replying to the tutor-list

2007-02-16 Thread Michael P. Reilly
On 2/16/07, ALAN GAULD <[EMAIL PROTECTED]> wrote: > However, the "standard behavior" at the time was that > replies went back to the mailing list, not to the original sender. But the mailing list was the original sender so it was all wonderfully consistent. Reply goes to sender only, which hap

Re: [Tutor] Replying to the tutor-list

2007-02-16 Thread Michael P. Reilly
On 2/16/07, Alan Gauld <[EMAIL PROTECTED]> wrote: As to standard list behaviour, I don't know of any list thats been around for more than say 10 years that uses Reply to send to All. This seems to be a very recent thing. (And most of the lists I am on have been around for much more than 10 years

Re: [Tutor] __init__.py for running a file from commandline?

2006-11-27 Thread Michael P. Reilly
Marcus, When you type something from the command-line, you are at the whims of the WinXP command shell. You have to follow its rules, not Python's. It would need to have "python" in %PATH%, and then it would need to have to run "python C:\path\to\pyroot\utils\commands\mygrep.py". The arguments

Re: [Tutor] shebang question

2006-11-26 Thread Michael P. Reilly
Very true about Python being installed in different places. In fact, for system compatibility reasons, it is sometime required that two or three very different releases of Python need to exist on the same system. If more than one happen to be in your path, then the use of "env python" becomes a

Re: [Tutor] is gotchas?

2006-11-06 Thread Michael P. Reilly
On 11/6/06, Tim Johnson <[EMAIL PROTECTED]> wrote: * Kent Johnson <[EMAIL PROTECTED]> [061106 10:31]:>> In [9]: a=[1,2]>> In [10]: b=[1,2]  Hmmm! Hmmm!  Lookee here:  ## console session >>> a=[1,2]>>> b=[1,2]>>> a is bFalse>>> c='1'  ## one byte>>> d='1'  ## one byte>>> c is dTrue>>> c='1,2'>>> d='

Re: [Tutor] Exception and sys.exit() in a cgi script

2006-10-22 Thread Michael P. Reilly
On 10/21/06, Paulino <[EMAIL PROTECTED]> wrote: Mike Hansen Mike.Hansen at atmel.com Mon Oct 16 18:43:29 CEST 2006 > This is a peace of a CGI script i have.> > 1 import cgi> 2 form=cgi.FieldStorage()> 3 try :> 4 ano=form["ano"].value> 5 conta=form["conta"].v

Re: [Tutor] python equivalent of perl readlink()?

2006-10-15 Thread Michael P. Reilly
On 10/15/06, Bill Campbell <[EMAIL PROTECTED]> wrote: Is there a python equivalent of the perl readlink() function(e.g. one that returns the relative path in cases where a commandsuch as ``ln -s ls /usr/local/bin/gls'' created the link?Reading the documentation on the various os.path functions, th

Re: [Tutor] what is "user time" in os.times()?

2006-10-03 Thread Michael P. Reilly
t;[EMAIL PROTECTED]> wrote:At 05:24 AM 10/3/2006, Michael P. Reilly wrote: >It is not really a "ghost".  On most systems, there is a split>between what happens while you are a "user" and what happens deep>inside the operation "system".  The function is showin

Re: [Tutor] file open (take 2)

2006-09-27 Thread Michael P. Reilly
On 9/27/06, Dave S <[EMAIL PROTECTED]> wrote: Hi,I am trying to read in an ascii text file, do some alterations and write itback.file = open(self.config.get('pdf','cert') + '/cert.pdf' , 'r+')lines = file.readlines()... process lines ... file.writelines(lines)file.close()works but ends up appending

Re: [Tutor] tuples versus lists

2006-09-14 Thread Michael P. Reilly
Tuples, like other immutable data types, are hashable (assuming the contents are immutable as well), and so they can be used as keys to dictionaries.  Lists cannot be used this way. >>> {['a']: 'a'}Traceback (most recent call last):  File "", line 1, in ?TypeError: list objects are unhashable>>> {(

Re: [Tutor] HTML page status

2006-09-12 Thread Michael P. Reilly
On 9/12/06, Johan Geldenhuys <[EMAIL PROTECTED]> wrote: Hi all,I looked a little bit at the urllib and it all looks fairly easy.What I didn't see, if it is there, was how to know or identify if a pagewas successfully downloaded. I want to do tests to see if a connection to a webpage was successful

Re: [Tutor] How to un-import modules?

2006-08-14 Thread Michael P. Reilly
On 8/14/06, Dick Moores <[EMAIL PROTECTED]> wrote: Actually, my question is, after using IDLE to do some importing ofmodules and initializing of variables, how to return it to it'sinitial condition without closing and reopening it.So, for example after I've done >>> import math, psyco >>> a = 4**2

Re: [Tutor] When am I ever going to use this?

2006-08-02 Thread Michael P. Reilly
On 8/1/06, Christopher Spears <[EMAIL PROTECTED]> wrote: I've been working through a tutorial:http://www.ibiblio.org/obp/thinkCSpy/index.htm.Lately, I have been learning about abstract data types(linked lists, stacks, queues, trees, etc.).  While I do enjoy the challenge of creating these objects,

Re: [Tutor] problem with rejected mail smtplib

2006-07-30 Thread Michael P. Reilly
On 7/29/06, shawn bright <[EMAIL PROTECTED]> wrote: Hello there,i have a customer list, each with a number of email address that we send notifications to via text message.the problem is, there are a number of providers ( just two ) that reject our messages. the script goes a little something like t

Re: [Tutor] Calling a function by string name

2006-07-21 Thread Michael P. Reilly
On 7/21/06, Smith, Jeff <[EMAIL PROTECTED]> wrote: I have an object and I want to call a method that I have constructed the name for in a string.   For example: str_method = 'myfun' obj.str_method   Of course, this fails.  I know I could probably do this with exec but is there a better

Re: [Tutor] So close! But ... error: (10054, 'Connection reset by peer')

2006-07-16 Thread Michael P. Reilly
You are running on a PC, which doesn't have a SMTP server running on it.  The default hostname for smtplib.SMTP().connect() is to localhost (your own machine).   You will need to find out the hostname of the mail server that your ISP provides.  You probably set it when you set up your email (based

Re: [Tutor] create 1000 000 variables

2006-07-15 Thread Michael P. Reilly
Good.  But one VERY important point to note is that that you are not working with "variables" here.  You are working with members of a class instance.  This is a very different beast.  You could just use getattr(), setattr() and delattr() for these. But continuing... you might want to think about t

Re: [Tutor] create 1000 000 variables

2006-07-15 Thread Michael P. Reilly
On 7/14/06, Сергій <[EMAIL PROTECTED]> wrote: suppose I need to create 1000 000 variables var_1, var_2, var_100   how to do this using for? (something like for i in range(100): ___var_ You should think about not creating variables like this, it is bad programming and continuing to use

Re: [Tutor] Need Help

2006-07-11 Thread Michael P. Reilly
On 7/10/06, Shappell, John J CW2 <[EMAIL PROTECTED]> wrote: Here is the assignment You've been given an assignment by your supervisor to program a small application to monitor the current status of the cash account in the firm's petty cash fund (the amount of cash kept on hand in the off

Re: [Tutor] How can I copy files recursively?

2006-07-11 Thread Michael P. Reilly
On 7/10/06, Richard Querin <[EMAIL PROTECTED]> wrote: I know this is probably a dumb question:I've got mp3 files that are downloaded (by ipodder) into individual subfolders. I'd like to write a quick script to move (not copy) all the mp3 files in those folders into a single destination folder. I wa

Re: [Tutor] Difference between popens

2006-06-10 Thread Michael P. Reilly
On 6/9/06, Bernard Lebel <[EMAIL PROTECTED]> wrote: Hey, thanks for the nice explanation Michael!BernardWhoops.. Hit "reply" instead of "reply to all".  My apologies to the group.  Dang gmail.  -Michael -- There's so many different worlds,So many different suns.And we have just one world,But we liv

Re: [Tutor] launching and monitor from make

2005-10-12 Thread Michael P. Reilly
On 10/12/05, Ertl, John <[EMAIL PROTECTED]> wrote: I have a very simple python program that reads one file and overwritesanouther text file.  This workes great from the command line and it haserror checking but just outputs messages and the like to the screen. The CM team here would like to have th

Re: [Tutor] Where did those spaces come from?

2005-09-13 Thread Michael P. Reilly
On 9/12/05, Tom Tucker <[EMAIL PROTECTED]> wrote: Tutor, Good evening!    The goal is to parse a simple file and grab column one.  Then print each value horizontally separated by a comma. Why is Python adding a space padding between each value?   Please see below. Thanks ahead of time. INPU

Re: [Tutor] Killing a thread from main - was RE: "Lock"ing threads

2005-08-30 Thread Michael P. Reilly
On 8/29/05, Hans Dushanthakumar <[EMAIL PROTECTED]> wrote: Thanks KentHow do I send a signal from the main thread to stop execution of a childthread?I tried the foll:, but got an error:Other than by this method, is there any other mechanism to stop athread? import threadingimport timeclass shownum(

Re: [Tutor] Generate 8 digit random number

2005-08-26 Thread Michael P. Reilly
On 8/26/05, Alberto Troiano <[EMAIL PROTECTED]> wrote: Hi everyoneI need to generate a password..It has to be an 8 digit number and it has tobe randomThe code I've been trying is the following:import randomrandom.randrange(,) The code works but sometimes it picks a number with 7 dig

Re: [Tutor] OT self-implementation?

2005-07-01 Thread Michael P. Reilly
On 7/1/05, Brian van den Broek <[EMAIL PROTECTED]> wrote: Hi all,a bit off topic for Python Tutor, but I am think there are decent oddsthat folks here both know good resources and have an idea of whatlevel would be appropriate for me. So, I hope no one minds. A recent thread on comp.lang.python has

Re: [Tutor] Help with Tkinter teachers' report program?

2005-06-24 Thread Michael P. Reilly
On 6/24/05, Adam Cripps <[EMAIL PROTECTED]> wrote: On 6/24/05, Michael P. Reilly <[EMAIL PROTECTED]> wrote:> On 6/24/05, Adam Cripps <[EMAIL PROTECTED]> wrote:> > I hadn't thought about a scrollbar - that would be very useful, > > although doesn't add t

Re: [Tutor] Help with Tkinter teachers' report program?

2005-06-24 Thread Michael P. Reilly
On 6/24/05, Adam Cripps <[EMAIL PROTECTED]> wrote: I hadn't thought about a scrollbar - that would be very useful,although doesn't add to the management side of the statement (i.e.organising them according to subjects).The user can load a text file and adapt that - so they don't have to enter them

Re: [Tutor] Help with Tkinter teachers' report program?

2005-06-24 Thread Michael P. Reilly
On 6/24/05, Adam Cripps <[EMAIL PROTECTED]> wrote: I am a teacher and have written this little Python/Tkinter applicationto help me with my report writing:http://cvs.sourceforge.net/viewcvs.py/squawk/ It's released under GPL and was quite fun to write.However, currently the application only allows

Re: [Tutor] Clearing the Console Screen

2005-06-16 Thread Michael P. Reilly
On 6/16/05, Don Parris <[EMAIL PROTECTED]> wrote: Thanks!  I thought there had to be a way to call the OS' clear screencommand, but was going about it the wrong way.  I was trying to usesys.clear instead of os.system.  Would it be difficult to test the OS, store the result in a variable, and call t

Re: [Tutor] Process problem

2005-06-16 Thread Michael P. Reilly
On 6/16/05, Alberto Troiano <[EMAIL PROTECTED]> wrote: Hey allNevermind, it worked with the & trick.I just posted because the first 2 times didn't do anything but there was anerror in the crontab so... Alberto, If you are going to use put the processes in the background with the ampersand ('&'), t

Re: [Tutor] interactif or not

2005-06-04 Thread Michael P. Reilly
On 6/3/05, Cedric BRINER <[EMAIL PROTECTED]> wrote: hi,How can I know if a script is launched interactively or not because I'd like to make a script verbose or not depending if it is executed as interactive or not.eg.If I invoke it in a shell.. then it can be verboseIf it is launched from a crontab