Re: Looking for a text file based wiki system written in Python

2006-08-14 Thread Marcel

Jack wrote:
> I'd like to set up a wiki system for a project I'm working on.
> Since I'm not good at databases, and there's really not much
> stuff to put into the wiki, I hope it is text file-based.
> I used DokuWiki before, which is very nice but it's written
> in PHP. Is there a similar system that's written in Python?
> I found pwyky but it's functionality is a bit too simple.

A TiddlyWiki with a python backend.
http://www.cs.utexas.edu/~joeraii/pytw/

-- Marcel

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


Re: Scripting Visio using Python

2007-02-13 Thread Marcel
On Feb 13, 6:52 pm, Paul Watson <[EMAIL PROTECTED]> wrote:
> I would like to create some additional shapes in Microsoft Visio using
> the Python language.  It would appear that Visio can use any CLR
> language.  Has anyone done this?  Can I use the Python package from
> python.org, or must I use IronPython?

Don't know how to do that, but I suggest you post your question on the
IronPython list: http://groups.google.com/group/ironpy?lnk=li

Python is not a .NET language, IronPython is.

HTH,
-- Marcel

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


Re: Fatal Python error

2013-05-29 Thread Marcel Rodrigues
I just tried your code with similar results: it does nothing on PyPy
2.0.0-beta2 and Python 2.7.4. But on Python 3.3.1 it caused core dump.
It's a little weird but so is the code. You have defined a function that
calls itself unconditionally. This will cause a stack overflow, which is a
RuntimeError.
 Since you are handling this very exception with a pass statement, we would
expect that no error occurs. But the fatal error message seems pretty
informative at this point: "Cannot recover from stack overflow.".

One thing to note is that while it's reasonable to handle exceptions that
happens at the level of your Python code, like a ValueError, it's not so
reasonable to try to handle something that may disturb the interpreter
itself in a lower level, like a stack overflow (I think that the stack used
by your code is the same stack used by the interpreter code, but I'm not
sure).


2013/5/29 Joshua Landau 

> Hello all, again. Instead of revising like I'm meant to be, I've been
> delving into a bit of Python and I've come up with this code:
>
> class ClassWithProperty:
>  @property
> def property(self):
> pass
>
> thingwithproperty = ClassWithProperty()
>
> def loop():
> try:
> thingwithproperty.property
>  except:
> pass
>
> loop()
>
> try:
> loop()
> except RuntimeError:
> pass
>
> As you will expect, this does nothing... on Python2.7 and PyPy. Python3.3
> prefers to spit out a "Fatal Python error: Cannot recover from stack
> overflow.", which seems a bit unexpected.
>
> Wuzzup with that?
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fatal Python error

2013-05-29 Thread Marcel Rodrigues
I think the issue here has little to do with classes/objects/properties.
See, for example, the code posted by Oscar Benjamin.

What that code is trying to do is similar to responding to an "Out Of
Memory" error with something that might require more memory allocation.

Even if we consider the Py3 behavior here a bug, that code is unreliable by
design. It's an infinite loop at the best.


2013/5/29 Joshua Landau 

> On 29 May 2013 13:30, Marcel Rodrigues  wrote:
> >
> > I just tried your code with similar results: it does nothing on PyPy
> 2.0.0-beta2 and Python 2.7.4. But on Python 3.3.1 it caused core dump.
> > It's a little weird but so is the code. You have defined a function that
> calls itself unconditionally. This will cause a stack overflow, which is a
> RuntimeError.
>
>
> The weirdness of the code is simply as I've taken all the logic and
> conditionality away, since it was irrelevant. Why, though, does removing
> any one element make it fail properly? That's what's confusing, largely.
>
>
> >
> >  Since you are handling this very exception with a pass statement, we
> would expect that no error occurs. But the fatal error message seems pretty
> informative at this point: "Cannot recover from stack overflow.".
> >
> > One thing to note is that while it's reasonable to handle exceptions
> that happens at the level of your Python code, like a ValueError, it's not
> so reasonable to try to handle something that may disturb the interpreter
> itself in a lower level, like a stack overflow (I think that the stack used
> by your code is the same stack used by the interpreter code, but I'm not
> sure).
>
>
> What is the expected response here then? Should I ever feel justified in
> catching a Stack Overflow error? This code was extracted from a file
> manager after much difficulty, but it should have been "caught" by a global
> try...except and not crashed the whole program immediately. I'd imagine
> that's a good enough reason to bring this up.
>
>
>
> Also;
> This works for the code:
>
> def loop():
> thingwithproperty.prop
> loop()
>
> This does not:
>
> def loop():
> try:
> thingwithproperty.prop
> except:
> pass
> loop()
>
> thingwithproperty.prop NEVER creates an error.
> (.prop is the new .property)
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: weird behavior. bug perhaps?

2013-06-18 Thread Marcel Rodrigues
Note that

print [shape(m)[1],1]

just prints a list with two elements where the first element is shape(m)[1]
and the second is the number 1 (regardless of the value of m). I'm pretty
sure that's not what you want.


2013/6/18 zoom 

