Based on what you initally stated, that you would have a list containing 500
numbers, and for each number, there would be a player, using a dict would be
ideal. For example, once you've got the winning number, how do you then
intend on handling what happens to each player as they win? Do you intend
As a rule, I tend to open and close a connection based on what I'm doing
with the database. If I were to directly run a series of queries one after
another, I would keep it open until a change in interface (referring to
changes in objects, both masters and slaves).
Also, you can perform any query t
>
> >Which is suggestible just in case the app or program crashes during use.
>
(To O.P)
Indeed, though in such cases you must rely on your programmers instinct to
make the right decision - what applies for certain instances of an
application doesn't always conform with what applies for other inst
>
> > But to be sure, it is perfectly safe and valid to open the database on
> program startup, commit changes during the process and close it
> on exit (or unhandled exception)?
As long as it makes sense to do so, yes. There's no point having an open
connection to a database if there doesn't ne
I'll just add there's a better way to do both of the examples you've done
there -
> > a, b = 0, 1
> > while b < 10:
> >print '%i%i' % (a,b) + ',',
> >b = b+1
An easier way of doing this is to instead do the following, including the a
(although not needed, as simply using 0 would work) -
>
> > I am caught off guard but what is the purpose of the plus sign? I don't
> recall seeing it used like that.
>
The + sign there is used for concating two strings together, for example -
output = 'foo' + 'bar'
Will give the variable output the value of the characters 'foobar'. This
also work
It's part of the Python naming conventions laid out by PEP 8. Have a read
here - http://www.python.org/dev/peps/pep-0008/.
Hope this helps.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mail
He has no classes in there. Therefore, there is no place it should be in
this code. Please remember this is Python, and not Java nor anything else.
To quote directly from PEP 8, in regards to functions and variables,
"should be lowercase, with words separated by underscoresas necessary to
improve
>
> Please quote enough of the previous message to establish context -- when
> you are replying to the message, it is fresh in your mind. When others read
> your reply (possibly days later like I'm doing now), the context is anything
> but clear and your message comes across as merely mysterious a
>
> "Please" and "Thank you" are rude? Oh my, have you lived a sheltered life
> :)
>
Nej, it was your condescension that I found rude. Also, you did it again,
perhaps on purpose though.. ;)
___
Tutor maillist - Tutor@python.org
To unsubscribe or change
> import random
> for x in range(0,1):
> num = random.random()
> print (num)
> m=input('input pass:')
> if m==num:
> print('you entered correctly, proceed')
Your problem lines in the differences in between the types - your num
variable is a float, whereas your m variable i
Adding reply to list -
On Sat, Jan 15, 2011 at 2:55 AM, walter weston wrote:
> I only want to generate a random number once
>
Then you don't need a for loop. Think of a for loop as something you
need when you want to run a piece of code several times, for example
for x in range(1,6):
print('
Based on the number of emails you're sending to the mailing list, I
suggest you read a tutorial, work your way through it, and return with
any further issues you come across.
http://docs.python.org/tutorial/ is a good start, and I recommend any
of the tutorials on
http://wiki.python.org/moin/Begin
> minus_weekends=hourly_income*64
> total_income=int(minus_weekends-sum_of_monthly)
Here's problem number 1 - you're taking the values the wrong way around :)
It should be total_income=int(sum_of_monthly-minus_weekends)
> sum_of_monthly=int(yearly_income/12)
Here's the second problem
> I get this error when I try and load the datetime module,
>
> Traceback (most recent call last):
> File "C:/Python27/TIMED_PROGRAM.py", line 2, in
> datetime.ctime()
> AttributeError: 'module' object has no attribute 'ctime'
Your problem, I guess comes from you having code like the follow
On Thu, Feb 3, 2011 at 11:11 AM, C.Y. Ruhulessin
wrote:
> For an application that I am designing, i'd like to achieve the same
> functionality, so the end users don't have to bother installing Python
> themselves.
> Can anybody shed their lights on how one would program this?
> kind regards,
The
On Thu, Feb 10, 2011 at 4:17 AM, Bill Allen wrote:
>
> I have found there are a few systems available to package Python programs as
> standalone programs for distribution. Do the folks here have any
> recommendation or comment on any of these?
My favourites are http://www.py2exe.org/ and http:/
> I have found that this line will return an error every time while running
> the completed program, unless I enter a number. If I enter a numeric value
> the program will continue on as written.
When it comes to things like error messages, you need to post enough
code and the _exact_ error messag
On Tue, Mar 8, 2011 at 6:38 PM, Vickram wrote:
> The python result is wrong because I may have misread the C++ code
Well, really, I suggest you read a tutorial on Python - you don't seem
to be getting a hang on the basics, for example, there's no need for
to use the float() function.
On Mon, Mar 14, 2011 at 8:56 AM, Alan Gauld wrote:
> "Yasar Arabaci" wrote
>> Apperantly, I can change something (which is mutable) inside a list
>> without even touching the list itself :)
> But the point is that you *are* touching the list.
> In this case you have two names referring to the sa
On Tue, Apr 12, 2011 at 5:40 PM, wrote:
> Hello,
>
> I would like to print the adresses of every image that are on the main page
> of www.columbia.edu. Do you know how to do this?
Yes, I do. ;)
As this sounds like homework -
Firstly, you want to grab the source code of the webpage.
Secondly,
On Sat, Apr 16, 2011 at 4:33 AM, Lea Parker wrote:
> budget = float(raw_input('Enter the amount of your budget for the month:
> '))
>
> # Validation variable for budget
>
> while budget <0:
>
> print 'ERROR: the budget cannot be a negative amount'
>
> budget = float(raw
On Sat, Apr 23, 2011 at 11:58 PM, pierre dagenais wrote:
> The following code works as expected with python version 2.6.5, but with
> version 3.1.2 I get the following error:
>
> pierre:/MyCode/mesProjets$ py3 test.py
>
> Traceback (most recent call last):
> File "test.py", line 3, in
> sock
On Wed, Apr 27, 2011 at 1:32 PM, Johnson Tran wrote:
> Program:::
> model=raw_input("What kind of car do you drive?")
> number_string1=raw_input("How many gallons have you driven?")
> number1 = float (number_string1)
There's no validation for the variables when you try to convert them
(see bottom
On Wed, Apr 27, 2011 at 9:17 PM, Johnson Tran wrote:
> Thanks for the reply Alan and Noah, I really appreciate the help. I am really
> trying to understand this although still cannot seem to grasp it all. I have
> modified my program although now it seems to be giving me the wrong answer
> with
On Tue, May 10, 2011 at 5:27 AM, Clara Mintz wrote:
> Sorry I am completely new at python and don't understand why this function
> is returning an empty dictionary. I want it to take a list of files open
> them then return the number of characters as the value and the file name as
> the key.
> def
On Wed, May 18, 2011 at 11:27 AM, Cindy Lee wrote:
> Thanks for the advice. I seem to keep getting the same errror:
> Any advise? Also, is the _add_ string something I should be using?
help(str.__add__)
> Help on wrapper_descriptor:
> __add__(...)
> x.__add__(y) <==> x+y
No, not really.
On Thu, May 19, 2011 at 11:10 AM, Cindy Lee wrote:
> Sorry I am still lost. So I am suppose to use a string? Something like:
> (just not sure is the right string...)
Well, no. The assignment you've been given states the you need to
define a function that takes a string as an argument, for example
On Thu, May 19, 2011 at 7:23 PM, Johnson Tran wrote:
> So I figured out how to use the loop method, thanks. I still cannot seem to
> figure out how to use Len() to show the output of my answers (from all my
> googling Len() seems to be used to count characters?) Also, I am not really
> sure I u
On Thu, May 19, 2011 at 9:14 PM, Neha P wrote:
> C:\>python hello.py
> 'python' is not recognized as an internal or external command,
> operable program or batch file.
This happens because "python.exe" is not in the system path.
> C:\>cd python26
> C:\Python26>python
> Python 2.6.4 (r264:75708,
On Fri, May 20, 2011 at 6:43 PM, michael scott wrote:
> Okay, my title might be undescriptive, let me try to explain it better. I
> want to take a script I've written and make it usable by typing its name in
> the terminal. Perfect example is the python interpreter. You just type in
> the word pyt
On Wed, May 25, 2011 at 6:25 PM, Wolf Halton wrote:
> Is there a less clunky way to do this?
> [code]
> def new_pass():
> series = ['`', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-',
> '=', \
> '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_',
> '+', \
>
On Tue, May 31, 2011 at 10:36 PM, Rachel-Mikel ArceJaeger
wrote:
> Isn't one of the unsolved millenium prize problems one that includes the
> ability to find all of the prime numbers? I'm not sure if your program is
> possible if the input number is large.
> But to check if a number x is an int, j
On Fri, Jun 17, 2011 at 11:34 PM, Victor wrote:
> I am in the process of building a script but I do not know if what I am
> trying to do is possible. So, long story short, I need help.
>
> The concept:
> I am want to be able to ask the user a series of questions in the program
> window.
>
> But h
On Sat, Jun 18, 2011 at 12:46 AM, Chris Calloway wrote:
> University of Washington Marketing and the Seattle Plone Gathering host the
> inaugural Seattle PyCamp 2011 at The Paul G. Allen Center for Computer
> Science & Engineering on Monday, August 29 through Friday, September 2,
> 2011.
>
> Regis
On Sat, Jun 18, 2011 at 2:15 AM, Steven D'Aprano wrote:
> Noah Hall wrote:
>
>> Just a note, but are these questions jokes?
>>
>>> Know how to use a text editor (not a word processor, but a text editor)?
>>> Know how to use a browser to download a file
On Sat, Jun 18, 2011 at 2:13 AM, Corey Richardson wrote:
> "Noah Hall" wrote
>
>> Of course, if you mean *completely in-place replace* the question,
>> then you
>> will need something like ncurses (if on Linux) -
>> http://docs.python.org/library/curses
On Sun, Jun 19, 2011 at 6:47 PM, Chris Calloway wrote:
> On 6/17/2011 11:03 PM, Noah Hall wrote:
>>
>> On Sat, Jun 18, 2011 at 2:15 AM, Steven D'Aprano
>> wrote:
>>>
>>> Noah Hall wrote:
>>>
>>>> Just a note, but are these ques
> 1984 was not to be taken literally, of course. ;)
>
>
> Well, if you decide that in this day and age that asking whether
> someone knows how to use a browser to download files, or if someone
> knows how to install a program, then that's entirely up to you. I am
> merely in disbelief that you coul
On Sat, Jun 25, 2011 at 9:18 AM, Vincent Balmori
wrote:
>
> The question for this is to make a program that simulates a TV by creating it
> as an object. The user should be able to to enter a channel and or raise a
> volume. Make sure that the Channel Number and Volume stay within valid
> ranges.
On Sun, Jun 26, 2011 at 12:05 PM, Lisi wrote:
> In the following excerpt from a program in the book I am following:
>
> print "If I add %d, %d, and %d I get %d." % (
> my_age, my_height, my_weight, my_age + my_height + my_weight)
>
> is
>
> % (
> my_age, my_height, my_weight, my_age +
On Sun, Jun 26, 2011 at 2:42 PM, Lisi wrote:
> Thanks, Noah and Steven. :-)
>
> On Sunday 26 June 2011 12:24:12 Steven D'Aprano wrote:
>> Lisi wrote:
>> > In the following excerpt from a program in the book I am following:
>> >
>> > print "If I add %d, %d, and %d I get %d." % (
>> > my_a
On Sun, Jun 26, 2011 at 2:02 AM, Vincent Balmori
wrote:
>
> It's working better now. The problem I have left is that I have to set the
> channel and volume values in a range (for both I intend for 0-10). I thought
> the range() would be the choice, but probably I'm not using it right.
I think the
On Sun, Jun 26, 2011 at 8:28 PM, Vincent Balmori
wrote:
>
> I made in elif statement for the channel changer that works for it, but the
> volume systems system boundary does not the way I want it to. If the volume
> is 2 and I lower it by a value of 5, it will accept the volume at a negative
> num
2011/7/5 Válas Péter :
> Hi,
>
> I have a dictionary with the keys 'a' and 'b'. It is not in a class. (I know
> that everything is in a class, but not explicitly.)
> May I use the value of 'a' when defining the value of 'b'? If so, what is
> the syntax?
Yes. The syntax is the same as anything invo
On Thu, Jul 7, 2011 at 3:17 PM, Lisi wrote:
> Hi! :-)
>
> >From the book I am working from:
>
> A shortcut is to do your import like this:
> from ex25 import *
>
> Is this a new and wonderful meaning of the word "shortcut"? _Why_, _how_ is
> that a shortcut for:
>
> import ex25
>
> when it has
2012/1/8 emin :
> http://www.youtube.com/watch?src_vid=QaYAOR4Jq2E&feature=iv&annotation_id=annotation_149056&v=M3g1GEkmyrw
> in this tutorial what does mean x%2 ?
> i think: i * 2% = always even number
> but why not 4,6 or 8? but i * 4(6,8,10,12...)% = always even number too
> for example: 100 *
On Tue, Jan 10, 2012 at 6:24 PM, emin wrote:
> answers = ["yes","no"]
> reaction = ["OK.I GOT IT.But why symbol of percent % not symbol of division
> / ?","PLEASE EXPLAIN MORE"]
>
> print "1st SORRY FOR BAD ENGLISH & DISTURBING:((i am beginner)"
> print "So you want to say it doesnt mean 2 percent
On Wed, Jan 11, 2012 at 7:14 AM, Chris Johnson wrote:
> Hi there,
>
> I am *new* (I cannot put enough emphasis on that!) to Python programming,
> and to programming in general. I am trying to write out a statement that
> will protect a file on my computer from being run unless I enter the right
>
On Wed, Jan 11, 2012 at 10:24 AM, Steven D'Aprano wrote:
> Noah Hall wrote:
>>
>> On Wed, Jan 11, 2012 at 7:14 AM, Chris Johnson
>> wrote:
>>>
>>> Hi there,
>>>
>>> I am *new* (I cannot put enough emphasis on that!) to Python progra
50 matches
Mail list logo