Re: [Tutor] DATA TYPES

2008-02-20 Thread Michael Langford
> - Since the OP is trying to find cases where the same variable is > assigned different types, presumably in a single scope, checking just at > the end of a function won't help. This is a starting point to get the type for the variables when you start the port, before you run the unit tests.

Re: [Tutor] designing POOP

2008-02-20 Thread Alan Gauld
"Michael Langford" <[EMAIL PROTECTED]> wrote > I'm firmly with Kent here: OO programming is not about simulation. Wooah! I'm partly on board here and do agree the noun/verb thing is a gross simplification. But it does work and is how probably the majority of OOP programmers started out - in the 8

Re: [Tutor] results not quite 100 percent yet

2008-02-20 Thread Tiger12506
> As far as I can see, these routines give me the results > I'm looking for. I get a distribution of four negative numbers, > four positive integers in the range 10 to 110, and nothing > is placed in room 6 or room 11: I'll throw a couple of thoughts out there since I know that you appreciate to

Re: [Tutor] DATA TYPES

2008-02-20 Thread Kent Johnson
Tiger12506 wrote: > Hehehe, did you try it Kent? Obviously not :-) > Which is not what I expected! > Until I realized that you are missing the % sign in between the print string > and the tuple of values to interpolate Blame that one on Michael, I copied from him :-) > Then it returns this: >

Re: [Tutor] DATA TYPES

2008-02-20 Thread Tiger12506
> I was thinking more or less along the same lines, but > - you don't need the copy() Hehehe, did you try it Kent? > - locals is a dict mapping names to values, so something like > for name, value in locals().iteritems(): > print "varname: %s type: %s" (name,type(value)) And this returns

Re: [Tutor] DATA TYPES

2008-02-20 Thread Tiger12506
> As I understand it python is not a strongly typed language so no > declaration > of variables is necessary. My question is this: > > If I use a variable in a program that stores certain numbers and I'm > porting > it to say ... java where I must first declare the variables before I use > them

Re: [Tutor] How to deal with a thread that doesn't terminate

2008-02-20 Thread Tiger12506
Similar to the TerminateProcess function in win32api, there is the TerminateThread function which you can use if you know the handle of the thread, but it seems that you can only get the thread handle if you are calling from that thread, or if you were the one who created it (and saved the retu

Re: [Tutor] DATA TYPES

2008-02-20 Thread Kent Johnson
Michael Langford wrote: >you can > print out the type of the local variables at the end of your > functions. > > i.e.: > > for var in locals().copy(): > print "varname: %s type: %s" (var,type(var)) I was thinking more or less along the same lines, but - you don't need the copy() - locals is

Re: [Tutor] DATA TYPES

2008-02-20 Thread Michael Langford
On Wed, Feb 20, 2008 at 12:41 PM, Toby <[EMAIL PROTECTED]> wrote: > I have used a certain variable to hold literally > dozens of different values and I BELIEVE them all to be integers but I'm not > entirely sure that I have not stumbled into the float realm is there a way > to have python list a

Re: [Tutor] DATA TYPES

2008-02-20 Thread Kent Johnson
Toby wrote: > As I understand it python is not a strongly typed language so no declaration > of variables is necessary. Actually Python has strong, dynamic typing but I guess that is a discussion for another thread. > If I use a variable in a program that stores certain numbers and I'm porting >

Re: [Tutor] results not quite 100 percent yet

2008-02-20 Thread bhaaluu
As far as I can see, these routines give me the results I'm looking for. I get a distribution of four negative numbers, four positive integers in the range 10 to 110, and nothing is placed in room 6 or room 11: #!/usr/bin/python import random #print "\n"*30 table= [[ 0, 2, 0, 0, 0, 0, 0],#

[Tutor] DATA TYPES

2008-02-20 Thread Toby
As I understand it python is not a strongly typed language so no declaration of variables is necessary. My question is this: If I use a variable in a program that stores certain numbers and I'm porting it to say ... java where I must first declare the variables before I use them how do I find out

Re: [Tutor] using os module on windows

2008-02-20 Thread Kent Johnson
Timmie wrote: > Which command do you recommend if the destination already exists? > I'd like to overwrite or sychronise a local with a remote directory and > therefore the destinations files already exist. Delete, then copy. Or use rsync instead of Python... Kent _

Re: [Tutor] How to deal with a thread that doesn't terminate

2008-02-20 Thread Tony Cappellini
Thanks Michael. On Feb 19, 2008 11:23 PM, Michael Langford <[EMAIL PROTECTED]> wrote: > Instead of using a thread, you could see if you could use a second > process. For instance, the following would work on windows (and is > killable). > > import subprocess > import win32api > > class SpawnCont

Re: [Tutor] using os module on windows

2008-02-20 Thread Timmie
Thanks for your reply! > The destination path should not already exist, it should end with the > directory you want to create. Did you read the docs for copytree()? They > say, "The destination directory, named by dst, must not already exist; > it will be created as well as missing parent direc

Re: [Tutor] Silly question: Modifying code while the script is running

2008-02-20 Thread Luke Paireepinart
Scott Wolcott wrote: > Okay, I've got this ircbot that i wrote in python, and while we were > all making Terminator jokes, it occurred to me that it would actually > be reletively easy to have redqueen (that's the bot) write code into > another file. Then you just have to specify the file and im

Re: [Tutor] using os module on windows

2008-02-20 Thread Kent Johnson
Timmie wrote: > ## config ## > source = 'C:/my/local/directory' > dest = 'Z:/my/network/drive' > ## start action > #os.remove(dest) > > ## error output > Traceback (most recent call last): > File "test_os_on_win", line 14, in > os.remove(dest) > WindowsError: [Error 5] Zugriff verw

[Tutor] using os module on windows

2008-02-20 Thread Timmie
Dear list, I have some problems using the os module on windows. I kindly ask you do give me advice why os.remove and os.shutil fail here: ### using remove ## #!/usr/bin/env python # -*- coding: utf-8 -*- import shutil import os ## config ## source = 'C:/my/local/directory' dest = 'Z:/my