Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
stylistic question
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
William Stein  
View profile  
 More options Feb 7 2009, 3:33 pm
From: William Stein <wst...@gmail.com>
Date: Sat, 7 Feb 2009 12:33:25 -0800
Local: Sat, Feb 7 2009 3:33 pm
Subject: Re: stylistic question

I've cc'd this to the sage-finance Sage development group, which you
might want to subscribe to:
http://groups.google.com/group/sage-finance

Regarding your question:

  1. It should be FinanceDate(2009, 2, 6).add_business_days(5)
since in Python people usually use CamelCase for class constructors,
but lower case and underscores for function names.  It's just the
usual convention.

  2. What you are doing -- returning a new object -- is generally a
good idea, though of course it depends on context.    If you don't,
imagine code like this:

sage: foo = FinanceDate(2009,2,6)
sage: foo
datetime.date(2009, 2, 6)
sage: o = find_optimum(bar, foo)
sage: foo
datetime.date(2009, 2, 14)

... suddenly foo has a completely different value just because you happened
to call some function, which happened to internally muck with foo's
value.  By making the date object immutable, this possible confusing
side-effect is avoided.

In C++ there is a const keyword that helps avoid this problem.  But in
Python there is not const -- anything passed into a function is just a
reference, and has to "protect itself".

How's your finance package work going?

William


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »