calling a class method

2006-03-01 Thread John Salerno
I'm reading about class methods now and I have a question about calling them. I know it is wrong of me to assume it needs to work in a parallel manner to an instance method, but I'm curious why it doesn't. Here's the book's example: class Multi: def imeth(self, x): print self, x

Re: Matplotlib logarithmic scatter plot

2006-03-01 Thread John Hunter
> "Derek" == Derek Basch <[EMAIL PROTECTED]> writes: Derek> formatter = FuncFormatter(log_10_product) Derek> ax.xaxis.set_major_formatter(formatter) Derek> ax.yaxis.set_major_formatter(formatter) I would caution you against using identical objects for the x and y axis *Locators*.

Re: calling a class method

2006-03-01 Thread Simon Percivall
Read this: http://users.rcn.com/python/download/Descriptor.htm Long story short: The type of the instance is passed along together with the instance itself. -- http://mail.python.org/mailman/listinfo/python-list

Re: Matplotlib logarithmic scatter plot

2006-03-01 Thread Derek Basch
Good tip John. Hopefully it will help someone out. Thanks again. Derek Basch -- http://mail.python.org/mailman/listinfo/python-list

Re: Best python module for Oracle, but portable to other RDBMSes

2006-03-01 Thread dananrg
The other thing I didn't do a good job of explaining is that I want to have a layer of abstraction between the underlying RDBMS and the business logic. It's the business logic I want to use Python for, so that would stay roughly the same between RDBMS changes, if we ever have an RDBMS change. I agr

Re: Make staticmethod objects callable?

2006-03-01 Thread Terry Reedy
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > >>> class Parrot: > ... def speak(): > ... return "dead parrot" > ... speak = staticmethod(speak) > ... def playdead(): > ... return "still dead" > ... > >>> type(Parrot.speak) > >

Re: calling a class method

2006-03-01 Thread John Salerno
Simon Percivall wrote: > Read this: http://users.rcn.com/python/download/Descriptor.htm > > Long story short: The type of the instance is passed along together > with the instance itself. > "Unlike static methods, class methods prepend the class reference to the argument list before calling the

Re: Accessing 'mangled' class attrbutes

2006-03-01 Thread Gerard Flanagan
Steve Juranich wrote: > Gerard Flanagan wrote: > > > I tried that Steve but it didn't work, and i don't think I can do what > > I want in any case. There is no method '__write' in the base class, it > > is only declared as an instance attribute in the constructor, like so: > > > > def __init__

Re: newbie question

2006-03-01 Thread Steve Juranich
orangeDinosaur wrote: > Hi, > > I'm brand new to using/playing with Python, and I have what is likely a > very simple question but can't seem to figure it out. > > I wrote up a script in my preferred text editor. It contains maybe ten > lines of code. I want to be able to execute those code li

Proper class initialization

