[Tutor] 200 dollar questions!

2007-06-29 Thread elis aeris

I am a 4 day python newbie, and already I am writing practical codes.

I want to learn as fast as possible so I am willing to pay for some
tutorials.

Please reply if you are interested, although 200 is not a lot of money.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Mouse clicking

2007-06-30 Thread elis aeris

what module should be imported?

On 6/30/07, Alan Gauld <[EMAIL PROTECTED]> wrote:



"Lisa Barrott" <[EMAIL PROTECTED]> wrote

> I was wondering if there was any way to force a mouse click at a set
> location using python even when the another window is focussed.
> I'm using Windows XP

Yes, you can use the Win32 API.
You need to get the target window handle with

-
HWND FindWindow(
LPCTSTR lpClassName, // pointer to class name
LPCTSTR lpWindowName  // pointer to window name
   );
---

or


BOOL EnumWindows(
WNDENUMPROC lpEnumFunc, // pointer to callback function
LPARAM lParam  // application-defined value
   );
--

Then you can use PostMessage() to generate a mouse event.

BOOL PostMessage(
HWND hWnd, // handle of destination window
UINT Msg, // message to post
WPARAM wParam, // first message parameter
LPARAM lParam  // second message parameter
   );

You can get the full docs on these functions on MSDN and the winall
package should provide access to them, or the ctypes module will
allow direct access for a bit more work.

There might be other more pythonic modules around that do the
heavy lifting for you, but these are not too hard to use.

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Mouse clicking

2007-06-30 Thread elis aeris

win32gui .FindWindow

int = *FindWindow(className, WindowName *)

Retrieves a handle to the top-level window whose class name and window name
match the specified strings.

Parameters

*className* : int/string
*WindowName* : string


HWND FindWindow(
   LPCTSTR lpClassName, // pointer to class name
   LPCTSTR lpWindowName  // pointer to window name
  );





BOOL EnumWindows(
   WNDENUMPROC lpEnumFunc, // pointer to callback function
   LPARAM lParam  // application-defined value
  );

I am not sure what this is for @_@



BOOL PostMessage(
   HWND hWnd, // handle of destination window
   UINT Msg, // message to post
   WPARAM wParam, // first message parameter
   LPARAM lParam  // second message parameter
  );



with pywin32, shouldn't

win32api.keybd_event
win32api.GetFocus
win32api.mouse_event



be used instead?





On 6/30/07, Alan Gauld <[EMAIL PROTECTED]> wrote:



"Lisa Barrott" <[EMAIL PROTECTED]> wrote

> I was wondering if there was any way to force a mouse click at a set
> location using python even when the another window is focussed.
> I'm using Windows XP

Yes, you can use the Win32 API.
You need to get the target window handle with

-
HWND FindWindow(
LPCTSTR lpClassName, // pointer to class name
LPCTSTR lpWindowName  // pointer to window name
   );
---

or


BOOL EnumWindows(
WNDENUMPROC lpEnumFunc, // pointer to callback function
LPARAM lParam  // application-defined value
   );
--

Then you can use PostMessage() to generate a mouse event.

BOOL PostMessage(
HWND hWnd, // handle of destination window
UINT Msg, // message to post
WPARAM wParam, // first message parameter
LPARAM lParam  // second message parameter
   );

You can get the full docs on these functions on MSDN and the winall
package should provide access to them, or the ctypes module will
allow direct access for a bit more work.

There might be other more pythonic modules around that do the
heavy lifting for you, but these are not too hard to use.

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Mouse clicking

2007-06-30 Thread elis aeris

Bit torrent .torrent file aquisition assistance.

Given a webpage of forum threads that links to download links of .torrent
files, the code should
download every .torrent files it can find within 2 levels of connections.




Bit torrent high performance client

Given that popular bit torrent clients cannot handle past 400 simultanuous
torrents activities,
A code can be written to selectively run only active torrents. If and when
an active torrent
download has been deemed less productive, alternatives should be initiated
until the most
productive option has been found.

This process should continue until when at least when the bandwiths
available has been saturated.
In the ideal scenario, both system computational power as well as the
internet connection should
be used to their maximum.





How do I do this?
It shoulbe be easy to run .py of the bit torrent client, I think it's all
about getting data
from the client so the code can have feedback. I am not sure how to do this.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Mouse clicking

2007-06-30 Thread elis aeris

can you take a look of these?


It's very cryptic to me and more or less is not explained in any python
tutorials.



http://search.msdn.microsoft.com/search/results.aspx?view=msdn&qu=mouse_event
http://search.msdn.microsoft.com/search/results.aspx?view=msdn&qu=keybd_event
http://search.msdn.microsoft.com/search/results.aspx?view=msdn&qu=GetFocus
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] 200 dollar questions!

2007-06-30 Thread elis aeris

http://search.msdn.microsoft.com/search/results.aspx?view=msdn&qu=mo
use_event
http://search.msdn.microsoft.com/search/results.aspx?view=msdn&qu=ke
ybd_event
http://search.msdn.microsoft.com/search/results.aspx?view=msdn&qu=Ge
tFocus


I am using pywin32, for python 2.5 on windows xp.


What I want to do is these:


handle = Gethandle ("window_name")

"window_name"   =  "123.txt"  with notepad, for example.

it should return a list if there are more than one with the same name.


and then



GainFocus(handle)

Keyboard_event ( "hello python!")
Mouse_event (x,y, left, 2)

the (x,y) = should be relative to the active window and independent of the
window's position.
2 as in clicking twice.


Last,  maximize, minimize, resize, move, kill,

above(handle)
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] 200 dollar questions!

2007-06-30 Thread elis aeris

import win32api
import win32ui
window = win32ui.FindWindow(None, "123.txt")
yourwindow.ShowWindow()

Traceback (most recent call last):
 File "C:/python codes/gain_focus.py", line 3, in 
   window = win32ui.FindWindow(None, "123.txt")
win32ui: No window can be found.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] 200 dollar questions!

2007-06-30 Thread elis aeris

I ran this:




import time

import ImageGrab  # Part of PIL
from ctypes import *

# Load up the Win32 APIs we need to use.
class RECT(Structure):
 _fields_ = [
   ('left', c_ulong),
   ('top', c_ulong),
   ('right', c_ulong),
   ('bottom', c_ulong)
   ]

time.sleep(2)

GetForegroundWindow = windll.user32.GetForegroundWindow
GetWindowRect = windll.user32.GetWindowRect

# Sleep for 2 seconds - click the window you want to grab.
#time.sleep(2)

# Grab the foreground window's screen rectangle.
rect = RECT()
foreground_window = GetForegroundWindow()
GetWindowRect(foreground_window, byref(rect))
image = ImageGrab.grab((rect.left, rect.top, rect.right, rect.bottom))

# Save the screenshot as a BMP.
#image.save("c:\ee\screenshot.bmp")

# Get the pixel 10 pixels along the top of the foreground window - this
# will be a piece of the window border.

print time.time()

x = 0
y = 0
while x < 400:
 while y < 20:
   rgb = image.getpixel((10, 0))
   y = y + 1
 y = 0
 x = x + 1


print time.time()

# PIL returns colours as RGB values packed into a triple:
print "RGB(%d, %d, %d)" % (rgb[0], rgb[1], rgb[2])  # This prints RGB(0, 74,
216) on my XP machine






















What that does is to take a screen shot and then pixelgetcolor() over 8000
(x,y)  points

for me it clocked at 0.08 seconds and I am trying cut it down to maybe 0.04


any hints on performance increase?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] 200 dollar questions!

2007-06-30 Thread elis aeris

Yes, I am trying to write a OCR algorithm with neural network, but the
theories of NN is of little importance, what I am trying to get ready for
the project is run speed.


the problem comes in a number of ways:


first, as you mentioned,   image.getpixel   is not very fast,  according to
PIL
http://www.pythonware.com/products/pil/

so an alternative should be searched for,


also, I loop (x,y)

x = 0 -1023
y = 0- 768  through

and currently i use this:



x = 0
y = 0
for x in xrange(1, 1024, 1):
   for y in xrange(1, 768, 1):
   rgb = image.getpixel ((10, 12))





according to
http://www.python.org/doc/essays/list2str.html


a while loop is slow than for, and then map is faster.








as for that this:

image.getpixel ((10, 12))


currently i only use the shell window itself, so i can't really loop
1024*768, that's why it's only
10 12,
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] 200 dollar questions!

2007-06-30 Thread elis aeris

which modules and origin is this function?

is it the fastest way to get it?

I am told to optimize getpixel (x, y)  alone, so that's the only thing i am
trying, it's part of a project that will go live in september, so the prof
we are under hasn't one anything but some introductory readings.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] optimization: faster than for

2007-06-30 Thread elis aeris

I found this on the net, and it's a different arrangement to using for

the author claims it will result in faster performance, but i can't find
documents on it, because I can't figure out which parts are parameters and
which parts on special words, for python.
The operations with explicit loop counters have to be translated into Python 
byte code and must be interpreted. Implicit loop counter can be incremented by 
the core code (translated from C sources). Try this:

import timeit

sWhile = """\
x = 0
y = 0
number_scanned = 0
while x < 1024:
while y < 768:
y = y + 1
number_scanned = number_scanned + 1
y = 0
x = x + 1
"""
t = timeit.Timer(stmt=sWhile)
print "%.2f usec/pass" % (100 * t.timeit(number=10)/10)


sFor = """\
number_scanned = 0
for x in xrange(1024):
for y in xrange(768):
number_scanned = number_scanned + 1
"""
t = timeit.Timer(stmt=sFor)
print "%.2f usec/pass" % (100 * t.timeit(number=10)/10)


The sWhile and sFor are the multiline strings containing the equivalent code 
written using while and for loop respectively.___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] optimization: faster than for

2007-06-30 Thread elis aeris

The for version, as claimed by

http://www.python.org/doc/essays/list2str.html
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] optimization: faster than for

2007-06-30 Thread elis aeris

my question, is there any other way to make it run faster,

as described in the webpage, it's possible to use map()  but I don't know
how to do it with this one, 2 dimensional arrays.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] optimization: faster than for

2007-06-30 Thread elis aeris

x = 0
y = 0
for x in xrange(1,1024,1):
   for y in xrange(1,768,1):
   rgb = image.getpixel((10, 12))



Luke said there is a faster way to do  image.getpixel((10, 12))

so i am still waiting on that,

the above has been improved many times and it's a lot faster than while, I
am trying to find out if there are any more new ways.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] optimization: faster than for

2007-06-30 Thread elis aeris

oh yeah,  he said getdata()  but i don't know where it comes from

and
image.getpixel((10, 12))   is from
http://www.pythonware.com/products/pil/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] im.getdata()

2007-07-01 Thread elis aeris

Googling "PIL Handbook" yields this page
http://www.pythonware.com/library/pil/handbook/image.htm
and, as I said,
"""


getdata

*im.getdata()* => sequence

Returns the contents of an image as a sequence object containing pixel
values. The sequence object is flattened, so that values for line one
follow directly after the values of line zero, and so on.

Note that the sequence object returned by this method is an internal PIL
data type, which only supports certain sequence operations, including
iteration and basic sequence access. To convert it to an ordinary
sequence (e.g. for printing), use *list(im.getdata())*.





How do I find out how the list look like?

Is it list[x][y]  ?  or rather, how did you find out how this internal
data type look like?

how do I access it ?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] im.getdata()

2007-07-01 Thread elis aeris

I am capturing a screen shot, but then the image was already


image,   how do I .load it ?

it's not image.load()




import time
import ImageGrab  # Part of PIL
from ctypes import *

class RECT(Structure):
 _fields_ = [
   ('left', c_ulong),
   ('top', c_ulong),
   ('right', c_ulong),
   ('bottom', c_ulong)
   ]


GetForegroundWindow = windll.user32.GetForegroundWindow
GetWindowRect = windll.user32.GetWindowRect


rect = RECT()
foreground_window = GetForegroundWindow()
GetWindowRect(foreground_window, byref(rect))
image = ImageGrab.grab((rect.left, rect.top, rect.right, rect.bottom))



print time.time()

pix = image.load()
print pix[x, y]

x = 0
y = 0
for x in xrange(1,1024,1):
 for y in xrange(1,768,1):
   print pix[10,10]
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] optimization: faster than for

2007-07-01 Thread elis aeris

ugh, can someone who is online at this time give me some pointers on how to
read this?

i don't know how to look it up,

in is listed,
out is not, so i am not sure if this is python at all.

On 7/1/07, Eike Welk <[EMAIL PROTECTED]> wrote:


On Sunday 01 July 2007 06:17, elis aeris wrote:
> The for version, as claimed by
>
> http://www.python.org/doc/essays/list2str.html

The fastest version of the algorithm is this one:

In [4]:import array

In [5]:def f7(list):
   .5.:  return array.array('B', list).tostring()
   .5.:

In [6]:f7([97, 98, 99])
Out[6]:'abc'


The implicit loop is the "tostring" function. It is written in C and
it happens to perform the desired algorithm. So there is nothing
magical about "implicit loops". It just means: Find a library
function that is written in C and that performs your task.

For manipulating images it means: Find some operations in PIL that do
what you want, and don't look at pixel values.

Kind regards,
Eike.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fastest way to iterate through a file

2007-07-01 Thread elis aeris

no, this one:



In [4]:import array

In [5]:def f7(list):
 .5.:  return array.array('B', list).tostring()
 .5.:

In [6]:f7([97, 98, 99])
Out[6]:'abc'
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fastest way to iterate through a file

2007-07-01 Thread elis aeris

The for version, as claimed by

http://www.python.org/doc/essays/list2str.html


The fastest version of the algorithm is this one:



In [4]:import array

In [5]:def f7(list):
  .5.:  return array.array('B', list).tostring()
  .5.:

In [6]:f7([97, 98, 99])
Out[6]:'abc'

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fastest way to iterate through a file

2007-07-01 Thread elis aeris

I found out that by making a copy of it, it can be load()  ed !


it runs 3 times faster now














import time

import ImageGrab
from ctypes import *


class RECT(Structure):
 _fields_ = [
   ('left', c_ulong),
   ('top', c_ulong),
   ('right', c_ulong),
   ('bottom', c_ulong)
   ]

GetForegroundWindow = windll.user32.GetForegroundWindow
GetWindowRect = windll.user32.GetWindowRect


rect = RECT()
foreground_window = GetForegroundWindow()
GetWindowRect(foreground_window, byref(rect))
image = ImageGrab.grab((rect.left, rect.top, rect.right, rect.bottom))

start_time = time.time()
num_pixels = 0
num_black = 0

pix = image.copy().load()


print time.time()

for x in xrange(200):
 for y in xrange(200):
   num_pixels += 1
   if pix[x, y] == (0, 0, 0):
   num_black += 1
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] optimization: faster than for

2007-07-01 Thread elis aeris

so this is the actual code?



[4]:import array
[5]:def f7(list):
.5.:  return array.array('B', list).tostring()
.5.:
[6]:f7([97, 98, 99])




Output on the screen:


[6]:'abc'- Hide quoted text -
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] optimization: faster than for

2007-07-01 Thread elis aeris

oh i get it, it's line number.



import array
def f7(list):
   return array.array('B', list).tostring()

f7([97, 98, 99])



##

NOW, this looks python !
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] optimization: faster than for

2007-07-01 Thread elis aeris

oh crancky!   C#  !


i better try to find the best way to do it with the official python genre
before venturing into that world of pain without PIL !
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] optimization: faster than for

2007-07-01 Thread elis aeris

my reply
oh crancky!   C#  !

http://en.wikipedia.org/wiki/Iron_Python

i better try to find the best way to do it with the official python genre
before venturing into that world of pain without PIL !


Quote:- Hide quoted text -







In [4]:import array
In [5]:def f7(list):
   .5.:  return array.array('B', list).tostring()
   .5.:

In [6]:f7([97, 98, 99])
Out[6]:'abc'



I can't remember which tool does this - IronPython maybe?

but the Ins are Inputs, the numbers arethe current command
(hence the continuation lines all have 5) and the OUT is the output.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] optimization: faster than for

2007-07-01 Thread elis aeris

of course. but i tried only the code, not rewriting the pixelget part into
that, because I have to understand it first.


so, i should look into ipython's doc for this code?


ok,

import array
def f7(list):
   return array.array('B', list).tostring()
f7([97, 98, 99])
Out[6]:'abc'


searching with ipython search engine returns returns  "parrel computing"

ack,

so i call the array.array function, and tostring()   function,

I have no idea how to read that. @_@
what a great one liner!





On 7/1/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:


elis aeris wrote:
> my reply
> oh crancky!   C#  !
>
> http://en.wikipedia.org/wiki/Iron_Python
>
> i better try to find the best way to do it with the official python
> genre before venturing into that world of pain without PIL !
Please don't reply directly to me.

Iron Python is an implementation of Python in .NET
similarly Jython is an implementation of Python in Java.
This doesn't have anythign to do with their libraries.
The example code
> >> In [4]:import array
> >> In [5]:def f7(list):
> >>.5.:  return array.array('B', list).tostring()
> >>.5.:
> >>
> >> In [6]:f7([97, 98, 99])
> >> Out[6]:'abc'
Would run in IronPython, Jython or cPython.
The way that the code is marked up (adding In or >>> before each line)
is a feature of the IDE that one uses.
Did you even try the code?
-Luke

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Power Shells [WAS:] optimization: faster than for

2007-07-01 Thread elis aeris

Oie, as if the battle for the best text editor is not enough ...



Well, can you run a test for me?

Use the best for-equivalent and run the code below,


instead of 1024*768,  scale to 800*600 , just so the window you are screen
shotting from is small enough.







import time

import ImageGrab  # Part of PIL
from ctypes import *

# Load up the Win32 APIs we need to use.
class RECT(Structure):
 _fields_ = [
   ('left', c_ulong),
   ('top', c_ulong),
   ('right', c_ulong),
   ('bottom', c_ulong)
   ]

time.sleep(2)

GetForegroundWindow = windll.user32.GetForegroundWindow
GetWindowRect = windll.user32.GetWindowRect

# Sleep for 2 seconds - click the window you want to grab.
#time.sleep(2)

# Grab the foreground window's screen rectangle.
rect = RECT()
foreground_window = GetForegroundWindow()
GetWindowRect(foreground_window, byref(rect))
image = ImageGrab.grab((rect.left, rect.top, rect.right, rect.bottom))

# Save the screenshot as a BMP.
#image.save("c:\ee\screenshot.bmp")

# Get the pixel 10 pixels along the top of the foreground window - this
# will be a piece of the window border.

print time.time()

pix = image.load()
print pix[x, y]



x = 0
y = 0
for x in xrange(1,1024,1):
 for y in xrange(1,768,1):
   rgb = pix[x,y]



print time.time()

# PIL returns colours as RGB values packed into a triple:
#print "RGB(%d, %d, %d)" % (rgb[0], rgb[1], rgb[2])  # This prints RGB(0,
74, 216) on my XP machine
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fastest way to iterate through a file

2007-07-01 Thread elis aeris

in that case, can we talk about what this is?


import array

def f7(list):
   return array.array('B', list).tostring()

f7([97, 98, 99])

Out[6]:'abc'


It's only one line, and it's faster than for(), getting through this one
might just end my quest for
optimized python source code. (then i ll begin the hacking on the psycho and
things ...)

so,   array is a module,  and then from that, a function called array is
called, and then
tostring,


ugh,

what does it mean ?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fastest way to iterate through a file

2007-07-01 Thread elis aeris

oh i want to bring something up,  there is this one line which i think is
suggesting that there is a way to use this object that the document says
it's a lot faster than getdata and getpixel.


*im.load()*

Allocates storage for the image and loads it from the file (or from the
source, for lazy operations). In normal cases, you don't need to call this
method, since the Image class automatically loads an opened image when it is
accessed for the first time.

(New in 1.1.6) In 1.1.6 and later, *load* returns a pixel access object that
can be used to read and modify pixels. The access object behaves like a
2-dimensional array, so you can do:

pix = im.load()
print pix[x, y]
pix[x, y] = value

Access via this object is a lot faster than *getpixel* and *putpixel*.




according to it, this load function is a new addition to 1.1.6, and this
object is different from the rest.





On 7/1/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:


elis aeris wrote:
> I found out that by making a copy of it, it can be load()  ed !
ImageGrab returns an image instance.
You can get the pixel data directly using getdata().
There's no reason to do what you're doing.
-Luke

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Power Shells [WAS:] optimization: faster than for

2007-07-01 Thread elis aeris

http://memoryhacking.com/forums/viewtopic.php?p=1195#1195




On 7/1/07, Alan Gauld <[EMAIL PROTECTED]> wrote:



"elis aeris" <[EMAIL PROTECTED]> wrote

> Use the best for-equivalent and run the code below,

Elis,

Can you tell us what exactly you are trying to do?

I'm not sure whether its just running tests on loop contructs
or trying to get a list of pixels from an image (and if so to do
what with them?)

Until we know what your underlying project is trying to achieve
its impossible to give sensible help in making things run faster.
As Kent mentioned the things you do with the pixels are likely
to make as much difference to total performance as the loops
you use. Python is not C and the fastest solution in one scenario
might not be fastest in another. It's better to get the best solution
that works then tune it for speed where its actually necessary.

What performance do you actually need?
What is too slow at the moment?

Are you in danger of succumbing to the danger of premature
optimisation? It looks a lot like it from your posts.

Alan G.


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Power Shells [WAS:] optimization: faster than for

2007-07-01 Thread elis aeris

uh, can i ask about something very quickly?



how do i write a function to do


a pop up window with designated window name, type (ok, cancel, those) and
message?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] optimization: faster than for

2007-07-01 Thread elis aeris

>> In [4]:import array
>> In [5]:def f7(list):
>>.5.:  return array.array('B', list).tostring()
>>.5.:
>>
>> In [6]:f7([97, 98, 99])
>> Out[6]:'abc'





ugh the code it self is not generic python,  that was an example of how to
do this


my project is OCR
http://www.eternite.co.uk/gundam_clips/ocr.PNG

The letter I equals to "282" because it has 2 points on the y axis of the
first point, and 8 points on the y axis on the second, and then 2 on the
last one.


So the string would be translated into:

282017220300004222400722240172206 and so on.

#


so what I am going to have is a string like above and what I 'll have is

a list of tuples, for instance   [a, 222] , [b,333]  and so forth

how do I write the fastest code to do this



optimization is immediately needed because the job is done as soon this
translation is complete.


so two bottle neck

image.getdata()  is a good solution, i haven't found a better one,

and the other bottle neck is this translation process.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] pop up window

2007-07-02 Thread elis aeris

i won't do that again, i am a 2 day newbie (hello)

uh,

how about a less quick one that's built-in in python ?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tutor Digest, Vol 41, Issue 7

2007-07-02 Thread elis aeris

they cancelled this class
http://reg.cstudies.ubc.ca/course_info.cfm?courseid=IP468


due to low enrollment.

I'd love to be in a class.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fastest way to iterate through a file

2007-07-05 Thread elis aeris

I need some of a something to be imported into python


these are the functions I need, anyway know anything that might do any of
the following?

Eg:

suppose the class' name is autowindow:


autowindow.gainfocus(handle)
put the window of that handle into focus.


import autowindow


autowindow.imagechecksum()

autowindow.imagechecksum("c:\image\image.bmp")


autowindow.areachecksum()

sum = autowindow.areachecksum(x1,y1,x2,y2) absolute screen coordinate

autowindow.getmousepos()

pos = autowindow.getmousepos()
pos = {x, y}


autowindow.restart()

reboot computer

autowindow.shutdown()

shutdown computer

autowindow.winexist()

true/false = autowindow.winexist()
handle or window name. (no class wanted!)


autowindow.listwindows()

autowindow.listwindows("window name")
returns a list of handles if multiple window of the same name.

autowindow.GainFocus()

autowindow.GainFocus()
window name or handle

autowindow.KeyboardEvent(text)

autowindow.KeyboardEvent("Python rocks!", keyholddelay )
keyholddelay = miliseconds.

autowindow.mouseclick(button, clicks)

autowindow.MouseEvent(x, y, button, clicks)

autowindow.mousemove()

autowindow.mousemove(x,y, speed)

autowindow.winMove(x, y)
autowindow.winResize(x, y)
autowindow.winMinimize()
autowindow.winMaximize()
autowindow.winClose()

they all take handle

autowindow.listwindows()

autowindow.listwindows("window name")
returns a list of handles if multiple

autowindow.hotkey()

autowindow.hotkey(keyboard key, function)
keyboard key = any key on keyboard
function = function to start


auntwindow.run ( /source/exe.exe, "image.bmp" )

autowindow.msgbox("window name", "window message", box_number )

box_number = 1, 2, 3


OK = 1
OK + Cancel = 2
Yes + No = 3

return = autowindow.msgbox("window name", "window message", box_number )

return ok = 1
cancel = 2
yes = 3
no = 4
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] object names

2007-07-08 Thread elis aeris

I need to create object with numbers,

for instance, i need to create 5 object of names like these

object_1
object_2
and so on,

how do I write a script that would do it when I specify that I need # number
of it?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] object names

2007-07-08 Thread elis aeris

or it's not an object but common variables.


var_1
var_2
and so on
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] object names

2007-07-08 Thread elis aeris

ugh,  i guess what I need is just to name variables, not objects.


var_1
var_2

and so on.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] file methods

2007-07-09 Thread elis aeris

python 3.9 File Objects  of Python Library Reference



from the document i know that if I want to open a text file I do:

f = open("text.txt", "r+")

and thus create f as an file object i can then use.

however, i don't understand these functions

.readline
.readlines
.read
.xlinesread

I have a file like this one:

command = func_babara
parameter_1 = 300
parameter_2 = 300
parameter_3 = 50
parameter_4 = 0
parameter_5 = 0
parameter_6 = 0


,as you see, i need to process it one line at a time and use this .ini file
as a configuration file.

how do I use those functions, I don't understand the libarry reference.

also, I need to output lines like above to text.txt,  how do I do it?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] I/O error (?)

2007-07-11 Thread elis aeris

number_1 = 1
number_2 = 2
number_3 = 3
number_4 = 4
number_5 = 5
number_6 = 6

f = open("data.ini", "w")
f.write("[1]")
f.write("\n")
f.write("command" + "=" + "mousemove\n")
f.write("parameter_" + str(number_1) + "=" + " 500\n")
f.write("parameter_" + str(number_2) + "=" + " 500\n")
f.write("parameter_" + str(number_3) + "=" + " 500\n")
f.write("parameter_" + str(number_4) + "=" + " 500\n")
f.write("parameter_" + str(number_5) + "=" + " 500\n")
f.write("parameter_" + str(number_6) + "=" + " 500\n")





I am not sure why this wouldn't work,  but this actually doesn't output at
all.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] I/O error (?)

2007-07-11 Thread elis aeris

oh in this case they actually aren't possible to be listized, because they
are just place holders for quite a number of other names of variables and
stuff :)
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] strange output

2007-07-11 Thread elis aeris

def mousemove():
   f.write("command" + " =" + " mousemove\n")
   f.write("parameter_" + str(number_1) + "=" + " 500\n")
   f.write("parameter_" + str(number_2) + "=" + " 500\n")
   f.write("parameter_" + str(number_3) + "=" + " 500\n")
   f.write("parameter_" + str(number_4) + "=" + " 500\n")
   f.write("parameter_" + str(number_5) + "=" + " 500\n")
   f.write("parameter_" + str(number_6) + "=" + " 500\n")


f = open("data.ini", "w")
mousemove()
f.close()




even though this part is skippe

number_1 = 100
number_2 = 200
number_3 = 300
number_4 = 400
number_5 = 500
number_6 = 600






it doesn't say something like undefined functions and instead it would print
the numbers fine.


strange eh?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] I/O error (?)

2007-07-11 Thread elis aeris

no, no, the values are coming from all over the place, so having to remember
which member of the list that function is tied to may be more of a headache

I get the technique though








On 7/12/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:


elis aeris wrote:
> oh in this case they actually aren't possible to be listized, because
> they are just place holders for quite a number of other names of
> variables and stuff :)
That is untrue.
You can put any variables into a list that you want.
For example:
x = 'hello'
b = 42
abba = 0xABBA

Then you can do this:
mylist = [x,b,abba]
and print from the list.

-Luke

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] green brackets?

2007-07-11 Thread elis aeris

def mousemove(x,y):
   f.write("n\")
   f.write("command" + " =" + " mousemove\n")
   f.write("parameter_1 = " + str(x) + "\n")
   f.write("parameter_2 = " + str(y) + "\n")
   f.write("n\")





for some reason that last bracket of the 2nd and last line line in IDLE  are
green.\
why is that?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] green brackets?

2007-07-11 Thread elis aeris

@_@ i see

On 7/12/07, Paulo Nuin <[EMAIL PROTECTED]> wrote:


Hi

f.write("n\") should be

f.write("\n")

Paulo

elis aeris wrote:
> def mousemove(x,y):
> f.write("n\")
> f.write("command" + " =" + " mousemove\n")
> f.write("parameter_1 = " + str(x) + "\n")
> f.write("parameter_2 = " + str(y) + "\n")
> f.write("n\")
>
>
>
>
>
> for some reason that last bracket of the 2nd and last line line in
> IDLE  are green.\
> why is that?
> 
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] making aaa.txt in notepad focused.

2007-07-11 Thread elis aeris

import time
from ctypes import *

# Load up the Win32 APIs we need to use.
GetForegroundWindow = windll.user32.GetForegroundWindow


foreground_window = GetForegroundWindow()





this is a part of a code I from a separate project.


I am trying to find out it's possible to do this:

handle = gesomethingfromthefocusedwindow()

later when I want to do this:

handle.gainfocus()


and zap that window to the front!
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] making aaa.txt in notepad focused.

2007-07-11 Thread elis aeris

is it possible to do patial window title?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] how do I input " as part of a string?

2007-07-13 Thread elis aeris

how do I input " as part of a string?

f.write("my "car" has been a great one for me")

I am trying to write the above lines into a file, including the " as part of
a the single string

how do I do that?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how do I input " as part of a string?

2007-07-13 Thread elis aeris

also, why does the interpreter restart when I run this?



f = open("data.ini","w")

f.write("yeahppe")

f.close()
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how do I input " as part of a string?

2007-07-13 Thread elis aeris

def winlist(title):
   f.write("winlist(\"title\")")



how about if "title" is a variable?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] interpreter restarts

2007-07-13 Thread elis aeris

why deos the interpreter restarts with this?

f = open("data.ini","w")

f.write("yeahppe")

f.close()
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how do I input " as part of a string?

2007-07-13 Thread elis aeris

this one doesn't work; did I misread your string?

f = open("data.ini","w")

title = "taitle"

f.write('title is \"%title\"\n ')


f.close()
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how do I input " as part of a string?

2007-07-13 Thread elis aeris

def send(string):
   f.write("send( \"%s\"\n' % string )" )




f = open ("data.ini")

send("string is very nice and all those things are pretty cool")





this one is wrong, i guess i didn't ask you how to add things after this


\"%s\"\n' % title)
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] interpreter restarts

2007-07-13 Thread elis aeris

IDLE

On 7/14/07, Alan Gauld <[EMAIL PROTECTED]> wrote:



"elis aeris" <[EMAIL PROTECTED]> wrote

> why deos the interpreter restarts with this?

Which interpreter?
Command prompt python? IDLE? PythonWin?
PyCrust?

And are you running them line by line manually
or is the code in a file?

> f = open("data.ini","w")
>
> f.write("yeahppe")
>
> f.close()

Works OK for me in PyCrust and the vanilla interpreter.

Alan G.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] interpreter restarts

2007-07-13 Thread elis aeris

from a file, i click run from the IDLE interpreter

On 7/14/07, elis aeris <[EMAIL PROTECTED]> wrote:


IDLE

On 7/14/07, Alan Gauld <[EMAIL PROTECTED]> wrote:
>
>
> "elis aeris" <[EMAIL PROTECTED]> wrote
>
> > why deos the interpreter restarts with this?
>
> Which interpreter?
> Command prompt python? IDLE? PythonWin?
> PyCrust?
>
> And are you running them line by line manually
> or is the code in a file?
>
> > f = open("data.ini","w")
> >
> > f.write("yeahppe")
> >
> > f.close ()
>
> Works OK for me in PyCrust and the vanilla interpreter.
>
> Alan G.
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how do I input " as part of a string?

2007-07-13 Thread elis aeris

I actually meant to type send, because the text file is then going to read
by auto it 3, which
has the function
send
I use that functions this way because I have
this
for sale , for that, unless someone wants to make 100USd, I have to write a
application interface between the two, which is what I am doing.


# opens autoit3source.au3 to write

f = open ("sc.au3", "w")

#  au3  send("text")

def send(string):
f.write('\"%s\"\n' % string)



to restate my question, this is what I need:



how do I do this?


variable = taitle
   f.write(texttexttexttext'\"%s\"\n' % variable   textextexte  )

?


as in, I not only need to

include " in between,  I also need to input text string before and after the
variable.

an example

http://www.autoitscript.com/autoit3/docs/functions/MsgBox.htm

MsgBox ( 0, "title", "text" )

0 means it's a vanilla popbox with "ok"  other numbers could mean , ignore,
cancel and so forth.



how I want to use it

organge = 5

f.write( "there are orange "florida" oranges on the counter")


:)
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] interpreter restarts

2007-07-13 Thread elis aeris

ohhh, you are the greatest :))
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how do I input " as part of a string?

2007-07-13 Thread elis aeris

understood.

On 7/14/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:


elis aeris wrote:
> I actually meant to type send, because the text file is then going to
> read by auto it 3, which
> has the function send
> <http://www.autoitscript.com/autoit3/docs/functions/Send.htm>
> I use that functions this way because I have this
> <
http://rentacoder.com/RentACoder/misc/BidRequests/ShowBidRequest.asp?lngBidRequestId=719268
>
> for sale , for that, unless someone wants to make 100USd, I have to
> write a application interface between the two, which is what I am doing.
So instead of taking the time to learn Python, which would've made this
an easy project, you are just going to keep trying stuff until something
works?
And you're getting us to help you to brute-force this problem, when the
actual purpose of this list is to help people learn python?
I don't see any reason why I should continue to reply to you, or why
anyone else should, for that matter.
It's frustrating that this deluge of messages from you, that you could
honestly solve yourself in a few minutes if you had any desire
whatsoever to learn, is getting in the way of people who are actually
trying to learn.  Not only by way of taking up the exceptional tutors'
(Alan, Kent, etc) time reading and rereading the same problem you have
over and over, that is slightly different, but also that I (and likely
others) get pretty peeved when you aren't picking up on the obvious
hints that everyone's dropping that you should stop working on this
project until you learn the fundamentals of programming in Python.

I feel my time has been wasted, because every e-mail I send to you that
has constructive advice, you just ignore.
Answers, answers, solutions, solutions!
That's not what we do here!
We give you hints and guidance so you can solve the problems yourself,
so that you can _understand_ them, and so that you will know how to
solve the next problem that arises that is similar.  Yet all I've seen
from you is slightly different problems cropping up over and over, and
obvious fundamental lack of understanding not only of the method in
which to implement a solution to a problem, but also in formulating a
solution in the first place.

The previous e-mail of this nature I wrote was significantly less
coarse, but more detailed in the manner in which you could proceed, so
that you would learn properly, and it went ignored.  Do I have your
attention?

(Apologies to Alan et. al. for my tactlessness.)
-Luke

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] tutor

2007-07-14 Thread elis aeris

please think about your first programming class, and then think about how
long it took the prof to teach the concept of array.

yes, it's about a week, if he is really good.



python is a very young language, prefered by professionals of its
simplicity, as such, the number of character of the document divided by the
actual code has a very high ratio,

because its well written document of people who know multiple languages, I
have to as what appears to be the same question over and over because
Ican't  read
the documents.

it's too cryptic. and as I go, i just come across dumb problem like:


how I want to use it



organge = 5

f.write( "there are orange "florida" oranges on the counter")



yes i know that i have asked about how to include a qutation mark and I have
asked about how to include a variable, but separately.

i know  it 's less than 3  "  , but i don't know where

entertain my frustration.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Python Image library

2007-07-18 Thread elis aeris

import time

import ImageGrab  # Part of PIL
from ctypes import *

# Load up the Win32 APIs we need to use.
class RECT(Structure):
 _fields_ = [
   ('left', c_ulong),
   ('top', c_ulong),
   ('right', c_ulong),
   ('bottom', c_ulong)
   ]

# time.sleep(2)

GetForegroundWindow = windll.user32.GetForegroundWindow
GetWindowRect = windll.user32.GetWindowRect

# Sleep for 2 seconds - click the window you want to grab.
#time.sleep(2)



# Grab the foreground window's screen rectangle.
rect = RECT()
foreground_window = GetForegroundWindow()
GetWindowRect(foreground_window, byref(rect))
image = ImageGrab.grab((rect.left, rect.top, rect.right, rect.bottom))

# Save the screenshot as a BMP.
time.sleep(2)


image.save("c:\python_codes\screenshot.bmp")

# Get the pixel 10 pixels along the top of the foreground window - this
# will be a piece of the window border.

# print time.time()

start = time.time()

pixels = image.getdata()
for x in xrange(0, 500):
 for y in xrange(0, 500):
   rgb = pixels[500 * x + y]

# print pixels[500 * 2 + 400]

print ( time.time() - start )

# PIL returns colours as RGB values packed into a triple:
#print "RGB(%d, %d, %d)" % (rgb[0], rgb[1], rgb[2])  # This prints RGB(0,
74, 216) on my XP machine













getdata() returns a flattened list, [n]


but i am not sure how to access it.

when I want to get rgb from a window of 100,200,

get data starts from 0(0~99, 0~199)

the point of  x,y = 2, 1

do I put in

pixel[100]   ?


it's actually not the case  @_@

what should I put in ?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python Image library

2007-07-18 Thread elis aeris

ahh~

it goes horizontally first

why didn't I think of that?

thank you ~

On 7/19/07, Tiger12506 <[EMAIL PROTECTED]> wrote:


You know the height and the width of the image, no?

So you know that every 'width' number of pixels will start a new row.
So if you wanted say the fifth row down, second pixel, how would you find
it?

The 1st line:  'width' number of pixels
The 2nd line: 'width' number of pixels
The 3rd line: 'width number of pixels
The 4th line: 'width' number of pixels
The 5th line: 2 pixels in from the left

Add those up ~  width+width+width+width+2
Or  4*width+2

That number is the index to use to get the pixel at coords (2,5)
so

pixel = getdata()
pixel[4*width+2]

For this example.
Work out a more general solution for yourself please.

JS

> getdata() returns a flattened list, [n]
>
>
> but i am not sure how to access it.
>
> when I want to get rgb from a window of 100,200,
>
> get data starts from 0(0~99, 0~199)
>
> the point of  x,y = 2, 1
>
> do I put in
>
> pixel[100]   ?
>
>
> it's actually not the case  @_@
>
> what should I put in ?

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python Image library

2007-07-18 Thread elis aeris

that's illustrative.

On 7/19/07, Luke Paireepinart <[EMAIL PROTECTED]> wrote:


Tiger12506 wrote:
> You know the height and the width of the image, no?
>
> So you know that every 'width' number of pixels will start a new row.
> So if you wanted say the fifth row down, second pixel, how would you
find
> it?
>
> The 1st line:  'width' number of pixels
> The 2nd line: 'width' number of pixels
> The 3rd line: 'width number of pixels
> The 4th line: 'width' number of pixels
> The 5th line: 2 pixels in from the left
>
> Add those up ~  width+width+width+width+2
> Or  4*width+2
>
if you start counting at the 0th row and 0th column, this will give you
the 4th row and 2nd column.
if you're counting from the 1st row and 1st column, this will give you
the 5th row and 3rd column.
> That number is the index to use to get the pixel at coords (2,5)
>
So this is actually (3,5) or, to count from 0, (2,4).
But yeah, the general idea is there.
If my math is wrong I'm sure you won't hesitate to correct me ;)
-Luke

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] odd

2007-07-18 Thread elis aeris

I ran this


for x in range(5,10):
   print x




and OP was

5
6
7
8
9



why is that? shouldn't it print


t
6
7
8
9
10?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] if and things

2007-07-18 Thread elis aeris

full code below.



#  pixel[]  is a list of tuples:   (r,g,b)
#  pixel[1030*(y-a) + x][0] = r
#  pixel[1030*(y-a) + x][1] = g
#  pixel[1030*(y-a) + x][2] = b

for a in range(0, 10):
   ifpixel[1030*(y-a) + x][1] > pixel[1030*(y-a) + x][0] and
pixel[1030*(y-a) + x][1] > pixel[1030*(y-a) + x][2]:
   box = box + 1

print box


i have never used double conditions before, is this correct?

I want box++ when  the g is both bigger than r and b.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] if and things

2007-07-18 Thread elis aeris

man that looks totally pythonic.

On 7/19/07, Ian Witham <[EMAIL PROTECTED]> wrote:


try this:

for a in range(10):
r, g, b = pixel[1030*(y-a) + x]
if g > r and g > b:
box += 1

This is an example of "unpacking" a tuple into separate variables, r, g
and b.

On 7/19/07, elis aeris <[EMAIL PROTECTED]> wrote:
>
> #  pixel[]  is a list of tuples:   (r,g,b)
> #  pixel[1030*(y-a) + x][0] = r
> #  pixel[1030*(y-a) + x][1] = g
> #  pixel[1030*(y-a) + x][2] = b
>
> for a in range(0, 10):
> ifpixel[1030*(y-a) + x][1] > pixel[1030*(y-a) + x][0] and
> pixel[1030*(y-a) + x][1] > pixel[1030*(y-a) + x][2]:
> box = box + 1
>
> print box
>
>
> i have never used double conditions before, is this correct?
>
> I want box++ when  the g is both bigger than r and b.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> import time
>
> import ImageGrab  # Part of PIL
> from ctypes import *
>
> # Load up the Win32 APIs we need to use.
> class RECT(Structure):
>   _fields_ = [
> ('left', c_ulong),
> ('top', c_ulong),
> ('right', c_ulong),
> ('bottom', c_ulong)
> ]
>
> # time.sleep(2)
>
> GetForegroundWindow = windll.user32.GetForegroundWindow
> GetWindowRect = windll.user32.GetWindowRect
>
> # Sleep for 2 seconds - click the window you want to grab.
> #time.sleep(2)
>
>
>
> # Grab the foreground window's screen rectangle.
> rect = RECT()
> foreground_window = GetForegroundWindow()
> GetWindowRect(foreground_window, byref(rect))
> image = ImageGrab.grab((rect.left, rect.top, rect.right, rect.bottom))
>
> # Save the screenshot as a BMP.
> time.sleep(2)
>
>
> image.save("c:\python_codes\screenshot.bmp")
>
> # Get the pixel 10 pixels along the top of the foreground window - this
> # will be a piece of the window border.
>
> # print time.time()
>
> start = time.time()
>
> pixels = image.getdata()
> for x in xrange(0, 500):
>   for y in xrange(0, 500):
> rgb = pixels[500 * x + y]
>
> print pixels[1][0]
>
> print ( time.time() - start )
>
> # PIL returns colours as RGB values packed into a triple:
> #print "RGB(%d, %d, %d)" % (rgb[0], rgb[1], rgb[2])  # This prints
> RGB(0, 74, 216) on my XP machine
>
>

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] if and things

2007-07-18 Thread elis aeris

given up? man i have a project to go live :)
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] if and things

2007-07-18 Thread elis aeris

#  pixel[]  is a list of tuples:   (r,g,b)
#  pixel[1030*(y-a) + x][0] = r
#  pixel[1030*(y-a) + x][1] = g
#  pixel[1030*(y-a) + x][2] = b

for a in range(0, 10):
   ifpixel[1030*(y-a) + x][1] > pixel[1030*(y-a) + x][0] and
pixel[1030*(y-a) + x][1] > pixel[1030*(y-a) + x][2]:
   box = box + 1

print box


i have never used double conditions before, is this correct?

I want box++ when  the g is both bigger than r and b.

















import time

import ImageGrab  # Part of PIL
from ctypes import *

# Load up the Win32 APIs we need to use.
class RECT(Structure):
 _fields_ = [
   ('left', c_ulong),
   ('top', c_ulong),
   ('right', c_ulong),
   ('bottom', c_ulong)
   ]

# time.sleep(2)

GetForegroundWindow = windll.user32.GetForegroundWindow
GetWindowRect = windll.user32.GetWindowRect

# Sleep for 2 seconds - click the window you want to grab.
#time.sleep(2)



# Grab the foreground window's screen rectangle.
rect = RECT()
foreground_window = GetForegroundWindow()
GetWindowRect(foreground_window, byref(rect))
image = ImageGrab.grab((rect.left, rect.top, rect.right, rect.bottom))

# Save the screenshot as a BMP.
time.sleep(2)


image.save("c:\python_codes\screenshot.bmp")

# Get the pixel 10 pixels along the top of the foreground window - this
# will be a piece of the window border.

# print time.time()

start = time.time()

pixels = image.getdata()
for x in xrange(0, 500):
 for y in xrange(0, 500):
   rgb = pixels[500 * x + y]

print pixels[1][0]

print ( time.time() - start )

# PIL returns colours as RGB values packed into a triple:
#print "RGB(%d, %d, %d)" % (rgb[0], rgb[1], rgb[2])  # This prints RGB(0,
74, 216) on my XP machine
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] python: how do I create a list of definitions?

2007-07-19 Thread elis aeris

like, I am doing string substitution:


if  x = 2243:
   string = string + "e"
if  x = 2234:
  string = string + "p"

and so forth.


how do I create this:


list = [
   (2342,p)
   (4234,e)
 and so forth,


  ]



so I can use it like this:

for a in range(10):
   If x = list[a][0]:
   string = string + list[a][1]


?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python: how do I create a list of definitions?

2007-07-19 Thread elis aeris

I don't understand dict

On 7/20/07, Eric Brunson <[EMAIL PROTECTED]> wrote:


elis aeris wrote:
> like, I am doing string substitution:
>
>
> if  x = 2243:
> string = string + "e"
> if  x = 2234:
>string = string + "p"

If I'm following correctly...

How about using a dict:

list = { 1: 'a', 2: 'b', 3: 'c', 2342: 'p', 4234: 'e' }

if x in list:
string += list[x]

But I'm not sure what that outer loop is good for in your final example,
so I may not understand what you're asking.

>
> and so forth.
>
>
> how do I create this:
>
>
> list = [
> (2342,p)
> (4234,e)
>   and so forth,
>
>
>]
>
>
>
> so I can use it like this:
>
> for a in range(10):
> If x = list[a][0]:
> string = string + list[a][1]
>
>
> ?
> 
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] python: how do I create a list of definitions?

2007-07-19 Thread elis aeris

oh, just to have

some numerals translated into the later.

array[n][0] = "this"
array[n][1] = "= to this"



On 7/20/07, Eric Brunson <[EMAIL PROTECTED]> wrote:


elis aeris wrote:
> like, I am doing string substitution:
>
>
> if  x = 2243:
> string = string + "e"
> if  x = 2234:
>string = string + "p"

If I'm following correctly...

How about using a dict:

list = { 1: 'a', 2: 'b', 3: 'c', 2342: 'p', 4234: 'e' }

if x in list:
string += list[x]

But I'm not sure what that outer loop is good for in your final example,
so I may not understand what you're asking.

>
> and so forth.
>
>
> how do I create this:
>
>
> list = [
> (2342,p)
> (4234,e)
>   and so forth,
>
>
>]
>
>
>
> so I can use it like this:
>
> for a in range(10):
> If x = list[a][0]:
> string = string + list[a][1]
>
>
> ?
> 
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] odd bug

2007-07-19 Thread elis aeris

I ran the code attached at the end of the email, it' supposed to out put a
string of characters,

yet I got only this

###
2.4.3.3.8.5.
definition check:
3


###


now, it's proper output, however, this part got run only once, when it's
supposed to run multiple times to produce more portions like the one above,
i don't know why this part got run only once:





when that happens
  if box_v == 0:
  zero_count = zero_count + 1
  if zero_count == 2:
  zero_count = 0
  if one_char_box in
loc_window_loc_definition:
  print one_char_box
  box_string = box_string +
str(loc_window_loc_definition [one_char_box])
  print "definition check:"
  print box_string







##

for b in range(1,50,1):

  ## Next point to check
  x = radar_loc_window_xx + b
  y = radar_loc_window_yy

  ## omit 0 when there are 2 zeros, and check def
when that happens
  if box_v == 0:
  zero_count = zero_count + 1
  if zero_count == 2:
  zero_count = 0
  if one_char_box in
loc_window_loc_definition:
  print one_char_box
  box_string = box_string +
str(loc_window_loc_definition[one_char_box])
  print "definition check:"
  print box_string

  else:
  one_char_box = one_char_box + str(box_v) + "."
  box_v = 0
  for a in range(0,10,1):
  r, g, b = pixels[1030*(y-a) + x]
  if g > r and g > b:
  box_v = box_v + 1
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] scite with python 2.51

2007-09-22 Thread elis aeris
how do I set up scite editor with python so that I can click check
syntax and compile from the editor?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] python image libray

2007-10-29 Thread elis aeris
http://www.pythonware.com/products/pil/#pil116


how do I distribute standalone python executable with some contents of this
library?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] python image libray - source to Mac OS X

2007-10-29 Thread elis aeris
http://www.pythonware.com/products/pil/#pil116


has anyone been able to compile this on Mac os x?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] network - send one line of text

2007-11-23 Thread elis aeris
is it possible to do this with python?


a server script to listen for

a client script, it sends a line of text to server when a given criteria is
met.


i just need to send text alone, and then code it best kept simple,

is this possible to do with python?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] use my own code

2007-11-25 Thread elis aeris
I have some .py files that have things I need to use,  sometimes it's the
functions and sometimes it's the whole .py (they have no functions)


how do I use them in my other .py codes?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] use my own code

2007-11-25 Thread elis aeris
ok, i can import them.


how do I use them though?





On Nov 26, 2007 1:42 AM, Evert Rol <[EMAIL PROTECTED]> wrote:

> > I have some .py files that have things I need to use,  sometimes
> > it's the functions and sometimes it's the whole .py (they have no
> > functions)
> >
> > how do I use them in my other .py codes?
>
> Import them at the top of your other .py file(s):
>
> import 
>
> (without the .py extension).
> If they're in the current directory, you're fine. Otherwise you may
> need to set the PYTHONPATH variable.
> See chapter 6 in the Python tutorial, especially section 6.1.1:
> http://docs.python.org/tut/node8.html#SECTION00811
>
>  Evert
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] pipeline - what is it and how do I use it?

2007-11-25 Thread elis aeris
I need to keep a bit of python code ready to run at anytime, in the ram, but
this is what I need to do

I am using two languages at the same time, because python doesn't really
have any effective way of simulating keyboard and mouse events,

so I need to run auto it 3, and then call my python code to perform a little
bit of work, it only takes 0.1 seconds to run, but it takes almost a second
to start the code,
if i I can keep the code alive in the ram waiting for the cue, then it
should run fast enough.

but how do I pass information from one code to the other?

in fact - another language.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pipeline - what is it and how do I use it?

2007-11-25 Thread elis aeris
thanks for the reply

On Nov 26, 2007 2:38 AM, Evert Rol <[EMAIL PROTECTED]> wrote:

> > I need to keep a bit of python code ready to run at anytime, in the
> > ram, but this is what I need to do
> >
> > I am using two languages at the same time, because python doesn't
> > really have any effective way of simulating keyboard and mouse events,
>
> Well, not the language itself, but there may be some library out
> there that has this functionality. But I guess it'll indeed be hard
> to find though.
>
>
> > so I need to run auto it 3, and then call my python code to perform
> > a little bit of work, it only takes 0.1 seconds to run, but it
> > takes almost a second to start the code,
> > if i I can keep the code alive in the ram waiting for the cue, then
> > it should run fast enough.
> >
> > but how do I pass information from one code to the other?
> >
> > in fact - another language.
>
> It's the virtual machine you want to keep around in memory (together
> with the code), not so much the code itself.
> The quickest thing I can think of right now is having a daemon
> program running, and communicate with it through signals or sockets.
> But that doesn't feel very (thread)safe.
> Depending on your problem, you may want to go at it in another way.
> In fact, if speed is a concern, you may be better off writing your
> time essential code in C or something, and compile it to machine
> code. Less fun & easy than to code in Python probably.
>
>
> btw: odd subject line, when relating it to the actual question ;-)
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] pipeline - what is it and how do I use it?

2007-11-25 Thread elis aeris
any specific leads?
any ready code would rock

thankyou for responding

On Nov 26, 2007 2:41 AM, bob gailer <[EMAIL PROTECTED]> wrote:

> elis aeris wrote:
> > I need to keep a bit of python code ready to run at anytime, in the
> > ram, but this is what I need to do
> >
> > I am using two languages at the same time, because python doesn't
> > really have any effective way of simulating keyboard and mouse events,
> >
> > so I need to run auto it 3, and then call my python code to perform a
> > little bit of work, it only takes 0.1 seconds to run, but it takes
> > almost a second to start the code,
> > if i I can keep the code alive in the ram waiting for the cue, then it
> > should run fast enough.
> >
> > but how do I pass information from one code to the other?
> See the signal and socket modules.
>
> Also I sorta recall there are modules that enable Python to simulate
> keyboard and mouse events.
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] windows api

2007-12-02 Thread elis aeris
this code uses windows api, but where do I find documentation about how to
use them?



import time
import ImageGrab # Part of PIL
from ctypes import *


#time.sleep(5)


# Load up the Win32 APIs we need to use.
class RECT(Structure):
_fields_ = [
('left', c_ulong),
('top', c_ulong),
('right', c_ulong),
('bottom', c_ulong)
]


# time.sleep(2)

GetForegroundWindow = windll.user32.GetForegroundWindow
GetWindowRect = windll.user32.GetWindowRect

# Grab the foreground window's screen rectangle.
rect = RECT()
foreground_window = GetForegroundWindow()
GetWindowRect(foreground_window, byref(rect))
image = ImageGrab.grab((rect.left, rect.top, rect.right, rect.bottom))

# Save the screenshot as a BMP.
image.save("C:\projects\screenshot.bmp")
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] windows api (Out of office)

2007-12-02 Thread elis aeris
On Dec 2, 2007 11:28 PM, Pierre DeWet <[EMAIL PROTECTED]> wrote:

> I will be out of the office until Monday 10 December. If your request is
> urgent, please contact the helpdesk at: [EMAIL PROTECTED],
> alternatively, please dial: 0207 566 8771
>
> Cheers
> Pierre
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] windows api

2007-12-02 Thread elis aeris
i know that site, i program in c++ on windows.

however, the syntax in different. how do I find out python's way of using
it?



On Dec 2, 2007 11:36 PM, bob gailer <[EMAIL PROTECTED]> wrote:

> elis aeris wrote:
> > this code uses windows api, but where do I find documentation about
> > how to use them?
> Hmm - looks like something from Experts Exchange.
>
> If you are asking for the Windows API Reference, try:
>
> http://msdn2.microsoft.com/en-us/library/aa383749.aspx
>
> ctypes is a Python module that wraps the api calls
> >
> >
> >
> > import time
> > import ImageGrab # Part of PIL
> > from ctypes import *
> >
> >
> > #time.sleep(5)
> >
> >
> > # Load up the Win32 APIs we need to use.
> > class RECT(Structure):
> > _fields_ = [
> > ('left', c_ulong),
> > ('top', c_ulong),
> > ('right', c_ulong),
> > ('bottom', c_ulong)
> > ]
> >
> >
> > # time.sleep(2)
> >
> > GetForegroundWindow = windll.user32.GetForegroundWindow
> > GetWindowRect = windll.user32.GetWindowRect
> >
> > # Grab the foreground window's screen rectangle.
> > rect = RECT()
> > foreground_window = GetForegroundWindow()
> > GetWindowRect(foreground_window, byref(rect))
> > image = ImageGrab.grab((rect.left, rect.top, rect.right, rect.bottom))
> >
> > # Save the screenshot as a BMP.
> > image.save("C:\projects\screenshot.bmp")
> >
> > 
> >
> > ___
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Anyone fancy giving me some tips and an expert opinion??

2008-03-18 Thread elis aeris
i am not sure if I am still in the mailing list of tutor@python.org so
please use reply all to send me a email directly please!



x = 0
y = 0
for x in xrange (20, 0):
print x



this doesn't work because it goes from a big number to a small number, which
does nothing



but what if I need the for loop to go from a big number to a small number?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] xrange

2008-03-18 Thread elis aeris
x = 0
y = 0
for x in xrange (20, 0):
print x



this doesn't work because it goes from a big number to a small number, which
does nothing



but what if I need the for loop to go from a big number to a small number?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] c++::return

2008-03-18 Thread elis aeris
what do I do if i want the program/function to end?


in c++ of

int main(){}

I do a return 0;
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] c++::return

2008-03-18 Thread elis aeris
and also, I didn't need to break function is that program, to which i am
amazed of, now come to think of it.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] xrange

2008-03-18 Thread elis aeris
ok.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] xrange

2008-03-18 Thread elis aeris
ok i need about 500~1000

is that ok?

my pet practice works works fine with it,but what should I watch out for?

sorry for double reply kent, forgot to reply all.

On Tue, Mar 18, 2008 at 3:21 PM, Kent Johnson <[EMAIL PROTECTED]> wrote:

> Alan Gauld wrote:
>
> > Add a 3rd step-value argument to range. (You don't need the xrange
> > on modern versions of Python BTW)
>
> Only if by 'modern' you mean Python 3; on Python 2.x there is a
> difference between range() and xrange(). Though for a list of 20 ints I
> don't think it matters much.
>
> Kent
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] c++::return

2008-03-18 Thread elis aeris
i was reading it the second time 6months after and in fact i am working on
version 3 of it with update to functionality.

(and yes, it is MY code)

how do I return a function?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] xrange

2008-03-18 Thread elis aeris
Oh i am good with range then, because it's not a real time program.



On Tue, Mar 18, 2008 at 3:55 PM, Shrutarshi Basu <[EMAIL PROTECTED]>
wrote:

> I'm not entirely sure about this, but I think for range(), the entire
> range of numbers is generated at one go, which could cause a
> slow-down. But xrange() generates the list of numbers one at a time.
> For a thousand, there shouldn't be much of a difference, but if you
> need a million or so go with xrange()
> Basu
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] c++::return

2008-03-18 Thread elis aeris
I actually said "ending" to avoid problems with different terminology
between different languages - but i guess a return is still a return in
python.

i did this search

http://www.google.ca/search?hl=en&q=python+tutorial+return&btnG=Google+Search&meta=

and it didn't return any particularly obvious answer.

The funny thing is, i wrote that program last june and managed to not
know/use a single return :)







On Tue, Mar 18, 2008 at 6:11 PM, Alan Gauld <[EMAIL PROTECTED]>
wrote:

> "elis aeris" <[EMAIL PROTECTED]> wrote
>
> > how do I return a function?
> >
> Do you realise that this is an entirely different question
> to the one you asked originally, namely:
>
> >> what do I do if i want the program/function to end?
> >>
> >> in c++ of
> >>int main(){}
> >>I do a return 0;
>
>
> One is asking about *ending* the program(or function), the
> other about returning. Those are two different concepts.
> In particular returning implies that the program does not
> end but goes on to use the returnedvalue in some way.
>
> Assuming that it is returning you are interested in then
> all the tutorials that discuss Python functions (including
> mine) will tell you how to return a value from a function.
>
> You use the return statement exactly like in C++.
>
> Where did you look if you couldn't find it?
>
> Even searching "return" on the Python web site gets me this as
> the first link:
>
> 6.7 The return statement
>  When return passes control out of a try statement with a finally
> clause, that finally clause is executed before really leaving the
> function. ...
>  docs.python.org/ref/return.html - 7k - Cached - Similar pages
>
>
> And visiting it it tells me:
>
> ---return_stmt ::= "return" [expression_list]
>
>
> return may only occur syntactically nested in a function definition,
> not within a nested class definition.
>
> If an expression list is present, it is evaluated, else None is
> substituted.
>
> return leaves the current function call with the expression list (or
> None) as return value.
> -
>
> Now, its not that we mind answering questions, but if you claim
> to have looked for an answer and then ask a somewhat vaguely
> worded question we will assume you are looking for something
> deeper. Its easier for all of us if you are as specific as possible
> in your questions.
>
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.freenetpages.co.uk/hp/alan.gauld
>
>
>
>
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] returning two values

2008-03-21 Thread elis aeris
is it possible to return two values?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] list

2008-03-21 Thread elis aeris
how do I create an empy int array of 10?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] append string

2008-03-21 Thread elis aeris
how do I append to the end of strings?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] int to string

2008-03-21 Thread elis aeris
how do I convert int to string?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] returning two values

2008-03-21 Thread elis aeris
oh this is brillant, i LOVE python

thank for replying

On Fri, Mar 21, 2008 at 5:11 PM, Gregor Lingl <[EMAIL PROTECTED]> wrote:

>  elis aeris schrieb:
>
> is it possible to return two values?
>
>  Yes:
> >>> def return2():
> return "this", "that"
>
> >>> return2()
> ('this', 'that')
> >>> a,b=return2()
> >>> a
> 'this'
> >>> b
> 'that'
> >>>
> Regards,
> Gregor
>
>  --
>
> ___
> Tutor maillist  -  [EMAIL PROTECTED]://mail.python.org/mailman/listinfo/tutor
>
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] returning two values

2008-03-21 Thread elis aeris
so just str(int)

got it,
thanks !

On Fri, Mar 21, 2008 at 5:11 PM, elis aeris <[EMAIL PROTECTED]> wrote:

>
> oh this is brillant, i LOVE python
>
> thank for replying
>
>
> On Fri, Mar 21, 2008 at 5:11 PM, Gregor Lingl <[EMAIL PROTECTED]> wrote:
>
> >  elis aeris schrieb:
> >
> > is it possible to return two values?
> >
> >  Yes:
> > >>> def return2():
> > return "this", "that"
> >
> > >>> return2()
> > ('this', 'that')
> > >>> a,b=return2()
> > >>> a
> > 'this'
> > >>> b
> > 'that'
> > >>>
> > Regards,
> > Gregor
> >
> >  --
> >
> > ___
> > Tutor maillist  -  [EMAIL 
> > PROTECTED]://mail.python.org/mailman/listinfo/tutor
> >
> >
> >
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] list

2008-03-21 Thread elis aeris
arra = [0] * 10 ?

On Fri, Mar 21, 2008 at 5:29 PM, Andreas Kostyrka <[EMAIL PROTECTED]>
wrote:

> Empty?
>
> array = []
>
> If you want to assign 10 "None", that would be:
>
> array = [None] * 10
>
> Andreas
>
> Am Freitag, den 21.03.2008, 17:03 -0700 schrieb elis aeris:
> > how do I create an empy int array of 10?
> > ___
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] windows: pop up window

2008-03-22 Thread elis aeris
how do I pop up a window to ask user's input?
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


  1   2   >