Hey Tutor
Assuming i have a class bank as below .
class bank(object):
def __init__(self, bal=0):
self.bal = bal
def deposit(self, amount):
self.bal+=amount
print self.bal
I define a method debit - which i add to the class onthefly
def debit(self, amt):
self.bal-=am
Hello all,
I am seeking for information about the template pattern applied to python.
Could you explain some implementation or anything else? it would be helpful.
Regards
Thanks a lot
Karim
___
Tutor maillist - Tutor@python.org
To unsubscribe or cha
Hi All,
I was trying to use the ctypes module for a project. I was creating a
dynamically allocated array of "max_entries" pairs and once the array was
exhausted, I was creating a new array of size (1.5 * max_entries) and copying
the contents from the old array to the new array.
Unfortunate
Hi folks:
I'm trying to define a short function that will import yaml data into
a python dictionary. I am able to do this by dumping my data into a
temporary file and then importing it with yaml.load. I would like to
see if I can eliminate the temporary file and import the data
directly.
This w
On Mon, Dec 13, 2010 at 11:08 AM, Sean Carolan wrote:
> Hi folks:
>
> I'm trying to define a short function that will import yaml data into
> a python dictionary. I am able to do this by dumping my data into a
> temporary file and then importing it with yaml.load. I would like to
> see if I can
When I learned FORTRAN years ago they didn't teach us OOP or what I
like to call Class based programming.
since then I've sort of always fallen back to be a procedural
programmer with lots of functions.
Python and the tkinter (Tkinter on Versions < 3) seem like a great way
to write cross platform
Op 2010-12-12 22:33, Steven D'Aprano schreef:
> Terry Carroll wrote:
>
>> import time
>> for t in range(10,0, -1):
>> print "%s \x0D" %t,
>> time.sleep(1)
>> print # get to next line
>> print "Done!"
>
> Which operating system and terminal did you use?
>
> In my experience, using print i
On Mon, Dec 13, 2010 at 11:51 AM, Rance Hall wrote:
> When I learned FORTRAN years ago they didn't teach us OOP or what I
> like to call Class based programming.
>
That must have been a few years ago, then ;)
> since then I've sort of always fallen back to be a procedural
> programmer with lot
Alan,
Oh wow! I was not aware of the WConio module. That is exactly what I
have been needing!
Thanks,
Bill Allen
On Sun, Dec 12, 2010 at 6:49 PM, Alan Gauld wrote:
>
> "Modulok" wrote
>
> For more complex stuff, (think blue screens with little white boxes
>> you press spacebar to acti
I'm searching line by line for certain tags and then printing the tag
followed by the word immediately following the tag.
So for example, suppose I had the following line of text in a file:
"this is a key test123 noisenoise noise noise noise"
In this example, I would wan
"Jojo Mwebaze" wrote
Assuming i have a class bank as below .
class bank(object):
def __init__(self, bal=0):
self.bal = bal
def deposit(self, amount):
self.bal+=amount
print self.bal
I define a method debit - which i add to the class onthefly
bank.debit = debit
#I can
Yes, I tried using os.subprocess() but there was some sort of parsing
error. I'll just stick with the temporary file for now; the
documentation seems to indicate that is how yaml.load should be used
anyway...
On Mon, Dec 13, 2010 at 11:43 AM, Wayne Werner wrote:
> On Mon, Dec 13, 2010 at 11:08
"Rance Hall" wrote
When I learned FORTRAN years ago they didn't teach us OOP or what I
like to call Class based programming.
One of the requirements of OOP is to be able to group data together
and from memory FORTRAN didn't have any such construct being
based primarily on arrays. I beliebve
"Sean Carolan" wrote
a python dictionary. I am able to do this by dumping my data into a
temporary file and then importing it with yaml.load. I would like
to
see if I can eliminate the temporary file and import the data
directly.
You could use a stringIO buffer. It acts like an in-memory
"Ben Ganzfried" wrote
def test(infile, outfile):
for line in infile:
tagIndex = line.find("key")
start = tagIndex + 4
stop = line[start:].find("\t") -1
if tagIndex != -1:
print("start is: ", start)
print("stop is: ", sto
On Mon, Dec 13, 2010 at 1:55 PM, Ben Ganzfried wrote:
> I'm searching line by line for certain tags and then printing the tag
> followed by the word immediately following the tag.
>
> So for example, suppose I had the following line of text in a file:
>
> mystring = "this is a key
On Mon, Dec 13, 2010 at 2:08 PM, Alan Gauld wrote:
>
>
>> Does anyone have or know of a good tutorial or explanation of class
>> based coding that I could have a run at?
>>
>
> Try my tutor. It has topics on both OOP and GUIs.
> And before doing the GUI one also read the event-driven topic becau
Greetings Ben,
: I'm searching line by line for certain tags and then printing the
: tag followed by the word immediately following the tag.
What you are describing is an awful lot like 'grep'. But, of
course, many different sorts of file searching resemble grep.
: So for example, suppose
I confess I don't know a lot about C so I may be off base here... But it looks
like your c func extendarray returns a pointer to the new extended array, but
you are not capturing this pointer in your python when you call the c func. So
the python code is pointing at the old deallocated array.
Karim wrote:
Hello all,
I am seeking for information about the template pattern applied to python.
Could you explain some implementation or anything else? it would be
helpful.
Design patterns are means to an end, not an end in themselves. You
shouldn't say "I want to use the template patter
On Mon, Dec 13, 2010 at 8:44 PM, Alan Gauld wrote:
>
> "Jojo Mwebaze" wrote
>
> Assuming i have a class bank as below .
>>
>> class bank(object):
>> def __init__(self, bal=0):
>> self.bal = bal
>> def deposit(self, amount):
>> self.bal+=amount
>> print self.bal
>>
>> I define a
On 12/13/2010 11:47 PM, Steven D'Aprano wrote:
Karim wrote:
Hello all,
I am seeking for information about the template pattern applied to
python.
Could you explain some implementation or anything else? it would be
helpful.
Design patterns are means to an end, not an end in themselves. You
The OOP topic in my tutor has a section on persisting objects
by writing them to a text file. The basic principle being that
each subclass only persists the attributes that it adds and
relies on the superclass to persist itself.
In this case you would have to do someting like get the save()
me
Anyone know how to get WConio.putch() to properly put out a box drawing
character to the screen in the while at a cmd prompt? The code page is
437, but it when I tell it to put out 188, for example, it get a 1/4
character instead of the box drawing character.
I am using WConio.putch(188)
I have
I'm no expert, but you probably need to tell Python which character set to use.
Alan Gauld
Author of the Learn To Program website
http://www.alan-g.me.uk/
>
>From: Bill Allen
>To: Alan Gauld
>Cc: *tutor python
>Sent: Tuesday, 14 December, 2010 1:08:05
>Subject: Re: [Tutor] Writing to the t
25 matches
Mail list logo