Problem combining Scientific (leastSquaresFit) and scipy (odeint)

2009-11-21 Thread Harold Fellermann
Hi, I need to perform leastSquaresFit of a model that is given by a differential equation for which there seems to be no analytic solution. So, I am trying to solve the ODE numerically (using scipy.integrate.odeint) within the function I provide to leastSquaresFit as a model: def func(L, t, a, k)

Re: Don't you just love writing this sort of thing :)

2008-12-04 Thread Harold Fellermann
On Dec 4, 10:39 am, Cong Ma <[EMAIL PROTECTED]> wrote: > Lawrence D'Oliveiro wrote: > > for \ > >         Entry \ > >     in \ > >         sorted \ > >           ( > >             f for f in os.listdir(PatchesDir) if PatchDatePat.search(f) != > > None > >           ) \ > > : > >     Patch = (open,

Re: Creating classes and objects more than once?

2008-11-27 Thread Harold Fellermann
On Nov 27, 6:42 pm, Viktor Kerkez <[EMAIL PROTECTED]> wrote: > Is this a bug? It is not a bug: the dictionaries are different because they are loaded from different modules. >>> import os >>> import test.data >>> test.data >>> os.chdir('test') >>> import data >>> data >>> test.data is data Fals

Re: Python Linear Programming on Ubuntu

2008-09-17 Thread Harold Fellermann
> > http://wiki.python.org/moin/NumericAndScientific/Libraries > > > > Scroll down. > > Yes, many of those seem to be deprecated, without destinations to > links, most are poorly or not documented at all. The few that are, I > still can't get running. Of those 254, I think I have tried at least >

Re: Profiling, sum-comprehension vs reduce

2008-09-13 Thread Harold Fellermann
> doesnt sum first construct the list then sum it? > def com(lst): > return sum(x for x in lst) You construct a generator over an existing list in your code. Try sum([x for x in lst]) to see the effect of additional list construction. And while you're at it, try the simple sum(lst). Cheers,

Re: Problem with the strip string method

2008-03-03 Thread Harold Fellermann
> Thanks to all respondents, Steve Holden > is right, I expected more than I should > have. Others have explained why all your examples work as they should. >From your exmaples, it seems like you would like strip to remove the leading and trailing characters from EVERY LINE in your string. This ca

Re: Better writing in python

2007-10-24 Thread Harold Fellermann
Hi Alexandre, On Oct 24, 2:09 pm, Alexandre Badez <[EMAIL PROTECTED]> wrote: > I'm just wondering, if I could write a in a "better" way this code Please tell us, what it is you want to achieve. And give us some context for this function. > lMandatory = [] > lOptional = [] > for arg in cls.dArgum

passing options to __import__

2007-04-03 Thread Harold Fellermann
Dear list, I looked through the list but could not find any solutions for my current problem. Within my program, I am importing a module via __import__(module_name,globals(),locals()) and I want to pass comand line options to this module. I would prefer not to save them in a config module or a Con

Re: design question: no new attributes

2007-03-14 Thread Harold Fellermann
Hi Alan, > One last point. While I remain interested in examples of how > "late" addition ofattributesto class instances is useful, > I must note that everyone who responded agreed that it > has been a source of bugs. This seems to argue against a > general ban on "locking" objects in some way, i

Re: mp3 libs and programs

2006-09-15 Thread Harold Fellermann
hi, Jay wrote: > I'm writing a python script that involves playing mp3 files. The first > approach I had was sending commands to unix command-line programs in > order to play them. I tired mpg123 and moosic, but there was a key > feature to my program's success that's missing. SEEK! I need to

Re: ScientificPython - LeastSquareFit diverges

2006-07-19 Thread Harold Fellermann
Thanks for your advices, Terry and Konrad, using the linear fit as initial condition for the pawerlow fit works pretty well for my data. (I already had the two calculations but performed them vice versa ... :-) Anyway, I had the impression that the leastSquaresFit in Scientific Python is an implem

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

ScientificPython - LeastSquareFit diverges

2006-07-18 Thread Harold Fellermann
Dear all, I am trying to fit a powerlaw to a small dataset using Scientific.Functions.LeastSquares fit. Unfortunately, the algorithm seems to diverge and throws an OverflowException. Here is how I try it: >>> from Scientific.Functions.LeastSquares import leastSquaresFit >>> >>> data = [ ... (2

Re: Searching and manipulating lists of tuples

2006-06-12 Thread Harold Fellermann
MTD wrote: > Hello, > > I'm wondering if there's a quick way of resolving this problem. > > In a program, I have a list of tuples of form (str,int), where int is a > count of how often str occurs > > e.g. L = [ ("X",1),("Y",2)] would mean "X" occurs once and "Y" occurs > twice > > If I am given a

Re: how to switch from os.tmpnam to os.tmpfile

2006-06-08 Thread Harold Fellermann
Chris Lambacher wrote: > You should be able to find exactly what you need in the tempfile module. > http://docs.python.org/lib/module-tempfile.html thanks! tempfile.NamedTemporaryFile() is exaclty what I have been looking for. Using python for such a long time now, and still there are unknown goo

Re: how to switch from os.tmpnam to os.tmpfile

2006-06-08 Thread Harold Fellermann
Maric Michaud wrote: > Le Jeudi 08 Juin 2006 15:30, Harold Fellermann a écrit : > > to os.tmpfile() which is supposed to be safer, but I do not know how to > > get > > the path information from the file object returned by tmpfile(). any > > clues? > There is no path

Re: From Python to Shell

2006-06-08 Thread Harold Fellermann
> Im not a total noob but i don't know the command and the module to go > from python to the default shell. there are several ways depending on what exactly you want to achieve: sys.exit(return_value): terminates the python process and gives controll back to the shell os.system(command_string

how to switch from os.tmpnam to os.tmpfile

2006-06-08 Thread Harold Fellermann
Hi, I need to create a temporary file and I need to retrieve the path of that file. os.tmpnam() would do the job quite well if it wasn't for the RuntimeWarning "tmpnam is a potential security risk to your program". I would like to switch to os.tmpfile() which is supposed to be safer, but I do not

Re: Feature request: sorting a list slice

2006-05-19 Thread Harold Fellermann
Fredrik Lundh wrote: > George Sakkis wrote: > > > It would be useful if list.sort() accepted two more optional > > parameters +1 > useful for what? what's the use case ? Actually, I was in need of such a construct only few weeks ago. The task was to organize playlists of an mp3 player. I wanted

Re: Help System For Python Applications

2006-05-16 Thread Harold Fellermann
I usually go for the webbrowser package that allows me to launch the systems webbrowser and opens my html help files. It is really simple: >>> import webbrowser >>> webbrowser.open("file:///path_to/help.html#topic") and thats all there is to do. - harold - -- http://mail.python.org/mailman/lis

Re: what is the difference between tuple and list?

2006-05-16 Thread Harold Fellermann
The main difference is that lists are mutables while tuples are not. Tuples are fine if you only want to group some objects (e.g. as a return value) and access their members as in >>> t = (1,2,3,4) >>> t[2] 3 Lists give you a lot more flexibility, because they are mutable: you can change the orde

scientific libraries for python

2006-05-11 Thread Harold Fellermann
Hi all, I want to use the current need for a Levenberg-Marquardt least squares fitting procedure for my long term desire to dive into scientific libraries for python. However, I am always confused by the shear sheer variety of available packages and the fact that some of them (Numeric, Numarray) s

Re: redirecting print to a a file

2006-05-11 Thread Harold Fellermann
>>> import sys >>> sys.stdout = file("output","w") >>> print "here you go" -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I do this with python ?

2006-05-09 Thread Harold Fellermann
Better go for the subprocess module. It is supposed to replace os.popen and has a much nicer interface. - harold - -- http://mail.python.org/mailman/listinfo/python-list

Re: __getattr__ for global namespace?

2006-05-06 Thread Harold Fellermann
Great! sys.excepthook() is exactly what I was looking for. Thank you. -- http://mail.python.org/mailman/listinfo/python-list

__getattr__ for global namespace?

2006-05-04 Thread Harold Fellermann
Hi, I am writing an application that initializes the global namespace, and afterwards, leaves the user with the python prompt. Now, I want to catch NameErrors in user input like e.g. >>> some_name Traceback (most recent call last): File "", line 1, in ? NameError: name 'some_name' is not define

Re: python game with curses

2006-04-28 Thread Harold Fellermann
Jerry, if you want anyone to answer your question, please read this: http://www.catb.org/~esr/faqs/smart-questions.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Protocols for Python?

2006-04-27 Thread Harold Fellermann
[EMAIL PROTECTED] wrote: > Still, I'm designing an application that I want to be extendable by > third-party developers. I'd like to have some sort of documentation > about what behavior is required by the components that can be added to > extend the application. I'd thought I might try documenting

Re: How can I import a py script by its absolute path name?

2005-07-14 Thread harold fellermann
> for f in os.listdir(os.path.abspath(libdir)): > module_name = f.strip('.py') > import module_name > > Obviously, this throws: > > ImportError: No module named module_name > > Is there some way to do this? have a look at help(__import__) to import a module whose name is given as a string

Re: automatic form filling

2005-07-12 Thread harold fellermann
> I would like to know how I could automatically fill a > (search) form on a web page and download the resulting > html page. More precisely I would like to make a > program that would automatically fill the "Buscador > lista 40" (in spanish, sorry) form in the following > webpage: > http://www.los

Re: Missing Something Simple

2005-07-12 Thread harold fellermann
>>> I have a list of variables, which I am iterating over. I need to set >>> the value of each variable. My code looks like: >>> >>> varList = [ varOne, varTwo, varThree, varFour ] >>> >>> for indivVar in varList: >>>indivVar = returnVarFromFunction() >>> >>> However, none of the variables in

Re: Missing Something Simple

2005-07-12 Thread harold fellermann
Hi, > I have a list of variables, which I am iterating over. I need to set > the value of each variable. My code looks like: > > varList = [ varOne, varTwo, varThree, varFour ] > > for indivVar in varList: > indivVar = returnVarFromFunction() > > However, none of the variables in the list ar

Re: Windows Cmd.exe Window

2005-07-07 Thread harold fellermann
On 07.07.2005, at 15:43, harold fellermann wrote: > On 07.07.2005, at 15:25, Giles Brown wrote: > >> Nah. You're missing my point. I only want the command window not to >> be closed if there is an *exception*. Picky I know, but there you go. > > well, then regist

Re: Windows Cmd.exe Window

2005-07-07 Thread harold fellermann
On 07.07.2005, at 15:25, Giles Brown wrote: > Nah. You're missing my point. I only want the command window not to > be closed if there is an *exception*. Picky I know, but there you go. well, then register raw_input as exit function: >>> import atexit >>> atexit.register(raw_input) works

Re: inheriting file object

2005-07-06 Thread harold fellermann
> I don't know if I should be inheriting file or just using a file > object. > How would I determine which one would be more appropriate? Inheritance is often refered to as an IS relation, whereas using an attribute is a HAS relation. If you inherit from file, all operations for files should

Re: inheriting file object

2005-07-06 Thread harold fellermann
On 06.07.2005, at 18:58, Jeremy wrote: > Hello all, > I am trying to inherit the file object and don't know how to do it. I > need to open a file and perform operations on it in the class I am > writing. I know the simple syntax is: > > class MyClass(file): > ... > > but I don't kno

Re: Conditionally implementing __iter__ in new style classes

2005-07-06 Thread harold fellermann
> I'm trying to implement __iter__ on an abstract base class while I > don't > know whether subclasses support that or not. > Hope that makes sense, if not, this code should be clearer: > > class Base: > def __getattr__(self, name): > if name == "__iter__" and hasattr(self, "Iterator")

trace function calls to get signatures

2005-07-04 Thread harold fellermann
Hi all, I am trying to write a script that prints out the signatures of each function call that occurs during the execution of a second script which is invoked by my program. i.e. if the inspected program is 'foo.py': def bar(x,y,z=None) : pass bar(1,"a",bar) bar(2,int) t

Re: I need help figuring out how to fix this code.

2005-06-28 Thread harold fellermann
Hi, > I need help figuring out how to fix my code. I'm using Python 2.2.3, > and > it keeps telling me invalid syntax in the if name == "Nathan" line. The problem is that you indent the if statement. the if/elif/else statements are part of the outer block, so they do not need indentation. >

Re: Python internals and parser

2005-06-23 Thread harold fellermann
Hi, On 22.06.2005, at 23:18, Michael Barkholt wrote: > Is there any detailed documentation on the structure of Pythons > internals, > besides the source code itself? > > More specifically I am looking for information regarding the C parser, > since > I am looking into the viability of using it i

Re: eval() in python

2005-06-21 Thread harold fellermann
> the doc seems to suggest that eval is only for expressions... it says > uses exec for statements, but i don't seem to see a exec function? Python 2.4 (#1, Dec 30 2004, 08:00:10) [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin Type "help", "copyright", "credits" or "license" for mo

Re: dir() with string as argument

2005-06-16 Thread harold fellermann
On 16.06.2005, at 20:59, Shankar Iyer ([EMAIL PROTECTED]) wrote: > Hi, > > Suppose I have a string, sModuleName, that contains the name of a > module. I now want to see what functions are in that module, but if I > call dir(sModuleName), I instead get the list of operations that can > be done

Re: extending Python base class in C

2005-06-15 Thread harold fellermann
Yah! Finally, I got the thing to work. Here is how I did it. /* import the module that holds the base class */ PyObject *base_module = PyImport_ImportModule("module_name"); if (!base_module) return; /* get a pointer to the base class */ PyObject *base_class = PyMapping_GetItemString(

Re: extending Python base class in C

2005-06-14 Thread harold fellermann
> "harold fellermann" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > Hi all, > > I once read that it is possible to use a python base class for a C > extension class. On 14.06.2005, at 09:29, Grigoris Tsolakidis wrote: > There was good

Re: Problem with simple C extension

2005-06-14 Thread harold fellermann
On 14.06.2005, at 18:58, harold fellermann wrote: > Am I stupid or what? Yes I was ... > // PhysicsDPD instance structure > typedef struct { >PyObject_HEAD >double cutoff; >double friction; >double noise; >double

Problem with simple C extension

2005-06-14 Thread harold fellermann
Am I stupid or what? I want to implement a very simple extension class in C (as I did it many times before...) The python equivalent of my class whould look like: class physics_DPD : def __init__(self,cutoff,friction,noise,dt) : self.cutoff = cutoff self.fr

Re: translating C++ exceptions to python

2005-06-14 Thread harold fellermann
On 13.06.2005, at 13:23, [EMAIL PROTECTED] wrote: > Hi all, > > I have a C++ library I call from python. The problem is I have c++ > exceptions that i want to be translated to python. I want to be able to > do stuff like: > try: > my_cpp_function() > except cpp_exception_1: > do_stuff > e

Re: Controlling assignation

2005-06-13 Thread harold fellermann
On 13.06.2005, at 19:23, Terry Reedy wrote: > > "harold fellermann" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >> if you write >>>>> a=A() >> an instance of class A is created and bound to the local identifier >>

extending Python base class in C

2005-06-13 Thread harold fellermann
Hi all, I once read that it is possible to use a python base class for a C extension class. To be precise, I want to achieve the following behavior: class PythonClass : pass class CClass(PythonClass) : "this class should be implemented as C extension" pass Unfortunate

Re: string formatting using the % operator

2005-06-13 Thread harold fellermann
> to return 'WHERE name LIKE %smith%'I have tried using escapes, > character codes for the % sign, and lots of other gyrations with no > success. The only thing that works is if I modify searchterm first: > >searchterm = 'smith' >searchterm ='%'+'smith'+'%' >sql += 'WHE

Re: Controlling assignation

2005-06-13 Thread harold fellermann
On 13.06.2005, at 15:52, Xavier Décoret wrote: > I would like to know if there is for python's classes an equivalent of > the operator= that can be overidden. > > Let's say I have a=A() > and I want to write a=5 > and I want this to change some internal value of a instead of making a >

Re: How do I know when a thread quits?

2005-06-09 Thread harold fellermann
On 07.06.2005, at 16:44, harold fellermann wrote: > import thread > > def parentThread() : > lock = thread.allocate_lock() > child = thread.start_new_thread(childThread,(parent,)) > lock.acquire() > > def childThread(parent) : >

Re: redirecting messgaef from sys.stdout

2005-06-07 Thread harold fellermann
On 07.06.2005, at 16:43, Ahmad Hosseinzadeh wrote: > Hello, > > I’m trying to run an external program in my > application. Both are coded in python. I need to write > an independent module that is used in the main > application. Its responsibility is to run the external > program and redirect its

Re: How do I know when a thread quits?

2005-06-07 Thread harold fellermann
we had some off-group mails. A summary is posted to improve the knowledge base of the list. Prashanth wrote: > Hi, > > I can use the threading module but I am just looking if there is a > reliable way using the thread module. > > If I use a lock... > Let us assume that the child thread has done

Re: How do I know when a thread quits?

2005-06-07 Thread harold fellermann
Hi, > I want a reliable way of knowing when the child > thread finished execution so that I can make the main thread wait till > then. > > Any ideas? use a lock. the subthread allocates the lock and releases it after processing. the main thread must wait until the lock is released. otherwiese, u

Re: Declaring self in PyObject_CallMethod

2005-05-13 Thread harold fellermann
Hi, > Calling a python method from C++ has the following signature: > > PyObject * > PyObject_CallMethod(PyObject *self, char *method_name, > char *arg_format, ...); > > I'm having trouble figuring out how to declare self. > > Let's say my python file is called stuff.py and is

Re: Question about extending the interperter

2005-05-13 Thread harold fellermann
> The problem for me is that the pointer "p" in the last function points > to the arguments: > If a user caller foo("123") - p points to '123'. > What I need is to point it to the whole string received - 'foo > ("123")'. > > Is there a way I can do this? no. at least not a simple one. you can obta

Re: curses for different terminals

2005-04-14 Thread harold fellermann
On 14.04.2005, at 19:17, Christos TZOTZIOY Georgiou wrote: On Thu, 14 Apr 2005 18:39:14 +0200, rumours say that harold fellermann <[EMAIL PROTECTED]> might have written: Hi all, I want to use curses in a server application that provides a GUI for telnet clients. Therefore, I ne

curses for different terminals

2005-04-14 Thread harold fellermann
Hi all, I want to use curses in a server application that provides a GUI for telnet clients. Therefore, I need the functionality to open and handle several screens. Concerning http://dickey.his.com/ncurses/ncurses-intro.html#init this can be done using the function newterm(type,ofp,ifp). However

Re: Equivalent string.find method for a list of strings

2005-04-08 Thread harold fellermann
I have read a text file using the command lines = myfile.readlines() and now I want to seach those lines for a particular string. I was hoping there was a way to "find" that string in a similar way as searching simply a simple string. I want to do something like lines.find.('my particular stri

Re: richcmpfunc semantics

2005-04-07 Thread harold fellermann
Thank you Greg, I figured most of it out in the meantime, myself. I only differ from you in one point. What has to be done, if the function is invoked for an operator I don't want to define? Return Py_NotImplemented. (Note that's return, *not* raise.) I used PyErr_BadArgument(); return NULL; instea

richcmpfunc semantics

2005-04-06 Thread harold fellermann
Hi all, I want to implement rich comparision in an extension class. Problem is I cannot find good documentation of the richcmpfunc semantics. Given the signature richcmpfunc compare(PyObject *,PyObject, int); I supposed the two objects passed are the ones to be compared. What is the meaning of t

Re: Class, object question.

2005-04-06 Thread harold fellermann
What I am wondering is if I have a 2nd init  or something similar to create a vector. Such as what follows and if I can how do I go about implementing it? Class vector(point): def __init___(self, point1, point2): self.i = point2.get_x() - point1.get_x() self.j = point2.get_y(

Re: class attributes and inner classes in C extensions

2005-04-01 Thread harold fellermann
I think you could as well, after PyType_Ready() is called, set it yourself with PyObject_SetAttrString(FooType, "Bar", FooBarType); You *may* have to cast the FooType and FooBarType to (PyObject *), to avoid compiler warnings. I tried this. Its shorter and and works fine, too. thanks for the pro

Re: class attributes and inner classes in C extensions

2005-04-01 Thread harold fellermann
I am working on a C extension module that implements a bunch of classes. Everything works fine so far, but I cannot find any way to implement class attributes or inner classes. Consider you have the following lines of Python : class Foo : class Bar : pass spam = "foo

class attributes and inner classes in C extensions

2005-04-01 Thread harold fellermann
Hello, I just posted this question with a wrong subject... So here again with a better one. I am working on a C extension module that implements a bunch of classes. Everything works fine so far, but I cannot find any way to implement class attributes or inner classes. Consider you have the foll

Re: property and virtuality

2005-04-01 Thread harold fellermann
Hello, I asked this question some time ago, but as I got no answer, so I just try it a second time. I am working on a C extension module that implements a bunch of classes. Everything works fine so far, but I cannot find any way to implement class attributes or inner classes. Consider you have

Re: Class introspection and dynamically determining functionarguments

2005-01-24 Thread harold fellermann
On 20.01.2005, at 12:24, Mark English wrote: I'd like to write a Tkinter app which, given a class, pops up a window(s) with fields for each "attribute" of that class. The user could enter values for the attributes and on closing the window would be returned an instance of the class. The actual app

Re: pickling extension class

2005-01-18 Thread harold fellermann
On 18.01.2005, at 20:31, Alex Martelli wrote: harold fellermann <[EMAIL PROTECTED]> wrote: File "/sw/lib/python2.4/pickle.py", line 760, in save_global raise PicklingError( pickle.PicklingError: Can't pickle : it's not found as hyper.PeriodicGrid dir

pickling extension class

2005-01-18 Thread harold fellermann
Hi all, I have a problem pickling an extension class. As written in the Extending/Embedding Manual, I provided a function __reduce__ that returns the appropreate tuple. This seams to work fine, but I still cannot pickle because of the following error: >>> from model import hyper >>> g = hyper.Pe

Tix.FileSelectDialog wait for user?

2005-01-13 Thread harold fellermann
Hi, I have a question concerning the Tix file select mechanisms. Unfortunately, I have very little experience with neither tk, Tkinter nor Tix. Somewhere in my GUI I have a save button. What I want is that pressing the button opens a file requester. The user can either select a filename or cancel

Re: Using Tix and Tkinter

2005-01-13 Thread harold fellermann
On 31.12.2004, at 16:50, Harlin Seritt wrote: import Tix from Tkconstants import * from Tkinter import * root = Tix.Tk() Label(root, text="Hello!").pack() Tix.tixControl().pack() root.mainloop() When I run this, I get the following error: Traceback (most recent call last): File "TixTest.py", lin

Re: Pickling a class instead of an instance

2005-01-13 Thread harold fellermann
have a look at the thread "copying classes?" some days ago. what goes for copying goes for pickling also, because the modules use the same interface. - harold - On 13.01.2005, at 13:32, Sebastien Boisgerault wrote: Hi, It seems to me that it's not possible with the pickle module to serialize a clas

Re: Unclear On Class Variables

2005-01-13 Thread harold fellermann
Hi Tim, If you have class Foo(object) : x = 0 y = 1 foo = Foo() foo.x # reads either instance or class attribute (class in this case) foo.x = val # sets an instance attribute (because foo is instance not class) Foo.x = val # sets a class attribute foo.__class.__x = val

Re: Why would I get a TypeEror?

2005-01-12 Thread harold fellermann
On 12.01.2005, at 18:35, It's me wrote: For this code snip: a=3 b=(1,len(a))[isinstance(a,(list,tuple,dict))] Why would I get a TypeError from the len function? the problem is, that (1,len(a)) is evaluated, neither what type a actually has (python has no builtin lazy evaluation like ML). You

Re: Why would I get a TypeEror?

2005-01-12 Thread harold fellermann
On 12.01.2005, at 18:35, It's me wrote: For this code snip: a=3 b=(1,len(a))[isinstance(a,(list,tuple,dict))] Why would I get a TypeError from the len function? because len() works only for sequence and mapping objects: >>> help(len) Help on built-in function len in module __builtin__: len(...

Re: how to set doc-string of new-style classes

2005-01-12 Thread harold fellermann
On 11.01.2005, at 19:35, Alex Martelli wrote: harold fellermann <[EMAIL PROTECTED]> wrote: ... But, I cannot even find out a way to set the doc string, when I CREATE a class using type(name,bases,dict) ... At least this should be possible, IMHO. x=type('x',(),dict(__doc_

Re: exporting from Tkinter Canvas object in PNG

2005-01-11 Thread harold fellermann
On 11.01.2005, at 19:14, Nicolas Pourcelot wrote: Hello, I'm new to this mailing list and quite to Pyhon too. I would like to know how to export the contain of the Canvas object (Tkinter) in a PNG file ? Thanks :) Nicolas Pourcelot -- http://mail.python.org/mailman/listinfo/python-list you can make

how to set doc-string of new-style classes

2005-01-11 Thread harold fellermann
Hello, does anyone know a way to set the __doc__ string of a new style class? Any attempt I tried results in the following error: Python 2.4 (#1, Dec 30 2004, 08:00:10) [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin Type "help", "copyright", "credits" or "license" for more informati

Re: here document

2005-01-11 Thread harold fellermann
On 11.01.2005, at 11:34, Nader Emami wrote: Would somebody help me how i can write the 'here document' in Python script please? I have a csh script in which a program is invoked with some argument in the form of here document: /bin/exe.x << End_Here CategorY = GRIB etc. End_Here I translate this

Re: syntax error in eval()

2005-01-10 Thread harold fellermann
Thank you, Duncan and Steven. I completely forgot about setattr. Of course that's the way ... as its name might suggest *g* What you are doing wrong is attempting to use eval before exhausting all the simpler techniques. Why not just call 'setattr'? setattr(X, 'attr', 5) BTW, the syntax error is

syntax error in eval()

2005-01-10 Thread harold fellermann
Hi all, I am trying to dynamically add class attributes at runtime using the function eval(), i.e. I want to do something like >>> class X : pass ... >>> X.attr = 5 but without knowing either the attributes name nor its value. However, I encounter a syntax error I cannot understand: Python 2.4 (#

Re: cosmetic Tkinter question

2005-01-03 Thread harold fellermann
On 26.12.2004, at 16:38, Sean McIlroy wrote: I've got a bunch of Frames, all packed into the root window with side=TOP, and in each Frame I've got a Checkbutton packed with side=LEFT. I expected the Checkbuttons to be flush with the left edge of the window, but they're not, and it looks a little gr

Re: copying classes?

2004-12-31 Thread harold fellermann
On 30.12.2004, at 01:24, It's me wrote: I would not think that a generic deepcopy would work for all cases. An object can be as simple as a number, for instance, but can also be as complex as the universe. I can't imagine anybody would know how to copy a complex object otherthen the object its

copying classes?

2004-12-29 Thread harold fellermann
Hi all, In the documentation of module 'copy' it is said that "This version does not copy types like module, class, function, method, stack trace, stack frame, file, socket, window, array, or any similar types." Does anyone know another way to (deep)copy objects of type class? What is special a

Re: Keyword arguments - strange behaviour?

2004-12-21 Thread harold fellermann
Hi, I cannot see any strange behavior. this code works exacly as you and I suspect: >>> def otherfunction(x) : ... return x ... >>> def function(arg=otherfunction(5)) : ... return arg ... >>> function(3) 3 >>> function() 5 Or is this not what you excepted? - harold - On 21.12.2004, at 15:

How to extend inner classes?

2004-12-21 Thread harold fellermann
Thank you very much. Of course I know how to do it in python. The problem is that I want to reimplement these classes as a python extension in C. The question is: how can I add class members (like e.g. inner classes) to a PyTypeObject defined in a C extension? - harold - > You can define a class