Re: Partial classes

2006-07-18 Thread Kay Schluehr
Sanjay wrote: > Hi All, > > Not being able to figure out how are partial classes coded in Python. > > Example: Suppose I have a code generator which generates part of a > business class, where as the custome part is to be written by me. In > ruby (or C#), I divide the code into two source files. L

Re: Python : Event-Driven Paradigm

2006-07-18 Thread Kusanagi
Were you looking for more specific features?   Parallel Processing.   Grant,             It looks like I have a lot more studying to do, all of the information that I have seems to be screwed up. I will look at event loops in Python to see if that answers my question. I was just looking a

Re: Partial classes

2006-07-18 Thread alex23
Sanjay wrote: > Not being able to figure out how are partial classes coded in Python. Hi Sanjay, To the best of my knowledge, Python currently has no support for partial classes. However, BOO (http://boo.codehaus.org/) - which is a Python-like language for the .NET CLI)- _does_ support partial c

Re: Dispatch with multiple inheritance

2006-07-18 Thread looping
Michael J. Fromberger wrote: > > Is there a better (i.e., more elegant) way to handle the case marked > (**) above? > You have to call super in each method __init__, if you don't, the call chain break before the end: class A (object): def __init__(self): super(A, self).__init__()

Re: What is a type error?

2006-07-18 Thread Marshall
Joachim Durchholz wrote: > Marshall schrieb: > > Chris Smith wrote: > >> Joachim Durchholz <[EMAIL PROTECTED]> wrote: > >> I *think* I understand Marshall here. When you are saying "assignment", > >> you mean assignment to values of attributes within tuples of the cell. > >> When Marshall is sayin

Partial classes

2006-07-18 Thread Sanjay
Hi All, Not being able to figure out how are partial classes coded in Python. Example: Suppose I have a code generator which generates part of a business class, where as the custome part is to be written by me. In ruby (or C#), I divide the code into two source files. Like this: GeneratedPerson.

Re: Object Persistence Using a File System

2006-07-18 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Chris Spencer wrote: > I've been looking for a method of transparent, scalable, and > human-readable object persistence... Don't do object persistence. What is an object? It's a combination of code and data. Code structure is internal to your program--it has no bus

Re: Authentication

2006-07-18 Thread Nick Vatamaniuc
Matheus, There is libgmail @ http://libgmail.sourceforge.net/ Here is the excerpt from their page. """ The following code logs into an account, retrieves a list of threads, displays information about them and displays the source of the individual messages. """ import libgmail ga = libgmail.GmailAcc

Re: Dispatch with multiple inheritance

2006-07-18 Thread Michele Simionato
Michael J. Fromberger ha scritto: > Consider the following class hierarchy in Python: > > Is there a better (i.e., more elegant) way to handle the case marked > (**) above? > > Curious, > -M > > -- > Michael J. Fromberger | Lecturer, Dept. of Computer Science > http://www.dartmouth.e

Re: range() is not the best way to check range?

2006-07-18 Thread Simon Forman
tac-tics wrote: > Simon Forman wrote: > > To me, and perhaps others, "T = > > set(xrange(0, 1, 23))" and "n in T" are somewhat easier to read > > and write than "not n % 23 and 0 <= n < 1", YMMV. > > Eh? How is the first easier to read than the second?? You have a nested > function call in

Re: win32com.client.Dispatch - understanding error messages

2006-07-18 Thread mirandacascade
Duncan Booth wrote: > Are you really sure that the browser isn't making guesses about what you > meant and correcting the error for you? Does what remains in the address > bar when the page is retrieved really match *exactly* what you copied and > pasted? Thank you for that pointer. The answer i

Re: Recursive function returning a list

2006-07-18 Thread malkarouri
Bruno Desthuilliers wrote: > Boris Borcic a écrit : > > Hello Bruno, > > > > Bruno Desthuilliers wrote: > > > >> Boris Borcic wrote: > >> > Do you have any ideas? > >>> > >>> > >>> you could use a recursive generator, like > >>> > >>> def genAllChildren(self) : > >>> for child in self.chil

vmware/python web dev

2006-07-18 Thread [EMAIL PROTECTED]
someone has made a "virtual appliance" specialized for python web development. it has a huge list of included software. if you're interested, see: http://www.vmware.com/vmtn/appliances/directory/289 -- http://mail.python.org/mailman/listinfo/python-list

Re: Coding style

2006-07-18 Thread Carl Banks
Jorge Godoy wrote: > "Carl Banks" <[EMAIL PROTECTED]> writes: > > > Well, I certainly can agree with that, except for the last point. :) I > > certainly wouldn't want to keep that unfortunate behavior around just I > > have something to use as an argument using len to test emptiness. > > On the o

Re: Coding style

2006-07-18 Thread Terry Reedy
"Patrick Maupin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Carl Banks wrote: >> def process_values(lst): >> if not lst: >> return >> do_expensive_initialization_step() >> for item in lst: >> do_something_with(item) >>

Re: CSV with comments

2006-07-18 Thread skip
Whoops, missed the second part. John> Is there any reason to prefer this approach to Daniel's, apart John> from being stuck with an older (pre-yield) version of Python? No, it's just what I came up with off the top of my head. John> A file given to csv.reader is supposed to be opened

Re: CSV with comments

2006-07-18 Thread skip
John> This is recursive. Unlikely of course, but if the file contained a John> large number of empty lines, might this not cause the recursion John> limit to be exceeded? Sure, but I was lazy. ;-) Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: New SourceForge project: Diet Python!!!

2006-07-18 Thread skip
>> Hm didn't I leave ctypes in there? I added calldll because it >> had a really nice can opener. Oh, I have no idea (didn't download). I just sort of assumed if you had included calldll you probably hadn't included ctypes. Skip -- http://mail.python.org/mailman/listinfo/python-li

