matplotlib and zope

2006-11-14 Thread markacy
Hello All,

  I've been using zope and matplotlib for some time now, and I want to
connect them. I'am using the example code from page:
http://www.scipy.org/Cookbook/Matplotlib/Matplotlib_and_Zope ,
but whenever I try to import matplotlib, and/or pylab packages i get
this error from zope:

Error Type: RuntimeError
Error Value: '/' is not a writable dir; you must set environment
variable HOME to be a writable dir

Have You got any ideas, on what might go wrong?
Is it a problem with matplotlib itself? Have anyone had the same issue?

 I'am using matplotlib 0.87.4, and zope 2.9.5 with python 2.4.3 on
gentoo linux box.

Thanks in advance for any help.

Marek Szczypinski

Here is the traceback:

Traceback (innermost last):
  Module ZPublisher.Publish, line 115, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 41, in call_object
  Module Products.ExternalMethod.ExternalMethod, line 59, in
manage_addExternalMethod
  Module Products.ExternalMethod.ExternalMethod, line 111, in __init__
  Module Products.ExternalMethod.ExternalMethod, line 134, in
manage_edit
  Module Products.ExternalMethod.ExternalMethod, line 141, in
getFunction
  Module App.Extensions, line 148, in getObject
   - __traceback_info__:
('/var/lib/zope/zope-markacy/Extensions/mpl.py', 'mpl')
  Module /var/lib/zope/zope-markacy/Extensions/mpl.py, line 1, in ?
  Module None, line 1011, in ?
  Module None, line 968, in rc_params
  Module None, line 914, in matplotlib_fname
  Module None, line 273, in wrapper
  Module None, line 324, in _get_configdir
RuntimeError: '/' is not a writable dir; you must set environment
variable HOME to be a writable dir

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: magic names in python

2007-06-04 Thread markacy
On 4 Cze, 08:43, per9000 <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I recently started working a lot more in python than I have done in
> the past. And I discovered something that totally removed the pretty
> pink clouds of beautifulness that had surrounded my previous python
> experiences: magic names (I felt almost as sad as when I discovered
> the strange pink worms that eat you in nethack, not to mention the
> mind flayers - I really hate them).
>
> I guess all programming languages have magic names to some extent
> (f.x. classes in the "C-family" have constructors that must have the
> same name as the class (foo::foo) instead of foo.__init__).
>
> I just used a search engine a little on this topic and I found no
> comprehensive list of magic names in python.
>
> So my questions:
>  * is there a comprehensive list of magic names in python (so far i
> know of __init__ and __repr__)?
>  * are these lists complete or can magic names be added over time (to
> the python "core")?
>  * are magic names the same in different python versions?
>
> I also tried (selected parts of(?)) the unittest package for use in
> Zope and it seemed functions that I created for my test with the magic
> prefix "test" were magic, other functions were not.
>
> So another question emerges:
>  * is the use of magic names encouraged and/or part of good coding
> practice.
>
> Live long and prosper,
> Per
>
> --
>
> Per Erik Strandberg
> home:www.pererikstrandberg.se
> work:www.incf.org
> also:www.spongswedencare.se

On "magic" methods and their usage You can read here:
http://diveintopython.org/object_oriented_framework/special_class_methods.html
By the way - this is a very good book on python.
Cheers,
Marek

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to create a tuple quickly with list comprehension?

2007-06-13 Thread markacy
On 13 Cze, 09:45, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I can use list comprehension to create list quickly. So I expected that I
> can created tuple quickly with the same syntax. But I found that the
> same syntax will get a generator, not a tuple. Here is my example:
>
> In [147]: a = (i for i in range(10))
>
> In [148]: b = [i for i in range(10)]
>
> In [149]: type(a)
> Out[149]: 
>
> In [150]: type(b)
> Out[150]: 
>
> Is there a way to create a tuple like (1, 2, 3, 4, 5, 6, 7, 8, 9)
> quickly? I already I can use tuple() on a list which is created by list
> comprehension to get a desired tuple.
>
> Regards,
>
> Xiao Jianfeng

You should do it like this:

>>> a = tuple([i for i in range(10)])
>>> type(a)

>>> print a[0]
0
>>> print a[9]
9
>>> print a
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)

Cheers,
Marek

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to save python codes in files?

2007-06-13 Thread markacy
On 13 Cze, 10:06, why? <[EMAIL PROTECTED]> wrote:
> Evan Klitzke wrote:
> > On 6/12/07, why? <[EMAIL PROTECTED]> wrote:
> > > Im working with Python 2.2 on my red hat linux system. Is there any
> > > way to write python codes in separate files and save them so that i
> > > can view/edit them in the future? Actually I've just started with
> > > python and would be grateful for a response. Thanx!
>
> > Of course -- just put the code into a text file (using your favorite
> > text editor) and then run the script using the python command, e.g. by
> > executing on a command line:
> >   python my_program.py
>
> > Since you're on a Linux system you can also use this as the first line
> > of your file and then chmod +x the file to make it into an executable
> > script:
>
> > #!/usr/bin/env python
>
> > --
>
> Im still unable to follow... :(
> See, if i have to save the following code in a file, how should i
> proceed?
>
> >>> def sum(x,y): return x+y
> ...

:D You should try some basic manual on linux :D

Copy and paste the code (do not include >>> and ...) to the editor,
save. Then run as advised above.
Good luck.

Cheers,
Marek

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: running a Delphi part from Python ?

2007-07-16 Thread markacy
On 16 Lip, 11:33, Stef Mientki <[EMAIL PROTECTED]>
wrote:
> tool69 wrote:
> > Stef Mientki a écrit :
>
> >> AFAIK, Scintilla is a code editor.
> >> What I need looks more like ms-word,
> >> handling lists, tables, images, formulas.
>
> >> thanks,
> >> Stef Mientki
>
> > So you'll need the RichTextCtrl
>
> >http://www.wxpython.org/docs/api/wx.richtext.RichTextCtrl-class.html
>
> > See a sample in the demo under "Recent Additions".
>
> Well it's better,
> - it has lists
> - it has images, but no image editing,
> It doesn't have
> - drag & drop
> - tables,
> - formula editing,
> - screen capture,
> - links
> - embedded code
> - CSS
> - 
> so unfortunately it's not yet sufficient :-(
>
> thanks,
> Stef Mientki

Of course You can always write one, that's succicient for Your needs,
and make it available under GPL. ;-)

Cheers,

Marek

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Directory

2007-07-31 Thread markacy
On 30 Lip, 23:43, Rohan <[EMAIL PROTECTED]> wrote:
> I would like to get a list of sub directories in a directory.
> If I use os.listdir i get a list of directories and files in that .
> i only want the list of directories in a directory and not the files
> in it.
> anyone has an idea regarding this.

Hi Rohan,

http://diveintopython.org/file_handling/os_module.html

Hope this helps,

Cheers,
Marek

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: the one python book

2007-08-04 Thread markacy
On 4 Sie, 15:23, "dhr" <[EMAIL PROTECTED]> wrote:
> newbie question:
>
> Is there a 'K&R" type of Python book? The book that you'd better have on
> your shelf if you are going into Python?

There are actually two of them:

"How to Think Like a Computer Scientist: Learning with Python" by
Allen B. Downey, Jeffrey Elkner and Chris Meyers
http://www.ibiblio.org/obp/thinkCSpy/

and

"Dive Into Python" by Mark Pilgrim
http://diveintopython.org/toc/index.html

Hope this helps :-)

Cheers and good luck,
Marek

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Best programs written completly in Python

2007-08-05 Thread markacy
On 5 Sie, 12:14, Franz Steinhäusler <[EMAIL PROTECTED]>
wrote:
> Hello NG,
>
> wWhat are the best programs in your opinion, written entirly
> in pyhton, divided into categories like:
> a) Games
> b) Utilities/System
> c) Office
> d) Web/Newsreader/Mail/Browser
> ...
>
> I don't want to start a long thread, if a site of such
> an discussion already exists, a link will be enough.
>
> Many thanks in advance!
>
> --
> Franz Steinhaeusler

I guess, that gentoo's portage is (almost?) entirely written in
python. The same is with Zope/Plone (Web category), though I know,
that Zope has some parts of code written in C. Django?

Big part's of google "tools" are written in python as well. Matplotlib
is said to be written entirely in python.
These are examples from the top of my head. If I'll came up with
something else, I will let You know :-)

Cheers,
Marek

-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Drawing a graph

