Dear tutor,
I have a question regarding a functions based assignment. The assignment
is:
For this project, you will write two small Python programs:
Investment Thresholds
Define a Python function threshold(dailyGains, goal) that behaves as
follows. The first pa
Jeff Younker wrote:
> Or if you're using python 2.5 then you can use with statements:
>
> from __future__ import with_statements
> from contextlib import closing
> ...
> def mails(self):
> with closing(open_file(self.direcciones)) as fIncl:
>with closing(open_file(self.excluidas))
"Shumail Siddiqui" <[EMAIL PROTECTED]> wrote
> I have a question regarding a functions based assignment. The
> assignment is:
> For this project, you will write two small Python programs:
>
OK, Since this is for homework I cannot give you the answers
but I will point out some things you s
Shumail Siddiqui wrote:
> Dear tutor,
> I have a question regarding a functions based assignment.
I agree with Alan.
And I wonder why this assignment is hard for you.
Are you in the wrong course (insufficient prerequisites)?
Is the instructor failing to provide the resources you need?
Are
Hi Python Practicioners!
I'm trying to come to terms with how Python handles the scope of
objects. In particular, I'd like to create an instance of one class and
make it available inside instances of other classes. Something like:
# Test 1-
# I want a "globa
James Newton wrote:
> # So that I can call one of its functions from another instance
> class Bar(object):
> def doBar(self):
> # I'd like be able to call a "global" object, but this fails:
> # global name 'foo_instance' is not defined
> return foo_instance.doFoo()
It
On Jan 7, 2008 12:07 PM, James Newton <[EMAIL PROTECTED]> wrote:
> Hi Python Practicioners!
> ...
> I am not so much concerned in getting this to work (I can already do
> that); I am more concerned with understanding how to treat this in the
> most Pythonesque way.
>
I'd like to get the party lin
Hello Everyone-
I'd like to announce the tutorials sessions for PyCon 2008 (US). As you may
know, this year PyCon is being held in Chicago, Illinois March 14-16 with
the Thursday before (the 13th) being "Tutorial Thursday". We are expecting
nearly 600 Python enthusiasts to meet up for the confer
Hi,
I'll try to swallow down the "Globals are eevil" comment, there's enough
literature on that already.
Maybe I'm spoiled from programming too much Java in the last year, but
IMHO it's a good idea to put the singleton instance into the class
itself rather than into some module.
This way, you (c
Kent Johnson [mailto:[EMAIL PROTECTED] wrote:
> Why does a Counter need to know about screen position?
> It sounds like the Counter might be doing too much.
> Maybe the Counters should be attributes of the Board
> which can ask them their index numbers and do the
> appropriate drawing?
> Maybe the
Very good questions indeed. Also familiar ones to me. The first is
Exercise 5.28 and the second is Exercise 5.23 from the text book
"Object-Oriented Programming in Python."
Alan's advice was very sound, but I strongly recommend that you work
with your instructor in guiding you through these prob
Marc Tompkins wrote:
> I'd like to get the party line on this as well. For a while now, I've
> made a habit of defining an empty class called Global (Mr. Newton's
> could be called Board, of course) at the top of my apps, and using its
> attributes as if they were global variables. It works, o
Torsten Marek wrote:
> Maybe I'm spoiled from programming too much Java in the last year, but
Hmm. Would that be
spoil 3 a: to damage seriously : ruin
or
spoil 4 b: to pamper excessively : coddle
? ;-)
> IMHO it's a good idea to put the singleton instance into the class
> itself rather than int
I assume you realize that jpeg is a lossy format and that consecutively
resizing the same image will no doubt end poorly in image quality.
Also, I assume that you have a better understanding of the NEAREST and
BICUBIC options than I do because you are apparently comparing them. I do
know that thos
> Hi
>
> I was trying to learn about classes in Python and have been playing
> around but I am having a problem with the deepcopy function. I want to
> have a function that returns a clean copy of an object that you can
> change without it changing the original, but no matter what I do the
> origin
Kent Johnson wrote:
> Jeff Younker wrote:
>
>> Or if you're using python 2.5 then you can use with statements:
>>
>> from __future__ import with_statements
>> from contextlib import closing
>> ...
>> def mails(self):
>> with closing(open_file(self.direcciones)) as fIncl:
>>with clo
> Tiger12506 wrote:
>
>> Ouch. Usually in OOP, one never puts any user interaction into a class.
>
> That seems a bit strongly put to me. Generally user interaction should be
> separated from functional classes but you might have a class to help with
> command line interaction (e.g. the cmd module
Ricardo Aráoz wrote:
> PEP 0343 is not an
> example of clarity in the definition of a statement, it mixes
> justification with historic development with definition with actual
> equivalent code. Couldn't or wouldn't bother to understand it.
Here is a better starting point:
http://docs.python.org/w
James Newton wrote:
> Hi Python Practicioners!
>
> I'm trying to come to terms with how Python handles the scope of
> objects. In particular, I'd like to create an instance of one class and
> make it available inside instances of other classes. Something like:
>
>
> # Test 1---
Ricardo Aráoz wrote:
> Kent Johnson wrote:
>> from contextlib import nested
>> with nested(open_file(self.direcciones), open_file(self.excluidas))
>> as (fIncl, fExcl):
>>
>
> Nice! How would you add exception reporting to this?
I don't have a good answer to that, that's why I didn't propos
Jeff Younker wrote:
>> Maybe it is my poor understanding of exception handling. My intention
>> here is to open the first file, if error then report in logging and
>> finish normally, else open the 2nd file, if error then report in
>> logging
>> close the 1st file and finish normally. If no error
Kent Johnson wrote:
> Ricardo Aráoz wrote:
>> PEP 0343 is not an
>> example of clarity in the definition of a statement, it mixes
>> justification with historic development with definition with actual
>> equivalent code. Couldn't or wouldn't bother to understand it.
>
> Here is a better starting p
Kent Johnson wrote:
> Ricardo Aráoz wrote:
>> Kent Johnson wrote:
>>> from contextlib import nested
>>> with nested(open_file(self.direcciones), open_file(self.excluidas))
>>> as (fIncl, fExcl):
>>>
>> Nice! How would you add exception reporting to this?
>
> I don't have a good answer to tha
On Mo, 2008-01-07 at 21:15 -0300, Ricardo Aráoz wrote:
> Kent Johnson wrote:
> > Ricardo Aráoz wrote:
> >> PEP 0343 is not an
> >> example of clarity in the definition of a statement, it mixes
> >> justification with historic development with definition with actual
> >> equivalent code. Couldn't o
I like this.
class Counter:
def __init__(self):
self.score = 0
def incr(x, y):
self.score += 2*x+3*y
class Board:
def __init__(self):
self.counter = Counter()
self.curcoords = (0,0)
def update(self)
self.counter.incr(*self.curcoords)
Whatever OOP term is used to d
Please reply to the list not just me. We all participate and learn.
Shumail Siddiqui wrote:
> I know this assignment is not too hard, but I have been greatly
> overwhelmed with work as I have been taking a 19 credits recently. I
> kind of have an approach to this by importing random numbers and
Torsten Marek wrote:
>> try :
>> with open('/etc/passwd', 'r') as f:
>> for line in f:
>> print line
>> ... more processing code ...
>> except ExceptionsOnOpening :
>> ... exception handling
>> except :
>> ... exceptions inside the for
>>
>>
>>
>> Whereas
Ricardo Aráoz wrote:
> looking at the simpler use, if you would have exception handling in :
>
> try :
> with open('/etc/passwd', 'r') as f:
> for line in f:
> print line
> ... more processing code ...
> except ExceptionsOnOpening :
> ... exception handling
Hi there,
I'm been following a tutorial in a Python Programming book, making a
Guess My Number game.
I decided to go and modify it a bit more, therefore expanding it.
What I added in was the ability to modify the range of the pseudo-random
number generator, an exit strategy (i.e. type stop at t
29 matches
Mail list logo