Re: Coding style

2006-07-18 Thread Jorge Godoy
"Carl Banks" <[EMAIL PROTECTED]> writes: > Well, I certainly can agree with that, except for the last point. :) I > certainly wouldn't want to keep that unfortunate behavior around just I > have something to use as an argument using len to test emptiness. On the other hand, having this behavior

Re: No need to close file?

2006-07-18 Thread Kevin Watters
There's always the new 'with' statement in Python 2.5. So instead of > f = open('foo', 'r') > try: >for line in f: > print line > finally: >f.close() > ...you do: with open('foo','r') as f: for line in f: print line It's at least a little bit cleaner, and it will clos

Re: Coding style

2006-07-18 Thread Carl Banks
Bruno Desthuilliers wrote: > Carl Banks a écrit : > > Bruno Desthuilliers wrote: > > > >>There are less risk of a typo with "if a:" than with "if len(a) > 0". > > > > > > So, it's more important to protect against typos than subtle bugs? > > > > People making smart points are really annoying... !-

Re: XMLRPC Solution Code

2006-07-18 Thread dylpkls91
Frank Millman wrote: > I use something called 'srvany' - >http://support.microsoft.com/kb/q137890/ I am familiar with srvany. Seems like it is a whole bunch easier than the PyWin32 stuff. I'll write a wrapper script that can be used like this: createservice.py -myservicename -myservicepath or

Re: Coding style

2006-07-18 Thread Bruno Desthuilliers
Carl Banks a écrit : > Bruno Desthuilliers wrote: > >>There are less risk of a typo with "if a:" than with "if len(a) > 0". > > > So, it's more important to protect against typos than subtle bugs? > People making smart points are really annoying... !-) wrt/ to the "subtle bug" point, MHO is t

Re: how to know if socket is still connected

2006-07-18 Thread John J. Lee
Grant Edwards <[EMAIL PROTECTED]> writes: [...] > > Often normal send() and recv() semantics have been mistaught. > > An alert alien, looking at other common APIs in isolation, > > might reasonably wonder whether there is some sort of > > still_ok_to_use() sort of check as part of TCP. As it hap

Re: Track keyboard and mouse usage

2006-07-18 Thread Lars
Diez B. Roggisch wrote: > will make the devices world readable. While I haven't thought about any > security implications that might have (and am not especially > knowledgeable in such things to be honest), I'm convinced it is way less > likely to introduce any exploitable holes than suid root w

Re: Coding style

2006-07-18 Thread Carl Banks
Bruno Desthuilliers wrote: > There are less risk of a typo with "if a:" than with "if len(a) > 0". So, it's more important to protect against typos than subtle bugs? Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Coding style

