In a try except clause, you can end with finally block. I know it runs
after the try and except blocks regardless of the outcome, but why use it.
Couldn't you just put the code after the try and except block without using
a finally block. Does the finally command do something I don't know about
you mean it will always run even if the exception is handled?
On Thu, Jun 24, 2010 at 9:06 AM, Hugo Arts wrote:
> On Thu, Jun 24, 2010 at 4:36 AM, Christopher King
> wrote:
> > In a try except clause, you can end with finally block. I know it
> runs
> > after the
i mean isn't handled
On Thu, Jun 24, 2010 at 9:12 AM, Christopher King wrote:
> you mean it will always run even if the exception is handled?
>
>
> On Thu, Jun 24, 2010 at 9:06 AM, Hugo Arts wrote:
>
>> On Thu, Jun 24, 2010 at 4:36 AM, Christopher King
>> wrote:
what manual?
On Wed, Jun 23, 2010 at 10:59 PM, bob gailer wrote:
> On 6/23/2010 7:36 PM, Christopher King wrote:
>
> In a try except clause, you can end with finally block. I know it runs
> after the try and except blocks regardless of the outcome, but why use it.
> Couldn
I have a module which measures elapsed time. It can also wait til a certain
amount of time has passed till ending. I can send it to you if you like.
On Thu, Jun 24, 2010 at 8:59 AM, Hugo Arts wrote:
> On Wed, Jun 23, 2010 at 3:11 AM, Dave Angel wrote:
> >
> > If you're really looking to measure
so if you encounter an error that you won't handle, but you still to close
files and save data, you could use finally?
On Thu, Jun 24, 2010 at 10:05 AM, Christopher King wrote:
> let me try it
>
> On Thu, Jun 24, 2010 at 9:38 AM, Hugo Arts wrote:
>
>> On Thu,
well, if you use a backlash in the middle of a statement, you can continue
the statement on the next line like so.
>>> for \
i \
in \
('neat', 'ha') \
: \
print \
i
neat
ha
>>>
you can abuse it as much as you like [?]
On Thu, Jun 24, 2010 at 10:00 AM, Richard D. Moores wr
Well the application of defining ones own error is in a module. For example,
if I make a banking account module, I might define a WithdrawError if there
is a place where a error might occur. That way if client code tries to
withdraw too much, you can have a very descriptive error making it easier t
only new classes can have properties, a major tool
On Sat, Jun 26, 2010 at 8:17 AM, Payal wrote:
> Hi,
> Some questions about which I am a bit confused.
>
> 1. I know there is a difference between mro of classic and new style
> classes. but I do not get why we need the new mro, the old one is eas
sorry, my reply to all button goofed up
On Sat, Jun 26, 2010 at 7:43 PM, Steven D'Aprano wrote:
> Hi Christopher,
>
> Are you aware you have written directly to me instead of the tutor
> mailing list? It's normally considered rude to do so, unless your
> message truly is meant to be private.
>
>
I'm wondering how to allow one process to communicate with another
process. In other words, I want to connect two computers. I've looked up
socket but the explanations are too complex. I think I need a 2-way
conversation with a expert to understand it. Or even better, point me to a
easier module
Well, I would just use the builting function open. I think Nick said in the
beggining. Or, I would use the module I created. It's a file object, with
the property file_txt. Unlike the other modules which you have to use read
and write methods, I made a method which allows you to manulipulate like a
I will spilt it up and add comments.
Books =\ #Assign to Books
[Book('War & Peace", [3, 56, 88]), #The first is a Book named 'War & Peace'
Book("Huck Finn", [2, 5, 19])] #You use the book class twice in a row, one
for each book
On Thu, Jul 15, 2010 at 8:09 AM, Payal wrote:
> On Tue, Jul 13, 201
sorry, accidentally hit reply instead of reply to all
On Thu, Sep 9, 2010 at 8:42 AM, Steven D'Aprano wrote:
> Please don't reply privately to me unless you mean to ask me something
> private or personal.
>
> If you send your reply to the tutor list, I'll respond there.
>
>
> Regards,
>
>
>
> --
forgot to send it to the list
On Thu, Sep 9, 2010 at 9:58 PM, Christopher King wrote:
> you could try random.shuffle and save a lot of time, it takes a mutable
> sequence (like a list) and shuffles it
>
>
> On Thu, Sep 9, 2010 at 6:39 PM, lists wrote:
>
>> >>&g
Dear Tutors,
I'm using the Facebook API. How do you get an access token? The
documentations at http://developers.facebook.com/docs/api, but I
can't figure out an easy way to do it.
Sincerely,
Chris
___
Tutor maillist - Tutor@python.org
To unsub
es for brevity and top-posting.
> -
>
> On Jan 27, 2011, at 9:08 AM, Christopher King wrote:
>
> Dear Tutors,
> I'm using the Facebook API. How do you get an access token? The
> documentations at <http://developers.facebook.com/docs/api>
> h
I was playing around with socket. It raised a connection error when I tried
to connect a non-local client to a linux server. It timed out when I tried
to connect a Linux client to a Windows server.
I did succeed when I:
connected a Linux client to a local server
connected a Windows client to a loca
Well, that's a trick me and jake learned in a book to stop the program
from changing.
On Saturday, June 18, 2011, aditya wrote:
>
>
> On Sat, Jun 18, 2011 at 9:35 PM, Jacob Bender wrote:
>
> Dear Tutors,
>
> Alright, I'm using linux (ubuntu) and I took all of your advice and I got
> something t
Looks all good except for this:
while guess == the_number:
Since you break out at the end, an if statement would be a more logical
choice.
and also:
if tries == 4:
print("\nYou fail!")
input("\n\nPress the enter key to exit.")
break
you don't need to break because t
wait a minute, I clicked the link but didn't submit my info,
does that mean my email will start corrupting the list now?
On Mon, Jun 20, 2011 at 2:31 AM, nitin chandra wrote:
> Thank you.
>
> Nitin
>
> On Mon, Jun 20, 2011 at 5:17 AM, Steven D'Aprano
> wrote:
> > nitin chandra wrote:
> >>
> >> H
Also, we tried removing the raw input, but it wouldn't print correct
On Sat, Jun 18, 2011 at 9:55 PM, aditya wrote:
>
>
> On Sat, Jun 18, 2011 at 9:35 PM, Jacob Bender wrote:
>
>> Dear Tutors,
>>
>> Alright, I'm using linux (ubuntu) and I took all of your advice and I got
>> something that works
Well it depends what you mean. If you have a critter object and want
to invoke its method inside the farm, do somethinh like this.
class Farm_class(object):
def feed(self, critter):
critter.eat(self.food)
or if you want to use a method of the Critter class within the farm do
class Farm_clas
Just some programming philosophy.
On Fri, Jun 24, 2011 at 3:58 AM, Vincent Balmori
wrote:
>
> "Your whole approach is very fragile in this respect, it only
> takes one small mistake in the data to wreck your program,.
> Somethjing like a config file format would be much more
> robust (and readabl
It would be cool if their where decorators that modified decorators. I know
its possible, but I can't think of a use.
On Thu, Jun 23, 2011 at 11:05 PM, Steven D'Aprano wrote:
> Robert wrote:
>
>> Is there a good tutorial out there somewhere about decorators? Google
>> doesn't bring up much.
>>
>>
What's step 4?
On Sat, Jun 25, 2011 at 10:08 AM, Mac Ryan wrote:
> On Sat, 25 Jun 2011 06:18:14 -0700 (PDT)
> Adam Carr wrote:
>
> > Good Morning:
> >
> > I am very new to Python but I am enjoying the learning process. I
> > have a question about the application of Python to a problem at the
>
dude, what are all those story comments, did you just edit the mad
lib program from Python for Absolute Beginners?
On Wed, Jun 29, 2011 at 12:28 AM, David Merrick wrote:
> # Guess My Number GUI
> # Create a story based on user input
>
> from tkinter import *
> import random
> class Application(Fr
/myfiles/my_db/ needs to be a string
that right there is trying to divide nothing by the variable called myfiles,
divided by my_db, divide by nothing
On Mon, Jun 27, 2011 at 3:45 PM, wrote:
> I am trying to write a script that will dump a mysql db and then zip the
> file.
>
>
> I do know about m
I would go with __cmp__ which covers them all. 1 for greater, 0 for equal,
-1 for less than.
On Thu, Jun 30, 2011 at 5:35 AM, Alan Gauld wrote:
>
> "Vincent Balmori" wrote
>
>> I keep getting a Type Error since for the moment since the
>> values of the cards cannot be compared due to their
>> ty
Sorry, I haven't upgraded to 3 yet.
On Thursday, June 30, 2011, Steven D'Aprano wrote:
> Christopher King wrote:
>
> I would go with __cmp__ which covers them all. 1 for greater, 0 for equal,
> -1 for less than.
>
>
>
> So-called "rich comparisons" us
I know a way to do that
set1 = set(list1)
set2 = set(list2)
combined = set1&set2
On Sat, Jul 2, 2011 at 5:16 PM, Walter Prins wrote:
> Hi Ankur,
>
> On 2 July 2011 21:30, ANKUR AGGARWAL wrote:
>
>> Hey
>> I am looking for an algo for the largest sequence search in the two list.
>>
>> Example :
Actually maybe not, depending on the complexity of the pattern, but it would
be difficult. You would have to know how much it decreases for every time
you go down or to the right.
If its more complex than that, you may have to program each rule in, not
just enter them in a prompt. I'm assuming none
On Thu, Jul 28, 2011 at 5:08 AM, Peter Otten <__pete...@web.de> wrote:
> Pete O'Connell wrote:
>
> > Hi I was wondering if there is a way to disable a function.
>
>
You could use this decorator:
class Disabler(object):
def __init__(self, old_function):
self.__old = old_function
On Wed, Jul 27, 2011 at 9:11 PM, Thomas C. Hicks wrote:
> On Wed, 27 Jul 2011 20:16:31 -0400
> Alexander Quest wrote:
x=range(1,50)
> mid=x[len(x)/2]
>
> You would have to make sure there is a way to work around decimal points in
the division. Also, I would try it in practice. (remember range(
Dear Tutor Dudes,
I have a socket Gui program. The only problem is that socket.recv waits
for a response, which totally screws Tkinter I think. I tried making the
timeout extremely small (it was alright if I didn't receive anything, I
was excepting that a lot) but I think that screwed socket. A
I was afraid of that.
On Thursday, July 28, 2011, Dave Angel wrote:
> On 07/28/2011 08:32 PM, Christopher King wrote:
>>
>> Dear Tutor Dudes,
>> I have a socket Gui program. The only problem is that socket.recv
waits
>> for a response, which totally screws Tkinter
I think I'll go with threading. I've become more familiar with it.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Wow wow, way is a ser...@might.co.za person doing a tutor response. And why
can I see it if it isn't to me.. I'm sorry Sergey if this
isn't something malicious, it just seems suspicious.
On Sun, Jul 31, 2011 at 3:30 PM, Sergey wrote:
> On Sun, 31 Jul 2011 14:22:41 -0400 Alexander Etter
> wrote
On Tue, Aug 2, 2011 at 10:44 PM, Alexander Quest wrote:
>
> have [0] to indicate that I want to go to the second value within that
> first item, which is the
> point value
>
Actually [0] is the first element. I would go with [1].
___
Tutor maillist - Tu
To make a package, you make a folder named what you want to name the
package, for example: virus_toolkit. Then you make a file in it called
__init__.py. This is what you import if you import the virus_toolkit. You
usually put documentation and general functions in this I believe (I'm not
100% sure
I give +0. I'm sure that it could come in use somewhere, as long as it isn't
used everywhere.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On Sat, Aug 6, 2011 at 4:10 AM, David Townshend wrote:
>
> def counter(add) as func:
> if not hasattr(func, 'count'):
> func.count = 0
> func.count += 1
> print(func.count)
>
You already can do that without an as statment.
>>> def counter(add):
if not hasattr(counter, 'coun
>
> try:
> iter(item) # test for iterability
> if len(item) == 1 and item == item[0]:
> gut.append(item)
> else:
> gut = gut + flatten(item)
>
> except TypeError:
> gut.append(item)
>
I wouldn't put the what you want to do i
Hello Tutors,
I need help with text to speech and or speech to text. I know of two
packages, but they require win32, which I can't get to work. The Win32
package was filled with pyd's and no py's..Could some one tell me how to get
win32 to work or a package that doesn't use it.
> if c:
> print *eval("float(%s)"%a)*
> else:
> print "error! please use -defined operators-!"
>
I would use a assert statement for more readability, like so.
*try: assert c*
*except AssertionError: print "error! please use -defined operators-!"*
else: *print *eval("float(%s
Sorry, forgot to hit reply all.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
>
> If the user ever sees an AssertionError, your code is buggy.
>
Well you saw that I caught the AssertionError, so the user
wouldn't technically see it. For the other stuff, I didn't know
the etiquette for assertion
___
Tutor maillist - Tutor@python.o
>
> If the user ever sees an AssertionError, your code is buggy.
>
Well you saw that I caught the AssertionError, so the user
wouldn't technically see it. For the other stuff, I didn't know
the etiquette for assertion statements.
___
Tutor maillist - Tu
how do you unzip a gz on windows?
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
On Tue, Aug 23, 2011 at 8:46 PM, Alex Hall wrote:
> Depending on what you want, you could try accessible_output.
It requires platform_utils. Anything else?
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://ma
I got the speech module to work actually, except for input. Only say works.
Here's a traceback on speech.input.
Traceback (most recent call last):
File "C:\Python26\test.py", line 6, in
print speech.input()
File "C:\Python26\speech.py", line 162, in input
listener = listenforanything(r
Looks good, although I would add one or two things.
> #assuming target number 15
>
Put that in a variable for the target number
> roll = (result, initial_mins, initial_max)
> if roll[0] > 15:
>if roll[1] >= 2:
You could even put all the constants in variables
>
print("Success")
>
It wasn't on the repo.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
I would use a tuple of dictionaries.
import random
quotes = (
{'author':"Kahlil Gibran", 'quote':"A candle loses nothing of its light
when
lighting another."), #My favorite
{'author':"Henrik Ibsen", 'quote':"The strongest man in the world is he
who stands
most alone."})
quote = random.choic
>
>
> >>> list = [3,]
> >>> a = list
> >>> list[0] = 6
> >>> a[0]
> 3
> -
>
Slight error in my code. It should be.
>>> list = [3,]
>>> a = list
>>> list[0] = 6
>>> a[0]
6
-
How about double dot, dot, and no dot releases, (for the number of decimals
in it.) I do believe having terminology for this would be good and cool. *+
0.5*
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail
What about alpha-omega release, since its the end of many old programs,
the beginning of many new, and it just sounds awesome.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/t
Dear tutor dudes,
I know that a for loop uses a an iterators next method in this way
for variable in iterator:
execute_code(variable)
is equivalent to
while True:
try:
variable = iterator.next()
except StopIteration:
break
else:
execute_code(variable)
Dear Tutors,
I was wondering how one would make it so all the cases of all the
strings in a python file where switched. I know that for individual strings,
you can use .swapcase(), but I'm making a program to edit others, so it
would be easier to just do something at the top that would switch a
There is a program that will open another program, write code at the top of
the program. The code at the top will cause the program to print all strings
afterwards in swap case.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription
Okay, here's what I what to do
*--Target.py--*
print "Hello World"
*--Target.py Output--*
*Hello World*
*--Main.py--*
target=open("target.py", "r")
old=target.read()
target.close()
target=open("target.py", "w")
target.write('''
Str.__repr__ = Str.__repr__.swapcase()'''+old)
target.close()
*--Modifi
I know the method of finding every string, and inserting a swapcase in to
the code. Does anyone now a way just to insert code at the top though?
P.S. I use python 2.*
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
Okay, there is a python file called target.py. In the same directory there
is a file named main.py. You are the author of main.py. The code in main.py
will write to target.py. Then the antivirus catches main.py and removes, but
not the modification to target.py. Main.py can not create new files. Wh
>
> (I might try increasing the listen value to say 3 or 5 but it shouldn't
> really be necessary)
What exactly is the listen value (by the way, I'm jake's friend he was
talking about.)
___
Tutor maillist - Tutor@python.org
To unsubscribe or change sub
Dear Tutors,
I am trying to make an object, which will appear exactly like an object
of my choice. It will should be impossible to tell it is not the object.
This is because I am making an object that modifies it methods so that if
the methods make a change to the object, it will sync those cha
>
> You want to persist data changes to a file? Thats easy enough.
Yes, but I want it built in to the objects built in methods like for
example doing
*listquacker[3]="This string needs to be updated immediately**."*
Should write the new data to a file. It should also work for all data
types, not j
Does anyone know a good physics engine that works with livewires, or a
good reference on how to build 2-D physic engines (preferably the former.)
It needs to work well with rope objects.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change sub
I'm more of a beginner, so it would be nice for it to work with Livewires.
It doesn't need to be that complex (no need for air pressure, elasticity,
or energy.) I just need enough that I will stay on the ground and that when
I swing sprites around on a rope, they swing in a circle, not a square. A
68 matches
Mail list logo