2006-03-01 Thread Christoph Zwerschke
Usually, you initialize class variables like that: class A: sum = 45 But what is the proper way to initialize class variables if they are the result of some computation or processing as in the following silly example (representative for more: class A: sum = 0 for i in range(10):

Re: Threading - will threads run in parallel?

2006-03-01 Thread Mc Osten
On 28 Feb 2006 11:20:05 -0800, SolaFide wrote: > (get() is a function which waits for a ping on a specific port, thus > stopping the program for a while.) It's a busy wait? -- USB Priests for only 10$ -- http://mail.python.org/mailman/listinfo/python-list

Stopping Windows Service

2006-03-01 Thread D
I have a simple file server utility that I wish to configure as a Windows service - using the examples of the Python Win32 book, I configured a class for the service, along with the main class functions __init__, SvcStop, and SvcDoRun (which contains my server code). After registering the service,

Re: Proper class initialization

2006-03-01 Thread Jack Diederich
On Wed, Mar 01, 2006 at 09:25:36PM +0100, Christoph Zwerschke wrote: > Usually, you initialize class variables like that: > > class A: > sum = 45 > > But what is the proper way to initialize class variables if they are the > result of some computation or processing as in the following silly

Re: newbie question

2006-03-01 Thread D
Yep, that should work. Just keep in mind that if python.exe is not in your path, you will need to either specify the entire path to it (i.e. 'C:\python24\python C:\path\to\script\myscript.py'), or cd into its directory first (i.e. if you want to just run 'python C:\path\to\script\myscript.py'). D

Re: Stopping Windows Service

2006-03-01 Thread Paul Metzger
On Wed, 2006-03-01 at 12:41 -0800, D wrote: > I have a simple file server utility that I wish to configure as a > Windows service - using the examples of the Python Win32 book, I > configured a class for the service, along with the main class functions > __init__, SvcStop, and SvcDoRun (which conta

Re: newbie question

2006-03-01 Thread Paul Metzger
> I'm brand new to using/playing with Python, and I have what is likely a > very simple question but can't seem to figure it out. > Python is fun and it's easier to use a real OS to develop the programs, then if need be, not that difficult to move them to windows:) > I wrote up a script in my pr

Re: Cross compile generation of .pyc from .py files...

2006-03-01 Thread David Wahler
[EMAIL PROTECTED] wrote: > I was under the impression, that the .pyc files will be used (if found) > by python to speed up execution of scripts... and so we packaged, > deployed and installed the .py/.pyc files on to the ppc-target system. > That package includes, site.py(c), types.py(c) etc., amon

Re: Proper class initialization

2006-03-01 Thread Larry Bates
Christoph Zwerschke wrote: > Usually, you initialize class variables like that: > > class A: >sum = 45 > > But what is the proper way to initialize class variables if they are the > result of some computation or processing as in the following silly > example (representative for more: > > cla

Re: Stopping Windows Service

2006-03-01 Thread Larry Bates
D wrote: > I have a simple file server utility that I wish to configure as a > Windows service - using the examples of the Python Win32 book, I > configured a class for the service, along with the main class functions > __init__, SvcStop, and SvcDoRun (which contains my server code). After > regis

Re: Stopping Windows Service

2006-03-01 Thread D
Thanks guys. Larry - I inserted the rc lines right after I do the listen() and the service is not functioning properly (service is terminating). Where am I going wrong here? Doug -- http://mail.python.org/mailman/listinfo/python-list

Re: Is it better to use class variables or pass parameters?

2006-03-01 Thread Dave Benjamin
On Wed, 1 Mar 2006, Derek Basch wrote: > This one has always bugged me. Is it better to just slap a "self" in > front of any variable that will be used by more than one class method > or should I pass around variable between the methods? As a general rule, I only turn a parameter into an instance

Re: Make staticmethod objects callable?

2006-03-01 Thread Steven D'Aprano
On Wed, 01 Mar 2006 08:32:20 -0700, Steven Bethard wrote: > (For anyone else out there reading who doesn't already know this, Steven > D'Aprano's comments are easily explained by noting that the __get__ > method of staticmethod objects returns functions, and classes always > call the __get__ me

PythonWin: any way to delete all objects without exiting and without doing it with "del"?

2006-03-01 Thread dananrg
In PythonWin, is there any way to bulk-delete all objects without using "del object" for each, and without having to exit out of PythonWin? -- http://mail.python.org/mailman/listinfo/python-list

Re: PythonWin: any way to delete all objects without exiting and without doing it with "del"?

2006-03-01 Thread Lawrence Oluyede
[EMAIL PROTECTED] writes: > In PythonWin, is there any way to bulk-delete all objects without using > "del object" for each, and without having to exit out of PythonWin? PythonWin is just an IDE. For what reason you have to delete all objects by yourself? Garbage collector is there for that :) -

Re: Is it better to use class variables or pass parameters?

2006-03-01 Thread Steven D'Aprano
On Wed, 01 Mar 2006 11:32:02 -0800, Derek Basch wrote: > This one has always bugged me. Is it better to just slap a "self" in > front of any variable that will be used by more than one class method > or should I pass around variable between the methods? That depends on whether the variable is con

Re: Proper class initialization

2006-03-01 Thread Christoph Zwerschke
Jack Diederich wrote: > ... __metaclass__ = MyMeta Thanks. I was not aware of the __metaclass__ attribute. Still a bit complicated and as you said, difficult to read, as the other workarounds already proposed. Anyway, this is probably not needed so often. -- Christoph -- http://mail.python.o

Re: PEP 354: Enumerations in Python

2006-03-01 Thread Peter Maas
Paul Rubin schrieb: >> But if you have a good usage case for an empty enum, please feel free >> to tell us. > > Do you have a good usage case for the number > 647574296340241173406516439806634217274336603815968998799147348150763731 ? Yes, it could be the value of my property in any currency :) Bu

Re: [coding style] Searching for uniqness in a list of data

2006-03-01 Thread Bruno Desthuilliers
Claudio Grondi a écrit : (snip) > > list=['1p2m_3.3-1.8v_sal_ms','1p2m_3.3-1.8v_pol_ms','1p3m_3.3-18.v_sal_ms'] Avoid using 'list' as an identifier. (snip) -- http://mail.python.org/mailman/listinfo/python-list

Decimal(1) > 0.0 == False

2006-03-01 Thread Konstantin Veretennicov
Hello, I'm having hard time trying to justify this decimal quirk to my coworker (he calls it a bug): ActivePython 2.4.1 Build 247 (ActiveState Corp.) based on Python 2.4.1 (#65, Jun 20 2005, 17:01:55) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more i

why descriptors? (WAS: Make staticmethod objects callable?)

2006-03-01 Thread Steven Bethard
Steven Bethard wrote: > (For anyone else out there reading who doesn't already know this, > Steven D'Aprano's comments are easily explained by noting that the > __get__ method of staticmethod objects returns functions, and classes > always call the __get__ methods of descriptors when those desc

Re: Is it better to use class variables or pass parameters?

2006-03-01 Thread Terry Hancock
On 1 Mar 2006 11:32:02 -0800 "Derek Basch" <[EMAIL PROTECTED]> wrote: > This one has always bugged me. Is it better to just slap a > "self" in front of any variable that will be used by more > than one class method or should I pass around variable > between the methods? My first reaction was that

Re: newbie question

2006-03-01 Thread Brain Murphy
i keep on getting this message that says socket error, then says that python was unable to connect to its start up process. what does this mean and how can i fix it? D <[EMAIL PROTECTED]> wrote: Yep, that should work. Just keep in mind that if python.exe is not inyour path, you will need to eith

Re: Proper class initialization

2006-03-01 Thread Steven Bethard
Christoph Zwerschke wrote: > But I wonder whether it is possible to put all this init code into one > class initialization method, something like that: > > class A: > > @classmethod > def init_class(self): > sum = 0 > for i in range(10): > sum += i > s

Re: PythonWin: any way to delete all objects without exiting and without doing it with "del"?

2006-03-01 Thread Steven Bethard
[EMAIL PROTECTED] wrote: > In PythonWin, is there any way to bulk-delete all objects without using > "del object" for each, and without having to exit out of PythonWin? I think you just want to modify the globals() dict: >>> list(globals()) ['__builtins__', 'text', 'glob', 'pywin', 're', 'match'

Re: PEP 354: Enumerations in Python

2006-03-01 Thread Terry Hancock
On Wed, 01 Mar 2006 12:26:19 +1100 Ben Finney <[EMAIL PROTECTED]> wrote: > Steven Bethard <[EMAIL PROTECTED]> writes: > > -1 on the proposal as-is. I don't have many use cases > > for enumerations, and I don't think they merit appearing > > in the builtins. If you put them in the collections > > m

Re: PEP 354: Enumerations in Python

2006-03-01 Thread Terry Hancock
On Wed, 01 Mar 2006 12:37:26 +1100 Ben Finney <[EMAIL PROTECTED]> wrote: > Ben Finney <[EMAIL PROTECTED]> writes: > > PEP:354 > > Title: Enumerations in Python > > Version:$Revision: 42186 $ > > Last-Modified: $Date: 2006-01-26 11:55:20 +1100 (Thu, > > 26 Jan 2006) $ >

Re: Proper class initialization

2006-03-01 Thread Leif K-Brooks
Steven Bethard wrote: > class A(object): > def _get_sum(): > return sum(xrange(10)) > sum = _get_sum() What's wrong with sum = sum(xrange(10))? -- http://mail.python.org/mailman/listinfo/python-list

Help: Runtime Error when loading ".pyd" module

2006-03-01 Thread Terry Tang
Hi There, We are extending Python interpreter to support special functions of our tools. What we did is to compile Python's source code (which is got from the an installation on a Linux environment for Python 2.3.3) and our extensions (C++ code) on Windows with Microsoft Visual C++ 6.0 compiler t

Re: Proper class initialization

2006-03-01 Thread Steven Bethard
Leif K-Brooks wrote: > Steven Bethard wrote: >> class A(object): >> def _get_sum(): >> return sum(xrange(10)) >> sum = _get_sum() > > What's wrong with sum = sum(xrange(10))? Nothing, except that it probably doesn't answer the OP's question. The OP presented a "s

Re: Suggestions for documentation generation?

2006-03-01 Thread John M. Gabriele
kpd wrote: > Hello, > > I have written a C++ library that I've then wrapped with Pyrex. > Any suggestions to the best-in-class tool to create documentation for > the libraries? > > I would love to document things in one spot (could be the code) and > generate html and PDF from there. > > Doxygen

Re: PEP 354: Enumerations in Python

2006-03-01 Thread Roy Smith
>> Should I amend the PEP to propose "either in the builtins >> or in the collections module"? Or should I propose two >> PEPs and let them compete? I see the issue of whether it's a built-in or part of the standard library as being a detail. My personal opinion is that they're important enough

Encoding problems with gettext and wxPython: how to do things in "good style"

2006-03-01 Thread André
I'm trying to change an app so that it uses gettext for translations rather than the idiosyncratic way I am using. I've tried the example on the wxPython wiki http://wiki.wxpython.org/index.cgi/RecipesI18n but found that the accented letters would not display properly. I have found a workaround t

Re: newbie question

2006-03-01 Thread John Zenger
orangeDinosaur wrote: > I wrote up a script in my preferred text editor. It contains maybe ten > lines of code. I want to be able to execute those code lines with a > single command either from the inline mode or from IDLE. How do I do > this? I saved the file (myscript.py) in a folder that I'

Removing .DS_Store files from mac folders

2006-03-01 Thread David Pratt
Hi. I'm trying to clean files for packaging on mac using os.path.walk and want to clean the .DS_Store files that are hidden from view but could end up in code that I produce. # Clean mac .DS_Store if current_file == '.DS_Store': print 'a DS_Store item encountered' os.remove

Re: Removing .DS_Store files from mac folders

2006-03-01 Thread Ben Cartwright
David Pratt wrote: > # Clean mac .DS_Store > if current_file == '.DS_Store': > print 'a DS_Store item encountered' > os.remove(f) ... > I can't figure why > remove is not removing. It looks like your indentation is off. From what you posted, the "print" line is prepended with

Re: Is it better to use class variables or pass parameters?

2006-03-01 Thread James Stroud
Derek Basch wrote: > This one has always bugged me. Is it better to just slap a "self" in > front of any variable that will be used by more than one class method > or should I pass around variable between the methods? > > FlamewarNOW! > > jk, I really do want other opinions. > > Thanks,

Re: newbie question

2006-03-01 Thread Michael Tobis
I think the answers so far are unnecessarily confusing and off the mark. Here is what I think you think you want to know: 1) import only works once. If you try import again, it will see the module already exists, and will ignore you 2) the functionality you think you want is reload. >>> reload m

Re: Removing .DS_Store files from mac folders

2006-03-01 Thread David Pratt
Hi Ben. Sorry about the cut and paste job into my email. It is part of a larger script. It is actually all tabbed. This will give you a better idea: for f in file_names: current_file = os.path.basename(f) print 'Current File: %s' % c

Re: PEP 354: Enumerations in Python

2006-03-01 Thread Ben Finney
Paul Rubin writes: > I don't know about this. It makes athlon64_instructions a > completely separate enum from pentium_instructions. It could be > that athlon64_instructions.add should be the same as > pentium_instructions.add . If you want the members of two distinct

Friend brings a friend.

2006-03-01 Thread Shisha Girl
http://groups.google.com/group/Hookah-Lovers.All the best discussion and inside info on hookahs and smoking tobaccos from all over the world. Shisha Girl -- http://mail.python.org/mailman/listinfo/python-list

Re: Removing .DS_Store files from mac folders

2006-03-01 Thread Ben Cartwright
David Pratt wrote: > Hi Ben. Sorry about the cut and paste job into my email. It is part of a > larger script. It is actually all tabbed. This will give you a better idea: > > for f in file_names: > current_file = os.path.basename(f) > print

WxPython question re: embedded activex internet explorer and excel

2006-03-01 Thread jojoba
Hi I currently am using an activex wrapper in wxpython to embed Internet Explorer in a wxPanel: IEmodule=win32com.client.gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-C05BAE0B}', 0,1,1) InternetExplorerActiveXClass = MakeActiveXClass(IEmodule.WebBrowser, eventObj = self) self.WebBrowser

Re: Removing .DS_Store files from mac folders

2006-03-01 Thread David Pratt
My apologies Ben. I should have included the traceback in my message. The last line of the traceback I get from python when it gets to os.remove is OSError: [Errno 2] No such file or directory: '.DS_Store' The traceback occurs immediately after printing: Current File: .DS_Store a DS_Store item

Re: WxPython question re: embedded activex internet explorer and excel

2006-03-01 Thread David Pratt
Hi jojoba. I work with wxPython too but cannot answer this question. There is an active and friendly community of wxPython users on [EMAIL PROTECTED] Robin Dunn, the lead person behind wxPython and others provide excellent advice and support on this list. Regards, David jojoba wrote: > Hi > I

Newbie in python

2006-03-01 Thread - C Saha -
Hello Python Experts   I am Chirantan, a beginner in python programming world. I have some programming knowledge in SHELL, BATCH and little bit PERL. I subscribed to this list with the hope that I will get support and help from all of you.   To start with, I thought it will be a good idea to s

Re: Suggestions for documentation generation?

2006-03-01 Thread Terry Hancock
On Wed, 01 Mar 2006 19:58:50 -0500 "John M. Gabriele" <[EMAIL PROTECTED]> wrote: > kpd wrote: > > I have written a C++ library that I've then wrapped with > > Pyrex. Any suggestions to the best-in-class tool to > > create documentation for the libraries? > > > > I would love to document things in

Re: PEP 354: Enumerations in Python

2006-03-01 Thread Paul Rubin
Ben Finney <[EMAIL PROTECTED]> writes: > > I don't know about this. It makes athlon64_instructions a > > completely separate enum from pentium_instructions. It could be > > that athlon64_instructions.add should be the same as > > pentium_instructions.add . > > If you want the members of two dist

in need of some sorting help

2006-03-01 Thread ianaré
Hey all, if i use a os.walk() to append files to a list like so... files = [] root = self.path.GetValue() # wx.TextCtrl input filter = self.fileType.GetValue().lower() # wx.TextCtrl input not_type = self.not_type.GetValue() # wx.CheckBox input for base, dirs, walk_files in os.walk(root):

Re: Removing .DS_Store files from mac folders

2006-03-01 Thread Ben Cartwright
David Pratt wrote: > OSError: [Errno 2] No such file or directory: '.DS_Store' Ah. You didn't mention a traceback earlier, so I assumed the code was executing but you didn't see the file being removed. > >>for f in file_names: > >>current_file = os.path.basename

Weekly Python Patch/Bug Summary

2006-03-01 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 382 open ( -3) / 3079 closed (+12) / 3461 total ( +9) Bugs: 880 open (+16) / 5624 closed ( +3) / 6504 total (+19) RFE : 211 open ( +0) / 201 closed ( +1) / 412 total ( +1) New / Reopened Patches __ PEP 357 -

Re: Numerical solver

2006-03-01 Thread David Isaac
"Laszlo Zsolt Nagy" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I would like to use a numerical solver for a specific problem. Another possibility: http://nlpy.sourceforge.net/ Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Rapid web app development tool for database

2006-03-01 Thread George Sakkis
Is there any tool in python (or with python bindings) like Oracle Application Express, former HTML DB (http://www.oracle.com/technology/products/database/application_express/index.html) ? Ideally it should be dbms-agnostic, e.g. by using SQLObject to talk to the database. The closest I can think of

Re: How can I find the remainder when dividing 2 integers

2006-03-01 Thread George Sakkis
Learn about ther itertools module, one of the most useful and elegant modules in the standard library (http://docs.python.org/lib/module-itertools.html): import itertools as it colors = ["#ff", "#00FF00", "#FF"] words = "Itertools is a pretty neat module".split() for word_color in it.izip(

Re: Writing an applilcation that can easily adapt to any language

2006-03-01 Thread Mikael Olofsson
Chance Ginger wrote: > I am rather new at Python so I want to get it right. What I am doing > is writing a rather large application with plenty of places that > strings will be used. Most of the strings involve statements of > one kind or another. > > I would like to make it easy for the support

<    1   2