> Hi, I have a strange problem here. Perhaps someone would care to help me.
>
> In the file test.py I have the following code:
>
> from scipy import matrix, tile, mean, shape
> import unittest
>
> class TestSequenceFunctions(**unittest.TestCase):
>
> def setUp(self):
> self.m = [[1,2],[3,4],[3,4],[3,4]]
>
> def test_simplify(self):
> m = matrix(self.m)
> print shape(m)
> print [shape(m)[1],1]
> print shape(tile(mean(m,1),[shape(m)**[1],1]).T)
>
> if __name__ == '__main__':
> unittest.main()
>
> (Note that test.py, is just a simplification of my testing file,
> sufficient to reproduce the weird behavior that I'm  about to describe.)
>
> If i run it in terminal via "python test.py" command I get the following
> output:
>
> (4, 2)
> [2, 1]
> (1, 8)
> .
> --**--**--
> Ran 1 test in 0.000s
>
> OK
>
>
> Now comes the funny part.
> Let's try to run the following code in python interpreter:
>
> >>> m = [[1,2],[3,4],[3,4],[3,4]]
> >>>
> >>> from scipy import matrix, tile, mean, shape
> >>> print shape(m)
> (4, 2)
> >>> print [shape(m)[1],1]
> [2, 1]
> >>> print shape(tile(mean(m,1),[shape(m)**[1],1]).T)
> (4, 2)
>
> Note the difference between outputs of:
> print shape(tile(mean(m,1),[shape(m)**[1],1]).T)
>
>
> I mean, WTF?
> This is definitely not the expected behavior.
> Anybody knows what just happened here?
>
> --
> http://mail.python.org/**mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Python 3.3, gettext and Unicode problems

2012-12-30 Thread Marcel Rodrigues
I'm using Python 3.3 (CPython) and am having trouble getting the standard
gettext module to handle Unicode messages.
My problem can be isolated as follows:

I have 3 files in a folder: greeting.py, greeting.po and msgfmt.py.

-- greeting.py --
import gettext

t = gettext.translation("greeting", "locale", ["pt"])
_ = t.lgettext

print("_charset = {0}\n".format(t._charset))
print(_("hello"))
-- EOF --

-- greeting.po --
msgid ""
msgstr ""
"Project-Id-Version: 1.0\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

msgid "hello"
msgstr "olá"
-- EOF --

msgfmt.py was downloaded from
http://hg.python.org/cpython/file/9e6ead98762e/Tools/i18n/msgfmt.py, since
this tool apparently isn't included in the python3 package available on
Arch Linux official repositories.

It's probably also worth noting that the file greeting.po is encoded itself
as UTF-8.

>From that folder, I run the following commands:

$ mkdir -p locale/pt/LC_MESSAGES
$ python msgfmt.py -o !$/greeting.mo greeting.po
$ python greeting.py

The output is:
_charset = UTF-8

Traceback (most recent call last):
  File "greeting.py", line 7, in 
print(_("hello"))
  File "/usr/lib/python3.3/gettext.py", line 314, in lgettext
return tmsg.encode(locale.getpreferredencoding())
UnicodeEncodeError: 'ascii' codec can't encode character '\xe1' in position
2: ordinal not in range(128)

My interpretation of this output is that even though gettext correctly
detects the MO file charset as UTF-8, it tries to encode the translated
message with the system's "preferred encoding", which happens to be ASCII.

Anyone know why this happens? Is this a bug on my code? Maybe I have
misunderstood gettext...

Thanks,

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


Re: Python 3.3, gettext and Unicode problems

2012-12-30 Thread Marcel Rodrigues
Thank you Terry!

I was trying to follow the documentation but somehow didn't payed attention
to the lgettext/gettext distinction until I read your first response.
Changing lgettext to gettext solved the problem.

It prints correctly to my console because I have to environmental
variable PYTHONIOENCODING set to utf8, which is what my console emulator
uses. But that's actually not necessary in my original application (it has
a web interface), just for this isolated test. I really should have
separated the call to print() as you suggested tough, if only to make the
problem clearer.

As for the "multiple different limited national encodings" vs "everything
as UTF-8", I agree with you and am definitely going for the latter because
the former seems to be unnecessarily complicated.

Thanks again for the help! Problem solved.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: TkTable and Python 3.1

2011-03-02 Thread Marcel Jakobs
Hello Chuck,

I am working with Ubuntu 10.04 LTS - Lucid Lynx, Python 3.1 and Tktable2.10.

I have installed Python and Tktable separatly. So I had to "tell" Python where 
to find Tktable. 

I built a file named 'tkTable.pth' in the directory 
"/usr/lib/python3.1/dist-packages". The file is has only one row:
/usr/lib/Tktable2.10
This is the directory where my Tktable-module is stored. ".pth"-files are 
working as "pointer" to modules.

I don't know how your directories are built, but I think the structure is equal.

Marcel

> On Tuesday, February 16, 2010 12:00 AM Charles McKnight wrote:

> HI All,
> 
> I am fiddling around with Python and I am trying to get tktable to work
> with Python 3.1 on Apple OS X 10.6 (Snow Leopard). Has anyone
> successfully accomplished this task, and if so, can you share how that
> you got it working? I have got Darwin Ports installed (current version)
> and I am using Python 3.1 (ports), Tcl/Tk 8.5 (ports) and I have
> installed TkTable 2.10 (ports). Somehow, I have missed doing something
> because the Python interpreter cannot seem to find the tktable module.
> 
> Thanks in advance!
> 
> Chuck


> Submitted via EggHeadCafe 
> Statistics, Probability, Lotteries and Dumb Programmers
> http://www.eggheadcafe.com/tutorials/aspnet/041de19a-e704-468f-bd3c-79164fc739f5/statistics-probability-lotteries-and-dumb-programmers.aspx
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Re: TkTable and Python 3.1

2011-03-02 Thread Marcel Jakobs

...
I built a file named 'tkTable.pth' in the directory
"/usr/lib/python3.1/dist-packages"
... 



Submitted via EggHeadCafe 
Pass Values Between Windows Forms
http://www.eggheadcafe.com/tutorials/aspnet/a3e1e170-21d9-4a59-a659-3ead05bb36f2/pass-values-between-windows-forms.aspx
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Re: Re: TkTable and Python 3.1

2011-03-02 Thread Marcel Jakobs
I don't know why, but every time when I have "sent" the directories name, it's 
not to see in the site. 
=> '/usr/lib/python3.1/dist-packages' 
=> Got to the home-directory of python and then save the file in the 
subdirectory "dist-packages".

