Re: Implicit initialization is EXCELLENT

2011-07-05 Thread Stefaan Himpe

Hello,

I agree with the contents of this post.

I see a similar problem with API's requiring to initialize all kinds of 
data using setters/properties instead of receiving it in the initializer 
(or constructor).



Python generally follows this design. Apart from files, I can't easily think
off the top of my head of any types that require a separate
open/start/activate call before they are usable.


database connections, network connections, spawning expensive 
processes/threads, things that benefit from lazy evaluation...



Now, I have an ulterior motive in raising this issue... I can't find the
original article I read! My google-fu has failed me (again...). I don't
suppose anyone can recognise it and can point me at it?


My sarcasm detector warns me not to add a link, although perhaps it's 
time for recalibration (after all, summer season started) :-)


Best regards,
Stefaan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Implicit initialization is EXCELLENT

2011-07-06 Thread Stefaan Himpe



No! I was serious. I've spent *ages* trying to find the link to the
article... if you know it, please share.


Ok - I thought you were referring to some troll's rant with similar 
title. I'm probably way off, but were you referring to the RAII technique?


http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization




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


Re: list comprehension to do os.path.split_all ?

2011-07-28 Thread Stefaan Himpe

Hi,


[python 2.7] I have a (linux) pathname that I'd like to split
completely into a list of components, e.g.:
'/home/gyoung/hacks/pathhack/foo.py'  -->   ['home', 'gyoung',
'hacks', 'pathhack', 'foo.py']


Not sure what your exact requirements are, but the following seems to work:

pathname = '/home/gyoung/hacks/pathhack/foo.py'
print pathname[1:].split("/")

Note that this would only work for absolute linux paths (i.e. starting 
with "/").


Best regards,
Stefaan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python IDE/text-editor

2011-04-16 Thread Stefaan Himpe

Here's a mockup of the app I'm looking for: http://i52.tinypic.com/2uojswz.png

Which would you recommend?


You drew editra! http://editra.org/preview

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


Re: Python IDE/text-editor

2011-04-27 Thread Stefaan Himpe



Thanks for all the suggestions, glad I found the right one!


You're welcome :D
--
http://mail.python.org/mailman/listinfo/python-list


Re: Easiest framework to develop simple interactive web site in python?

2011-09-12 Thread Stefaan Himpe

The simplest one to learn is web2py http://www.web2py.com
No configuration needed, just unpack and get started.
It also has very good documentation and tons of little examples to get 
things done.


The other options you mentioned are good too :)

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


Re: Usefulness of the "not in" operator

2011-10-08 Thread Stefaan Himpe




So what is the usefulness of the "not in" operator ? Recall what Zen of
Python tells

There should be one-- and preferably only one --obvious way to do it.


the zen of python also says (amongst other things):

...
Readability counts.
...
Although practicality beats purity
...

Best regards,
Stefaan.

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


auto upgrade scripts?

2006-09-11 Thread stefaan . himpe
Hello list,

Is anyone aware of a (light-weight, easy-to-use)
auto-upgrade framework for python scripts?

I find it hard to believe no one has wanted this before,
yet google doesn't find too much relevant stuff.

Thanks,
Best regards,
Stefaan.

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


Re: auto upgrade scripts?

2006-09-12 Thread stefaan . himpe
> Auto-upgrade from what to what?
> -Larry Bates

Interesting question.

In my case I want my program to check for (e.g.) bug-fix releases on
some location (network drive or ftp), and if available, allow to
automatically download and install them.
Kind of like the AutoUpgrade functionality in .net (*shudder*) ;)

Best regards,
Stefaan.

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


Re: auto upgrade scripts?

2006-09-13 Thread stefaan . himpe
> Since you mention .NET and didn't state otherwise, I'm assuming
> Windows platform?

No, I need both linux and windows. I guess this means
I'll have to make something myself ...

Thanks, and best regards,
Stefaan.

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


Re: Pythonic way to determine if one char of many in a string

2009-02-16 Thread Stefaan Himpe

An entirely different approach would be to use a regular expression:

import re
if re.search("[abc]", "nothing expekted"):
   print "a, b or c occurs in the string 'nothing expekted'"

if re.search("[abc]", "something expected"):
   print "a, b or c occurs in the string 'something expected'"

Best regards,
Stefaan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: p2exe for python 2.6

2008-10-22 Thread Stefaan Himpe

How can convert my python script in exe for the python version 2.6?


You must use a standalone executable builder like
* py2exe (Windows)
* py2app (Mac OS)
* PyInstaller (all platforms)
* cx_Freeze (Windows and Linux)
* bbFreeze (Windows and Linux)

Presumably you could use GUI2EXE [1] as a graphical front-end to these
tools (never tried this myself).

Best regards,
Stefaan.

[1] http://xoomer.alice.it/infinity77/main/GUI2Exe.html
--
http://mail.python.org/mailman/listinfo/python-list


Re: Building musical chords starting from (a lot of) rules

2008-11-15 Thread Stefaan Himpe

The costrunction of a chord is based on a root note and a structure,
so by default, giving just a note, it creates a major chord adding the
third and fifth note.


Quite some time ago I wrote something to solve the reverse problem: 
given a list of note names, find out a chord name. 
(http://chordrecognizer.sourceforge.net/ )


I used a look-up table to made a correspondence between the chord-name 
and the notes from which the chord is built. The notes are expressed as

a distance from the root note.

E.g. starting from a chromatic scale built on C, the distances would be:
C:0  C#:1  D:2  D#:3  E:4  F:5  F#:6  G:7  G#:8  A:9  A#:10  B:11
(and similar for flats, double sharps and double flats, ...)

Any chord thus can be constructed from a root note + the distance 
information.


example distance information:

 { 'm' : [ 0, 3, 7 ],# minor triad
   ''  : [ 0, 4, 7 ],# major triad
   '7' : [ 0, 4, 7, 10]  # etc...
...
 }

How does one e.g. construct the E7 chord from this information?

1. generate the chromatic scale starting from E, and annotate with note 
distance to root note:


E:0  F:1  F#:2  G:3  G#:4  A:5  A#:6  B:7  C:8  C#:9  D:10  D#:11

2. take the recipe for a '7' chord from the distance information:
[0, 4, 7, 10]

3. map the numbers from step 2. to the note names from step 1.: E G# B D

If you care about proper enharmonic spelling of the chord's note names 
(i.e. do  not confuse F# and Gb), you will need to add some extra 
information in the look-up tables or you need to pass extra information 
to the chord construction recipe at the moment of creating a chord, but 
that is left as an excercise to you - the interested reader ;)


HTH,
Stefaan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Using Python after a few years of Ruby

2009-04-14 Thread Stefaan Himpe

Hi,


1) Is there anything like a Python build tool? (Or do I
even need something like that?)


If you're going to run the python source code, you don't need anything.
Python builds what it needs automagically. Some tools exist to build
stand-alone executables though, if you'd like to do so (e.g. py2exe, 
http://www.py2exe.org)



