[Tutor] DATA TYPES

Toby toby.pas at gmail.com
Wed Feb 20 18:41:33 CET 2008


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 what type to give that variable, specifically is
there a way to identify the type of a variable used in a python program for
reference?

What I'm saying is if 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 all variables contained in a program and tell me what
type it has internally stored them as?  I realize I could trudge through the
entire 1000 lines and check all the variables and see what values I have
assigned them one at a time but I'm wondering if there is an easier way to
get that data?


Thanks

Toby

-----Original Message-----
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org] On Behalf
Of tutor-request at python.org
Sent: Wednesday, February 20, 2008 1:23 AM
To: tutor at python.org
Subject: Tutor Digest, Vol 48, Issue 48

Send Tutor mailing list submissions to
	tutor at python.org

To subscribe or unsubscribe via the World Wide Web, visit
	http://mail.python.org/mailman/listinfo/tutor
or, via email, send a message with subject or body 'help' to
	tutor-request at python.org

You can reach the person managing the list at
	tutor-owner at python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Tutor digest..."


Today's Topics:

   1. Re: reading webpage (Kent Johnson)
   2. Re: Change mouse cursor position (bob gailer)
   3. Re: Change mouse cursor position (Flaper87)
   4. Re: Change mouse cursor position (bob gailer)
   5. Re: Change mouse cursor position (Michael Langford)
   6. How to deal with a thread that doesn't terminate (Tony Cappellini)
   7. Re: How to deal with a thread that doesn't terminate (bob gailer)
   8. Re: How to deal with a thread that doesn't terminate
      (Tony Cappellini)
   9. Re: How to deal with a thread that doesn't terminate (bob gailer)
  10. Re: How to deal with a thread that doesn't terminate (John Fouhy)
  11. Re: Putting the Output of Help to a File (Justin Ezequiel)
  12. Re: How to deal with a thread that doesn't terminate
      (Michael Langford)


----------------------------------------------------------------------

Message: 1
Date: Tue, 19 Feb 2008 07:46:48 -0500
From: Kent Johnson <kent37 at tds.net>
Subject: Re: [Tutor] reading webpage
To: "Guess?!?" <wtfwhoami at gmail.com>
Cc: tutor at python.org
Message-ID: <47BACFB8.9090508 at tds.net>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Guess?!? wrote:
> Hi Kent,
>  
> Broken machine gives
>  
> IDLE 1.2.1     
>  >>> import urllib
>  >>> print urllib.getproxies()
> {'http': 'http://proxy-address:port' <http://proxy-address:port'>}
>  >>>
>  
> correct machine gives empty dictionary ... { }

Well that is the problem. Now you have to fix it. The proxy comes either 
from the environment variable HTTP_PROXY or from the Windows registry, I 
think it is the proxyServer value of the key 
Software\Microsoft\Windows\CurrentVersion\Internet Settings
but I'm not on Windows and this is no longer a Python question so that 
is as far as I will take it.

Kent


------------------------------

Message: 2
Date: Tue, 19 Feb 2008 08:56:50 -0500
From: bob gailer <bgailer at alum.rpi.edu>
Subject: Re: [Tutor] Change mouse cursor position
To: Flaper87 <flaper87 at gmail.com>
Cc: Tutor at python.org
Message-ID: <47BAE022.3090608 at alum.rpi.edu>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Flaper87 wrote:
> Hey Guys!!!
>
> is it possible to change the mouse position by passing it the coords?
>
> I'm developing an application that needs to be able to change the 
> cursor's possition.
We need more information. Is this a GUI application? If so which GUI 
software? Or are you trying to control the mouse in another application?
>
> O.S. Linux Debian Sid
> Python: 2.4=<
-- 
Bob Gailer
919-636-4239 Chapel Hill, NC



------------------------------

Message: 3
Date: Tue, 19 Feb 2008 16:48:11 +0100
From: Flaper87 <flaper87 at gmail.com>
Subject: Re: [Tutor] Change mouse cursor position
To: "bob gailer" <bgailer at alum.rpi.edu>
Cc: Tutor at python.org
Message-ID:
	<da1c02120802190748qa86fee0lcb85257525ea1152 at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

it is not a GUI application, i need to be able to change the cursor position
if an event happens.


2008/2/19, bob gailer <bgailer at alum.rpi.edu>:
>
> Flaper87 wrote:
> > Hey Guys!!!
> >
> > is it possible to change the mouse position by passing it the coords?
> >
> > I'm developing an application that needs to be able to change the
> > cursor's possition.
> We need more information. Is this a GUI application? If so which GUI
> software? Or are you trying to control the mouse in another application?
> >
> > O.S. Linux Debian Sid
> > Python: 2.4=<
> --
> Bob Gailer
> 919-636-4239 Chapel Hill, NC
>
>


-- 
Flavio Percoco Premoli, A.K.A. [Flaper87]
http://www.flaper87.org
Usuario Linux registrado #436538
Geek by nature, Linux by choice, Debian of course.
Key Fingerprint: CFC0 C67D FF73 463B 7E55  CF43 25D1 E75B E2DB 15C7
The Solution to everything:
python -c "from struct import pack; print  pack('5b', (41*len('99')),
pow(8,2)+20, 4900**0.5, range(78)[-1], 10)"
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://mail.python.org/pipermail/tutor/attachments/20080219/6b15c4d5/attachm
ent-0001.htm 

