It is also good to know that overriding the "comparison magic methods" in
your class can be very useful if you wish to apply sorting/searching
procedures available in python.
If you also implement __gt__, __lt__, __ge__, __le__ in your class, then
you can append each of your objects to a list an
I once dabbled with wxPython. The code below may not run straight off as
I've cut it out of a bigger routine, but it may give you a flavour of a
basic (very basic) set up.
import wx
import math
def drawCircle (radius, canvas, strCol):
centre = (100,100)
cX = centre[0]
cY = centre[1]
d
For the benefit of others,I believe the full class (from the Django
Tutorial) is
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def was_published_recently(self):
return self.pub_date >= timezone.now() - d
Some other tools, if you haven't come across them yet.
You already know about str.join ()
Slicing
>>>b=['s','p','a','m']
b [ : 1 ]
['s']
b [ : 2 ]
['s', 'p']
Also, consider
>>>len ( b)
4
>>>range ( 4 )
[ 0, 1, 2, 3, 4]
# which I can iterate over.
On Tue, May 28, 2013 at 4:54 AM, T
Hi Tutors,
I'm confused by the following possible contradiction. Would someone please
explain or point me to the right docs.
FACT 1
"Variables in python hold references to objects."
http://en.wikipedia.org/wiki/Python_syntax_and_semantics
FACT 2
>>>def Increment ( x ) :
>>>// return x + 1
Thanks for all these clear and knowledgeable answers. I'm much clearer on
this now and will read up a bit more around these subjects.
John
On Mon, Jun 24, 2013 at 10:59 AM, Peter Otten <__pete...@web.de> wrote:
> John Steedman wrote:
>
> > Hi Tutors,
> >
>
Good morning all,
A question that I am unsure about. I THINK I have the basics, but I am not
sure and remain curious.
1. What does this mean?
>>> if my_object in my_sequence:
...
2. What can go wrong with this? What should a code review pick up on?
I believe that "my_sequence" might be a eithe
Many thanks, everyone. Great answers. I decided to read the manual
properly. May take some time but well worth it.
On Mon, Jul 1, 2013 at 2:40 PM, Steven D'Aprano wrote:
> On 01/07/13 19:58, John Steedman wrote:
>
>> Good morning all,
>>
>> A question that I am
I have in front of me a copy an (unread, borrowed) copy of "Python for
Data Analysis". Well, on page 104, there is the start of an answer.
Pandas : has two useful functions: read_csv and read_table
Numpy : see np.loadtxt and np.genfromtxt
There is an example for using the first numpy function: