Re: [Tutor] calling a variable name

2007-10-24 Thread Kent Johnson
Dave Kuhlman wrote:
> On Tue, Oct 23, 2007 at 10:10:24PM -0400, Kent Johnson wrote:
> 
> [snip]
> 
>> Perhaps I was a bit hasty.
>>
>> Lists are implemented as arrays of references. I believe they are
>> - amortized O(1) for append - occasionally the list must be reallocated 
>> and copied
> 
> OK. I'm groping here.  Wikipedia tells me that O(1) means constant
> increase.  So, what does "amortized O(1)" mean.
> 
> My understanding is that appending in lists is optimized in the
> sense that when more space is needed, Python allocates space for
> additional elements so that allocation does not need to happen at
> every append.  Here is a comment from the Python source code
> (Python-2.5.1/Objects/listobject.c):
> 
> /* This over-allocates proportional to the list size, making room
>  * for additional growth.  The over-allocation is mild, but is
>  * enough to give linear-time amortized behavior over a long
>  * sequence of appends() in the presence of a poorly-performing
>  * system realloc().
>  * The growth pattern is:  0, 4, 8, 16, 25, 35, 46, 58, 72, 88, ...
>  */
> 
> Hmmm.  There is that "amortized" thing again.  Very suspicious. 
> For a non-math and non-financial type like me, is it sort of like
> saying that the costs are averaged out over a sequence of appends?

Yes, that is exactly right. Most of the time - when there is room at the 
end of the allocated block - append is O(1) and very fast. Occasionally, 
when there is not enough room, append is O(n) and slow, requiring the 
entire list to be copied. Because the size of the new allocation is 
proportional to the size of the list, the reallocation happens only each 
1/n appends, so if you average out the cost of the reallocation, each 
append is O(1) (with a higher constant). That is what amortized cost 
means - sometimes the cost is greater than the specified cost but it 
averages out.

Note that if the reallocation added a fixed amount of extra space each 
time the cost would not average out over n inserts and it would not be 
O(1) amortized cost. It's important that the new allocation be 
proportional to the existing space.

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Logging in Linux

2007-10-24 Thread Noufal Ibrahim
wormwood_3 wrote:

> Now, what I would like to do is instead send this output to one or
> more of the standard linux log files. First though, I am wondering, what
> is the standard procedure in a case like this? 

You can either have a config file to specify a log area or use syslog to 
do the logging. The standard logging module has a RotatingFileHandler 
and a SysLogHandler for both these methods.

> Is it more appropriate to
> make a totally separate log file for all user-added scripts (or one a
> piece), and put them in /var/log or elsewhere? Where have you all found
> to be helpful places to log messages from automated scripts on Linux
> systems? The end goal is simply to have a place that I can check to see
> that the script is running as expected, or troubleshoot issues if need
> arise.

/var/log looks nice. I think you should just make it configurable enough 
  so that people can relocate if they want to.



-- 
~noufal
http://nibrahim.net.in/
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Looking to improve my stopWatch.py

2007-10-24 Thread Dick Moores
Please give me constructive criticism of 


(secsToHMS() was perfected with much Tutor help in this thread: 
)

Thanks,

Dick Moores 44

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking to improve my stopWatch.py

2007-10-24 Thread bhaaluu
On 10/24/07, Dick Moores <[EMAIL PROTECTED]> wrote:
> Please give me constructive criticism of
> 

$ python
Python 2.4.3 (#2, Oct  6 2006, 07:52:30)
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import msvcrt
Traceback (most recent call last):
  File "", line 1, in ?
ImportError: No module named msvcrt
>>>

>
> (secsToHMS() was perfected with much Tutor help in this thread:
> )
>
> Thanks,
>
> Dick Moores 44
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>

HTH
-- 
b h a a l u u at g m a i l dot c o m
http://www.geocities.com/ek.bhaaluu/index.html
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Calling a Method with a Reserved Name

2007-10-24 Thread Alex Ezell
I am working on building a SOAP client. Unfortunately, one of the
methods the SOAP server provides is named "import." The SOAP server is
written in PHP.

So, my problem is that Python really doesn't like me using the word
"import" to call the SOAP method. The call should look something like
this:

self.call_response = self.soap.import(self.soap_auth, file_name,
import_groups, soap_flags)

Is there any way to call this method despite it's name being a reserved word.

/alex
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Calling a Method with a Reserved Name

2007-10-24 Thread Kent Johnson
Alex Ezell wrote:
> I am working on building a SOAP client. Unfortunately, one of the
> methods the SOAP server provides is named "import." The SOAP server is
> written in PHP.
> 
> So, my problem is that Python really doesn't like me using the word
> "import" to call the SOAP method. The call should look something like
> this:
> 
> self.call_response = self.soap.import(self.soap_auth, file_name,
> import_groups, soap_flags)
> 
> Is there any way to call this method despite it's name being a reserved word.

You could try introspection:

importFunc = getattr(self.soap, 'import')
self.call_response = importFunc(self.soap_auth, file_name,
import_groups, soap_flags)

I don't know if this will work here or not, I assume self.soap is 
already doing some attribute magic.

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Calling a Method with a Reserved Name

2007-10-24 Thread Alex Ezell
On 10/24/07, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Alex Ezell wrote:
> > I am working on building a SOAP client. Unfortunately, one of the
> > methods the SOAP server provides is named "import." The SOAP server is
> > written in PHP.
> >
> > So, my problem is that Python really doesn't like me using the word
> > "import" to call the SOAP method. The call should look something like
> > this:
> >
> > self.call_response = self.soap.import(self.soap_auth, file_name,
> > import_groups, soap_flags)
> >
> > Is there any way to call this method despite it's name being a reserved 
> > word.
>
> You could try introspection:
>
> importFunc = getattr(self.soap, 'import')
> self.call_response = importFunc(self.soap_auth, file_name,
> import_groups, soap_flags)

Thanks Kent. I tried it and it seem like importFunc is now something
like 'import.__str__'. I could maybe do some string operations to just
get import out of that, but is there something I could do with
getattr() for that reference to come back the way I need.

Thanks again.

/alex
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Calling a Method with a Reserved Name

2007-10-24 Thread bob gailer
Alex Ezell wrote:
> I am working on building a SOAP client. Unfortunately, one of the
> methods the SOAP server provides is named "import." The SOAP server is
> written in PHP.
>
> So, my problem is that Python really doesn't like me using the word
> "import" to call the SOAP method. 
This seems unfortunate and too restrictive, to not allow keywords to be 
used for other purposes, when the context makes it clear that its use is 
not as a keyword.

PL/I works that way: one may code
if if = then then
  then = else
else
  else = if

Not that that is recommended coding style.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Calling a Method with a Reserved Name

2007-10-24 Thread Kent Johnson
Alex Ezell wrote:
>> You could try introspection:
>>
>> importFunc = getattr(self.soap, 'import')
>> self.call_response = importFunc(self.soap_auth, file_name,
>> import_groups, soap_flags)
> 
> Thanks Kent. I tried it and it seem like importFunc is now something
> like 'import.__str__'. I could maybe do some string operations to just
> get import out of that, but is there something I could do with
> getattr() for that reference to come back the way I need.

I guess you will have to dig into the implementation of the client a bit 
and find out what self.soap.import does and duplicate that somehow. What 
client code are you using? I would look for a __getattr__ method in the 
class implementing self.soap, for starters.

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Calling a Method with a Reserved Name

2007-10-24 Thread Kent Johnson
Alex Ezell wrote:
> On 10/24/07, Kent Johnson <[EMAIL PROTECTED]> wrote:
>> Alex Ezell wrote:
>>> I am working on building a SOAP client. Unfortunately, one of the
>>> methods the SOAP server provides is named "import." The SOAP server is
>>> written in PHP.
>>>
>>> So, my problem is that Python really doesn't like me using the word
>>> "import" to call the SOAP method. The call should look something like
>>> this:
>>>
>>> self.call_response = self.soap.import(self.soap_auth, file_name,
>>> import_groups, soap_flags)
>>>
>>> Is there any way to call this method despite it's name being a reserved 
>>> word.
>> You could try introspection:
>>
>> importFunc = getattr(self.soap, 'import')
>> self.call_response = importFunc(self.soap_auth, file_name,
>> import_groups, soap_flags)
> 
> Thanks Kent. I tried it and it seem like importFunc is now something
> like 'import.__str__'. I could maybe do some string operations to just
> get import out of that, but is there something I could do with
> getattr() for that reference to come back the way I need.

Hmm, with a quick look at the code for SOAPpy (v 0.11.6) I don't see why 
the getattr() method would not work. Can you show the code you tried and 
why you think the result was a string?

BTW pulling 'import' out of the string won't help; you need the import 
*function*.

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Calling a Method with a Reserved Name

2007-10-24 Thread Eric Brunson
bob gailer wrote:
> Alex Ezell wrote:
>   
>> I am working on building a SOAP client. Unfortunately, one of the
>> methods the SOAP server provides is named "import." The SOAP server is
>> written in PHP.
>>
>> So, my problem is that Python really doesn't like me using the word
>> "import" to call the SOAP method. 
>> 
> This seems unfortunate and too restrictive, to not allow keywords to be 
> used for other purposes, when the context makes it clear that its use is 
> not as a keyword.
>   

Python isn't the only language, try compiling this with a C compiler:

int main(){
int char = 1;
}

test.c:3: error: expected identifier or ‘(’ before ‘=’ token

or a C++ compiler:
test.C:3: error: expected unqualified-id before ‘=’ token

Or running this through a PHP interpreter:



PHP Parse error: syntax error, unexpected T_REQUIRE, expecting T_STRING 
in test.php on line 2

Oh, well. :-)

> PL/I works that way: one may code
> if if = then then
>   then = else
> else
>   else = if
>
> Not that that is recommended coding style.
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>   


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking to improve my stopWatch.py

2007-10-24 Thread bob gailer
Dick Moores wrote:
> Please give me constructive criticism of 
> 
>   
1 - lapCounter is not used.

2 - simplify:

if lapTimeFlag == False:
print "Total Time is", secsToHMS(totalTime)
print "StopWatch is continuing to time.."
else:
currentLapTime = markTime - lapEnd
print "Current time of this lap, Lap %d, is %s" % (lapNum, 
secsToHMS(currentLapTime))
print "Total Time is", secsToHMS(totalTime)
print "StopWatch is continuing to time.."

new version:

if lapTimeFlag:
currentLapTime = markTime - lapEnd
print "Current time of this lap, Lap %d, is %s" % (lapNum, 
secsToHMS(currentLapTime))
print "Total Time is", secsToHMS(totalTime)
print "StopWatch is continuing to time.."



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Calling a Method with a Reserved Name

2007-10-24 Thread Alex Ezell
Oops, meant to send to the list. Sorry, Kent.

> > > >>> I am working on building a SOAP client. Unfortunately, one of the
> > > >>> methods the SOAP server provides is named "import." The SOAP server is
> > > >>> written in PHP.
> > > >>>
> > > >>> So, my problem is that Python really doesn't like me using the word
> > > >>> "import" to call the SOAP method. The call should look something like
> > > >>> this:
> > > >>>
> > > >>> self.call_response = self.soap.import(self.soap_auth, file_name,
> > > >>> import_groups, soap_flags)
> > > >>>
> > > >>> Is there any way to call this method despite it's name being a 
> > > >>> reserved word.
> > > >> You could try introspection:
> > > >>
> > > >> importFunc = getattr(self.soap, 'import')
> > > >> self.call_response = importFunc(self.soap_auth, file_name,
> > > >> import_groups, soap_flags)
> > > >
> > > > Thanks Kent. I tried it and it seem like importFunc is now something
> > > > like 'import.__str__'. I could maybe do some string operations to just
> > > > get import out of that, but is there something I could do with
> > > > getattr() for that reference to come back the way I need.
> > >
> > > Hmm, with a quick look at the code for SOAPpy (v 0.11.6) I don't see why
> > > the getattr() method would not work. Can you show the code you tried and
> > > why you think the result was a string?
> > >
> > > BTW pulling 'import' out of the string won't help; you need the import
> > > *function*.
> >
> > Got ya on the string bit. That was actually my fault. I think I am the
> > victim of my own poorly written exception handling method. Or at
> > least, I can't correctly read the errors that it tells me. :)
> >
> > The introspection bit you offered seems to work fine. The error is now
> > within the call to the SOAP server.
> >
> > Sorry for getting everyone confused. I'm off to ask my fellow
> > developer if the SOAP server really does what it says does since she
> > wrote it :)
> >
> > /alex

Heh, I am still having problems with this. This is the whole method:

def importer(self, file_name, import_groups, import_flags):
   soap_flags = self.dict_to_key_value(import_flags)
   try:
   # TODO figure out how to call this soap method with reserved name
   self.call_response = self.soap.import(self.soap_auth,
file_name, import_groups, soap_flags)
   except Exception, e:
   method_name = sys._getframe().f_code.co_name
   method_args = '(%s,%s,%s)'
%(file_name,str(import_groups),str(import_flags))
   self.handle_exception(method_name + method_args,e)
   raise
   return self.call_response

I tried to replace the import() call with these two lines:
importFunc = getattr(self.soap, 'import')
self.call_response = self.soap.importFunc(self.soap_auth, file_name,
import_groups, soap_flags)

and this was the error:

AttributeError: importFunc

module body   in sync_members.py at line 143
function main in sync_members.py at line 138
function sforce_to_membersin sync_members.py at line 80
function do_importin sync_members.py at line 70
function importer in emma_ws.py at line 84
function __getattr__  in WSDL.py at line 96

Thanks again for working with me this far. I am certainly on the very
precipitous edge of my Python "knowledge."

/alex
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Calling a Method with a Reserved Name

2007-10-24 Thread Kent Johnson
Alex Ezell wrote:

># TODO figure out how to call this soap method with reserved name
>self.call_response = self.soap.import(self.soap_auth,
> file_name, import_groups, soap_flags)

> I tried to replace the import() call with these two lines:
> importFunc = getattr(self.soap, 'import')
> self.call_response = self.soap.importFunc(self.soap_auth, file_name,
> import_groups, soap_flags)

this should be
self.call_response = importFunc(self.soap_auth, file_name,
import_groups, soap_flags)

importFunc *is* the function you want to call, it is not an attribute of 
self.soap.

Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Calling a Method with a Reserved Name

2007-10-24 Thread Alex Ezell
On 10/24/07, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Alex Ezell wrote:
>
> ># TODO figure out how to call this soap method with reserved name
> >self.call_response = self.soap.import(self.soap_auth,
> > file_name, import_groups, soap_flags)
>
> > I tried to replace the import() call with these two lines:
> > importFunc = getattr(self.soap, 'import')
> > self.call_response = self.soap.importFunc(self.soap_auth, file_name,
> > import_groups, soap_flags)
>
> this should be
> self.call_response = importFunc(self.soap_auth, file_name,
> import_groups, soap_flags)
>
> importFunc *is* the function you want to call, it is not an attribute of
> self.soap.
>
> Kent

Awesome. I knew I had just been looking at it for too long.

Thanks so much, Kent!

Maybe one day, I will help you with something. ;)

/alex
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking to improve my stopWatch.py

2007-10-24 Thread Alan Gauld

"bhaaluu" <[EMAIL PROTECTED]> wrote

 import msvcrt
> Traceback (most recent call last):
>  File "", line 1, in ?
> ImportError: No module named msvcrt


You are on Linux so you'll need to port it to use curses instead of 
msvcrt...

Alan G 


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking to improve my stopWatch.py

2007-10-24 Thread bhaaluu
On 10/24/07, Alan Gauld <[EMAIL PROTECTED]> wrote:
>
> "bhaaluu" <[EMAIL PROTECTED]> wrote
>
>  import msvcrt
> > Traceback (most recent call last):
> >  File "", line 1, in ?
> > ImportError: No module named msvcrt
> 
>
> You are on Linux so you'll need to port it to use curses instead of
> msvcrt...
>
> Alan G

Thanks Alan!
I had absolutely no clue what mscrt was.

>>> help ("curses")

Whew!
There's quite a bit in that one!
-- 
b h a a l u u at g m a i l dot c o m
http://www.geocities.com/ek.bhaaluu/index.html
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] trouble with if

2007-10-24 Thread Bryan Fodness
I have the following code, it keeps giving me a value of 1 for e.

for line in file('21Ex6MV_oaf.dat'):
oa, openoa, w15, w30, w45, w60 = line.split()
if (float(oa) == round(offaxis)) and (eff_depth < 10 and unblockedFS >
15):
e = float(openoa)
else:
e = 1

If I comment out the else, I get the correct value

for line in file('21Ex6MV_oaf.dat'):
oa, openoa, w15, w30, w45, w60 = line.split()
if (float(oa) == round(offaxis)) and (eff_depth < 10 and unblockedFS >
15):
e = float(openoa)
#else:
#e = 1
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] trouble with if

2007-10-24 Thread John Fouhy
On 25/10/2007, Bryan Fodness <[EMAIL PROTECTED]> wrote:
> I have the following code, it keeps giving me a value of 1 for e.
>
> for line in file('21Ex6MV_oaf.dat'):
> oa, openoa, w15, w30, w45, w60 = line.split()
> if (float(oa) == round(offaxis)) and (eff_depth < 10 and unblockedFS >
> 15):
> e = float(openoa)
> else:
> e = 1
>
> If I comment out the else, I get the correct value
>
> for line in file('21Ex6MV_oaf.dat'):
> oa, openoa, w15, w30, w45, w60 = line.split()
> if (float(oa) == round(offaxis)) and (eff_depth < 10 and unblockedFS >
> 15):
> e = float(openoa)
> #else:
> #e = 1

Maybe you need a 'break' statement after 'e = float(openoa)'?

As written, e will have whatever value is appropriate for the last
line of your input file.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking to improve my stopWatch.py

2007-10-24 Thread Dick Moores


At 02:14 PM 10/24/2007, bob gailer wrote:
Dick Moores wrote:
Please give me constructive
criticism of
<
http://www.rcblue.com/Python/stopWatchForWeb14-a.py>
  1 - lapCounter is not used.
Deleted.

2 - simplify:
  
if lapTimeFlag == False:
  
print "Total Time is", secsToHMS(totalTime)
  
print "StopWatch is continuing to time.."
  
else:
  
currentLapTime = markTime - lapEnd
  
print "Current time of this lap, Lap %d, is %s" % (lapNum,
secsToHMS(currentLapTime))
  
print "Total Time is", secsToHMS(totalTime)
  
print "StopWatch is continuing to time.."
   new version:
  
if lapTimeFlag:
  
currentLapTime = markTime - lapEnd
  
print "Current time of this lap, Lap %d, is %s" % (lapNum,
secsToHMS(currentLapTime))
  
print "Total Time is", secsToHMS(totalTime)
  
print "StopWatch is continuing to time.."
Thanks. Missed that. 
I'm wondering about "if lapTimeFlag:". Following "The Zen
of Python", by Tim Peters ("Explicit is better than
implicit"), isn't "if lapTimeFlag == True"
preferable?
See the new revision
<
http://www.rcblue.com/Python/stopWatchForWeb14-b.py>
Dick



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking to improve my stopWatch.py