Marcel

Submitted via EggHeadCafe 
Excel Generate High Quality RoadMaps
http://www.eggheadcafe.com/tutorials/aspnet/3310004f-e1ae-45a7-9bea-7b2b970d1230/excel-generate-high-quality-roadmaps.aspx
-- 
http://mail.python.org/mailman/listinfo/python-list


DCOracle2/python/zope

2005-12-01 Thread Marcel Hartmann
Hi,

I have problems to get ZOracleDA run in Zope - I cannot found a solution 
  wheter in Zope Groups nor searching google and I think it's a python 
problem. The connection in python - without zope - functions without 
problems and the missing library (see errors later) is obviously found. 
Is it possible to set an library path for python? I tested changing the 
ld.conf.so and running ldconfig or setting LD_LIBRARY_PATH environment 
var, but without success. I am running SuSE 9.3/Python 2.4/DCOracle2 
1_3b/PDO 1.3.1
I get the following error starting the zope server:

2005-12-01T16:33:08 ERROR(200) Zope Couldn't install ZOracleDA
Traceback (most recent call last):
   File "/opt/zope/lib/python/OFS/Application.py", line 723, in 
install_product
 global_dict, global_dict, silly)
   File "/opt/zope/lib/python/Products/ZOracleDA/__init__.py", line 91, in ?
 import DA
   File "/opt/zope/lib/python/Products/ZOracleDA/DA.py", line 90, in ?
 from db import DB
   File "/opt/zope/lib/python/Products/ZOracleDA/db.py", line 89, in ?
 import DCOracle2, DateTime
   File "/opt/zope/lib/python/Products/ZOracleDA/DCOracle2/__init__.py", 
line 37, in ?
 from DCOracle2 import   *
   File 
"/opt/zope/lib/python/Products/ZOracleDA/DCOracle2/DCOracle2.py", line 
104, in ?
 import dco2
ImportError: libclntsh.so.10.1: cannot open shared object file: No such 
file or directory
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What is the recommended python module for SQL database access?

2014-02-09 Thread Marcel Rodrigues
As Chris said, if your needs are simple, use SQLite back-end. It's probably
already installed on your computer and Python has a nice interface to it in
its standard library. [1]

If you decide to use MySQL back-end instead, consider using PyMySQL [2].
It's compatible with both Python 2 and Python 3. Also, being written in
pure Python, it's easier to install compared to MySQLdb.

[1] http://docs.python.org/3/library/sqlite3.html#module-sqlite3
[2] https://pypi.python.org/pypi/PyMySQL


2014-02-08 6:55 GMT-02:00 Sam :

> Is MySQLdb the recommended python module for SQL database access? Are
> there other modules? What I want in a module is to be able to write
> readable and maintainable code.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why use _mysql module and not use MySQLdb directly?

2014-02-09 Thread Marcel Rodrigues
Another option is PyMySQL [1]. It's developed in the open at GitHub [2].
It's pure Python, compatible with both Python 2 and Python 3. It's DB-API 2
compliant. It also implements some non-standard bits that are present in
MySQLdb, in order to be compatible with legacy code, notably Django
(personally, I consider the use of non-standard API from a DB adapter a
bug, but while the big projects don't fix it, we have to work around it).

[1] https://pypi.python.org/pypi/PyMySQL
[2] https://github.com/PyMySQL/PyMySQL


2014-02-08 10:09 GMT-02:00 Asaf Las :

> On Saturday, February 8, 2014 1:42:30 PM UTC+2, Chris Angelico wrote:
> > On Sat, Feb 8, 2014 at 10:32 PM, Asaf Las  wrote:
> >
> > > Hi Chris
> > > The doc says
> > > https://pypi.python.org/pypi/mysql-connector-python/1.1.5
> > > MySQL driver written in Python which does not depend on MySQL C
> > > client libraries and implements the DB API v2.0 specification
> (PEP-249).
> >
> > Ah. And that links to dev.mysql.com, so it's presumably the same
> > thing... would be nice if they'd say that on their own site. That's
> > what I was looking for, anyhow. Confirms the suspicion.
> >
> > There may well be performance differences between pure-Python
> > implementations and ones that go via C, but having used a
> > pure-high-level-language implementation of PostgreSQL's wire protocol
> > (granted, that was Pike, which is a somewhat higher performance
> > language than Python, but same difference), I can assure you of what
> > ought to be obvious anyway: that performance is dominated by the
> > server's throughput and thus (usually) by disk speed. So it's going to
> > be pretty much the same with all of them; look for ancillary features
> > that might make your life easier, otherwise pick whichever you like.
> >
> > ChrisA
>
> Hmmm, they say :
>
> http://dev.mysql.com/doc/connector-python/en/connector-python-introduction.html
>
> "MySQL Connector/Python enables Python programs to access MySQL databases,
> using an API that is compliant with the Python DB API version 2.0. It
> is written in pure Python and does not have any dependencies except for
> the Python Standard Library..."
>
> i guess with Oracle connector there could be one advantage - they will
> try to be most compliant to their product in every aspect as they would
> raiser promote their DB instead of discouraging from it.
>
> /Asaf
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What is the recommended python module for SQL database access?

2014-02-09 Thread Marcel Rodrigues
I just checked in the Python sources and apparently you're right about
SQLite3. The Python distribution includes pysqlite which seems to be a
self-contained SQLite engine. No external dependencies. Sorry for the
confusion.


2014-02-09 9:00 GMT-02:00 Chris Angelico :

> On Sun, Feb 9, 2014 at 9:20 PM, Marcel Rodrigues 
> wrote:
> > As Chris said, if your needs are simple, use SQLite back-end. It's
> probably
> > already installed on your computer and Python has a nice interface to it
> in
> > its standard library.
>
> Already installed? I thought the point of SQLite3 being in the Python
> stdlib was that Python actually included the entire engine (that's why
> there's no, for instance, PostgreSQL client in the stdlib - because
> there's no server; I disagree with the reasoning, but it is consistent
> and valid), so you don't need _anything_ externally installed.
>
> In any case, SQLite is ideal for really simple databasing. Back in the
> 1990s, I had DB2, DB2, and DB2, for all my database work. I wanted a
> way to query a dictionary of English words using SQL, so I created a
> DB2 database and threw ~60K rows into a table. Massive overkill for a
> one-column table. These days, I could use SQLite (or more likely, just
> use grep on /usr/share/dict/words - grep does everything that I wanted
> SQL for, if you include piping from one grep into another), cutting
> the overhead down enormously.
>
> The biggest downside of SQLite3 is concurrency. I haven't dug into the
> exact details of the pager system and such, but it seems to be fairly
> coarse in its locking. Also, stuff gets a bit complicated when you do
> a single transaction involving multiple files. So if you have lots of
> processes writing to the same set of SQLite tables, you'll see pretty
> poor performance. PostgreSQL handles that situation far better, but
> has a lot more overhead, so it's a poor choice for a single simple
> application. MySQL's locking/concurrency system is specifically
> optimized for a model that's common for web applications: a huge
> number of readers and a tiny number of writers (sometimes referred to
> as Data Warehousing, because you basically stuff a warehouse full of
> data and then everyone comes looking for it). For the write-heavy
> model (sometimes called OLTP or On-Line Transaction Processing),
> PostgreSQL will hugely outperform MySQL, thanks to its MVCC model.
>
> Broad recommendation: Single application, tiny workload, concurrency
> not an issue, simplicity desired? Go SQLite. Big complex job, need
> performance, lots of things reading and writing at once, want
> networked access? Go PGSQL. And don't go MySQL if PG is an option.
>
> And definitely don't go for a non-free option (MS-SQL, DB2, etc)
> unless you've looked into it really closely and you are absolutely
> thoroughly *sure* that you need that system (which probably means you
> need your app to integrate with someone else's, and that other app
> demands one particular database).
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to clear all content in a Tk()

2014-03-25 Thread Marcel Rodrigues
What about this:

Put a Frame() inside the root: `frame = Frame(root)`. This frame will be
the only immediate child of root. Everything else will be put inside the
frame. When you need to clear the root, call `frame.destroy()`. This will
destroy `frame` and all its children. You will need to recreate the frame,
but not the root.


2014-03-24 17:30 GMT-03:00 :

> I have this program, and since I want to change stuff dynamically, I want
> to fully clear the root = Tk(), without deleting it. Is there a way to do
> so?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "Nested" virtual environments

2013-08-15 Thread Marcel Rodrigues
I don't know how to completely solve this problem, but here is something
that can alleviate it considerably.

If you have a recent version of pip, you can use wheels [1] to save built
packages locally. First create a new virtualenv and install the common
packages. Then put these packages in a wheel directory. Then, for any other
virtualenv that need the common packages, you can easily install then from
the wheel directory (this is fast even for numpy & friends, because nothing
will be compiled again) [2].

# Create a new virtualenv
virtualenv myenv
source myenv/bin/activate
# Install the wheel package
pip install wheel
# Install your common packages
pip install numpy scipy matplotlib
# Create a requirements file
pip freeze > /local/requirements.txt
# Create wheel for the common packages
pip wheel --wheel-dir=/local/wheels -r /local/requirements.txt

Now you have all the built packages saved to /local/wheels, ready to
install on any other environment. You can safely delete myenv. Test it with
the following:

# Create a virtualenv for a new project
virtualenv myproj
source myproj/bin/activate
# Install common packages from wheel
pip install --use-wheel --no-index --find-links=/local/wheels -r
/local/requirements.txt

[1] https://wheel.readthedocs.org
[2]
http://www.pip-installer.org/en/latest/cookbook.html#building-and-installing-wheels



2013/8/9 Luca Cerone 

> Dear all, is there a way to "nest" virtual environments?
>
> I work on several different projects that involve Python programming.
>
> For a lot of this projects I have to use the same packages (e.g. numpy,
> scipy, matplotlib and so on), while having to install packages that are
> specific
> for each project.
>
> For each of this project I created a virtual environment (using virtualenv
> --no-site-packages) and I had to reinstall the shared packages in each of
> them.
>
> I was wondering if there is a way to nest a virtual environment into
> another,
> so that I can create a "common" virtual environment  that contains all the
> shared packages and then "specialize" the virtual environments installing
> the packages specific for each project.
>
> In a way this is not conceptually different to using virtualenv
> --system-site-packages, just instead of getting access to the system
> packages a virtual environment should be able to access the packages of an
> other one.
>
> Thanks a lot in advance for the help,
> Luca
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Checking dependencies with distutils

2006-10-03 Thread Etienne Marcel
Hello,

I would like to know if there is something in distutils (or in Python
stdlib) which allow me to check for dependencies (shared libraries,
headers or any other progs) before building/installing ?

I am aware of this nice utility :
http://trentm.com/projects/which/

which is useful (and cross platforms) to check if some executables are
in the "PATH".

Thanks in advance,
-- 
http://mail.python.org/mailman/listinfo/python-list


LDAPUserFolder mapping roles

2006-01-30 Thread Marcel Hartmann
I'm using LDAPUserFolder for Zope 2.7.6 and it works fine.

Is it possible to do the mapping to zope roles by the _value_ of the 
group and not the group name?
We defined in LDAP many groups to define access to different 
applications - one is named "zope". I want to map the values of this 
group "zope" (e.g. "admin_intranet", "admin_extranet", ...) to zope 
roles. How can I do this?
-- 
http://mail.python.org/mailman/listinfo/python-list


Slicing an IXMLDOMNodeList

2005-06-12 Thread marcel . vandendungen
Hi,

I'm using MSXML to select elements from a XML document and want
to slice off the last part of an IXMLDOMNodeList.

>>> import win32com.client
>>> xmldoc = win32com.client.Dispatch('msxml.DOMDocument')
>>> xmldoc.load('file.xml')
True
>>> rgelem = xmldoc.selectNodes('/root/elem')
>>> if rgelem.length > 10:
... rgelem = rgelem[-10:]
...
Traceback (most recent call last):
  File "", line 2, in ?
  File "C:\Python24\Lib\site-packages\win32com\client\__init__.py",
line 454, in __getattr__
raise AttributeError, "'%s' object has no attribute '%s'" %
(repr(self), attr)
AttributeError: '' object has no attribute '__len__'
>>>

The IXMLDOMNodeList obviously doesn't have a '__len__' member
function (why not?).
Is there a way to make the IXMLDOMNodeList support slicing?
I've tried to give the rgelem object a __len__ member, but got
an exception from __setattr__:

  File "C:\Python24\Lib\site-packages\win32com\client\__init__.py",
line 462, in __setattr__
raise AttributeError, "'%s' object has no attribute '%s'" %
(repr(self), attr)
AttributeError: '' object has no attribute '__len__'

Anybody know how to make this work?

TIA,
-- Marcel

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


Re: Slicing an IXMLDOMNodeList

2005-06-13 Thread marcel . vandendungen
For future reference:

The solution to this problem is a simple one.
rgelem = list(xmldoc.selectNodes('/root/elem'))
returns a real list of IXMLDOMElements that can be sliced.

-- Marcel

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


Python AppStore / Marketplace

2009-02-22 Thread Marcel Luethi
Dear Community

Now I'm standing here, having this great idea for a brand new rocking app...
But where do I start? I want it to be multi-platform (Linux, Mac OS X,
Windows). It should be easy to install and upgrade. It should be
self-contained, independent of an already installed Python. And of course -
the world should be able to find it!

So what do I do? I'm studying all the possibilities to make it
self-contained (virtualenv, InstantDjango, PortablePython...), searching for
installers (PyInstaller, EasyInstall, ...), looking into making it
executable on every platform (py2exe, py2app, cx_Freeze, ...), analyzing all
GUI frameworks (wxPython, PyGTK, PyQt, ...), investigating all hosting
providers (Google Code, SourceForge, ...) and so on and so forth.

This is not easy at all!

Using my iPhone I suddenly realize how easy it is to find applications in
Apple's AppStore. How easy and fast it is to install or de-install an app.
My iPhone even checks in the background if there is an upgrade which could
be installed painlessly.

Then I see VMware's Virtual Appliance Marketplace, where you can download
already pre-configured "appliances" for all kind of stuff. You can even
download a basic appliance, install and configure your servers and tools -
and upload it again, so that others can profit of your work.

Unfortunately there's nothing like this in the Python world...

My idea: what about having a beefed up Cheeseshop for Python apps and an
accompanying client app kind of iTunes for Python apps?

The server side could be easily implemented with any of the current web
frameworks. It's simply a management platform for the app packages
(descriptions, versions, platforms, licenses, user's comments, number of
downloads, ...) and the package files themselves.
It should be definitely hosted by the PSF I think.

The multi-platform client should be intuitively and elegantly allow app
browsing, downloading and installing those Python apps. In that respect it
is sort of a Linux package manager (Synaptic, YUM, ...). But this is only
the end-user related stuff. Furthermore it should allow to create new apps
(probably based on a previously downloaded base app), package and upload
them again (kind of Google AppEngine Launcher). Those base packages should
include some basic management framework (for installation and configuration)
and hopefully soon after the release of this platform they will be created
in a broad variety to allow app developers to choose among many
Python-version/platform/GUI/...-combinations.

IMHO an architecture like this would greatly enhance the productivity of the
whole Python community by capitalizing the knowledge of many Python
specialists. I don't have to find/install/configure all the basic stuff
myself (see above) to build my app. But I can concentrate on my app because
I'm standing on the shoulders of giants.

I believe it also would make Python as a great platform more visible to the
world - because there is only one place you have to go...


What do you think???
Is this crazy??? Or simply stupid?
Or is this the way to world domination...? ;-)


Unfortunately I'm not expert enough to build such a system - but if there is
enough interest in the community I gladly would like to help.

Marcel


PS:
Naming is important! "Python AppStore" or "Python App Marketplace" is nice -
but I would prefer something like "Python Bazaar" or "Python Souq" to
emphasize the community aspect.
--
http://mail.python.org/mailman/listinfo/python-list


Python AppStore / Marketplace

2009-02-22 Thread Marcel Luethi
Dear Community

Now I'm standing here, having this great idea for a brand new rocking
app...
But where do I start? I want it to be multi-platform (Linux, Mac OS X,
Windows). It should be easy to install and upgrade. It should be self-
contained, independent of an already installed Python. And of course -
the world should be able to find it!

So what do I do? I'm studying all the possibilities to make it self-
contained (virtualenv, InstantDjango, PortablePython...), searching
for installers (PyInstaller, EasyInstall, ...), looking into making it
executable on every platform (py2exe, py2app, cx_Freeze, ...),
analyzing all GUI frameworks (wxPython, PyGTK, PyQt, ...),
investigating all hosting providers (Google Code, SourceForge, ...)
and so on and so forth.

This is not easy at all!

Using my iPhone I suddenly realize how easy it is to find applications
in Apple's AppStore. How easy and fast it is to install or de-install
an app. My iPhone even checks in the background if there is an upgrade
which could be installed painlessly.