2006-07-18 Thread Carl Banks
Bruno Desthuilliers wrote: > "Irrelevant" may not be the best expression of my thought here - it's > just that Carl's assertion is kind of a tautology and doesn't add > anything to the discussion. If Python had been designed as statically > typed (with declarative typing), the rules would be differ

Re: Object Persistence Using a File System

2006-07-18 Thread Bruno Desthuilliers
Nick Vatamaniuc a écrit : (please don't top-post - corrected) > > Bruno Desthuilliers wrote: > (snip) >>A few observations and questions : >>- you should avoid tests on concrete types as much as possible - at >>least use isinstance > > Good point about isinstance. Here is a good explanation w

Re: Recursive function returning a list

2006-07-18 Thread Bruno Desthuilliers
Boris Borcic a écrit : > Hello Bruno, > > Bruno Desthuilliers wrote: > >> Boris Borcic wrote: >> Do you have any ideas? >>> >>> >>> you could use a recursive generator, like >>> >>> def genAllChildren(self) : >>> for child in self.children : >>> yield child >>> for childc

Authentication

2006-07-18 Thread bigodines
Hello guys, I'm trying to learn python by making some small programs that could be useful for some bigger propouses. In fact, i've made a small "check latest-modified" for webpages and it's working great. The next step I would like to do is to check if I have new e-mails (I don't wanna read it fr

Re: Getting and Setting Cookies

2006-07-18 Thread John J. Lee
"Vlad Dogaru" <[EMAIL PROTECTED]> writes: > I am trying to use cookies and Python to create a simple login example. > But I am very disoriented at the existence of two cookie libraries, > namely Cookie and cookielib. I have seen examples of setting cookies [...] >From the cookielib docs: http://

Re: Can thread start other threads?

2006-07-18 Thread John Henry
Thanks for the confirmation. I will see if I can reduce the code down to something managable and post the failing code. Diez B. Roggisch wrote: > John Henry schrieb: > > Can Python thread start threads? It appears not. When I do that, the > > sub-threads gets to certain point and just sit the

Re: Coding style

2006-07-18 Thread Bruno Desthuilliers
Volker Grabsch a écrit : > Bruno Desthuilliers <[EMAIL PROTECTED]> schrieb: > >>Carl Banks wrote: >> >>>Bruno Desthuilliers wrote: >>> >>>I'm well aware of Python's semantics, and it's irrelvant to my >>>argument. > > [...] > >>>If the language >>>were designed differently, then the rules would

Re: Coding style

2006-07-18 Thread Bruno Desthuilliers
Volker Grabsch a écrit : > Bruno Desthuilliers <[EMAIL PROTECTED]> schrieb: > >>PTY wrote: >> >>>I was asking whether it was better style to >>>use len() or not. >> >>FWIW, it's also more generic (you could have an object supporting >>pop() but not __len__()), less error-prone, > > > While I agr

Re: need help getting xml feed from a url

2006-07-18 Thread John Bokma
"Shan" <[EMAIL PROTECTED]> wrote: > If i have a list of urls how can I extract or pull their respective xml > feeds? What have you tried so far? -- John MexIT: http://johnbokma.com/mexit/ personal page: http://johnbokma.com/

Re: tkinter help

2006-07-18 Thread Harold Fellermann
hi, groves wrote: > Now let me tell you that i was able to create a simple listbox which > had 6 options which one can select, but Now what I want is that from > the available menu, if I select an option it should give me another > menu associated with that option. Its like digging up that option

Re: range() is not the best way to check range?

2006-07-18 Thread Paul Boddie
John Machin wrote: > On 19/07/2006 1:05 AM, Dan Bishop wrote: > > > > xrange already has __contains__. > > As pointed out previously, xrange is a function and one would not expect > it to have a __contains__ method. Well, you pointed out that range is a function, but xrange seems to be a type...

Re: tkinter help

2006-07-18 Thread John McMonagle
On Tue, 2006-07-18 at 08:37 -0700, groves wrote: > hi eveyrbody , i have started working on python tkinter, > While I was working on one of the tkinter classes..named listbox > widget. I had a slight problem. > > Now let me tell you that i was able to create a simple listbox which > had 6 options

Re: Can thread start other threads?

2006-07-18 Thread Diez B. Roggisch
John Henry schrieb: > Can Python thread start threads? It appears not. When I do that, the > sub-threads gets to certain point and just sit there. If I run the > code serially and not run the sub-thread code as threads, everything is > fine. It can. import threading, time class Test(threadin

Re: Capturing instant messages

2006-07-18 Thread Yu-Xi Lim
Nick Vatamaniuc wrote: > Assuming a one person per one machine per one chat protocol it might be > possible to recreate the tcp streams (a lot of packet capturing devices > already do that). So the gateway would have to have some kind of a > dispatch that would recognize the initialization of a cha

Re: CSV with comments

2006-07-18 Thread John Machin
On 19/07/2006 5:34 AM, [EMAIL PROTECTED] wrote: > >> In csv.reader, is there any way of skip lines that start whith '#' or > >> empty lines > > Nope. When we wrote the module we weren't aware of any "spec" that > specified comments or blank lines. You can easily write a file wrapper to >

Can thread start other threads?

2006-07-18 Thread John Henry
Can Python thread start threads? It appears not. When I do that, the sub-threads gets to certain point and just sit there. If I run the code serially and not run the sub-thread code as threads, everything is fine. I throught the problem is when you run multiple processes of Pythons... -- http

Re: Cyclic class definations

2006-07-18 Thread John Henry
Thanks for the note, Nick. I ended up with cycles as a historical reason. Some code that were written long time ago did not anticipate that part of it will get sub-classed. Thanks again. Nick Vatamaniuc wrote: > John, > Cycles are tricky. Python is an interpreted dynamic language, whatever > ob

Re: Defining functions in an implementation file

2006-07-18 Thread Yu-Xi Lim
westymatt wrote: > I am fairly new to python and I want to put alot of my functions in > another python file and import or from it into my script so I can call > the functions. How is this done? > What you are describing are modules. The Python Tutorial has some information on this http://docs.

Re: range() is not the best way to check range?

2006-07-18 Thread John Machin
On 19/07/2006 1:05 AM, Dan Bishop wrote: > Paul Boddie wrote: > >> Yes, he wants range to return an iterator, just like xrange more or >> less does now. Given that xrange objects support __getitem__, unlike a >> lot of other iterators (and, of course, generators), adding >> __contains__ wouldn't b

Re: New SourceForge project: Diet Python!!!

2006-07-18 Thread The Eternal Squire
I'll try to figure out a way to let people know who the FAQ I am :) The Eternal Squire Méta-MCI wrote: > Hi! > > Interesting (or fun?). > Have you a Internet page, or only README? > > @+ > > MCI -- http://mail.python.org/mailman/listinfo/python-list

Re: New SourceForge project: Diet Python!!!

2006-07-18 Thread The Eternal Squire
Best interface for roguelike gaming. Jarek Zgoda wrote: > The Eternal Squire napisa³(a): > > > Diet Python is a flavor of Python with allegro, multiarray, umath, > > calldll, npstruct and curses builtin, all else nonessential to language > > ripped out. Total size < 3MB, 1% of PSF Python. Diet Pyt

Re: ScientificPython - LeastSquareFit diverges

2006-07-18 Thread konrad . hinsen
On 18.07.2006, at 15:59, Harold Fellermann wrote: def powerlaw((a,b),x) : > ... return a*x**b Fitting power laws is a tricky business, you need a pretty good initial guess to get convergence. > Note that I could easily fit the above data using gnuplots internal > fitting procedure. An

Re: range() is not the best way to check range?

2006-07-18 Thread tac-tics
Simon Forman wrote: > To me, and perhaps others, "T = > set(xrange(0, 1, 23))" and "n in T" are somewhat easier to read > and write than "not n % 23 and 0 <= n < 1", YMMV. Eh? How is the first easier to read than the second?? You have a nested function call in the first! Regardless, test

Re: range() is not the best way to check range?

2006-07-18 Thread Summercoolness
[EMAIL PROTECTED] wrote: > it seems that range() can be really slow: > > if i in range (0, 1): My original use was like this: if i in range (iStart, iEnd): listData.append(a) in which iStart is 1000 and iEnd is 1008 so in that case, the program ran fine... but later on, i

Re: New SourceForge project: Diet Python!!!

2006-07-18 Thread Jarek Zgoda
The Eternal Squire napisał(a): > Diet Python is a flavor of Python with allegro, multiarray, umath, > calldll, npstruct and curses builtin, all else nonessential to language > ripped out. Total size < 3MB, 1% of PSF Python. Diet Python helps keep > clients thin :) Why do you think curses are esse

Re: Coding style

2006-07-18 Thread bearophileHUGS
Volker Grabsch wrote: > IMHO, that flaw of Python should be documented in a PEP as it violates > Python's priciple of beeing explicit. It also harms duck typing. I think this may be good food for Python 3.0, the are removing undefined comparisons too (>), etc. bye, bearophile -- http://mail.pyt

Re: No need to close file?

2006-07-18 Thread Robert Kern
T wrote: > Thomas Bartkus wrote: >> "T" <[EMAIL PROTECTED]> wrote in message >> news:[EMAIL PROTECTED] >>> Do I need to close the file in this case? Why or why not? >>> >>> for line in file('foo', 'r'): >>> print line >> Are you asking if you can get away without closing it? >> Or are you asking

Re: No need to close file?

2006-07-18 Thread Grant Edwards
On 2006-07-18, T <[EMAIL PROTECTED]> wrote: >>> for line in file('foo', 'r'): >>> print line >> Good programming practice says that if you open it - you close it. >> >> And stay out of trouble ;-) > How do I close the file in the above case? Aye, there's the rub. You can't close an anonymous

Re: No need to close file?

2006-07-18 Thread T
Thomas Bartkus wrote: > "T" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Do I need to close the file in this case? Why or why not? > > > > for line in file('foo', 'r'): > > print line > > Are you asking if you can get away without closing it? > Or are you asking if it is a g

Re: Coding style

2006-07-18 Thread David M. Cooke
[EMAIL PROTECTED] (David M. Cooke) writes: > > Bruno's already mentioned that iterators and generators aren't > sequences. Numpy arrays act like the other sequence types: > a = numpy.array([]) a > array([], dtype=int64) len(a) > 0 bool(a) > False > > (0-dimensional numpy arrays

Re: No need to close file?

2006-07-18 Thread Grant Edwards
On 2006-07-18, Sybren Stuvel <[EMAIL PROTECTED]> wrote: > T enlightened us with: >> Do I need to close the file in this case? Why or why not? >> >> for line in file('foo', 'r'): >> print line > > Nope, it'll get closed automatically when the file object gets garbage > collected. Which might not

Re: Coding style

2006-07-18 Thread David M. Cooke
"Carl Banks" <[EMAIL PROTECTED]> writes: > Patrick Maupin wrote: >> PTY wrote: >> >> > It looks like there are two crowds, terse and verbose. I thought terse >> > is perl style and verbose is python style. BTW, lst = [] was not what >> > I was interested in :-) I was asking whether it was bette

Re: No need to close file?

2006-07-18 Thread [EMAIL PROTECTED]
T wrote: > Do I need to close the file in this case? Why or why not? > > for line in file('foo', 'r'): > print line I was running a program in IDLE that opened a file for reading and forgot to add the close. The program ran and terminated normally. But when I tried to open it from Windows Ex

need help getting xml feed from a url

2006-07-18 Thread Shan
If i have a list of urls how can I extract or pull their respective xml feeds? -- http://mail.python.org/mailman/listinfo/python-list

Re: pytables - best practices / mem leaks

2006-07-18 Thread py_genetic
py_genetic wrote: > I have an H5 file with one group (off the root) and two large main > tables and I'm attempting to aggragate my data into 50+ new groups (off > the root) with two tables per sub group. > > sys info: > PyTables version: 1.3.2 > HDF5 version: 1.6.5 > numarray version: 1.5.0

Re: New SourceForge project: Diet Python!!!

2006-07-18 Thread The Eternal Squire
Hm didn't I leave ctypes in there? I added calldll because it had a really nice can opener. The Eternal Squire [EMAIL PROTECTED] wrote: > >> Diet Python is a flavor of Python with allegro, multiarray, umath, > >> calldll, npstruct and curses builtin, all else nonessential to > >> lan

Re: run a string as code?

2006-07-18 Thread py_genetic
Gary Herron wrote: > py_genetic wrote: > > py_genetic wrote: > > > >> [EMAIL PROTECTED] wrote: > >> > >>> py_genetic wrote: > >>> > How can you make python interpret a string (of py code) as code. For > example if you want a py program to modify itself as it runs. I know > this is

Re: Using Visual Slick Edit for Python

2006-07-18 Thread jjones
> P.S. Have you already upgraded to v11 and is there anything worthwhile > in it (Python or otherwise)? Hi, We have just released 11.0.1 where we improve and add new support for scripting and dynamic languages. A snippet of the press release can be found below. SlickEdit v11.0.1 continues to im

Re: range() is not the best way to check range?

2006-07-18 Thread Simon Forman
K.S.Sreeram wrote: > Simon Forman wrote: > > Nick Craig-Wood wrote: > >> Sets are pretty fast too, and have the advantage of flexibility in > >> that you can put any numbers in you like > >> > > > > I know this is self-evident to most of the people reading this, but I > > thought it worth pointing

Re: No need to close file?

2006-07-18 Thread Thomas Bartkus
"T" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Do I need to close the file in this case? Why or why not? > > for line in file('foo', 'r'): > print line Are you asking if you can get away without closing it? Or are you asking if it is a good idea to not close it? Good progra

Re: Should this be added to MySQLdb FAQ?

2006-07-18 Thread Nick Vatamaniuc
gmax2006, Yes, perhaps the MySQLdb project should mention that packages are usually available in the popular distributions. I am using Ubuntu and everything I needed for MySQL and Python was in the repositories , 'apt-get' one-lines is all that is needed. In general though, I found that more often

Re: No need to close file?

2006-07-18 Thread Nick Vatamaniuc
I think file object should be closed whether they will be garbage collected or not. The same goes for DB and network connections and so on. Of course in simple short programs they don't have to, but if someone keeps 1000 open files it might be better to close them when done. Besides open files (

Re: Augument assignment versus regular assignment

