let me dig into documentation before thinking in the blind :) thanks a lot Alan !On 7/25/06, Alan Gauld <
[EMAIL PROTECTED]> wrote:> So from the answers, i want to imagine how python exercise the code
> when you push the button execute. My guess before looking at the> docs> or other material,>> 1.
After reading John's reply, I think I get it now:
>>> from linked_queue import *
>>> queue = Queue()
>>> queue.isEmpty()
True
>>> queue.insert("cargo")
>>> queue.length
1
>>> queue.insert("more cargo")
>>> queue.length
2
>>> print queue.head
cargo
>>> print queue.head.next
more cargo
>>> queue.ins
On 25/07/06, Christopher Spears <[EMAIL PROTECTED]> wrote:
>>>> from linked_queue import *
> >>> queue = Queue()
> >>> queue.isEmpty()
> True
> >>> queue.insert("cargo")
> >>> print queue.head
> cargo
> >>> print queue.length
> 1
> >>> queue.insert("more_cargo")
> >>> print queue.le
I am working out of How To Think Like A Computer
Scientist. I am on the chapter that covers linked
queues. Here is some code that creates a linked queue
class:
class Queue:
def __init__(self):
self.length = 0
self.head = None
def isEmpty(self):
> In a function of the class, I have put the code in try/except block.
>
> try:
> --
> --
> except AssertionError:
> print "Error Condition"
>
> In this code, when error occurs, it raises the AssertionError
> but the destuctor isnt called itself.
The destructor will onl
> So from the answers, i want to imagine how python exercise the code
> when you push the button execute. My guess before looking at the
> docs
> or other material,
>
> 1. check python syntax
> 2. transform to byte code.
> 3. execute the byte code.
What you have is correct for a main program.
If
> Is there a method in Python like this already:
> #This program calculates how many days it has been from one day to
> the other.
Look at the datetime module it has methods for getting differences in
daes/times etc.
> def first_date():
>1y = int(raw_input("Enter the year of the first date:
On 25/07/06, Nathan Pinno <[EMAIL PROTECTED]> wrote:
>
> What's the invalid syntax?
I don't know, what did python tell you when you tried to run the code?
--
John.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Ignore this. I've created too many errors to even
begin to solve.
- Original Message -
From:
Nathan
Pinno
To: Tutor mailing list
Sent: Monday, July 24, 2006 7:24 PM
Subject: What's the invalid syntax?
What's the invalid syntax?
[code]
from datetime impor
What's the invalid syntax?
[code]
from datetime import *
def menu(): print "(A)dd days
to current date." print "(F)ind how many days have passed
since a date." print "(E)xit."
def menu_choice(): choice =
raw_input("Enter the letter of your choice: ") return
choice
def
Nathan Pinno wrote:
> Is there a method in Python like this already:
>
> [code]
> #This program calculates how many days it has been from one day to the
> other.
Hi,
Check the datetime module, it will give you distance between dates in
the units you specify. It is included in the standard dis
On 25/07/06, Nathan Pinno <[EMAIL PROTECTED]> wrote:
>
> Is there a method in Python like this already:
>
> [code]
> #This program calculates how many days it has been from one day to the
> other.
Have a look at the datetime module: if date1 and date2 are both
datetime.date instances, then (date1-
Is there a method in Python like this
already:
[code]
#This program calculates how many days it has been
from one day to the other.
def first_date(): 1y =
int(raw_input("Enter the year of the first date: ")) 1m =
int(raw_input("Enter the month of the first date: ")) 1d =
int(ra
Does anyone here have a example/demo using the MVC pattern, in a simple QT/pyQT program?thanks
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
So from the answers, i want to imagine how python exercise the codewhen you push the button execute. My guess before looking at the docsor other material,1. check python syntax
2. transform to byte code.3. execute the byte code.
___
Tutor maillist - Tut
> class Tree:
>
>def Tree(self):
>self.rootNode = None
>def Tree(self, rootNode):
>self.rootNode = rootNode
This second definition overrides the first - you cannot do
function overloading based on parameters in Python.
>
> t = Tree()
> n = Node()
These just create instan
> Thanks for the great email.I am beginning to see the light on event
> binding, callbacks and functions. I have attached my program to show my
> efforts so far. I think I need a some help in application.
Hi Joe,
I haven't seen your message about this on Tutor yet; have you reposted
your que
Hi,I have a class in python which creates an ssh connection to a remote machine.In a function of the class, I have put the code in try/except block.try: -- --except AssertionError: print "Error Condition"In this code, when error occurs, it raises the AssertionError but t
Really, I have realized the difference Luke said. However sometimes IDLE runs theold version, this is the thing I cant realized.On 7/24/06, Luke Paireepinart
<[EMAIL PROTECTED]> wrote:
[snip code]> look at this code. Edit this code with IDLE. For example change one of> the 'self' statement> in the
[snip code]
> look at this code. Edit this code with IDLE. For example change one of
> the 'self' statement
> in the code. For instance change self => slf then save the file and
> press F5(Run Module)
> It doesn't complain about the code !!! this is my problem.
>
I think maybe you're just confuse
class Tree: def Tree(self): self.rootNode = None def Tree(self, rootNode): self.rootNode = rootNode def getRootNode(self): return self.rootNode def setRootNode(self, rootNode):
self.rootNode = rootNodeclass Node: def Node(self): self.content = ''
> I have a problem with IDLE on Windows.
> While I'm executing a python script in IDLE subsequence
> editing and executions on the file sometimes doesn't reflect the
> changes.
This is a common issue, you are presumably importing your
program rather than using IDLE's save/run feature? If so you
w
22 matches
Mail list logo