2007-08-13 Thread markacy
On 12 Sie, 21:09, Ghirai <[EMAIL PROTECTED]> wrote:
> Hello list,
>
> I need to draw a graph, 2 axes, 2D, nothing fancy.
> One of the axes is time, the other one is a series of integers.
>
> I don't care much about the output format.
>
> Are there any specialized libraries for this, or should i use PIL?
>
> Thanks.
>
> --
> Regards,
> Ghirai.

Matplotlib (http://matplotlib.sourceforge.net/)

Cheers,
Marek

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python socket usage

2007-08-16 Thread markacy
On 16 Sie, 09:42, O uz Yar mtepe <[EMAIL PROTECTED]> wrote:
> Is it possible to send a data object like a tuple or a list in socket
> programming? If so how? It seems with socket module it is only possible to
> send strings.
>
> --
> O uz Yar mtepehttp://www.yarimtepe.com/en

Hi Oguz,

   why don't you make a string out of your tuple, or list, send it via
socket and make a tuple/list again?

>>> x = (1,2,3,4,5,6,7,)
>>> type(x)

>>> y = str(x)
>>> type(y)

>>> print y
(1, 2, 3, 4, 5, 6, 7)
>>> z = tuple(y)
>>> type(z)

>>>

Cheers,
Marek

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting the result of a process after exec*()

2007-08-18 Thread markacy
On 17 Sie, 16:33, AndrewTK <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am trying to write a Python script that takes a ZIP file from a web
> form (using CGI) and uses either of the UN*X unzip, gunzip, tar,
> bunzip2 utilities to expand it.
>
> I can use Python to save the script to disk; but processing it is
> another matter. If for example I have received a *.tar.gz file, I need
> to first pass it through gunzip; then through the tar utility. I also
> want to process the resulting directory.
>
> The problem for me is this: once an external process is called via
> exec*() the script has effectively fulfilled its task. Is there any
> way one can process a file with an external process and continue
> further processing in Python; /once the external processing is
> completed/?
>
> Many thanks,
>
> Andrew

Hi Andrew,

Have You got some kind of requirement for using exec*() and calling
system gunzip etc?
I'd do It with urllib2 module (to download the file) and tarfile
module for extracting the *.tag.gz archive.

Cheers,
Marek

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C++2py

2007-12-02 Thread markacy
On 2 Gru, 15:56, farsheed <[EMAIL PROTECTED]> wrote:
> I,m looking for a tool for converting c++ to python. Any Ideas?
> TIA.

What about SWIG (http://www.swig.org/) or Boost.Python (http://
www.boost.org/libs/python/doc/)? These are not converters, but I hope
this helps you.

Cheers,

Marek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Any idea how to open Matlab and run M-files by using Python?

2007-12-03 Thread markacy
On 3 Gru, 05:02, itcecsa <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am implementing a small Python project, what I am going to do is to
> open Matlab and run some M-files, and get some output from Matlab
> command prompt.
>
> I have no idea how to open Matlab from Python!
>
> Any suggestions would be appriciated!

Why bother - use NumPy/SciPy/Matplotlib :-)

Cheers,
Marek
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 3D plotting with python 2.5 on win32

2007-12-19 Thread markacy
On 19 Gru, 15:15, anton <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I would like to know if some of you knows a
>
>  - working
>
>  - actual
>
>  - out of the box (for me: binaries available)
>
> Package/Lib to do 3D plotting out of the box.
>
> I know  matplotlib.
>
> There is MayaVi from enthon but you need to use their python (2.4.3),
> all other stuff need picking sources etc.
>
> IVuPy-0.1 seems to be abandonware, and there are no binaries.
>
> I don't get qwtplot3d-0.2.7 to compile on my pc, it seems you need the
> commercial
> qt 4.33 (with opensource qt 4.3.3 I doesnt work).
>
> Actually there is a big list on python org of 3D software, but I need
> only plotting facility (like Matlab for example), and some/most of
> the listed projects seem not be up to date (still based on python 2.4,
> like PyOpenGL where you get binaries only for python 2.4,
> seems to be abandonware too, sigh).
>
> Thanks for a hint :-)

Hi anton,

   Have you take a look at vpython? Here's their website:
http://www.vpython.org/
And here is an simple example of how to use it:
http://linuxgazette.net/144/john.html

Hope this helps :-)

Cheers,

Marek
-- 
http://mail.python.org/mailman/listinfo/python-list