raw_input takes one argument.
While
>>> x = 5
>>> b = 10
>>> print x, "+", b, "=", x+b
will print 5 + 10 = 15, you could also have written it -
>>>print str(x) + " + " + str(b) + " = " + str(x+b)
Now, if I have a function -
def divByTen(number):
return number/10
I can call it like s
Nathan Pinno wrote:
> guess = float(raw_input(a," + ",b," = "))
> TypeError: [raw_]input expected at most 1 arguments, got 4
>
> guess = float(raw_input(a," + ",b," = "))
> return answer, guess
>
hint: how many arguments are you passing to raw_input here?
--
Poor Yorick
mailing list wrote:
>It's like Pythoncard, a layer of abstraction makes 90% of what you do
>easier, and the other 10% you can still do the manual way.
>
>I don't know, I'm also tempted to try and write those layers, if
>anyone would benefit from them. But yeah, would it be better or worse
>for peo
On Friday 16 September 2005 21:30, Nathan Pinno wrote:
> Hey all,
>
> It looks like I started another running debate, the last time I did this, it
> went forever it seemed.
>
> Any hints or help on that original question?
cq is equal to 1
15<=q<=31
cq cannot be >= q
__
I changed the code and got an error:
Here is the screenshot containing the error:
27
Traceback (most recent call last): File
"D:\Python24\add_tutor.py", line 18, in -toplevel- answer,
guess = add(num1,num2) File "D:\Python24\add_tutor.py", line 5, in
add guess = float(raw_input(a,
At 09:30 PM 9/16/2005, Nathan Pinno wrote:
>Hey all,
>
>It looks like I started another running debate, the last time I did this, it
>went forever it seemed.
>
>Any hints or help on that original question?
>
>For clarity, I'll ask it again:
>
>Why won't it enter the quiz? Here is the code again:
>
Hi. I'm using
f = file("foo", 'w')
fileContents = f.readlines()
print fileContents[0] + "Hi!"
and I get:
Foo
Hi!
How can I get rid of that new line? fileContents[1] has Bar.
I wrote the file using Joe (a *nix test editor) and for the new line I
pressed Enter to add Bar.
This is a pain as I don't
Hey all,
It looks like I started another running debate, the last time I did this, it
went forever it seemed.
Any hints or help on that original question?
For clarity, I'll ask it again:
Why won't it enter the quiz? Here is the code again:
{code}
import random
def add(a,b):
answer = a+b
Joseph Quigley wrote:
> Ok... more probs with my GetGarf program...
> First I acidently and permanently deleted all versions and now I've
> improved it but it won't download new images
> Here's the code (attached... sorry :-( )
> More Questions to come later.
> Thanks,
> Joe
Do you know ab
Poor Yorick wrote:
> Joseph Quigley wrote:
>
> You might want to look into Twisted at http://twistedmatrix.com/
>
> A quick google for "python twisted irc" turned up this:
>
> http://sourceforge.net/projects/pynfo/
>
Thanks, but as I forgot to mention, I can't get the twisted
dependencies becaus
Ooops Sorry, no attachment.
Ok... more probs with my GetGarf program...
First I acidently and permanently deleted all versions and now I've
improved it but it won't download new images
Here's the code (attached... sorry :-( )
More Questions to come later.
Thanks,
Joe
#! /usr/bin/env python
Poor Yorick wrote:
> Once again you're implying that there's something wrong with Nathan
> asking for help on this list. Blow it out your hairdo...
No, I did not imply or state that at all. In fact, I was answering your
own statement in which you posted the following valid argument:
> "I'd
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
Today (Sep 16, 2005) at 5:29pm, D. Hartley spoke these wise words:
- ->I know how to use the code completion (hooray for me!) but so far,
- ->most everything else that's going on in PyDev/Eclipse is a mystery to
- ->me. But I managed to get an inter
Thanks to hear that. I will keep posting, though no sales, so not a great
business model. Any help with the original question?
Thanks,
Nathan Pinno
- Original Message -
From: "Byron" <[EMAIL PROTECTED]>
To: "Nathan Pinno" <[EMAIL PROTECTED]>;
Sent: Friday, September 16, 2005 9:25 PM
Subj
Christopher Arndt wrote:
>Hi,
>
>I wonder if there is a shorter form of the following idiom:
>
>list1 = []
>list2 = []
>for item in original_list:
>if condition(item):
>list1.append(item)
>else:
>list2.append(item)
>
>(optional step:)
>
>original_list[:] = list1
>
>
>I call
Byron wrote:
> Hi Nathan C,
>
> PS> No, (for the record only), there is a HUGE difference between
> selling "skills" and selling code that someone else wrote. :-D
>
Once again you're implying that there's something wrong with Nathan asking for
help on this list. Blow it out your hairdo...
B
Nathan Pinno wrote:
> Brian and all,
>
> I am just asking for help - after all I write most each program myself,
> and just ask for help in debugging it whenever I cannot figure it out.
> If this is being sneaky, I apologize, and won't ask for help anymore.
No, don't do that... Happy that you
Hi Nathan C,
No, I was not saying that he needed to stop. However, I thought it was
kind of funny / entertaining that the tutors here are helping to develop
his code for free -- and then he gets to sell it online! Quite the
efficient business model there... :-)
PS> No, (for the record only)
Brian and all,
I am just asking for help - after all I write most each program myself, and
just ask for help in debugging it whenever I cannot figure it out. If this
is being sneaky, I apologize, and won't ask for help anymore.
I wanted help, or at least a hint, but instead, you laugh at me.
O
One last note then I really have to go to bed...
There is a program to help browse the results of profiling a Python program.
It's not fancy but it helps.
http://webpages.charter.net/erburley/pprofui.html
Kent
___
Tutor maillist - Tutor@python.org
h
Byron wrote:
> Hi Nathan,
>
> Wow, I have to give you some good credit -- you are quite the sneaky and
> innovative business guy. You get the free tutors here to help write
> your programs and when they are finished, you sell them on your website
> for $20.00 each! I bet more businesses wish
Kent Johnson wrote:
>>Bernard Lebel wrote:
>>>Btw in case you wonder, I don't use BeautifulSoup because somehow it
>>>takes 20-30 seconds to parse a 2000-line xml file, and I don't know
>>>why. ElementTree is proving very performing.
>
> I took a bit of a look at this using the Python profiler. Th
Kent, sorry to send you back your request, I won't access to file
until Monday, so either you send it to Danny, either Dannay waits
until Monday. I'm fine with you sending the file to Danny.
Guys let me know if Danny receives the file, I'll send it Monday if not.
And thanks for looking into this,
Hi Nathan,
Wow, I have to give you some good credit -- you are quite the sneaky and
innovative business guy. You get the free tutors here to help write
your programs and when they are finished, you sell them on your website
for $20.00 each! I bet more businesses wish they could do business t
cq is for "current question" and q is for "question"
therefore cq >= q should be correct most of the time
- Original Message -
From: "Danny Yoo" <[EMAIL PROTECTED]>
To: "Nathan Pinno" <[EMAIL PROTECTED]>
Cc:
Sent: Friday, September 16, 2005 7:39 PM
Subject: Re: [Tutor] Why won't it enter
> I've got this program I've written that should give an addition quiz,
> except it never enters the quiz. How do I make it enter the quiz?
Hi Nathan,
Let's look at a small snippet of the code.
> q = random.choice(range(15,31))
> cq = 1
What does 'q' stand for? What does 'cq' stand
Danny Yoo wrote:
>>If you look at the list, for a while the functions are being called 777
>>times. This is probably the number of start tags in the document. But
>>when you get to recursiveChildGenerator(), all of a sudden it is called
>>898655 times, over 1000 times for each call to _fetch()! Thi
Thanks, but when I run the code, even after that change it always just
prints the questions, correct questions(which is always 0), and percent
right(always 0). How do I make it enter the quiz.
Thanks,
Nathan Pinno
- Original Message -
From: "John Fouhy" <[EMAIL PROTECTED]>
To: "Nathan Pi
On 17/09/05, Nathan Pinno <[EMAIL PROTECTED]> wrote:
> def add(a,b):
> answer = a+b
> guess = float(raw_input(a," + ",b," = "))
Hi Nathan,
When you define a function, any variables you create in the function
are _local_ variables. This means that they only exist within the
function, a
Hi all,
I've got this program I've written that should give an addition quiz,
except it never enters the quiz. How do I make it enter the quiz?
Here is the code:
import random
def add(a,b): answer = a+b
guess = float(raw_input(a," + ",b," = "))
num1 = random.choice(range(1,10))nu
> Hello there !
> i am having a problem with threading.
> OK, i have this GUI app that i am building with pygtk.
> there is a process (four actually, just working on getting one right now)
> that needs to run in the background.
> there is a button that starts the background function. But, it locks
Hey all,
Will the following code ever exit, or do I have to change something so that
it will exit? It's a sample of what I'm currently working on.
import random
def add(a,b):
answer = a+b
guess = float(raw_input(a," + ",b," = "))
num1 = random.choice(range(1,10))
num2 = random.cho
I know how to use the code completion (hooray for me!) but so far,
most everything else that's going on in PyDev/Eclipse is a mystery to
me. But I managed to get an interactive interpreter as an external
tool, so that's a lot of progress for me.
Technically I suppose this is OT, but did you guys
Hi,
I've googled, checked out the Python Cookbook but still can't find
anything usefull. I need to make python IRC client or find one written
in python to start off with. DO you know of anything?
thanks,
Joseph
___
Tutor maillist - Tutor@pytho
> I've always been about to bind each button to one callback function
> which could then determine which button was clicked, and from that
> data grab the necessary data and perfrom the operations on that
> data.
There are several ways to do this.
The most direct is to use bind which passes an
Ok... more probs with my GetGarf program...
First I acidently and permanently deleted all versions and now I've
improved it but it won't download new images
Here's the code (attached... sorry :-( )
More Questions to come later.
Thanks,
Joe
___
Tut
> If you look at the list, for a while the functions are being called 777
> times. This is probably the number of start tags in the document. But
> when you get to recursiveChildGenerator(), all of a sudden it is called
> 898655 times, over 1000 times for each call to _fetch()! This is a
> staggeri
Kent Johnson wrote:
> Bernard Lebel wrote:
>
>>Hello,
>>
>>With ElementTree, can you search a tag under an Element by not only
>>specifying the tag label, but also some tag attribute values? That
>>would be in the case where I have several tags with the same label but
>>with various attribute valu
> Daniel Watkins wrote:
>
>>I'm currently trying to write a script that will get all the files
>>necessary for a webpage to display correctly, followed by all the
>>intra-site pages and such forth, in order to try and retrieve one of the
>>many sites I have got jumbled up on my webspace. After star
If you would like to talk to me directly, (without the use of cluttering the
list -- I mean, you can, they don't mind, but one-on-one is okay with me) I
have very few things to do, and would be happy to help you out. I have a
tad of experience in python (about a years' worth of fiddling, actual
Okay, how about this?
#
import os
from fnmatch import fnmatch
def simplewalkgen(toplevel):
"""Yields full paths of all the text files in all the subdirectories"""
for root,dirs,files in os.walk(toplevel):
for x in files:
ok = os.path.join(r
Two further suggestions.
1) Do you believe each class have to be in a seperate file? Is that habit
from Perl?
Try putting each class in one library file and then importing as
needed/all into main script to be used
as desired, maybe coexistent with the dictionary approach mentioned
2) Ho
> As a file object, we can use the methods that files provide:
>
>http://www.python.org/doc/lib/bltin-file-objects.html
>
> But the one we'll probably want is 'write()': the write() method of a file
> object lets us send content out, without any adulteration:
For some odd reason I love doing this...
1) Save this code and run it as is
2) Screen instructions *should* be intuitive
enough
3) When entering file name, include extension (it uses the
difference between py and pyw to know if it needs console)
4) When done, there should be two ne
> You need to call the init method of the inherited class(es) from
> within your init. It's conventional to call the superclass
> constructor
> before doing your own initialisation so it should look like:
>
>def __init__(self, num):
>Thread.__init__(self)
>print "__init__: Num =
Might I suggest that you use the built in min() and max()
because they are probably faster.
Jacob
- Original Message -
From:
JackA
To: tutor@python.org
Sent: Monday, September 12, 2005 11:50
PM
Subject: [Tutor] GETTING AN _.EXE VERSION
OF _.PY pro
It sure does! Thanks.
For great sites go to: http://falcon3166.tripod.com
For great products go to: http://zoffee.tripod.com
- Original Message -
From: "Danny Yoo" <[EMAIL PROTECTED]>
To: "Nathan Pinno" <[EMAIL PROTECTED]>
Cc: "Tutor mailing list"
Sent: Friday, September 16, 2005 4:36 PM
On Fri, 16 Sep 2005, Nathan Pinno wrote:
> It sure does. Thanks Danny. One final question: Is it possible to write
> one setup.py and use it for multiple Python programs?
Just to make sure, we are talking about the Distutils setup.py that's used
to build distributions of Python applications, ri
> I've been able to bind each button to the same callback function (that
> part's trivial) but what hasn't been trival is determining which button
> was clicked and, from this information, gathering the correct datum from
> the list of StringVars which make up the first label text.
Hi David,
I
Greetings all:
First off, the necessary statistics: Python 2.4 using Tkinter as a GUI
manager.
Now, the problem: I've got an interface that generates a number of
buttons. Each of these buttons performs the same basic task over
different data based on which button is clicked. In other langu
It sure does. Thanks Danny. One final question: Is it possible to write one
setup.py and use it for multiple Python programs?
Thanks,
Nathan Pinno
For great sites go to: http://falcon3166.tripod.com
For great products go to: http://zoffee.tripod.com
- Original Message -
From: "Danny Yoo"
On Fri, 16 Sep 2005, Nathan Pinno wrote:
> I was curious about what I have to include in the setup.py file. Do I
> have to include such statements as "import random" if the code uses
> import random and the random functions in its code for example?
Hi Nathan,
Each module is responsible for its
Thanks Kent, I'll check your suggestion out.
I have sent you the xml file.
Bernard
On 9/16/05, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Bernard Lebel wrote:
> > Hello,
> >
> > With ElementTree, can you search a tag under an Element by not only
> > specifying the tag label, but also some tag
Bernard Lebel wrote:
> Hello,
>
> With ElementTree, can you search a tag under an Element by not only
> specifying the tag label, but also some tag attribute values? That
> would be in the case where I have several tags with the same label but
> with various attribute values.
>
> Right now I do a
At 10:12 AM 9/15/2005, Christopher Arndt wrote:
>Hi,
>
>I wonder if there is a shorter form of the following idiom:
>
>list1 = []
>list2 = []
>for item in original_list:
> if condition(item):
> list1.append(item)
> else:
> list2.append(item)
Consider (5 lines instead of 7):
Hello,
With ElementTree, can you search a tag under an Element by not only
specifying the tag label, but also some tag attribute values? That
would be in the case where I have several tags with the same label but
with various attribute values.
Right now I do a loop over every tag of the same labe
Pierre Barbier de Reuille schrieb:
> Well, I have some comments ^_^
As should be always expected, when it comes to benchmarking ;-)
> First, about the function 6, it is exactly equivalent (and a little bit
> quicker) to use:
> [...]
> That is, put the try block outside the loop ... however, if th
Well, I have some comments ^_^
First, about the function 6, it is exactly equivalent (and a little bit
quicker) to use:
===8<==8<==8<==8<==8<==8<==8<==8<==8<===
def cinderella6(original_list, condition):
"""Using while and list popping."""
list1 = []
i
Hey all,
I was curious about what I have to include in the setup.py file. Do I have
to include such statements as "import random" if the code uses import random and
the random functions in its code for example?
Hopefully this is not a beginner's question,
Nathan Pinno
For great sites go to
Terry Kemmerer schrieb:
>
>
> "Bearing in mind that shorter is not necessarily better..."
>
> Wouldn't shorter, as a rule of thumb, as in less language statements, mean
> fewer
> executions, and therefore faster?
Well, see for yourself...
I wrote a little benchmarking script for different so
Pierre Barbier de Reuille schrieb:
> Well, in the specific case of numeric arrays, you can use Numeric or
> numarray :
>
> from Numeric import array, compress
>
> ol = array(original_list)
> selection = array([condition(i) for i in original_list)
> list1 = compress(selection, ol)
> list2 = compre
Srinivas Iyyer wrote:
> I want to find such instances of jack and jill's that
> fall in the same ranges and they should be in opposite
> to each other.
>
> Truely, I always flunk and my mind gets blackedout
> when I see these number ranges. I do not know how to
> write : check "if a range of num
Well, in the specific case of numeric arrays, you can use Numeric or
numarray :
from Numeric import array, compress
ol = array(original_list)
selection = array([condition(i) for i in original_list)
list1 = compress(selection, ol)
list2 = compress(!selection, ol)
Even better, if condition can be
> "Bearing in mind that shorter is not necessarily better..."
>
> Wouldn't shorter, as a rule of thumb, as in less language
> statements, mean fewer
> executions, and therefore faster?
Only in a very general sense. In practice a complex expression
(such as a list comprehension or a regular expres
64 matches
Mail list logo