[Tutor] py.test on Windows

2009-04-23 Thread Hans DushanthaKumar
Hi, Has anyone here got py.test running on Windows? How do I run a test script? I have previously installed and used it on Linux and it all worked magically - all I needed to do was type in "py.test ". However on windows, the installation doesn't seem to set the paths appropriately. Thanks,

[Tutor] Importing serial module

2005-08-21 Thread Hans Dushanthakumar
Hi Folks Another newbie here :) Heres a couple of questions: 1) I downloaded the python serial port module (pyserial-2.2.win32.exe) from http://sourceforge.net/project/showfiles.php?group_id=46487 And installed it on my Win XP PC. However, when I try to import the module, I get the foll: err

[Tutor] Split a string into characters

2005-08-22 Thread Hans Dushanthakumar
Hi, A quick one... How do I split a string like "Hans" into a list of characters ['H','a','n','s']? Note that there are no spaces in the original string. Str.split() without any arguments looks for whitespace as splitting character. So, this doesn't serve the purpose. And str.split("") app

Re: [Tutor] Split a string into characters

2005-08-22 Thread Hans Dushanthakumar
Bingo :) Thanks Rick -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rick Pasotto Sent: Tuesday, 23 August 2005 1:55 p.m. To: tutor@python.org Subject: Re: [Tutor] Split a string into characters On Tue, Aug 23, 2005 at 01:18:43PM +1200, Hans

[Tutor] Importing modules/classes

2005-08-24 Thread Hans Dushanthakumar
Hi Am trying to get my head around classes in python. I have a file dummy_class.py with a class definition in it, as foloows class dummy_class: def __init__(self): print "__init__" def run(self): print "run" Now, I have another file test_dummy.py, which only has th

Re: [Tutor] Importing modules/classes

2005-08-24 Thread Hans Dushanthakumar
or your help (and time). U guys are awesome :) -Original Message- From: Danny Yoo [mailto:[EMAIL PROTECTED] Sent: Thursday, 25 August 2005 12:17 p.m. To: Hans Dushanthakumar Cc: Tutor Subject: Re: [Tutor] Importing modules/classes > class dummy_class: > def __init__(self): >

[Tutor] Differences in running a multithreaded script under IDLE and otherwise

2005-08-24 Thread Hans Dushanthakumar
Hi, While running the foll script by double-clicking it (under WinXP), it runs as expected. However, when I run it via IDLE, it hangs after a few secs (no runtime errors - just hangs). Why does this happen? Cheers Hans import threading class incr_num(threading.Thread): num = '' d

Re: [Tutor] Differences in running a multithreaded script under IDLE and otherwise

2005-08-25 Thread Hans Dushanthakumar
nt. Cheers Hans -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kent Johnson Sent: Thursday, 25 August 2005 11:23 p.m. Cc: tutor@python.org Subject: Re: [Tutor] Differences in running a multithreaded script under IDLE and otherwise Hans Dushanthaku

[Tutor] "Lock"ing threads

2005-08-28 Thread Hans Dushanthakumar
Hi, In a multithreaded program, how do I ensure that a block of code in a thread is always executed fully before passing control to another thread. Does "Lock" serve this purpose? The foll program is a dummy one, with 2 threads. One put a number onto a queue (of max size 1) and the other thread

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

2005-08-29 Thread Hans Dushanthakumar
Thanks Kent How do I send a signal from the main thread to stop execution of a child thread? I tried the foll:, but got an error: Other than by this method, is there any other mechanism to stop a thread? import threading import time class shownum(threading.Thread): def __init__(self

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

2005-08-29 Thread Hans Dushanthakumar
Oops - the error was probably due to using 'stop' as a method name. :) -Original Message----- From: Hans Dushanthakumar Sent: Tuesday, 30 August 2005 2:18 p.m. To: tutor@python.org Subject: Killing a thread from main - was RE: [Tutor] "Lock"ing threads Thanks Kent Ho

Re: [Tutor] How to write this to a file?

2005-10-06 Thread Hans Dushanthakumar
print outputs the string to the std output (sys.stdout). You could redirect the std output to a file instead of the screen as follows, but it's a bit clumsy. fptr = open("hans.log", "a+") import sys sys.stdout = fptr print "Hi there" This will output the string into the file hans.log. However, t

Re: [Tutor] help with elif statements

2005-10-12 Thread Hans Dushanthakumar
U might wanna change the code to something along the lines of def getcredits(num): if num < 7: return 'Freshman' elif num >= 7 and num <16 return 'Sophomore' elif num >= 16 and num < 26: return 'Junior' Etc... Or even def getcredits(num): if num < 7:

Re: [Tutor] question about serial coms

2005-11-14 Thread Hans Dushanthakumar
Ive worked on a similar application. I used one thread to read from the serial port and another one to handle the writes. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hugo González Monteverde Sent: Tuesday, 15 November 2005 7:36 a.m. To: nephish Cc:

Re: [Tutor] question about serial coms

2005-11-14 Thread Hans Dushanthakumar
port Release lock Cheers Hans -Original Message- From: nephish [mailto:[EMAIL PROTECTED] Sent: Tuesday, 15 November 2005 10:47 a.m. To: Hans Dushanthakumar Cc: Hugo González Monteverde; tutor Subject: RE: [Tutor] question about serial coms well thats encouraging, did you have to do

Re: [Tutor] question about serial coms

2005-11-14 Thread Hans Dushanthakumar
Lock() is provided by the threading module. see http://docs.python.org/lib/module-threading.html & http://docs.python.org/lib/lock-objects.html Cheers Hans -Original Message- From: nephish [mailto:[EMAIL PROTECTED] Sent: Tuesday, 15 November 2005 11:23 a.m. To: Hans Dushanthakuma

Re: [Tutor] question about serial coms

2005-11-14 Thread Hans Dushanthakumar
=== Cheers Hans -Original Message- From: nephish [mailto:[EMAIL PROTECTED] Sent: Tuesday, 15 November 2005 2:10 p.m. To: [EMAIL PROTECTED] Cc: Hans Dushanthakumar; tutor Subject: Re: [Tutor] question about serial coms oh yeah, i will need this too! sk On Mon,

Re: [Tutor] Newbie question

2005-11-22 Thread Hans Dushanthakumar
A short-cut if you dont want to use DOS to traverse to your directory or if you are feeling too lazy to type in the entire path & script name.   You can right-click on the script file in the Windows explorer and choose "Send to -> Command prompt". This opens a command prompt with the path al

[Tutor] Using py2exe

2005-11-22 Thread Hans Dushanthakumar
Hi, Im trying to convert a python program to a stand-alone executable that I can distribute. How do I use py2exe to do this? The python program consists of a py script that uses (imports) several other modules (py scripts) located in another directory. Heres what Ive tried so far: 1) Run

[Tutor] How to Pass lists by value

2005-12-05 Thread Hans Dushanthakumar
Hi folks, How do I pass a list by value to a function. The foll: snippet of code produces the output as shown: Code: - def junk(x): x.append("20") return x a = ["10"] b = junk(a) print b print a Output: --- >>> b = ['10', '20'] a = ['10', '20'] This indicates that the

Re: [Tutor] How to Pass lists by value

2005-12-05 Thread Hans Dushanthakumar
Tuesday, 6 December 2005 1:49 p.m.To: Hans DushanthakumarSubject: Re: [Tutor] How to Pass lists by value On 06/12/05, Hans Dushanthakumar <[EMAIL PROTECTED]> wrote: Hi folks,   How do I pass a list by value to a function.The foll: snippet of code produces the output as sho

Re: [Tutor] How to Pass lists by value

2005-12-06 Thread Hans Dushanthakumar
Thanks for your valuable feedback guys. Cheers Hans -Original Message- From: w chun [mailto:[EMAIL PROTECTED] Sent: Tuesday, 6 December 2005 9:11 p.m. To: Hans Dushanthakumar Cc: tutor@python.org Subject: Re: How to Pass lists by value On 12/5/05, Kent Johnson <[EMAIL PROTEC

[Tutor] Writing/reading lists to a file

2005-12-27 Thread Hans Dushanthakumar
Hi, Is there any easy way of writing lists to a file and more importantly, reading it back as a list of lists rather than as a list of strings. Eg: >>> t = ["t1", "PASS", 31] >>> f = open("pass.txt","a+") >>> f.write(str(t) + "\n") >>> f.write(str(t) + "\n") >>> f.close() At this stage, the

Re: [Tutor] new to linux and I cannot find some python things

2005-12-29 Thread Hans Dushanthakumar
Anothet linux noobie here :) How do I uninstall python? I use the SimplyMepis flavor of linux. The reason I want to uninstall python is that its an old version (2.3). Not that I particularly want the new version, but the IDLE installation that I downloaded reports all kinds of errors because appar

[Tutor] Disabling a frame in Tkinter

2006-01-05 Thread Hans Dushanthakumar
Hi, Is there any way to disable an entire frame (and all its included widgets) in Tkinter. It does not seem to support state=DISABLED. Another Tkinter question: In a listbox, how do I intially set a "selected" item? What I want to do here is have the 1st item in a listbox selected (ie highlight

Re: [Tutor] Disabling a frame in Tkinter

2006-01-05 Thread Hans Dushanthakumar
o_children(): self.setState(child, state=state) Cheers Hans -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of John Fouhy Sent: Friday, 6 January 2006 12:03 p.m. To: tutor@python.org Subject: Re: [Tutor] Disabling a frame in Tkinter On 06/0

[Tutor] Returning multiple values from a script

2006-01-11 Thread Hans Dushanthakumar
Hi, Can a script return multiple values to the os? What I have in mind is something like the following: 1) Test.py --- import sys r = 7 sys.exit(r) # What I really want to do is something along the lines of sys.exit(r, "Hans") 2) Script1.py (This script executes script test.py and pri

Re: [Tutor] Returning multiple values from a script

2006-01-11 Thread Hans Dushanthakumar
ginal Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kent Johnson Sent: Thursday, 12 January 2006 12:06 p.m. Cc: Python Tutor Subject: Re: [Tutor] Returning multiple values from a script Hans Dushanthakumar wrote: > Hi, >Can a script return multiple values to th

Re: [Tutor] Returning multiple values from a script

2006-01-11 Thread Hans Dushanthakumar
Subject: Re: [Tutor] Returning multiple values from a script Hans Dushanthakumar wrote: > Yes I agree that it'd be cleaner to import the second script and call > it. > > The reason I'm keen to find a alternate method is that I have a whole > lot of scripts that were design

Re: [Tutor] Returning multiple values from a script

2006-01-11 Thread Hans Dushanthakumar
= test.run_test() Cheers Hans -----Original Message- From: Hans Dushanthakumar Sent: Thursday, 12 January 2006 2:28 p.m. Cc: Python Tutor Subject: RE: [Tutor] Returning multiple values from a script Thanks for your reply Kent. Is it possible to dynamically import a module? The foll s

Re: [Tutor] Strings backwards

2006-01-18 Thread Hans Dushanthakumar
Try this: print word[::-1] -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of ryan luna Sent: Thursday, 19 January 2006 12:13 p.m. To: tutor@python.org Subject: [Tutor] Strings backwards Hello, what i need to do is get user input and then print the string

Re: [Tutor] Getting Running File's Name

2006-01-30 Thread Hans Dushanthakumar
Under WinXP, the variable sys.argv[0] holds the script file name (including the path). Not sure, but it may work the same under Linux as well. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bryan Carbonnell Sent: Tuesday, 31 January 2006 3:11 p.m. To: tu

[Tutor] Printing the Carriage return character

2006-02-19 Thread Hans Dushanthakumar
Hi, Not sure if this is a python thing or a Operating system peculiarity, but here goes: Why does the line print "FirstLine" + "\rSecondLine" produce different output when run via IDLE and when run in the python prompt (both under Windows XP)? Output in IDLE (ver 1.1.1, python 2.4.1): >>> print

Re: [Tutor] Printing the Carriage return character

2006-02-20 Thread Hans Dushanthakumar
Thanks Alan for clearing that up...I was trying to see why my "\r\n" does not print 2 empty lines when I stumbled across this 'gotcha'. -Original Message- From: Alan Gauld [mailto:[EMAIL PROTECTED] Sent: Monday, 20 February 2006 9:22 p.m. To: Hans Dushanthakum

[Tutor] Python for basic web-testing

2006-08-06 Thread Hans Dushanthakumar
Hi,    How do I use python for basic web-tasks like inputting data or clicking buttons on web-pages. For eg, how do I enter my username and password and click on the "OK" button on the yahoo mail page? I had a look at the webbrowser module documentation (http://www.python.org/doc/current/lib

Re: [Tutor] Python for basic web-testing

2006-08-06 Thread Hans Dushanthakumar
ECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dustin J. Mitchell Sent: Monday, 7 August 2006 11:45 a.m. To: tutor@python.org Subject: Re: [Tutor] Python for basic web-testing Hans Dushanthakumar wrote: > Hi, >How do I use python for basic web-tasks like inputting data or > clicking

[Tutor] command history in a console

2008-09-17 Thread Hans Dushanthakumar
G'day everyone. I'm experimenting with a custom console application, and trying to add command history functionality to it. It seems to basically work ok except for the fact that when I press the Up arrow key to run previous commands, the right commands are not displayed. It displays a wierd