2007-10-24 Thread John Fouhy
On 25/10/2007, Dick Moores <[EMAIL PROTECTED]> wrote:
>  I'm wondering about "if lapTimeFlag:". Following "The Zen of Python", by
> Tim Peters ("Explicit is better than implicit"), isn't "if lapTimeFlag ==
> True" preferable?

No :-)

Otherwise, maybe we should make it even more explicit:

  if (lapTimeFlag == True) == True:

...but that still requires the reader to understand that the body of
the if: block will only execute if ((lapTimeFlag == True) == True) ==
True..

(hmm, reminds me of Lewis Carroll's modus ponens paradox)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] where is the function from

2007-10-24 Thread linda.s
How can I know where a function such as abc is from (from which module)?
>>> abc

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] underlying C/C++ object has been deleted

2007-10-24 Thread Lawrence Shafer
I am trying to convert a program with hand coded QT over to using UI 
files from QT Designer. I am getting the error below and do not 
understand what's going on. I have a feeling I need to add self. to 
something in here, but I'm not sure what. Is this enough code for you to 
see whats going on?? If not I can upload the project somewhere.  Thanks, 
Lawrence

The error,

Traceback (most recent call last):
  File "atf.py", line 113, in on_actionOpen_triggered
self.open()
  File "atf.py", line 56, in open
if self.isUntitled and self.textBrowser.document().isEmpty() and not 
self.isWindowModified():
RuntimeError: underlying C/C++ object has been deleted


Here is the first part of the code.

#!/usr/bin/env python
# iaC.py - A Qt4 Calculator example

import sys
from math import pi
from PyQt4 import QtCore, QtGui
from iac_ui import Ui_mainWindow
from filterEdit2_ui import Ui_filterEdit


class iaC(QtGui.QMainWindow):
sequenceNumber = 1
windowList = []

@QtCore.pyqtSignature("")
def __init__(self, fileName=None, parent=None):
QtGui.QMainWindow.__init__(self, parent)

self.init()
if fileName:
self.loadFile(fileName)
else:
self.setCurrentFile(QtCore.QString())

self.ui = Ui_mainWindow()
self.ui.setupUi(self)

# Set up delete, up, and down buttons on the main 
form==
if self.ui.listWidget.count() < 1:
self.ui.deleteButton.setEnabled(False)
else:
self.ui.deleteButton.setEnabled(True)

if self.ui.listWidget.count() < 2:
self.ui.upButton.setEnabled(False)
self.ui.downButton.setEnabled(False)
else:
self.ui.downButton.setEnabled(True)
self.ui.upButton.setEnabled(True)

# Save settings on 
close?===
def closeEvent(self, event):
if self.maybeSave():
self.writeSettings()
event.accept()
else:
event.ignore()

# ===Open File=
@QtCore.pyqtSignature("")
def open(self):
fileName = QtGui.QFileDialog.getOpenFileName(self)
print "Loading fileName", fileName
if not fileName.isEmpty():

if self.isUntitled and self.textBrowser.document().isEmpty() 
and not self.isWindowModified():
self.loadFile(fileName)
else:
other = MainWindow(fileName)
if other.isUntitled:
del other
return
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] where is the function from

2007-10-24 Thread Eric Brunson
linda.s wrote:
> How can I know where a function such as abc is from (from which module)?
>   
 abc
 
> 
>   

You could:

   1. look it up in the index of the library reference
  (http://www.python.org/doc/current/lib/genindex.html),
   2. try "pydoc",
   3. examine abc.__module__

Let us know if none of those help.

e.

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking to improve my stopWatch.py

2007-10-24 Thread Dick Moores


At 09:41 PM 10/24/2007, John Fouhy wrote:
On 25/10/2007, Dick Moores
<[EMAIL PROTECTED]> wrote:
>  I'm wondering about "if lapTimeFlag:". Following
"The Zen of Python", by
> Tim Peters ("Explicit is better than implicit"), isn't
"if lapTimeFlag ==
> True" preferable?
No :-)
Otherwise, maybe we should make it even more explicit:
  if (lapTimeFlag == True) == True:
Well, how about "Readability counts"?
Dick



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor