All,
I have an image with a bunch of white space that I need to crop. I would
like to automate the process using python and I was wondering what is the
best module for image manipulation? I have seen PIL and Python magic what
is recommended?
John Ertl
Ryan Davis wrote:
I think map is a little cleaner is some cases. Not sure if its more Pythonic,
I'm still trying to figure out exactly what that
means.
map is (probably) going to be removed in Python3000 :-( So it's
probably better to not get into the habit of using it
ABLED)
Just remember that it needs to be enabled when you put the answer in.
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Hi to everyone first, this is my first posting and I hope that I won't make
a mess.
I am 100% newbie (and when I mean newbie it is with a big N).
I decided to have a go at programming and after reading different articles I
decided to have a go at Python (first because it is free, secondly becaus
Thanks everybody for their input. It is great to know that there are some
people ready to help.
Ara Kooser, what I meant by this "science", I have meant programming, sorry
if I was not too clear.
Alan, I will check those programming contests you were talking about, but
only when I will feel re
All
I have a string that has a bunch of numbers with the units attached to them.
I want to strip off the units. I am using a regular expression and sub to
do this. This works great for almost all of the cases.
These are the type of lines:
SigWind: 857hPa, , 21.0C, 20.1C, 210 @ 9
Hi there,
I have written (well almost as I copied some lines from an existing example)
this little programme - part of an exercise.
#By J Carmona
#Programme that compute area for
#circle, square, rectangle
def area_rect():
length = input("Length: ")
width = input ("Width: ")
; import eratosthenes
>>> eratosthenes.primes()
>>> eratosthenes.primes().next()
2
>>> eratosthenes.primes().next()
2
>>> eratosthenes.primes().next()
2
How does one get beyond the first prime?
Thanks,
John
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
?
Why not distribute pygame with your game?
(I assume that would be allowed)
I mean, you could write your own game library, but then you'd just have
to distribute that instead...
Also, in terms of creating standalone executables, have a look at py2exe.
--
ouble if you do this with mutable types.
eg:
>>> l = [[]] * 10 # A list of ten empty lists
>>> l
[[], [], [], [], [], [], [], [], [], []]
>>> l[3].append(2)
>>> l
[[2], [2], [2], [2], [2], [2], [2], [2], [2], [2]]
--
John.
___
l would not strip out the charecter...I
may try a bit harder to make it work just becouse it bugs me that you made
it work.
Thanks again
John Ertl
-Original Message-
From: Kent Johnson
Cc: tutor@python.org
Sent: 3/27/05 2:31 PM
Subject: Re: [Tutor] re question
Jacob S. wrote:
> Kent
this, I was printing to a postscript printer, and I wasn't
printing anything that required complex layout. So I generated the
postscript code myself, and then just sent it straight to the printer...
--
John.
___
Tutor maillist - Tutor@python.org
Hi guys, I have typed this programme from the Josh Cogliati manual
-
import calendar
year = input("Type in the year number: ")
calendar.prcal(year)
I get this error message
Traceback (most recent call last):
File "C:/Python24/Example/cal.
I am not sure that it is possible to ask that question please feel free to
turn me down if it is going against the forum rules.
I have going through Josh Cogliati tutorial, I am stuck on one of the
exercise. I need to rewrite the high_low.py program (see below) to use the
last two digits of tim
John Carmona wrote:
I have going through Josh Cogliati tutorial, I am stuck on one of the
exercise. I need to rewrite the high_low.py program (see below) to use
the last two digits of time at that moment to be the "random number".
This is using the import time module.
If you look a
John,
Thanks firstly to point about emailing back using the "Reply to all" option.
Thanks also about the explanation about the difference about the difference
between 32 and "32", being a number and a string respectively, your
explanation was very clear (you can see now my
Alan and John thanks for the help. I have now this bit of script but it is
not running.
--
from time import *
n = time()
s = str(n)
numb = s[-2:] # last two characters of the string
numb
Thanks Kent I kind of see what you are trying to explain to me, it makes it
easier by trying the different combination.
So even is I change the first line to
import time
My script is still not working properly, I am obviously missing a statement
somewhere, the script return:
Enter a number: 25
C Smith, Danny and Kent, thanks for the replies.
Here is my programme (I have reinstated the "while loop"
C Smith I like very much your method to get the last digits of a number.
It is WORKING NOW!! You can imagine how long I have spent on that, but I
have learnt so much. Many thanks to all the pe
;>> foo['a'].append(3)
>>> foo
{'a': [3], 'b': [3]}
But again, there are other ways of achieving this. (eg, x = []; foo =
{'a':x, 'b':x}) And maybe it's even what you wanted.
You could even make foo contain itsel
Dear Hoffmann, I am also a Newbie and I am currently going through "A Byte
of Python" tutorial from Swaroop C H.
http://www.byteofpython.info/download?PHPSESSID=c0d52343d90f69f25942f49df9ae7944
If you are completely new to programming like me, you will find that this
tutorial is excellent.
Good
I get the behaviour you expect.
Also ---
A + [4, 5, 6]
[1, 2, 3, 4, 5, 6]
This surprises me. Here's what I get:
>>> A + [3, 4, 5]
<__main__.MyList instance at 0x40065e4c>
because you haven't defined __repr__ for MyList.
Are you sure you
I am back, thanks again all to help me sorting out the High_Low guessing
game using time.
Can somebody put me on the right track for the following script. I know how
to use the calendar.prcal command to print the 12 months of choosen year.
But how do you use the prmonth command, if you, for exa
Thanks Kristian, it works a treat. Now you have set me up with finding out
how to use the months entered by name. If I am stuck I will post again.
Thanks very much
JC
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Kristian you wrote:
-
This assumes all input as integers; if you want months entered by
name, you'll have to write a conversion routine (hint: use a dict).
---
Roel you wrote:
-
A dictionary is a data structure containing keys and values that defines
a mapping from each key to its corresponding value. You define it like this:
>>> squares = {1: 1, 10: 100, 4: 15,
Thanks Jacob, I think that should keep me out of the street for a while!
I will get back to you if I have any question
Regards
JC
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Thanks John for your help.
Here is the final script (and it is working)
--
import calendar
MonthName = {'January': 1,'February': 2, 'March': 3,'April': 4
,
Kristian you have said:
-
I can think of 2 ways to accomplish this.
1. Try to convert monthString to an int, use the lookup if that fails.
This might be a good way to learn try/except processing.
Thanks Kristian, it is working fine now. I am learning so much with those
little exercises, I know they are probably very basics to most of the people
of this forum but they are great for a beginner like me. Jacob has sent me a
few exercise to do, some look pretty difficult for my level so surel
I need to manipulate and view gif and png images. I have PIL installed so I
can do the manipulation but PIL does not let me view the images, because I
do not have xv. What is the recommended python module for viewing gif and
png?
Thanks for the recommendation.
John Ertl
I am off to sunny Spain for the next 2 weeks and I would like to suspend the
emailing from Python.tutor for that period. Could someone put me in the
right direction on how to do that, thanks.
Regards
JC
___
Tutor maillist - Tutor@python.org
http://ma
t; >>> # print "Testing interval (intentional fail)."
> >>> wc = Wall_clock()
> >>> del(wc)
> >>> wclock = Wall_clock()
As a quick hack, try adding the following line here:
>>> wclock.__del__()
he 'running-order' should occur. But maybe
once you've begun to 'grok' doctest a little more you'll be able to
shed some light on it for us!
Regards
John Ridley
Send instant messages to your online friends http://uk.messenger.yahoo.com
__
;.
What is "n:" and what is "lambda m" ?
Thank You,
John A. Gooch
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 09, 2004 12:19 PM
To: tutor@python.org
Subject: Re: [Tutor] sorting a list of dictionaries
On 9 Dez 20
;getSize()'
function of the 'Dir' class from *inside* of the DirList class, it gives me this
->
'I added a node for dir d:/ with size >'
Any
ideas on what I am doing wrong?
Thank
You,
John A. Gooch
Systems
Administrator IT - Tools EchoStar Satel
things is the most pythonic: well, as always,
it depends on what you are trying to achieve - if your code is not
doing what you want it to do, then that is about as unpythonic as it
can get :-)
HTH
John Ridley
Send instant messages to your online friends http://uk.messenger.yahoo.com
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
s gone and now the previous "2" becomes "1"(
shifts down ), the for loop continues on to index "2", failing to delete the
new index "1".
Is there an algorithm that can delete the selected items in one pass? Or
would I have to iterate over the listbox items u
load
xv on the machines and PIL uses xv to display. I have looked at
PythonMagick but I could not even get past installing it. It does not have
a setup.py and uses boost. I am hoping for a more straightforward Python
way.
Thanks,
John Ertl
___
Tutor
Danny,
Pygame.org...I would not have thought to look there. In my google it did
not pop up. I will definitely take a look and thanks for the example.
John Ertl
-Original Message-
From: Danny Yoo [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 14, 2005 12:25
To: Ertl, John
Cc: Tutor
Ken,
I misspoke when I said these were lists of dictionaries, they are actually
lists of object that have a "getSize()" getter function that returns the
size of their contents, which I would like to use for sorting.
Thank You,
John A. Gooch
Systems Administrator
IT - Tools
EchoStar
input size when it crashes vs stack size, I was able to
get a nice graph displaying the space complexity of the algorithm :-)
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
):
dr = delRecord()
dr.someCommand( <-- tooltip popups up here
Thank You,
John A. Gooch
Systems Administrator
IT - Tools
EchoStar Satellite L.L.C.
9601 S. Meridian Blvd.
Englewood, CO 80112
Desk: 720-514-5708
___
Tutor maillist - Tu
Gooch, John wrote:
> Is there a way to create multiple __init__ routines in a Python Class?
Not directly (well, not that I know of). But you can always emulate it.
eg:
class Foo(object):
def __init__(self, init, *args, **kw):
if init == 'this':
self._initThis(*args, *
tried several times). When I try to close IDLE it says
the program is still running. How should I be getting this data is it
trying to read the binary and that is why it is stalled?
Thanks,
John Ertl
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
13:10
Cc: tutor@python.org
Subject: Re: [Tutor] Trying to d0 HTTP GET
Ertl, John wrote:
> All,
>
> I am trying to get some binary data from a web service. None of the tech
> guys are around so I am hoping you might be able to shed some light on
what
> might be happening.
I wou
a with '__init__' and you have a
picture of what I would like to do in Python, but I don't know if the
language support it or not.
Thank you for answering the second part of the question, I will try that
technique out.
John A. Gooch
Systems Administrator
IT - Tools
EchoStar Satellite
p()
print binvalues
-Original Message-
From: Kent Johnson
Cc: tutor@python.org
Sent: 4/18/05 1:10 PM
Subject: Re: [Tutor] Trying to d0 HTTP GET
Ertl, John wrote:
> All,
>
> I am trying to get some binary data from a web service. None of the
tech
> guys are around so I am hoping you
Kent and Danny,
Thanks for the help. The trick was to put the .read() at the end of the
urllib2 line. It makes some sense now but man I hate it when it is that
simple and I just can't see it.
Thanks again for the great help.
John Ertl
-Original Message-
From: Kent Johnson [m
he
correct env are in the .ksh files maintained by others. I would hate to
have to take the .ksh and tread each line and if it is an export turn that
into a python os.environ statement.
Any ideas.
Thanks
John
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Kent,
Good idea except that the environment that needs to be set depends on the
answers to some of the input that I get in the Python program. Nothing is
ever easy here.
Thanks for the ideas.
John Ertl
-Original Message-
From: Kent Johnson [mailto:[EMAIL PROTECTED]
Sent: Thursday
t manually).
Thanks,
John Ertl
-Original Message-
From: Kent Johnson [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 21, 2005 13:49
Cc: tutor@python.org
Subject: Re: [Tutor] trouble setting the environment
Ertl, John wrote:
> Kent,
>
> Good idea except that the environment that need
Hi guys, I am back from my hols.
Jacob S gave me this little exercise to do a little while ago.
1) Make a program to compute the areas of several figures. Make it display a
menu on startup, ask for a choice, and then compute the area of the
figure chosen by asking for dimensions.
2) Make
Thanks Kent, it is working now. Is this what you meant in your reply?
Because if I set up the main code at the end of the script I was still
getting an error message.
Also, what do I need to use if for example I want my code to rerun once I
have computed let's say a volume. Right now the execut
Thanks for the help Kent, Noel and Alan. Here is my final script (it seems
to be working ok but sometimes if I select "quit the programme", I need to
enter that option 2 or 3 times before it works, is this a bug (I am running
Win XP), please feel free to comment if you thing that something could
enter "f" first then the
programme ends. What am i missing?
JC
John Carmona wrote:
Thanks for the help Kent, Noel and Alan. Here is my final script (it
seems to be working ok but sometimes if I select "quit the programme", I
need to enter that option 2 or 3 times bef
close and then
display the next image.
I have tired several things but no luck.
Any help on getting the TK window to shutdown cleanly would be appreciated.
Thanks
John Ertl
# this is supposed to display an image in a TK window but the close
(X) does not work.
import Image
import Tkinter
I forgot to mention that I am running on a Linux system if that makes any
difference for the TK part.
Thanks,
John Ertl
-Original Message-
From: Ertl, John
Sent: Monday, April 25, 2005 10:24
To: tutor@python.org
Subject: using TK to view an image and then close the window
All,
I
ljVersion/lib/python2.4/lib-tk/Tkinter.py", line
2075, in _create
return getint(self.tk.call(
_tkinter.TclError: image "pyimage2" doesn't exist
-Original Message-
From: Michael Lange [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 26, 2005 01:58
To: Ertl, John
Sub
Hi Alan, sorry for not replying sooner I am right in the middle of setting
up a network at home. Thanks for your email.
OK the situation is that I haven't still found out what the answer is, I
have noticed in the other hand that if I select the option "a" let's say 4
times, I need to enter the
OK Alan, I thing I have seen the light!!. Here is the script that Kent and
you asked me to look at modified:
-
def print_options():
print "--"
print "Options:"
print "a. print opt
wall on my next exercise.
Thanks a million for your help (also Kent and John - I will try to rewrite
your poem/exercise once I get a minute, thanks)
Regards
JC
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
subtract a month
and get "December 1, 2004".
For the code I am working with I am only interested in the Month and the
Year. Is there a way to use datetime or date modules to do this? Or perhaps
I need to use a different module?
Thank You,
John A. Gooch
Systems Administrator
IT - Tool
world applications.
Does anyone have a more elegant solution?
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Kent Johnson
Sent: Tuesday, May 03, 2005 11:23 AM
Cc: tutor@python.org
Subject: Re: [Tutor] Subract Month From Date
Gooch, John wrote:
> What woul
Hello,
I am working on learning Python and writing some console applications to
apply what I am learning - I am using a generator function to implement a
status indicator as follows:
import sys
def neverEndingStatus(currentChar_ = '|'):
while 1:
if currentChar_ == '|':
Lightbulb!
It's clear that I don't yet fully understand the power of generator
functions... It never occurred to me to yield out of the middle of a loop,
and yet, seeing your code, it's obvious that that's one of the primary
purposes of "yield".
Thanks,
-jdc
On 5/7/05 8:00 AM, "Max Noel" <[EMAI
Hi to everybody reading this thread, can anybody point me to the URL where I
can find these challenges. Many thanks
JC
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Ooops - sorry - I spoke too soon...
It's clear that your code is a more elegant implementation of
neverEndingStatus() but I am still having to initialize a global variable
and call .next() when I want to get the next value... So the generator
function has been cleaned up, but the client code inter
t removes
the need for the client code to call .next() to get the next status
character. However, this is my first foray into the world of function
attributes and local functions, so this may not be the best way to do this -
any suggestions / critiques?
Thanks,
-jdc
On 5/7/05 8:00 AM, "Max
hearing about it, I thank Max and Karl
for their guidance...
-jdc
On 5/7/05 10:06 AM, "Max Noel" <[EMAIL PROTECTED]> wrote:
>
> On May 7, 2005, at 13:22, John Clark wrote:
>
>> (Either that, or I am not following what you mean when you say:
>>
>>
Jacob,
The "z loop" is in fact just to take time while the screen refreshes with
each output of the status character - as someone else pointed out I could
use a wait() call as well - if I don't put something there to eat up time, I
don't get to display the "spinning wheel" produced by the
sys.std
OK I am stuck on this one. I see what I need to do (correct me if I am
wrong). But I need to write a script that will replace each letter by
another one (In this case a --> c etc.). I look at String, List and
Dictionary. I thought I could use the text.replace option but I am not sure.
Anybody t
Thanks Liam, I will start checking this afternoon.
Regards
JC
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Terry, thanks very much that was very helpful right at this moment :)
This is what beginners like me needs small example that explain very well
how to use some of the functions. I found sometimes that the explanation on
the book or the documentation going over my head because they don't show a
Hey Liam thanks again for the hint. I have finally managed to use the
???trans function. But now "apply it to the URL", I am lost again. (I did
apply it to the URL-twice) but nope, nothing is happening. One more hint if
possible.
Thanks
JC
___
Tutor
This is what I did. I have tried the whole field, part of the URL (after the
.com), etc.. I Just get the old 404 not found message.
JC
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
copied the URL, paste it in my script in Python and run it (once) did not
get nowhere, then did it a second time, and again did not get nowhere.
JC
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
To all thanks I have got it now!!!
JC
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
David,
If you don't get an answer here on tutor.python.org then you might want to
try:
http://www.debian.org/MailingLists/ - where you'll find a link to
http://lists.debian.org/debian-python/ - the mailing list for
debian-python.
Don't forget to search the archive
MyText = open('The_text.txt','r').read()
In the above line could someone tell me what the 'r' stand for. Many thanks
JC
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Got it now, thanks.
JC
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
John,
The 'r' is the mode and is used to indicate you are reading the file. You
could also use 'w' for only writing. See the attached link for more.
http://www.python.org/doc/current/tut/node9.html#SECTION00920000
0
John
-Original Message-
From:
Got it now, thanks John
JC
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
while back. Python is cross platform but there
are platform specific issues and communities that can help with them.
Just a thought.
Thanks for being out there and making us look good.
John Purser
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Greg Lind
ld also use COM ... but that's a bit more effort)
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
I need to print all the ASCII characters within a string, how would I
delimit for example to print the first 100 only? Many thanks
JC
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Thanks Kent for the reply, I am actually having trouble to find the solution
of the following exercise:
## Write a for loop that prints the ASCII code of each character in a string
name S.##
I am ok with the for loop, put I don't know how get to print the ASCII code
of each character with a st
With the help of Pujo Aji I have written this little script that print every
single ASCII code>>
S = [chr(x) for x in range (0,256)]
for x in S:
print x,
The next step is to use the built-in functin ord() in order to convert each
character to an ASCII integer. I have had a look at the ord()
This would really help speed up my development so that I
can create the class skeleton quickly and then implement each function and
test it as I go.
Thank You,
John A. Gooch
Systems Administrator
IT - Tools
EchoStar Satellite L.L.C.
9601 S. Meridian Blvd.
Engl
Thanks Kent!
-Original Message-
From: Kent Johnson [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 26, 2005 9:52 AM
To: Gooch, John
Cc: tutor@python.org
Subject: Re: [Tutor] Are Empty "Placeholder" Functions possible?
Gooch, John wrote:
> Is there a way to create an e
Pujo, Alan, John and Ben, thanks for the input.
Sorry I should have been clearer with the query perhaps.
Alan I am just going through the book "Learning Python" written by Lutz and
Ascher, and this is part of one exercise. I am still having problem in
putting my head around in wri
To all that have answered, many thanks. I will check the tutorials that have
been pointed out to me. I have also got the Dive into Python printed and I
will start reading that one too pretty soon.
I am off on holiday starting Tuesday so I won't have the time to study too
much in the next couple
pose of OO?
Should I use a module instead of a class, and pretend the module is a class?
This would make the autocomplete available but make it more difficult to
migrate the code from Python to say, Java or C++.
Any advice is welcome.
Thank You,
John A. Gooch
Systems Admin
Hi Ben, you wrote
--- John Carmona <[EMAIL PROTECTED]> wrote:
>Ben I could not get your script working
indentation?
You were right, it is working now, thanks
JC
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
I am not sure if there is a better list to ask this question on, but here it
is:
I have a Python script that works fine for accessing WMI ( Windows
Management Interface ) class properties, but it does not let me access any
of their methods. The code below works fine with Win32_Process objects
unl
Kristiano,
It is sometimes hard to tell the indentions in an email but it looks like
your last line
print "Just right"
has a space in front of it. Python does not know what logical block the
indented part belongs to.
John Ertl
-Original Message-
From: Kristiano Ang [mai
w' )
return myCmd.close()
Currently, I have no idea what is being returned by the "close()" method, it
doesn't appear to be the exit code, so perhaps it is the output of the
command. If so, how can I capture and return the exit code?
Thank You,
John A. Gooch
Systems Administ
than
the "print" command does, because print recognizes that the backslash is
escaping the double quotes ( e.g. "\"" ) in the string, and popen does not.
On the other hand, it appears to be recognizing it in my first example, so
that is what is really confusing me. It isn
If that's your only question about programmers then you aint been around
them much.
I'm 45.
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of [EMAIL PROTECTED]
Sent: Wednesday, June 22, 2005 14:38
To: tutor@python.org
Subject: [Tutor] question abo
ne, None, 0, -2147352571),
2)
anybody with experience in python/com/labview has
idea?? thanks a lot in advance?
cheers,
john
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
201 - 300 of 1089 matches
Mail list logo