2006-07-18 Thread Piet van Oostrum
> Antoon Pardon <[EMAIL PROTECTED]> (AP) wrote: >AP> On 2006-07-17, Piet van Oostrum <[EMAIL PROTECTED]> wrote: Antoon Pardon <[EMAIL PROTECTED]> (AP) wrote: >>> >AP> On 2006-07-14, Piet van Oostrum <[EMAIL PROTECTED]> wrote: >>> >> Just read what it says. `It is only evaluated

Re: No need to close file?

2006-07-18 Thread Jarek Zgoda
T napisał(a): > Do I need to close the file in this case? Why or why not? > > for line in file('foo', 'r'): > print line No, if you only read from the file. But anyway, closing file object is considered good practice in many documents I found, no matter what you do with it. -- Jarek Zgoda

Re: range() is not the best way to check range?

2006-07-18 Thread bearophileHUGS
Dan Bishop: > xrange already has __contains__. The problem is, it's implemented by a > highly-inefficient sequential search. Why not modify it to merely > check the bounds and (value - start) % step == 0? I think this is a nice idea. Bye, bearophile -- http://mail.python.org/mailman/listinfo/

Re: No need to close file?

2006-07-18 Thread bearophileHUGS
T wrote: > Do I need to close the file in this case? Why or why not? > for line in file('foo', 'r'): > print line Close the file in Jython, but often it's not necessary in CPython. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Capturing instant messages

2006-07-18 Thread Nick Vatamaniuc
Assuming a one person per one machine per one chat protocol it might be possible to recreate the tcp streams (a lot of packet capturing devices already do that). So the gateway would have to have some kind of a dispatch that would recognize the initialization of a chat loggon and start a capture pr

Re: Defining functions in an implementation file

2006-07-18 Thread Diez B. Roggisch
westymatt schrieb: > I am fairly new to python and I want to put alot of my functions in > another python file and import or from it into my script so I can call > the functions. How is this done? import myfilefullofusefulfunctionsandclasses Works if you have the file myfilefullofusefulfuncti

Re: No need to close file?

2006-07-18 Thread skip
T> Do I need to close the file in this case? Why or why not? T> for line in file('foo', 'r'): T> print line No. The magic of reference counting. S -- http://mail.python.org/mailman/listinfo/python-list

Re: Coding style

2006-07-18 Thread Patrick Maupin
Daniel Dittmar wrote: > > Premature generalization: the new 'premature optimization'. Premature specialization: the new 'static typing'. -- Pat -- http://mail.python.org/mailman/listinfo/python-list

No need to close file?

2006-07-18 Thread T
Do I need to close the file in this case? Why or why not? for line in file('foo', 'r'): print line -- http://mail.python.org/mailman/listinfo/python-list

Re: Dispatch with multiple inheritance

2006-07-18 Thread Nick Vatamaniuc
Michael, You only need to call the __init__ method of the superclass if you need to do something special during initialization. In general I just use the SuperClass.__init__(self,...) way of calling the super class constructors. This way, I only initialize the immediate parents and they will in tur

Re: New SourceForge project: Diet Python!!!

2006-07-18 Thread M�ta-MCI
Hi! Interesting (or fun?). Have you a Internet page, or only README? @+ MCI -- http://mail.python.org/mailman/listinfo/python-list

Re: CSV with comments

2006-07-18 Thread skip
>> In csv.reader, is there any way of skip lines that start whith '#' or >> empty lines Nope. When we wrote the module we weren't aware of any "spec" that specified comments or blank lines. You can easily write a file wrapper to filter them out though: class BlankCommentCSVFile:

Re: ScientificPython - LeastSquareFit diverges

2006-07-18 Thread Terry Reedy
"Harold Fellermann" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I am trying to fit a powerlaw to a small dataset using > Scientific.Functions.LeastSquares fit. This is a bit off-topic here, and normally better for the scipy list, but I have some experience with nonlinear least

Defining functions in an implementation file

2006-07-18 Thread westymatt
I am fairly new to python and I want to put alot of my functions in another python file and import or from it into my script so I can call the functions. How is this done? -- http://mail.python.org/mailman/listinfo/python-list

Re: Cyclic class definations

2006-07-18 Thread Nick Vatamaniuc
John, Cycles are tricky. Python is an interpreted dynamic language, whatever object you instantiate in your methods is a different thing than class hierarchy. Your class hierarchy is fine: ClassA->ClassASubclass->ClassC and it should work. If it doesn't, create a quick mock example and post it alo

Re: execute a shell script from a python script

2006-07-18 Thread Cameron Laird
In article <[EMAIL PROTECTED]>, Thomas Nelson <[EMAIL PROTECTED]> wrote: >As described in the docs I pointed to before: >subprocess.call("foo.sh",shell=True) >Is the way to do it without args. I think it is simplest to learn the >subprocess module because (quoting from the docs) this module intend

Dispatch with multiple inheritance

2006-07-18 Thread Michael J. Fromberger
Consider the following class hierarchy in Python: class A (object): def __init__(self): print "cons A" class B (object): def __init__(self): print "cons B" class C (A): def __init__(self): super(C, self).__init__() print "cons C" class D (B): def

Re: Augument assignment versus regular assignment

2006-07-18 Thread Terry Reedy
"Antoon Pardon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On 2006-07-17, Terry Reedy <[EMAIL PROTECTED]> wrote: >> Or, whether docs (and reasonable interpretation thereof) and >> implementation match, which I claim they do it this case. The claim, in reference to the CPython

Re: Cyclic class definations

2006-07-18 Thread John Henry
I think I got the answer by playing around a bit. It appears you *don't* need to forward declare things. For example, the following code works: class a: def run(self): new_a=a_sub() new_a.print_it() class a_sub(a): def print_it(self): print "Hi" b=a().run() Regards, John He

Re: tkinter help

2006-07-18 Thread faulkner
add a xscrollcommand and/or yscrollcommand keyword argument to the construction of your listbox. def func(*a): print "i'm a callback!" L = Tkinter.Listbox(root, yscrollcommand=func)# note no parens after func groves wrote: > hi eveyrbody , i have started working on python tkinter, > Whi

Re: Accessors in Python (getters and setters)

2006-07-18 Thread mystilleef
Bruno Desthuilliers wrote: > mystilleef wrote: > > Bruno Desthuilliers wrote: > > > >>mystilleef wrote: > >>Please don't top-post > >> > >>>On State and Behavior: > >>> > >>>To understand objects in terms of state and behavior you need to > >>>absolve yourself from implementation details of langua

Re: range() is not the best way to check range?

2006-07-18 Thread Grant Edwards
On 2006-07-18, Paul Boddie <[EMAIL PROTECTED]> wrote: >> It's unclear what you're referring to as "the range". > > The notion of something describing a range of values which can be > expanded to a list or, of relevance here, whose boundaries can be > tested efficiently. > >> Perhaps you're thinkin

Cyclic class definations

2006-07-18 Thread John Henry
Hi list, I am trying to understand better Python packaging. This might be a messed up class hierachy but how would I break this cyclic relatioship? In file A: from B import B_Class Class_A_Main(): def def SomeMethod(self): res=B_Class(self) Class_A_SubClass(Class_A_Main):

Re: range() is not the best way to check range?

2006-07-18 Thread Grant Edwards
On 2006-07-18, Steve Holden <[EMAIL PROTECTED]> wrote: >> That said, "for pete's sake" is probably a just an cleaned up >> version of "for god's sake", so I probably did call pete god. > > No, actually you called god pete ;-) Well that's certainly wrong, because we all know god's name is Howard.

Re: Accessors in Python (getters and setters)

2006-07-18 Thread mystilleef
Bruno Desthuilliers wrote: > mystilleef wrote: > > Bruno Desthuilliers wrote: > > > >>mystilleef wrote: > >> > >>>Gerhard Fiedler wrote: > >>> > >>> > On 2006-07-15 06:55:14, mystilleef wrote: > > > > >In very well designed systems, the state of an object should only be > >>

Re: Piping external commands

2006-07-18 Thread Simon Forman
[EMAIL PROTECTED] wrote: > What is the Python translation for this Bash statement: > > tar cf - "[EMAIL PROTECTED]" | bzip2 > "$file".tar.bz2 > > (Ignoring the fact that "tar cjf" also exists...) > > In other words, how does one pipe together arbitrary commands? For piping subcommands check out

Re: range() is not the best way to check range?

2006-07-18 Thread Paul Boddie
Grant Edwards wrote: > > It's unclear what you're referring to as "the range". The notion of something describing a range of values which can be expanded to a list or, of relevance here, whose boundaries can be tested efficiently. > Perhaps you're thinking of a slice? Somethign like > > if (0

Re: range() is not the best way to check range?

2006-07-18 Thread Simon Forman
Diez B. Roggisch wrote: > Simon Forman wrote: > > > Nick Craig-Wood wrote: > >> > >> Sets are pretty fast too, and have the advantage of flexibility in > >> that you can put any numbers in you like > >> > > > > I know this is self-evident to most of the people reading this, but I > > thought it wor

Re: range() is not the best way to check range?

2006-07-18 Thread K.S.Sreeram
Simon Forman wrote: > Nick Craig-Wood wrote: >> Sets are pretty fast too, and have the advantage of flexibility in >> that you can put any numbers in you like >> > > I know this is self-evident to most of the people reading this, but I > thought it worth pointing out that this is a great way to te

Re: statistical analysis tools in python?

2006-07-18 Thread Thomas Nelson
Actually, after a little looking, the simple stats.py module at http://www.nmr.mgh.harvard.edu/Neural_Systems_Group/gary/python.html is exactly what I needed. It may not be as fast or as comprehensive as scipy or R, but installation simply involves downloading the module and importing into the cod

Should this be added to MySQLdb FAQ?

2006-07-18 Thread gmax2006
Hi, I went through couple of wrong paths to install MySQLdb on my RedHat box. I was trying to download MySQL client from MySQL.com and also mySQLdb from SourceForge. After some challenges with compile errors and also searching for pre-required RPMs, I found RedHat distribution already contains all

Re: question about what lamda does

2006-07-18 Thread [EMAIL PROTECTED]
I stand corrected. Not sure where I got that from, improper defragmentation due to sleep depravation perhaps... K.S.Sreeram wrote: > [EMAIL PROTECTED] wrote: > > The two primary differences between using def and using lambda is that > > lambda is limited to a single expression and def cannot be us

  1   2   3   >