Michelle:
Are you familiar with writing functions?
Here I've created a function named getInputs.
I've also created a few test cases to verify that (a)
my understanding of the problem is correct, and (b) my
solution is correct.
It's important to think about how your program is
supposed to behave
Mike Hansen wrote:
> -
> What are some good books on Python?
>
> See the Python wiki http://wiki.python.org/moin/PythonBooks or search
> comp.lang.python or the tutor archives since this is a very frequently
> asked.
>
> If you
Mike Hansen wrote:
> -
> What's the difference between "import foo" and "from foo import *"?
>
> import sys
>
> This brings the *name* "sys" into your module.
(Technically, it binds the name "sys" to the object that is the sys mo
Matt Richardson wrote:
> Just verifying what I looked up earlier: are strings and binary
> (through struct.pack) the only data types that can be sent through a
> socket? This is my first crack at socket programming, so I'll probably
> have lots of questions to bug you with.
The socket library
-
What is if __name__ == "__main__" for?
The 'if __name__ == "__main__": ..." trick exists in Python so that our
Python files can act as either reusable modules, or as standalone
programs. As a toy example, let's say that we hav
-
What are some good books on Python?
See the Python wiki http://wiki.python.org/moin/PythonBooks or search
comp.lang.python or the tutor archives since this is a very frequently
asked.
If you have no programming experience, tr
I need some help with this question and answer. It appears that useless
Python is gone. uselesspython.com. Is it still around? Does anyone have
any ideas on this one?
-
I'm learning Python. What should I program?
If you have a
-
What's the difference between "import foo" and "from foo import *"?
import sys
This brings the *name* "sys" into your module.
It does not give you access to any of the names inside sys itself (such
as
exit for example). To acc
Well, I posted a few questions to http://pyfaq.infogami.com/tutor-index
late last week. Since the next questions and answers are a bit on the
long side, I'll send them to this list in multiple messages. Please let
me know if you have any corrections or clarifications. Below is a
reworked questi
Just verifying what I looked up earlier: are strings and binary
(through struct.pack) the only data types that can be sent through a
socket? This is my first crack at socket programming, so I'll probably
have lots of questions to bug you with.
thanks,
Matt
__
> > "Beginning Python: From Novice to Professional", by
> > Magnus Lie Hetland
>
> There's also, on-line, Dive Into Python by Mark Pilgrim, often
> recommended as a good intro book
both of these are very good books, but the target audience is slightly
different, as is for "Core Python" -- 2nd ed
> "Beginning Python: From Novice to Professional", by
> Magnus Lie Hetland
> Publisher: Apress (September 26, 2005)
> ISBN: 159059519X
I would heartily second this recommendation. Different folks have
different learning styles, and having a good overview can make weeding
out the internet informati
On Wed, 2006-05-03 at 15:33 -0400, MICHELLE EVANS wrote:
> OK, I've tried a different approach to this.
> How do I get this to stop by using -1?
> I do not want this to print until either 5 inputs have been entered or -1
> has been entered. See below:
>
use a "for block" rather than a "while blo
> Just wondering how many lines of code is the maximum to post in the list
> to have it critiqued. I realise people are using their own time to help
> others in here for no real personal gain and I would hate to impose on
> their goodwill. Would about 100 lines of code be considered too much?
M
I have made scripts that work on many files (sometimes just some tens)
and appears that filesystem structure caching in Linux is very
efficient. That's why it runs very fast later.
I've seen this in Slackware, Debian, and RH, so I guess it's just a
linux/FS/disk thing.
Try doing 'find' combin
OK, I've tried a different approach to this.
How do I get this to stop by using -1?
I do not want this to print until either 5 inputs have been entered or -1
has been entered. See below:
# Add number of per hour
numbers = []
stop = None
while stop != "-1":
number = int(raw_input("Run number(-
For this case, just wanting to stop the code for testing, using a short
statement as the arg is not only OK it is an example in the doc.
exit( [arg])
Exit from Python. .. In particular, sys.exit("some error message") is a
quick way to exit a program when an error occurs.
I agree I should
It would be similar to Perl's die() commmand. But no, in Python the
argument is the error status of your script.
You'd have to do something like
def exitnow(arg):
print arg
#maybe sys has not been imported
import sys
sys.exit(1)
Hugo
Ertl, John wrote:
> Matthew,
>
> Not su
On Wed, 3 May 2006, Igor wrote:
> And I thought I understood python pretty well. Until I got hit by this:
>
def f(x):
> ... print x
>
cb = [lambda :f(what) for what in "1234"]
for c in cb:c()
> 4
> 4
> 4
> 4
Hi Igor,
I think you're getting caught by something that isn't quite
Igor wrote:
> Hi.
>
> And I thought I understood python pretty well. Until I got hit by this:
>
def f(x):
> ... print x
>
cb = [lambda :f(what) for what in "1234"]
for c in cb:c()
> 4
> 4
> 4
> 4
You haven't actually created a closure because you don't have any nested
scopes,
On Wed, 2006-05-03 at 14:00 +0200, Igor wrote:
> Hi.
>
> And I thought I understood python pretty well. Until I got hit by this:
>
> >>> def f(x):
> ... print x
>
> >>> cb = [lambda :f(what) for what in "1234"]
> >>> for c in cb:c()
> 4
> 4
> 4
> 4
>>> cb = [(lambda x=what:f(x)) for what in "
Are you just trying to make a continuation?
On 5/3/06, Igor <[EMAIL PROTECTED]> wrote:
> Hi.
>
> And I thought I understood python pretty well. Until I got hit by this:
>
> >>> def f(x):
> ... print x
>
> >>> cb = [lambda :f(what) for what in "1234"]
> >>> for c in cb:c()
> 4
> 4
> 4
> 4
>
> And
Hi Frank,
A couple of questions / issues here. Not really an answer, but hopefully
a start in the right direction.
Why do you need to use entity escapes at all? If you have a correct
charset declaration you can use whatever encoding you like for the web
page - latin-1, koi8-r, shift-jis, etc.
Matthew,
sys.exit() is one way to do it.
Or you could use a conditional to toggle printing the output.
-mtw
On Wed, May 03, 2006 at 05:35:04PM +0100, Matthew Webber ([EMAIL PROTECTED])
wrote:
> This has got to be trivial, but I can't find the answer ... I want to stop
> execution of my main sc
How about:import syssys.exit()On 5/3/06, Matthew Webber <[EMAIL PROTECTED]
> wrote:This has got to be trivial, but I can't find the answer ... I want to stop
execution of my main script half way through. This is just for debugging -the code in the bottom half of the script generates a whole lot of
Matthew,
Not sure if ipython is different but have you tried sys.exit("stoping now")
You could also put in a flag to turn the printing on and off so it wont
print it out when you are testing.
John
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Mat
This has got to be trivial, but I can't find the answer ... I want to stop
execution of my main script half way through. This is just for debugging -
the code in the bottom half of the script generates a whole lot of output
that I don't want. Inserting "break" or "return" doesn't work, but somethin
I have learend a great deal of python, and I have never bought a book.
All the information one really needs is available freely on the
internet.
As long as you understand the basic data types you should be able to
piece together what you need from the internet.
___
Greetings, John,
For my money, that book is:
Learning Python, 2nd Edition
By David Ascher, Mark Lutz
Publisher: O'Reilly
Pub Date: December 2003
ISBN: 0-596-00281-5
Pages: 620
$25.19 new, 18.47 used (+ shipping)
From amazon.com
I taught myself Python wit
(Tip: Best to use reply-to-all when responding to an email on the list)
On Tue, 2006-05-02 at 21:34 -0400, MICHELLE EVANS wrote:
> number1 = int(raw_input("Run number 1 (-1 to end) : "))
> number2 = int(raw_input("Run number 2 (-1 to end) : "))
> number3 = int(raw_input("Run number 3 (-1 to end) :
(Tip: Best to use reply-to-all when responding to an email on the list)
On Tue, 2006-05-02 at 21:34 -0400, MICHELLE EVANS wrote:
> number1 = int(raw_input("Run number 1 (-1 to end) : "))
> number2 = int(raw_input("Run number 2 (-1 to end) : "))
> number3 = int(raw_input("Run number 3 (-1 to end) :
This is what I have so far. Can anyone
help?
> number1 =
int(raw_input("Run number 1 (-1 to end) : "))> number2 =
int(raw_input("Run number 2 (-1 to end) : "))> number3 =
int(raw_input("Run number 3 (-1 to end) : "))> number4 =
int(raw_input("Run number 4 (-1 to end) : "))> number5 =
in
Hi,
I need to do some encoding of text that will be used in a web page.
The text has been translated into 16 different languages.
I've managed the manual translation of some of the more regular
languages (French, Spanish, Italian etc...) , by
replacing characters like 'á' with the numeric entity
*** 50% DISCOUNT to STUDENTS/TEACHERS ***
Dear fellow list members,
Below is the announcement we've just made this morning about our
upcoming advanced Python course, May 17-19, 2006. This advanced course
will be offered again in Nov 2006. In Aug 2006, we will have another
intensive introduction
--- John Connors <[EMAIL PROTECTED]> wrote:
> G'day,
>
> I know this is a difficult question to answer
> because it's probably more a
> matter of personal taste than anything else.
>
> I'm retired so money has to be watched fairly
> carefully and books are kind
> of expensive down here in Aust
Hi.
And I thought I understood python pretty well. Until I got hit by this:
>>> def f(x):
... print x
>>> cb = [lambda :f(what) for what in "1234"]
>>> for c in cb:c()
4
4
4
4
And even this works
>>> what = "foo"
>>> for c in cb:c()
foo
foo
foo
foo
I expected the output to be 1 2 3 4. Now I
On 5/3/06, John Connors <[EMAIL PROTECTED]> wrote:
> G'day,
>
> I know this is a difficult question to answer because it's probably more a
> matter of personal taste than anything else.
It is also a VFAQ. Check the archives - I'm not aware of any radical
new books that would render the most recen
G'day,
I know this is a difficult question to answer because it's probably more a
matter of personal taste than anything else.
I'm retired so money has to be watched fairly carefully and books are kind
of expensive down here in Australia but the Mrs has said I can lash out on a
book for my bir
38 matches
Mail list logo