Re: [Tutor] Serve a file using http

2007-07-18 Thread Kent Johnson
Sebastian Lara wrote: Hello all, I'm using a SimpleXMLRPCServer to update a file remotely from a simple xml-rpc python client. After that, I need to serve this file but I don't know if I can do this with SimpleXMLRPCServer or if I need another server. If you want to serve the file over

Re: [Tutor] reading random line from a file

2007-07-18 Thread Kent Johnson
Tiger12506 wrote: If you truly wish to kill yourself trying to make it as efficient memory as possible, then you can follow this example. (This is more like what I would write in C). The getrandomline function picks a random byte between the beginning and the end of the file, then backs up

Re: [Tutor] Basic DB question

2007-07-18 Thread Kent Johnson
z machinez wrote: Thank you. I am mainly interested in finding ways to connect to aKDB+ (KX Systems). That is the relational database that we are using. And I would like to open a connection to it. I understand from the vendor that they do not have a good ODBC driver. Googling 'python

Re: [Tutor] How do you install EGG files

2007-07-18 Thread Kent Johnson
Terry Carroll wrote: On Wed, 11 Jul 2007, shawn bright wrote: Hey there all, i got the news that storm was released as open source. Storm is a db orm for python. i have a downloaded package and i would like to play with it, but it does not come with any install instructions. i found the

Re: [Tutor] reading random line from a file

2007-07-18 Thread Poor Yorick
---Original Message--- From: Kent Johnson [EMAIL PROTECTED] Subject: Re: [Tutor] reading random line from a file Sent: 2007-07-18 10:19 [SNIP] It probably doesn't matter, but this will pick longer lines more often than short ones. This method only keeps one line in

Re: [Tutor] How do you install EGG files

2007-07-18 Thread shawn bright
Hey thanks for this, yes, i used the easy_install method and it did work on the python 2.4, the python 2.5 failed. shawn On 7/18/07, Kent Johnson [EMAIL PROTECTED] wrote: Terry Carroll wrote: On Wed, 11 Jul 2007, shawn bright wrote: Hey there all, i got the news that storm was released as

[Tutor] Question from a newbie

2007-07-18 Thread Junaid.Khan/Finance/Lahore
Hi I am totally new to Python. I downloaded it and I really like it as its very simple but I came across a small problem. My question is: How can I save something in Python. I tried to save it but it don't save it. Even I tried to add *.py as extension in the end of file name but still it

Re: [Tutor] Question from a newbie

2007-07-18 Thread Luke Paireepinart
Junaid.Khan/Finance/Lahore wrote: Hi I am totally new to Python. I downloaded it and I really like it as its very simple but I came across a small problem. My question is: How can I save something in Python. I tried to save it but it don’t save it. Even I tried to add *.py as extension

Re: [Tutor] Question from a newbie

2007-07-18 Thread Darren Williams
I have exactly the same problem using PythonWin. I know it's not saving because in the location where I am saving my program to, nothing appears, I can even search my whole computer for the file but nothing... I just use Komodo Edit for writing and saving the final versions and PythonWin for

[Tutor] while Loop

2007-07-18 Thread Darren Williams
Hi all, I'm writing a calculator for an online game that I used to play but don't seem to be able to break out of the while loop, the program will just go over and over the loop, crashing the program and I don't know if Python is just really slow at this type of thing or i'm doing it

Re: [Tutor] while Loop

2007-07-18 Thread Luke Paireepinart
Darren Williams wrote: Hi all, I'm writing a calculator for an online game that I used to play but don't seem to be able to break out of the while loop, the program will just go over and over the loop, crashing the program and I don't know if Python is just really slow at this type of

Re: [Tutor] while Loop

2007-07-18 Thread Darren Williams
Luke and Kent, you're right, I didn't think JavaScript calculated multiplaction and division before addition and subtraction but seems it does :) I dunno what you mean about usedPocketsOne not being defined, didn't I define it with usedPocketsOne = 192000? - Original Message - From:

[Tutor] python to serve xml or json or....

2007-07-18 Thread Picio
Hello, I' ve a bunch of things to ask about using Python as a server side language in a web application: I have a mysql db and I've alredy developed a python app that query the db and shot-out an xml file (made by the nice elementtree module like some people here on the list suggested). This file

[Tutor] python and Java developers, same team

2007-07-18 Thread Picio
Hello, a friend of mine want me to join a team on a project. They use Java (the IDE is java studio creator), and the deployment server is Tomcat. Anyway I have all my apps in python and I'd like to continue my development using it instead of learning java. Is it possible to translate my apps from

Re: [Tutor] python and Java developers, same team

2007-07-18 Thread Kent Johnson
Picio wrote: Hello, a friend of mine want me to join a team on a project. They use Java (the IDE is java studio creator), and the deployment server is Tomcat. Anyway I have all my apps in python and I'd like to continue my development using it instead of learning java. Is it possible to

Re: [Tutor] python to serve xml or json or....

2007-07-18 Thread Kent Johnson
Picio wrote: Hello, I' ve a bunch of things to ask about using Python as a server side language in a web application: I have a mysql db and I've alredy developed a python app that query the db and shot-out an xml file (made by the nice elementtree module like some people here on the list

Re: [Tutor] while Loop

2007-07-18 Thread Luke Paireepinart
Darren Williams wrote: Luke and Kent, you're right, I didn't think JavaScript calculated multiplaction and division before addition and subtraction but seems it does :) I dunno what you mean about usedPocketsOne not being defined, didn't I define it with usedPocketsOne = 192000? no, I

Re: [Tutor] while Loop

2007-07-18 Thread Darren Williams
Oops, didn't notice the uppercase U, thanks Luke. - Original Message - From: Luke Paireepinart [EMAIL PROTECTED] To: Darren Williams [EMAIL PROTECTED] Cc: tutor@python.org Sent: Wednesday, July 18, 2007 3:08 PM Subject: Re: [Tutor] while Loop Darren Williams wrote: Luke and Kent,

Re: [Tutor] reading random line from a file

2007-07-18 Thread Tiger12506
Yuck. Talk about a one shot function! Of course it only reads through the file once! You only call the function once. Put a second print randline(f) at the bottom of your script and see what happens :-) JS This method only keeps one line in memory, only reads through the file once, and does

[Tutor] pybluez + link quality

2007-07-18 Thread Flaper87
Hi everybody: I would like to know how can i get the link wuality of a device (cellphone), with the pybluez module. (if there is another way to do it without the pybluez, i'm interested too) Thanks -- Flavio Percoco Premoli, A.K.A. [Flaper87] http://www.flaper87.com Usuario Linux registrado

Re: [Tutor] pybluez + link quality

2007-07-18 Thread Luke Paireepinart
Flaper87 wrote: Hi everybody: I would like to know how can i get the link wuality of a device (cellphone), with the pybluez module. (if there is another way to do it without the pybluez, i'm interested too) PyBluez is not cross-platform for all aspects of the bluetooth protocol, so you

Re: [Tutor] pybluez + link quality

2007-07-18 Thread Flaper87
No, what i'm doing is just for linux 2007/7/18, Luke Paireepinart [EMAIL PROTECTED]: Flaper87 wrote: Hi everybody: I would like to know how can i get the link wuality of a device (cellphone), with the pybluez module. (if there is another way to do it without the pybluez, i'm

[Tutor] Working with bash (subversion)

2007-07-18 Thread Justin Cardinal
I'm trying to write a program that will list all subversion repository directories, then issue a command using each directory as an argument, then parse those results. So far, I'm able to get a list of the directories...and that's it! Here's what I've got so far:

Re: [Tutor] Working with bash (subversion)

2007-07-18 Thread Luke Paireepinart
Justin Cardinal wrote: I'm trying to write a program that will list all subversion repository directories, then issue a command using each directory as an argument, then parse those results. So far, I'm able to get a list of the directories...and that's it! Here's what I've got so far:

Re: [Tutor] Working with bash (subversion)

2007-07-18 Thread Luke Paireepinart
Justin Cardinal wrote: I'm trying to write a program that will list all subversion repository directories, then issue a command using each directory as an argument, then parse those results. So far, I'm able to get a list of the directories...and that's it! Here's what I've got so far:

Re: [Tutor] Working with bash (subversion)

2007-07-18 Thread Andreas Kostyrka
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 mkarg is quite useful, from time to time. Andreas Luke Paireepinart wrote: Justin Cardinal wrote: I'm trying to write a program that will list all subversion repository directories, then issue a command using each directory as an argument,

Re: [Tutor] reading random line from a file

2007-07-18 Thread Tiger12506
import os import random text = 'shaks12.txt' if not os.path.exists(text): os.system('wget http://www.gutenberg.org/dirs/etext94/shaks12.txt') def randline(f): for i,j in enumerate(file(f, 'rb')): Alright. But put randline in a loop and you open a lot of file handles. Thank goodness

Re: [Tutor] Working with bash (subversion)

2007-07-18 Thread Tiger12506
results.write(c.getoutput('svnadmin lslocks ' + eval(row))) Mmm... I want to add that the eval function tries to execute whatever is in the argument passed as python expressions. eval('1+2') 3 row = 4 1+row 5 eval('1+row') 5 JS ___ 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 =

Re: [Tutor] Working with bash (subversion)

2007-07-18 Thread Justin Cardinal
That fixed it, thanks! Now I just need to do some studying on working with lists (or whatever this output is...) so I can filter out the results I don't want. Here's an updated version of the program: #!/usr/bin/env python import

Re: [Tutor] Working with bash (subversion)

2007-07-18 Thread Luke Paireepinart
Tiger12506 wrote: results.write(c.getoutput('svnadmin lslocks ' + eval(row))) Mmm... I want to add that the eval function tries to execute whatever is in the argument passed as python expressions. Did I not say that already? ;) I guess my term 'command' was the problem, eh? -Luke

Re: [Tutor] Working with bash (subversion)

2007-07-18 Thread Luke Paireepinart
Justin Cardinal wrote: That fixed it, thanks! Now I just need to do some studying on working with lists (or whatever this output is...) so I can filter out the results I don't want. Here's an updated version of the program:

Re: [Tutor] Python Image library

2007-07-18 Thread Tiger12506
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:

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

Re: [Tutor] Python Image library

2007-07-18 Thread Luke Paireepinart
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

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

Re: [Tutor] Python Image library

2007-07-18 Thread Tiger12506
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

[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

Re: [Tutor] odd

2007-07-18 Thread wesley chun
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? no. the (well, one) syntax for range() is (start, stop) where it counts starting from 'start' up to but not including 'stop'. if you're familiar with C/C++ (or PHP or Java),

Re: [Tutor] odd

2007-07-18 Thread David Rock
* elis aeris [EMAIL PROTECTED] [2007-07-19 08:51]: 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 5 6 7 8 9 10? That is the expected behaviour, per the documentation:

Re: [Tutor] odd

2007-07-18 Thread Ian Witham
from Guido's tutorial: The given end point is never part of the generated list; range(10) generates a list of 10 values, the legal indices for items of a sequence of length 10. It is possible to let the range start at another number, or to specify a different increment (even negative; sometimes

Re: [Tutor] if and things

2007-07-18 Thread Ian Witham
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) +

[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) +

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

Re: [Tutor] if and things

2007-07-18 Thread Tiger12506
man that looks totally pythonic. What you had is correct though. Good job. JS ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] if and things

2007-07-18 Thread Tiger12506
It's nice to see you haven't given up. A few suggestions to make you code a little more creative. 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),

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 +

Re: [Tutor] reading random line from a file

2007-07-18 Thread Nathan Coulter
---Original Message--- From: Tiger12506 [EMAIL PROTECTED] Yuck. Talk about a one shot function! Of course it only reads through the file once! You only call the function once. Put a second print randline(f) at the bottom of your script and see what happens :-) JS *sigh*

[Tutor] Creating Packages

2007-07-18 Thread Greg Lindstrom
Hello- I have written a class to help folks like me manipulate data segments (the kind one deals with when reading/writing data files). The classes and tests are written -- at least enough to get things going -- what I need help with is creating a package out of this and then creating routines

Re: [Tutor] Creating Packages

2007-07-18 Thread Kent Johnson
Greg Lindstrom wrote: Hello- I have written a class to help folks like me manipulate data segments (the kind one deals with when reading/writing data files). The classes and tests are written -- at least enough to get things going -- what I need help with is creating a package out of