3) Web frameworks
I quite like the powerful and very intuitive and easy to use web2py 
(http://www.web2py.com).


(not to be confused with the minimalist web framework web.py, 
http://webpy.org).


Best regards,
Stefaan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: html ui + py background? any tut?

2009-05-23 Thread Stefaan Himpe

Perhaps you want to investigate
pyjamas[1] and pyjamas-desktop[2]

[1] http://pyjs.org/
[2] http://pyjd.sourceforge.net/

Best regards,
Stefaan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: html ui + py background? any tut?

2009-05-23 Thread Stefaan Himpe

Or maybe you are looking for something like nufox?
http://nufox.berlios.de/
--
http://mail.python.org/mailman/listinfo/python-list


Re: regarding SWIG

2008-07-22 Thread Stefaan Himpe

Hi..
I'm new to SWIG and need to create Wrapper for C code,
so, I have installed the SWIG already but doesnot know how to run it
for generating Interface file...


As far as I understand, SWIG will not generate an interface file for 
you. You have to write it yourself, to tell SWIG what parts of your API

you want to expose in python.

HTH,
Stefaan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: I donä't get while-loops

2008-08-02 Thread Stefaan Himpe


def read2():
expr = ""
while expr != "quit":
expr = raw_input("Lisp> ")
print parse(expr)
read2()

^

print "Good session!"



You shouldn't call read2() inside read2()...
just remove that line and retry...

Each time you call read2() recursively, a
new expr is initialized to "", so the condition
never becomes true
--
http://mail.python.org/mailman/listinfo/python-list


Re: Profiling weirdness: Timer.timeit(), fibonacci and memoization

2008-08-02 Thread Stefaan Himpe

Nothing weird about this ...
The difference will become larger as your input value becomes larger.

You can easily understand why if you try to calculate fib(10) by hand,
i.e. work through the algorithm with pencil and paper,
then compare the work you have to do to the memoized version which just 
takes fib(9) and fib(8) from memory and adds them together.


Best regards,
Stefaan.
--
http://mail.python.org/mailman/listinfo/python-list


Re: raw_input on several lines

2008-08-02 Thread Stefaan Himpe



How can I change this behavior, so that another action is needed to stop the
input? For example, CTRL-G. It would allow the user to input several lines.



I don't think you can change raw_input's behaviour in this respect, but 
you could build something yourself that's based on interpretation of raw 
keyboard scan codes.


Google is your friend in this...

e.g. on Linux you could use something like urwid
e.g. on win32 you could use something like 
http://code.activestate.com/recipes/197140/


I am not aware of an os independent way to accomplish what you want.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Distribution of Python Scripts

2010-11-19 Thread Stefaan Himpe



So, what's my options.


Maybe this page can give some inspiration?
http://wiki.python.org/moin/deployment


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


Re: A web site using Python

2010-12-09 Thread Stefaan Himpe

1. Pick a web framework, I'd suggest looking at:


web2py: http://web2py.com - probably the easiest to install (no 
configuration needed) and learn. Suitable for both small and big 
projects. No worries when upgrading to a newer version as backward 
compatibility is an explicit design goal.


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


surprised by import in python 2.6

2010-12-10 Thread Stefaan Himpe

Hello list,

Recently someone asked me this question, to which I could not give an 
answer. I'm hoping for some insight, or a manual page. What follows is 
python 2.6.


The problem is with the difference between

from test import *

and

import test

First things first. Here's the code to test.py:

a = 3
def f():
   global a
   return a

Now, in the interactive interpreter:

>>> from test import *
>>> a
3
>>> f()
3
>>> a = 4
>>> f()
3

in a second session:

>>> import test
>>> test.a
3
>>> test.f()
3
>>> test.a = 4
>>> test.f()
4

Somehow, in the first session I cannot modify the global variable a 
returned from f, but in the second session I can. To my eye, the only 
difference seems to be a namespace. Can anyone shine some light on this 
matter?


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


Re: Reactive programming in Python ?

2010-04-16 Thread Stefaan Himpe



You can find more information on this project at www.yoopf.org.  Your
comments are more than welcome!


Is this something similar to trellis?
http://pypi.python.org/pypi/Trellis

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


Re: Only one forum app in Python?

2010-07-09 Thread Stefaan Himpe

Is Pocoo really the only solution available out there?

No. See e.g. http://www.pyforum.org/


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


Re: can python make web applications?

2009-08-23 Thread Stefaan Himpe

Deep_Feelings wrote:

can python make powerfull database web applications that can replace
desktop database applications? e.g: entrprise accounting
programs,enterprise human resource management programs ...etc


In addition to the recommendations by other people, I'd like to
recommend the very easy to learn and use web2py. (www.web2py.com).
--
http://mail.python.org/mailman/listinfo/python-list


Re: Spreadsheet-style dependency tracking

2010-10-21 Thread Stefaan Himpe

Florian Weimer wrote:


Are there libraries which implement some form of spreadsheet-style
dependency tracking?


The first that come to mind (I have very limited experience with them):

trellis http://peak.telecommunity.com/DevCenter/Trellis
pycells http://pycells.pdxcb.net/

Best regards,
Stefaan.
--
http://mail.python.org/mailman/listinfo/python-list