------------------------------

Message: 4
Date: Tue, 19 Feb 2008 11:12:19 -0500
From: bob gailer <bgailer at alum.rpi.edu>
Subject: Re: [Tutor] Change mouse cursor position
To: Flaper87 <flaper87 at gmail.com>
Cc: Tutor at python.org
Message-ID: <47BAFFE3.2030801 at alum.rpi.edu>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Flaper87 wrote:
> it is not a GUI application, i need to be able to change the cursor 
> position if an event happens.
Sorry but that does not help at all. I guess you want a character-based 
console window and ability to respond to user keystrokes. If that is the 
case use the curses module.

If not please explain your situation in more detail.

And in future questions please give the relevant details in the original 
posting. Discovery processes like this are costly to everyone involved.

-- 
Bob Gailer
919-636-4239 Chapel Hill, NC



------------------------------

Message: 5
Date: Tue, 19 Feb 2008 15:02:44 -0500
From: "Michael Langford" <mlangford.cs03 at gtalumni.org>
Subject: Re: [Tutor] Change mouse cursor position
To: Flaper87 <flaper87 at gmail.com>
Cc: Tutor at python.org
Message-ID:
	<82b4f5810802191202ifa54d6bg23117bc94e60bd1e at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

I do not know of a python library to do this.

Therefore, I'd use a popen call to
http://www.hoopajoo.net/projects/xautomation.html.

         --Michael

PS: If we you were on windows, I'd use  http://pywinauto.openqa.org/

On Feb 19, 2008 4:34 AM, Flaper87 <flaper87 at gmail.com> wrote:
> Hey Guys!!!
>
> is it possible to change the mouse position by passing it the coords?
>
> I'm developing an application that needs to be able to change the cursor's
> possition.
>
> O.S. Linux Debian Sid
>  Python: 2.4=<
>
> Thanks
>
> --
> Flavio Percoco Premoli, A.K.A. [Flaper87]
> http://www.flaper87.org
> Usuario Linux registrado #436538
> Geek by nature, Linux by choice, Debian of course.
>  Key Fingerprint: CFC0 C67D FF73 463B 7E55  CF43 25D1 E75B E2DB 15C7
> The Solution to everything:
> python -c "from struct import pack; print  pack('5b', (41*len('99')),
> pow(8,2)+20, 4900**0.5, range(78)[-1], 10)"
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>



-- 
Michael Langford
Phone: 404-386-0495
Consulting: http://www.RowdyLabs.com


------------------------------

Message: 6
Date: Tue, 19 Feb 2008 13:53:06 -0800
From: "Tony Cappellini" <cappy2112 at gmail.com>
Subject: [Tutor] How to deal with a thread that doesn't terminate
To: "Tutor Python" <tutor at python.org>
Message-ID:
	<8249c4ac0802191353n7b07c87dxed50af4df38ade63 at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

When I executing a program external to the main program in a thread,
and that thread hangs, can the thread be terminated?
How does one handle this situation?


------------------------------

Message: 7
Date: Tue, 19 Feb 2008 17:02:16 -0500
From: bob gailer <bgailer at alum.rpi.edu>
Subject: Re: [Tutor] How to deal with a thread that doesn't terminate
To: cappy2112 at gmail.com
Cc: Tutor Python <tutor at python.org>
Message-ID: <47BB51E8.7070506 at alum.rpi.edu>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Tony Cappellini wrote:
> When I executing a program external to the main program in a thread,
> and that thread hangs, can the thread be terminated?
>   
Please define "hangs".

AFAIK that could mean waiting on an external event / signal / 
communication that never happens, or running in an "infinite loop". So 
which is it or is it something else?

-- 
Bob Gailer
919-636-4239 Chapel Hill, NC



------------------------------

Message: 8
Date: Tue, 19 Feb 2008 14:03:59 -0800
From: "Tony Cappellini" <cappy2112 at gmail.com>
Subject: Re: [Tutor] How to deal with a thread that doesn't terminate
To: "bob gailer" <bgailer at alum.rpi.edu>
Cc: Tutor Python <tutor at python.org>
Message-ID:
	<8249c4ac0802191403n4efdd461w5fb51d8ff73c6d6b at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On Feb 19, 2008 2:02 PM, bob gailer <bgailer at alum.rpi.edu> wrote:
> Tony Cappellini wrote:
> > When I executing a program external to the main program in a thread,
> > and that thread hangs, can the thread be terminated?
> >
> Please define "hangs".

> AFAIK that could mean waiting on an external event / signal /
> communication that never happens, or running in an "infinite loop". So
> which is it or is it something else?

Never happens.


------------------------------

Message: 9
Date: Tue, 19 Feb 2008 18:27:16 -0500
From: bob gailer <bgailer at alum.rpi.edu>
Subject: Re: [Tutor] How to deal with a thread that doesn't terminate
To: cappy2112 at gmail.com
Cc: Tutor Python <tutor at python.org>
Message-ID: <47BB65D4.8080706 at alum.rpi.edu>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Tony Cappellini wrote:
> On Feb 19, 2008 2:02 PM, bob gailer <bgailer at alum.rpi.edu> wrote:
>   
>> Tony Cappellini wrote:
>>     
>>> When I executing a program external to the main program in a thread,
>>> and that thread hangs, can the thread be terminated?
>>>
>>>       
>> Please define "hangs".
>>     
>
>   
>> AFAIK that could mean waiting on an external event / signal /
>> communication that never happens, or running in an "infinite loop". So
>> which is it or is it something else?
>>     
>
> Never happens.
>   

Sorry. I don't understand that, so I can't help. Perhaps someone else can.


-- 
Bob Gailer
919-636-4239 Chapel Hill, NC



------------------------------

Message: 10
Date: Wed, 20 Feb 2008 12:57:54 +1300
From: "John Fouhy" <john at fouhy.net>
Subject: Re: [Tutor] How to deal with a thread that doesn't terminate
To: "bob gailer" <bgailer at alum.rpi.edu>
Cc: Tutor Python <tutor at python.org>, cappy2112 at gmail.com
Message-ID:
	<5e58f2e40802191557r75ac1dfek2cf2a217e8004f96 at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

On 20/02/2008, bob gailer <bgailer at alum.rpi.edu> wrote:
> Tony Cappellini wrote:
> > On Feb 19, 2008 2:02 PM, bob gailer <bgailer at alum.rpi.edu> wrote:
> >
> >> Tony Cappellini wrote:
> >>
> >>> When I executing a program external to the main program in a thread,
> >>> and that thread hangs, can the thread be terminated?
> >>>
> >>>
> >> Please define "hangs".
> >>
> >
> >
> >> AFAIK that could mean waiting on an external event / signal /
> >> communication that never happens, or running in an "infinite loop". So
> >> which is it or is it something else?
> >>
> >
> > Never happens.
> >
>
> Sorry. I don't understand that, so I can't help. Perhaps someone else can.

I presume he means he defines "hangs" as "waiting on an external event
/ signal / communicaiton that never happens".

AFAIK, there's no good way to kill a thread (google for 'python kill
thread' for lots of hits).  IME most blocking operations have optional
timeout parameters, so you could restructure your main thread loop to
wait->work/timeout->repeat, which should make it easier to end the
thread.

-- 
John.


------------------------------

Message: 11
Date: Wed, 20 Feb 2008 09:33:35 +0800
From: "Justin Ezequiel" <justin.mailinglists at gmail.com>
Subject: Re: [Tutor] Putting the Output of Help to a File
To: tutor at python.org
Message-ID:
	<3c6718980802191733n1e3cf250r64e49640730d76bc at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

> From: Wayne Watson <sierra_mtnview at sbcglobal.net>
>
> See Subject. Is it possible?
>

python -m pydoc sys > sys.txt
more < sys.txt


------------------------------

Message: 12
Date: Wed, 20 Feb 2008 02:23:11 -0500
From: "Michael Langford" <mlangford.cs03 at gtalumni.org>
Subject: Re: [Tutor] How to deal with a thread that doesn't terminate
To: cappy2112 at gmail.com
Cc: Tutor Python <tutor at python.org>
Message-ID:
	<82b4f5810802192323t4d53459j80b3343ac0d91102 at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

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 SpawnController(object):
    def __init__(self,cmd):
        self.cmdline = cmd

    def start(self):
        self.process = subprocess.Popen([self.cmdline])

    def stop(self):
        win32api.TerminateProcess(int(self.process._handle), -1

       --michael

On Feb 19, 2008 4:53 PM, Tony Cappellini <cappy2112 at gmail.com> wrote:
> When I executing a program external to the main program in a thread,
> and that thread hangs, can the thread be terminated?
> How does one handle this situation?
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
Michael Langford
Phone: 404-386-0495
Consulting: http://www.RowdyLabs.com


------------------------------

_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor


End of Tutor Digest, Vol 48, Issue 48
*************************************



More information about the Tutor mailing list