Then I see VMware's Virtual Appliance Marketplace, where you can
download already pre-configured "appliances" for all kind of stuff.
You can even download a basic appliance, install and configure your
servers and tools - and upload it again, so that others can profit of
your work.

Unfortunately there's nothing like this in the Python world...

My idea: what about having a beefed up Cheeseshop for Python apps and
an accompanying client app kind of iTunes for Python apps?

The server side could be easily implemented with any of the current
web frameworks. It's simply a management platform for the app packages
(descriptions, versions, platforms, licenses, user's comments, number
of downloads, ...) and the package files themselves.
It should be definitely hosted by the PSF I think.

The multi-platform client should be intuitively and elegantly allow
app browsing, downloading and installing those Python apps. In that
respect it is sort of a Linux package manager (Synaptic, YUM, ...).
But this is only the end-user related stuff. Furthermore it should
allow to create new apps (probably based on a previously downloaded
base app), package and upload them again (kind of Google AppEngine
Launcher). Those base packages should include some basic management
framework (for installation and configuration) and hopefully soon
after the release of this platform they will be created in a broad
variety to allow app developers to choose among many Python-version/
platform/GUI/...-combinations.

IMHO an architecture like this would greatly enhance the productivity
of the whole Python community by capitalizing the knowledge of many
Python specialists. I don't have to find/install/configure all the
basic stuff myself (see above) to build my app. But I can concentrate
on my app because I'm standing on the shoulders of giants.

I believe it also would make Python as a great platform more visible
to the world - because there is only one place you have to go...


What do you think???
Is this crazy??? Or simply stupid?
Or is this the way to world domination...? ;-)


Unfortunately I'm not expert enough to build such a system - but if
there is enough interest in the community I gladly would like to help.

Marcel


PS:
Naming is important! "Python AppStore" or "Python App Marketplace" is
nice - but I would prefer something like "Python Bazaar" or "Python
Souq" to emphasize the community aspect.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python AppStore / Marketplace

2009-02-22 Thread Marcel Luethi
Hi Steve

I really appreciate your feedback!
Certainly I'm no expert "for the many differences in package formats and
install requirements between the different platforms".

But let me explain a bit more:
I don't have the idea that the multi-platform client should handle all the
different package formats - instead it should define a new one: a simple
zip-file.
For me "self-contained, independent of an already installed Python" means
that there is a complete, isolated Python environment for each app (see
virtualenv). So Python would go into APP/lib/..., APP/bin/... and the app
itself into APP/app/... Certainly there would be also some more files like
the app icons and a description file APP/app.xml
The packaged app is a zip/gzip of the whole APP directory. Installing is
simply unpacking to a defined directory (into something like PythonApps/APP)
and setting it up as an os app.

Because there is a complete Python environment for each app (disk space and
bandwidth are cheap nowadays!) and all 3rd party libs are "integrated" there
shouldn't be any other local dependencies. So there could be APP1 with a
Python 2.5.2 + a wxPython/wxWidgets and another APP2 with Python 2.6.1 +
PyQt4.
(This is something I'm not really sure about: is it possible to setup all
binary 3rd party libs «*.so/*.pyo/*.dll/*.pyd/...» into an isolated Python
environment?)
Of course there can't be a single APP1 for all possible platforms. But there
could be one setup for each: APP1_Linux, APP1_MacOsX10.5, APP1_WinXP
The developer has to setup/test every supported platform anyway.

The "bootstrap" (standing on the shoulders of giants) could work like this:
- first there is a base app "Python 2.5.1 for Mac OS X 10.5" built by
developer A
- next developer B creates "Django 1.0.2 for Mac OS X 10.5" based on the one
above
- then developer C integrates Pinax into B's app and creates "Pinax 0.5.1
for Mac OS X 10.5"

All those "apps" could be found in Python AppStore and a developer could
search for the one which matches his requirements best. His implementation
cost is therefore minimized.

A iTunes-like client would allow the end-user to find apps - assumed that
all (or most) developers upload their apps into the one and only Python
AppStore.
The client (there should be one for every supported platform) is a front-end
application for the (PSF-) hosted "super-cheeseshop", which end-users are
not expected to access directly.


Is my nirvana really that far away? ;-)

Best regards,
Marcel


PS
A "Souq" is an Arab market (similar to a bazaar):
http://en.wikipedia.org/wiki/Souq
I got to know one visiting one last year in Oman - and I really liked it.
But now I can see that soundex('souq') == soundex('suck').
You're right, this would be a very bad choice... ;-)




On Sun, Feb 22, 2009 at 3:21 PM, Steve Holden  wrote:

> Marcel Luethi wrote:
> > Dear Community
> >
> > Now I'm standing here, having this great idea for a brand new rocking
> > app...
> > But where do I start? I want it to be multi-platform (Linux, Mac OS X,
> > Windows). It should be easy to install and upgrade. It should be self-
> > contained, independent of an already installed Python. And of course -
> > the world should be able to find it!
> >
> > So what do I do? I'm studying all the possibilities to make it self-
> > contained (virtualenv, InstantDjango, PortablePython...), searching
> > for installers (PyInstaller, EasyInstall, ...), looking into making it
> > executable on every platform (py2exe, py2app, cx_Freeze, ...),
> > analyzing all GUI frameworks (wxPython, PyGTK, PyQt, ...),
> > investigating all hosting providers (Google Code, SourceForge, ...)
> > and so on and so forth.
> >
> > This is not easy at all!
> >
> > Using my iPhone I suddenly realize how easy it is to find applications
> > in Apple's AppStore. How easy and fast it is to install or de-install
> > an app. My iPhone even checks in the background if there is an upgrade
> > which could be installed painlessly.
> >
> > Then I see VMware's Virtual Appliance Marketplace, where you can
> > download already pre-configured "appliances" for all kind of stuff.
> > You can even download a basic appliance, install and configure your
> > servers and tools - and upload it again, so that others can profit of
> > your work.
> >
> > Unfortunately there's nothing like this in the Python world...
> >
> > My idea: what about having a beefed up Cheeseshop for Python apps and
> > an accompanying client app kind of iTunes for Python apps?
> >
> > The server side could be easily implemented with any of the current
> > web fra

binary decision diagrams

2017-12-20 Thread Wild, Marcel, Dr
Hello everybody:
I really don't know anything about Python (I'm using Mathematica) but with the 
help of others learned that

g=expr2bdd(f)

makes the BDD (=binary decision diagram)  g of a Boolean function f.  But what 
is the easiest (fool-proof) way to print out a diagram of g ?

Regards, Marcel Wild

The integrity and confidentiality of this email is governed by these terms / 
Die integriteit en vertroulikheid van hierdie e-pos word deur die volgende 
bepalings gere?l. http://www.sun.ac.za/emaildisclaimer
-- 
https://mail.python.org/mailman/listinfo/python-list


binary decision diagrams (BDD)

2017-12-20 Thread Wild, Marcel, Dr
Hello every body,
I'm new here and this is my first question.
I really don't know anything about Python (I use Mathematica) but with the help 
of others learned that

g=expr2bdd(f)

makes the BDD g of a Boolean function f.  But what is the easiest (fool-proof) 
way to print out the diagram of g (i.e. the usual binary tree) ?

The integrity and confidentiality of this email is governed by these terms / 
Die integriteit en vertroulikheid van hierdie e-pos word deur die volgende 
bepalings gere?l. http://www.sun.ac.za/emaildisclaimer
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Are the critiques in "All the things I hate about Python" valid?

2018-02-20 Thread Wild, Marcel, Prof
I scarcely know Python, and I have no intention delving into it further.
 I was forced to use Python because it features binary decision diagrams, which 
MATHEMATICA doesn't. Coming from Mathematica the account of Nathan Murphy reads 
like a nightmare.

The one point that stroke me the most was the schism between Python 2 and 3. No 
such thing with Mathematica: All its 11 or more versions are fully compatible, 
I never experienced any problems in this regard.

Another point is the bad online help provided to "teach yourself" Python. For 
instance, it took me more than an hour to find out how to negate a Boolean 
variable, whereas in Mathematica you would just type "Negation" in the Wolfram 
Documentation search window, and get the information you need.

I know one pays for Mathematica whereas Python is open source, but I've come to 
realize now that this money is very well spent!

Question: Apart from a few commands not available in Mathematica, such as 
expr2bdd, is there really any domain of computation where Mathematica is 
inferior to Python?

Marcel

-Original Message-
From: Python-list [mailto:python-list-bounces+mwild=sun.ac...@python.org] On 
Behalf Of bartc
Sent: 19 February 2018 02:35 PM
To: python-list@python.org
Subject: Re: Are the critiques in "All the things I hate about Python" valid?

On 19/02/2018 02:59, Chris Angelico wrote:
> On Mon, Feb 19, 2018 at 1:14 PM, bartc  wrote:

>> How would even a type for the odd numbers from 1 to 10 inclusive work?
>> (That, a type consisting of one of the values in {1,3,5,7,9}.) Would
>> they be ordered or unordered? Can I do arithmetic with them: will 3*3
>> work, but not 3*5?
>
> The type is "positive odd number below ten" and could be written as
> int(1..9|1%2). That is an orderable type; you can say that 3 < 7, for
> instance. And yes, arithmetic would be defined just fine;

Sometimes, the reason for creating a special numerical type is precisely so you 
can't do arithmetic on them, if it's not meaningful for the type.

So the special type of the values 65..90 might not allow the type be multiplied 
or divided, or added to itself. Because they represent characters A..Z. Or 
house numbers. Or the age of pensioners. (You'd need to convert to ordinary 
integers, is that is allowed.)

  there's no
> requirement for the result of an operation to have the same type as
> its inputs:

>
>>>> 5 / 2 # two integers
> 2.5

Try that when the type of {1..13} represents playing card ordinal values.

Type systems get rapidly very complicated when you have to deal with arbitrary 
sets of values and with arbitrary rules of interaction.
Someone has to devise a programming language to allow all that without tying 
itself up in knots. Someone else has to program in it. And someone else has to 
try and understand it!

Ones like C++ has already tied itself itself up in knots just doing the basics; 
I'm not sure how it would handle even my 1,3,5,7,9 type.

But Python has classes and can do some of this stuff; how would it handle a 
numeric type that is constrained to be whole numbers within
0..9 inclusive?

--
bartc
--
https://mail.python.org/mailman/listinfo/python-list
The integrity and confidentiality of this email is governed by these terms / 
Die integriteit en vertroulikheid van hierdie e-pos word deur die volgende 
bepalings gereël. http://www.sun.ac.za/emaildisclaimer
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to check...

2006-02-11 Thread Daniel Marcel Eichler
Lad wrote:

>How can I  check that a string does NOT contain NON English characters?

try:
foobar.encode('ascii')
except:
bla

or use string.ascii_letters and enhance it.


mfg

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


Re: getting the line just before or after a pattern searched

2006-02-17 Thread Daniel Marcel Eichler
[EMAIL PROTECTED] wrote:

>i have a file something like this
>
>abcdefgh
>ijklmnopq
>12345678
>rstuvwxyz
>.
>.
>.
>12345678
>.
>
>whenever i search the file and reach 12345678, how do i get the line
>just above and below ( or more than 1 line above/below) the pattern
>12345678 and save to variables? thanks

source = file(bla).read().split('\n')
for i, line in enumerate(source):
if line == '12345678':
print '\n'.join( source[i-1:i+1] )

Something like this, for example. Of course, you must also secure that i-1 
isn't smaller than zero.


mfg

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


Re: Am I missing something with Python not having interfaces?

2008-05-07 Thread Daniel Marcel Eichler
Am Dienstag 06 Mai 2008 16:07:01 schrieb Mike Driscoll:

> If so, then it looks like an Interface is a generic class with method
> stubs. You can do that with Python just as easily by creating empty
> methods with just the "pass" keyword. 

Well, no. It's a litte different. Interfaces force to implement methods. 
Simple inheritance with method-stubs can't garantee that a specific 
method is reimplementat in a sub-class. Interfaces work at 
compile-time, while method-stubs raise at their first call, so in worst 
case, never (when the developer is available). 

> Since it's just a construct to implement polymorphism, I don't think
> you'll lose anything. However, Python does not require you to re-
> implement every method of the class it is inheriting from. 

That's the point. Interfaces garantee that a duck is a duck, an not only 
a chicken that quack. 

> You can just override those that you want and leave the others alone.

Not always desirable. But often enough ;)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Am I missing something with Python not having interfaces?

2008-05-08 Thread Daniel Marcel Eichler
Am Mittwoch 07 Mai 2008 22:39:30 schrieb Luis Zarrabeitia:

> There you have it, interfaces are not enough to ensure that the
> implementors actually implement the methods. They are useful for
> warning at compile time if there is a missing method, but nothing
> more. 

It's not the fault of the enviroment, if the coder is to stupid to use 
it the right way.

> I believe you could achieve a very similar warning in python 
> using some kind of Interface metaclass (too lazy right now to hack a
> proof of concept, but it looks doable).

Of course. And unlike Javas interfaces, it ensure a more dynamic 
coding-style, without great tools which check all the time for correct 
behaviour.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Am I missing something with Python not having interfaces?

2008-05-08 Thread Daniel Marcel Eichler
Am Donnerstag 08 Mai 2008 00:12:26 schrieb 
[EMAIL PROTECTED]:

> very often sees do-nothing catch-all try/catch blocks in Java - which
> is way worse than just letting the exception propagate. I find all
> this totally pointless, because there's just no way for a compiler to
> check if your code is logically correct.

But it's enough if the called method exists and returns the correct 
type. At least it prevents a crash.

> > Interfaces work at
> > compile-time, while method-stubs raise at their first call, so in
> > worst case, never.
> And then ? If it's never called, why bother implementing it ?

You never can't say when it's called at least, that's the point. 

> > That's the point. Interfaces garantee that a duck is a duck, an not
> > only a chicken that quack.
> Who cares if it's a chicken as long as it quacks when you ask her to
> ? Now *This* is the whole point of chicken^Mduck typing, isn't it ?-)

Ducks can also swim and fly. And if you need a really duck, but have 
onyl a chicken while the coder was to bored to make one...

Of course, in the practical world that all doesn't  matter. But in the 
theoretical world of the big coding farms, called business, that's one 
cornerstone of success, in the tinking of managers and so.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Am I missing something with Python not having interfaces?

2008-05-09 Thread Daniel Marcel Eichler
Am Freitag 09 Mai 2008 10:19:45 schrieb Bruno Desthuilliers:

> >> very often sees do-nothing catch-all try/catch blocks in Java -
> >> which is way worse than just letting the exception propagate. I
> >> find all this totally pointless, because there's just no way for a
> >> compiler to check if your code is logically correct.
> >
> > But it's enough if the called method exists and returns the correct
> > type. At least it prevents a crash.
>
> Then providing an appropriate default in the base class is enough
> too.

Only working *if* there is a base-class, and not only convention for 
should-have-methods.

> >>> That's the point. Interfaces garantee that a duck is a duck, an
> >>> not only a chicken that quack.
> >>
> >> Who cares if it's a chicken as long as it quacks when you ask her
> >> to ? Now *This* is the whole point of chicken^Mduck typing, isn't
> >> it ?-)
> >
> > Ducks can also swim and fly.  And if you need a really duck,
>
> If you're code expects something that quacks, swims and flies,
> anything that quacks, swims and flies is ok. You just don't care if
> it's a duck or a flying whale with a quacking device tied to it.

Not the point.

> > Of course, in the practical world that all doesn't  matter. But in
> > the theoretical world of the big coding farms, called business,
> > that's one cornerstone of success, in the tinking of managers and
> > so.
>
> Sorry, I live in a very practical world - and we're by no mean
> running out of business here...

Like i said.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Index server

2005-01-14 Thread Marcel van den Dungen
[EMAIL PROTECTED] wrote:
Is there an Index server available in Python? For example:
I have large intranet with several servers and I would like to index
documents like  search engines do. Users then can search for a domument
in ALL intranet servers like I do on Google.
Thanks for answers
L.A.
Take a look at the following URLs:
http://www.methods.co.nz/docindexer/
http://www.divmod.org/Home/Projects/Lupy/index.html
http://www.divmod.org/Home/Projects/Pyndex/index.html
HTH,
-- Marcel
--
http://mail.python.org/mailman/listinfo/python-list


Re: Basic file operation questions

2005-02-02 Thread Marcel van den Dungen
alex wrote:
Hi,
I am a beginner with python and here is my first question:
How can I read the contents of a file using a loop or something? I open
the file with file=open(filename, 'r') and what to do then? Can I use
something like
for xxx in file:
   
Thanks for help
Alex
take a look at this:
http://www.devshed.com/c/a/Python/File-Management-in-Python/
HTH,
-- Marcel
--
http://mail.python.org/mailman/listinfo/python-list