Re: [2.4.2] Compiling Python with packages?

2008-02-03 Thread Martin v. Löwis
>   I need to compile Python with the packages "socket,sys,time,os", but
> I've never done it before, and would like confirmation that this will
> work as planned:
> 
> ==
> make clean
> ./configure --with-socket --with-sys --with-time --with-os
> make
> make install
> ==

No, it won't. You don't give any arguments to configure normally,
when building Python. Instead, setup.py will detect what libraries
are on your system, and use them.

There are a few --enable and --with flags supported; ask --help
what they are.

The modules you want to have (socket, sys, time, and os) are always
built.

> In addition, are there recommended switches I should know about?
> 
> Incidently, is there an equivalent to PHP's phpinfo() to check what
> packages Python provides on a host?

There is sys.builtin_module_names. However, some modules are
not builtin (they are shared libraries instead); it's easiest
to ls build/lib. after compiling Python to see what
modules have been built.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Windows Python 2.5.1 IPV6 problems

2008-02-03 Thread Thomas DiZoglio
Hi,

Thanks for the help. I had to make family and int. It
was defined as socket.AF_INET6 and for some reason not
making that an int. It is fix now.
---
t0md


--- "Martin v. Löwis" <[EMAIL PROTECTED]> wrote:

> > _sock = _realsocket(family, type, proto)
> > TypeError: an integer is required
> 
> So what values have family, type, and proto at that
> point?
> Edit socket.py to find out.
> 
> Could it be that you also need to set socketType for
> your
> Port subclass?
> 
> Regards,
> Martin
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 


CONFIDENTIALITY NOTICE: Proprietary/Confidential Information belonging to 
Virgil Software, Inc. may be contained in this message. If you are not a 
recipient indicated or intended in this message (or responsible for delivery of 
this message to such person), or you think for any reason that this message may 
have been addressed to you in error, you may not use or copy or deliver this 
message (and all attachments) to anyone else. In such case, you should destroy 
this message (and all attached documents) and are asked to notify the sender by 
reply email.


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 

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


"ping" not reconnecting in Python MySQLdb client interface

2008-02-03 Thread John Nagle
I have some long-running Python programs that can be idle
for hours, and, of course, the MySQL connection times out.
So I call

db.ping()

at the beginning of a new request cycle.  This should
reestablish the connection, but it doesn't:

   Traceback (most recent call last):
   File "rateapiv1.fcgi", line 60, in QuickSitetruthQuery
   db.ping() # reattach connection if necessary
   OperationalError: (2006, 'MySQL server has gone away')

The MySQL server is up, and new connection attempts succeed.

This problem was reported two years ago relative to TurboGears:

http://trac.turbogears.org/ticket/872

I suspect that MySQL has auto-reconnect turned off, but doesn't document this.

(MySQL 5 on Fedora Core)

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


Re: bags? 2.5.x?

2008-02-03 Thread Arnaud Delobelle
On Feb 2, 5:28 pm, Carsten Haese <[EMAIL PROTECTED]> wrote:
> On Sat, 2008-02-02 at 01:17 -0800, Paul Rubin wrote:
> > Arnaud Delobelle <[EMAIL PROTECTED]> writes:
> > > * For sets {x, y} union {y, z} = {x, y, z}.  The natural way of
> > >   extending this to multisets is having the union operator take the
> > >   max of the multiplicities of each element, i.e.
>
> > That certainly doesn't fit the intuition of a bag of objects.  I'd
> > think of the union of two bags as the result of dumping the contents
> > of both bags onto the table, i.e. you'd add the two vectors.
>
> In addition to possibly being more intuitive, the latter also agrees
> with a use case of bags in complex analysis. If you consider the zeroes
> of complex polynomials, let B1 be the zeroes of polynomial P1, and B2 be
> the zeroes of polynomial P2, then B1+B2 are the zeroes of the product
> P1*P2.

Note that I was proposing exactly this: B1+B2 would add
multiplicities.  On top of this, B1.union(B2) would take the max
(maybe spelt B1|B2).  IMHO this is more in the spirit of union:
conceptually, the union of two things is the smallest thing that
contains them both.

--
Arnaud

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


Re: dict comprehension

2008-02-03 Thread Arnaud Delobelle
On Feb 2, 9:10 pm, [EMAIL PROTECTED] wrote:
> Steven Bethard:
>
> > It also doesn't build the unnecessary intermediate tuples:
>
> I see, but can't the interpreter improved to remove similar
> intermediate tuples anyway?

Do you mean the compiler?

> Is this a difficult thing to do?

Yes, due to the HDNP (Highly Dynamic Nature of Python).

--
Arnaud

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


Re: python for a matlab user

2008-02-03 Thread Jeroen Ruigrok van der Werven
Hi David,

-On [20080202 17:51], David Wang ([EMAIL PROTECTED]) wrote:
>i use matlab in my daily research and some shell scripting as well
>(primarily for data analysis). i wonder how easy or difficult for a
>matlab user to pick up python? i also know Fortran but haven't used it
>for years.

Having recently done a bunch of Fortran to Matlab and Fortran to Python
conversions I hope I am able to pinpoint some things:

- Python has no built-in IDE of the magnitude of Matlab
- using the command line interpreter you can easily run pieces of code and
  check the details on the various variables and such you declared, so
  they're reasonably similar in this aspect
- structuring of the code is pretty much similar as well, the only thing you
  need to look at is the way the declaration part of loops are written
- Python is indentation-sensitive, whereas Matlab isn't
- Python starts indexing at 0, not 1 like Matlab does

-- 
Jeroen Ruigrok van der Werven  / asmodai
イェルーン ラウフロック ヴァン デル ウェルヴェン
http://www.in-nomine.org/ | http://www.rangaku.org/
We have met the enemy and they are ours...
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: bags? 2.5.x?

2008-02-03 Thread Arnaud Delobelle
On Feb 2, 3:21 pm, MRAB <[EMAIL PROTECTED]> wrote:
> I could see uses for both types of union. You could have both A + B
> which adds the multiplicities (the smallest bag which contains both
> the bags) and A | B which takes the max of the multiplicities (the
> smallest bag which contains either of the bags).

I agree, and this is what I proposed in my post (except that I spelt A|
B as A.union(B))

--
Arnaud

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


Re: Python feature request : operator for function composition

2008-02-03 Thread Arnaud Delobelle
On Feb 3, 5:09 am, Kay Schluehr <[EMAIL PROTECTED]> wrote:
> As you know, there is no operator for function composition in Python.
> When you have two functions F and G and  want to express the
> composition F o G you have to create a new closure
>
> lambda *args, **kwd: F (G (*args, **kwd))
>
> or you write a composition in functional style
>
> compose( F, G )
>
> None of these solutions is particular terse.
>
> Proposal
> -
> I want to propose overloading the logical __and__ operator i.e. '&'
> for functions s.t. F & G means "compose(F,G)". This suggestion is non-
> conflicting since & is not used as an operator in combination with
> function objects yet: given a function object F and an arbitrary
> object X the combination F & X raises a TypeError when evaluated.
>
> Alternatives
> -
> One could use other unused operators like F << G or F * G to write
> terse function composition expressions. I' m not sure which one is
> best and would use the proposed & if no one presents arguments against
> it.

What about other callable objects?

--
Arnaud

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


Re: Why chdir command doesn't work with client.get_transport() ?

2008-02-03 Thread Martin v. Löwis
> import paramiko
> def exec_command(trans, command):
> chan = trans.open_session()
> chan.exec_command(command)
> stdin = chan.makefile('wb')
> stdout = chan.makefile('rb')
> stderr = chan.makefile_stderr('rb')
> return stdin, stdout, stderr
> def main():
> client = paramiko.SSHClient()
> client.connect(hostname, username=username, password=password)
> trans = client.get_transport()
> dummy_chan = trans.open_session()
> exec_command(trans, 'cd temp')
> stdin, stdout, stderr = exec_command(pwd)
> 
>>From the last line I found from stdout that the pwd is not changed. I tried
> to type the full path in 'cd', did not help. Other UNIX commands such as ls,
> mkdir, cp, rm will work. Only this 'cd' never works. I got stuck here.
> 
> Please help. Thanks!

It works. However, each exec_command opens a new session. Within the
first session, you do the cd command, and in the second session, the
process in whose context the cd was executed has already terminated.
You get a new process, and that starts out with the default directory
again.

You need to open a remote shell, and send commands to its command
line; AFAICT, you can't use exec_command for that.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does anyone else use this little idiom?

2008-02-03 Thread Arnaud Delobelle
On Feb 3, 2:03 am, [EMAIL PROTECTED] wrote:
> Ruby has a neat little convenience when writing loops where you don't
> care about the loop index: you just do n.times do { ... some
> code ... } where n is an integer representing how many times you want
> to execute "some code."
>
> In Python, the direct translation of this is a for loop.  When the
> index doesn't matter to me, I tend to write it as:
>
> for _ in xrange (1,n):
>    some code
[...]

If 'some code' is a function (say f) you can write (with repeat from
itertools):

for action in repeat(f, n): action()

I don't know how 'Pythonic' this would be...

--
Arnaud

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


Re: psycopg2

2008-02-03 Thread DouhetSukd
On Feb 2, 9:22 pm, Tim Roberts <[EMAIL PROTECTED]> wrote:

> Also, psycopg will do the quoting for you.  You don't do it.  So this is
> what you want:

Second the above, it is much cleaner to leave the quoting to
psycopg2.  I know, I wrote my own quoting logic for dynamically
generated queries and I was happy as happy as a turkey on boxing day
to dump that code overboard when I realized I didn't need it anymore.

However, I think you are better off using dictionary based
substitutions:

cur.execute("SELECT * FROM names WHERE name= %(name)s ",
{"name":"S"} )

On small and simple queries it doesn't matter much and using dicts is
actually a bit harder.  On complex queries you may find:

- lots of binds.
- the same bind variable being used in several places
- optimization/adjustments may require you to rewrite the query
several times and shuffling the binds around into different
positions.

Maintaining positional binds is then a huge hassle compared to name-
based binds.

For the lazy, using dicts has another advantage:

name = "S"
firstname = "F"
cur.execute("SELECT * FROM names WHERE name = %(name)s and firstname =
%(firstname)s ", locals() )

Both MySQL and postgresql can work from the above examples as they
both accept name-binds and dicts.  Something which is not all that
clear in the docs.  Not all dbapi implementations allow this though.

Last but definitely not least, using dicts allows you to re-use bind
data more efficiently/painlessly:

di_cust = {"cust_id":
mynewcustid,"another_field_only_on_customer_table":3}

execute("insert into customer (cust_id) values (%
(cust_id)s...)",di_cust)

for order in get_order_lines():
  di_order = {"order_id":order.order_id}

  #grab shared field data from the customer dict.
another_field_only_on_customer_table will be ignored later.
  di_order.update(di_cust)

  execute("insert into customer_orders (cust_id,order_id) values (%
(cust_id)s, %(order_id)s...)",di_order)

None of this is very attractive if you believe in only using ORMs, but
it is bread and butter to looking after complex sql by yourself.

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


Re: Python feature request : operator for function composition

2008-02-03 Thread Kay Schluehr
On 3 Feb., 10:13, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
> On Feb 3, 5:09 am, Kay Schluehr <[EMAIL PROTECTED]> wrote:
>
>
>
> > As you know, there is no operator for function composition in Python.
> > When you have two functions F and G and  want to express the
> > composition F o G you have to create a new closure
>
> > lambda *args, **kwd: F (G (*args, **kwd))
>
> > or you write a composition in functional style
>
> > compose( F, G )
>
> > None of these solutions is particular terse.
>
> > Proposal
> > -
> > I want to propose overloading the logical __and__ operator i.e. '&'
> > for functions s.t. F & G means "compose(F,G)". This suggestion is non-
> > conflicting since & is not used as an operator in combination with
> > function objects yet: given a function object F and an arbitrary
> > object X the combination F & X raises a TypeError when evaluated.
>
> > Alternatives
> > -
> > One could use other unused operators like F << G or F * G to write
> > terse function composition expressions. I' m not sure which one is
> > best and would use the proposed & if no one presents arguments against
> > it.
>
> What about other callable objects?
>
> --
> Arnaud

Supporting general callables would be very fine. I thing a callable
ABC with two protocols named __call__ and __compose__ would be most
adequate. I'm just not sure if Python 2.X requires a more ad hoc
implementation for builtin callable types? On the level of user
defined classes a bundling between __call__ and __compose__ shall
remain optional ( unlike e.g. the dependency between __iter__ and
__next__ for iterables ).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python feature request : operator for function composition

2008-02-03 Thread Arnaud Delobelle
On Feb 3, 9:43 am, Kay Schluehr <[EMAIL PROTECTED]> wrote:
> On 3 Feb., 10:13, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Feb 3, 5:09 am, Kay Schluehr <[EMAIL PROTECTED]> wrote:
>
> > > As you know, there is no operator for function composition in Python.
> > > When you have two functions F and G and  want to express the
> > > composition F o G you have to create a new closure
>
> > > lambda *args, **kwd: F (G (*args, **kwd))
>
> > > or you write a composition in functional style
>
> > > compose( F, G )
>
> > > None of these solutions is particular terse.
>
> > > Proposal
> > > -
> > > I want to propose overloading the logical __and__ operator i.e. '&'
> > > for functions s.t. F & G means "compose(F,G)". This suggestion is non-
> > > conflicting since & is not used as an operator in combination with
> > > function objects yet: given a function object F and an arbitrary
> > > object X the combination F & X raises a TypeError when evaluated.
>
> > > Alternatives
> > > -
> > > One could use other unused operators like F << G or F * G to write
> > > terse function composition expressions. I' m not sure which one is
> > > best and would use the proposed & if no one presents arguments against
> > > it.
>
> > What about other callable objects?
>
> > --
> > Arnaud
>
> Supporting general callables would be very fine. I thing a callable
> ABC with two protocols named __call__ and __compose__ would be most
> adequate. I'm just not sure if Python 2.X requires a more ad hoc
> implementation for builtin callable types? On the level of user
> defined classes a bundling between __call__ and __compose__ shall
> remain optional ( unlike e.g. the dependency between __iter__ and
> __next__ for iterables ).

This would conflict with the fact that the operators you suggest for
composition can already be overloaded for other purposes.

--
Arnaud

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


Re: Multiple interpreters retaining huge amounts of memory

2008-02-03 Thread Graham Dumpleton
Nice to see that your comments do come from some understanding of the
issues. Been number of times in the past when people have gone off
saying things about multiple interpreters, didn't really know what
they were talking about and were just echoing what some one else had
said. Some of the things being said were often just wrong though. It
just gets annoying. :-(

Anyway, a few comments below with pointers to some documentation on
various issues, plus details of other issues I know of.

On Feb 3, 6:38 pm, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote:
> > If you are going to make a comment such as 'multi-interpreter feature
> > doesn't really work' you really should substantiate it by pointing to
> > where it is documented what the problems are or enumerate yourself
> > exactly what the issues are. There is already enough FUD being spread
> > around about the ability to run multiple sub interpreters in an
> > embedded Python application, so adding more doesn't help.
>
> I don't think the limitations have been documented in a systematic
> manner. Some of the problems I know of are:
> - objects can easily get shared across interpreters, and often are.
>    This is particularly true for static variables that extensions keep,
>    and for static type objects.

Yep, but basically a problem with how people write C extension
modules. Ie., they don't write them with the fact that multiple
interpreters can be used in mind.

Until code was fixed recently in trunk, one high profile module which
had this sort of problem was psycop2. Not sure if there has been an
official release yet which includes the fix. From memory the problem
they had was that a static variable was caching a reference to the
type object for Decimal from the interpreter which first loaded and
initialised the module. That type object was then used to create
instances of Decimal type which were passed to other interpreters.
These Decimal instances would then fail isinstance() checks within
those other interpreters.

Some details about this in section 'Multiple Python Sub Interpreters'
of:

  http://code.google.com/p/modwsgi/wiki/ApplicationIssues

That section of documentation also highlights some of the other errors
that can arise where file objects in particular are somehow shared
between interpreters, plus issues when unmarshalling data.

You might also read section 'Application Environment Variables' of
that document. This talks about the problem of leakage of environment
variables between sub interpreters. There probably isn't much that one
can do about it as one needs to push changes to os.environ into C
environment variables so various system library calls will get them,
but still quite annoying that the variables set in one interpreter
then show up in interpreters created after that point. It means that
environment variable separation for changes made unique to a sub
interpreter is impossible.

> - Py_EndInterpreter doesn't guarantee that all objects are released,
>    and may leak. This is the problem that the OP seems to have.
>    All it does is to clear modules, sys, builtins, and a few other
>    things; it is then up to reference counting and the cycle GC
>    whether this releases all memory or not.

There is another problem with deleting interpreters and then creating
new ones. This is where a C extension module doesn't declare reference
counts to static Python objects it creates. When the interpreter is
destroyed and objects that can be destroyed are destroyed, then it may
destroy these objects which are referenced by the static variables.
When a subsequent interpreter is created which tries to use the same C
extension module, that static variable now contains a dangling invalid
pointer to unused or reused memory.

PEP 3121 could help with this by making it more obvious of what
requirements exist on C extension modules to cope with such issues.

I don't know whether it is a fundamental problem with the tool or how
people use it, but Pyrex generated code seems to also do this. This
was showing up in PyProtocols in particular when attempts were made to
recycle interpreters within the lifetime of a process. Other packages
having the problem were pyscopg2 again, lxml and possibly subversion
bindings. Some details on this can be found in section 'Reloading
Python Interpreters' of that document.

> - the mechanism of PEP 311 doesn't work for multiple interpreters.

Yep, and since SWIG defaults to using it, it means that SWIG generated
code can't be used in anything but the main interpreter. Subversion
bindings seem to possibly have a lot of issues related to this as
well. Some details on this can be found in section 'Python Simplified
GIL State API' of that document.

> > Oh, it would also be nice to know exactly what embedded systems you
> > have developed which make use of multiple sub interpreters so we can
> > gauge with what standing you have to make such a comment.
>
> I have never used that feature myself. However, I wrote PEP 3121
> 

Re: Does anyone else use this little idiom?

2008-02-03 Thread James Matthews
Because 0 is counted therefore i only have to do it 99 times

Thanks

On Feb 3, 2008 4:38 AM, Gabriel Genellina <[EMAIL PROTECTED]> wrote:

> En Sun, 03 Feb 2008 01:03:43 -0200, James Matthews <[EMAIL PROTECTED]>
> escribió:
>
> Sorry to be nitpicking, but people coming from other languages may get
> confused by the wrong examples:
>
> > What i do is a simple range call. for i in range(number of times i want
> > to repeat something)
> > I guess it comes from my C days for(i=0;i<100;i++) { or in python for i
> > in range(99):
>
> Should be `for i in range(100)` to match exactly the C loop. Both iterate
> 100 times, with i varying from 0 to 99 inclusive.
>
> >>  [EMAIL PROTECTED] wrote:
> >>
> >> > Ruby has a neat little convenience when writing loops where you don't
> >> > care about the loop index: you just do n.times do { ... some
> >> > code ... } where n is an integer representing how many times you want
> >> > to execute "some code."
> >> >
> >> > In Python, the direct translation of this is a for loop.  When the
> >> > index doesn't matter to me, I tend to write it as:
> >> >
> >> > for _ in xrange (1,n):
> >> >some code
>
> Should be `for _ in xrange(n)` to match the Ruby example. Both iterate n
> times.
>
> > On Feb 3, 2008 3:34 AM, Roy Smith <[EMAIL PROTECTED]> wrote:
> >
> >> But, more to the point, I'd try to find variable name which described
> >> why I was looping, even if I didn't actually use the value in theloop
> >> body:
>
> Me too. Government don't collect taxes by the number of variable names
> used (yet).
>
> --
> Gabriel Genellina
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
http://search.goldwatches.com/?Search=Movado+Watches
http://www.jewelerslounge.com
http://www.goldwatches.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python feature request : operator for function composition

2008-02-03 Thread Kay Schluehr
On 3 Feb., 10:55, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
> On Feb 3, 9:43 am, Kay Schluehr <[EMAIL PROTECTED]> wrote:
>
>
>
> > On 3 Feb., 10:13, Arnaud Delobelle <[EMAIL PROTECTED]> wrote:
>
> > > On Feb 3, 5:09 am, Kay Schluehr <[EMAIL PROTECTED]> wrote:
>
> > > > As you know, there is no operator for function composition in Python.
> > > > When you have two functions F and G and  want to express the
> > > > composition F o G you have to create a new closure
>
> > > > lambda *args, **kwd: F (G (*args, **kwd))
>
> > > > or you write a composition in functional style
>
> > > > compose( F, G )
>
> > > > None of these solutions is particular terse.
>
> > > > Proposal
> > > > -
> > > > I want to propose overloading the logical __and__ operator i.e. '&'
> > > > for functions s.t. F & G means "compose(F,G)". This suggestion is non-
> > > > conflicting since & is not used as an operator in combination with
> > > > function objects yet: given a function object F and an arbitrary
> > > > object X the combination F & X raises a TypeError when evaluated.
>
> > > > Alternatives
> > > > -
> > > > One could use other unused operators like F << G or F * G to write
> > > > terse function composition expressions. I' m not sure which one is
> > > > best and would use the proposed & if no one presents arguments against
> > > > it.
>
> > > What about other callable objects?
>
> > > --
> > > Arnaud
>
> > Supporting general callables would be very fine. I thing a callable
> > ABC with two protocols named __call__ and __compose__ would be most
> > adequate. I'm just not sure if Python 2.X requires a more ad hoc
> > implementation for builtin callable types? On the level of user
> > defined classes a bundling between __call__ and __compose__ shall
> > remain optional ( unlike e.g. the dependency between __iter__ and
> > __next__ for iterables ).
>
> This would conflict with the fact that the operators you suggest for
> composition can already be overloaded for other purposes.
>
> --
> Arnaud

True. Extending a callable ABC by __add__ shall be sufficient and does
not cause ambiguities, Just one tiny teardrop for __add__ not being
very telling. Otherwise the intended semantics might be constrained to
builtin function/method/... types and classes that derive from a
callable ABCs. This is sufficient for covering the intended purpose of
function composition and does not exclude close relatives ( methods,
function-like objects ). How someone assigns semantics to a general
__call__ on his own classes is up to him.

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


Re: Does anyone else use this little idiom?

2008-02-03 Thread Robert Kern
James Matthews wrote:
> Because 0 is counted therefore i only have to do it 99 times

No, Gabriel is correct. range(n) creates a list of integers starting at 0 and 
going to n-1 (inclusive), not n.


In [1]: range(9)
Out[1]: [0, 1, 2, 3, 4, 5, 6, 7, 8]

In [2]: len(range(9))
Out[2]: 9

In [3]: len(range(1, 9))
Out[3]: 8

In [4]: range(10)
Out[4]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

In [5]: len(range(10))
Out[5]: 10


> On Feb 3, 2008 4:38 AM, Gabriel Genellina <[EMAIL PROTECTED] 
> > wrote:
> 
> En Sun, 03 Feb 2008 01:03:43 -0200, James Matthews
> <[EMAIL PROTECTED] >
> escribió:
> 
> Sorry to be nitpicking, but people coming from other languages may get
> confused by the wrong examples:
> 
>  > What i do is a simple range call. for i in range(number of times
> i want
>  > to repeat something)
>  > I guess it comes from my C days for(i=0;i<100;i++) { or in python
> for i
>  > in range(99):
> 
> Should be `for i in range(100)` to match exactly the C loop. Both
> iterate
> 100 times, with i varying from 0 to 99 inclusive.
> 
>  >>  [EMAIL PROTECTED]  wrote:
>  >>
>  >> > Ruby has a neat little convenience when writing loops where
> you don't
>  >> > care about the loop index: you just do n.times do { ... some
>  >> > code ... } where n is an integer representing how many times
> you want
>  >> > to execute "some code."
>  >> >
>  >> > In Python, the direct translation of this is a for loop.  When the
>  >> > index doesn't matter to me, I tend to write it as:
>  >> >
>  >> > for _ in xrange (1,n):
>  >> >some code
> 
> Should be `for _ in xrange(n)` to match the Ruby example. Both iterate n
> times.
> 
>  > On Feb 3, 2008 3:34 AM, Roy Smith <[EMAIL PROTECTED]
> > wrote:
>  >
>  >> But, more to the point, I'd try to find variable name which
> described
>  >> why I was looping, even if I didn't actually use the value in
> theloop
>  >> body:
> 
> Me too. Government don't collect taxes by the number of variable names
> used (yet).
> 
> --
> Gabriel Genellina

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

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

Is it explicitly specified?

2008-02-03 Thread mario ruggier

Is there any way to tell between whether a keyword arg has been explicitly
specified (to the same value as the default for it) or not... For example:

def func(key=None):
do something with key

But the following two usages give same results:

func()
func(key=None)

It may sometimes be useful to make use of the conceptual difference between
these two cases, that is that in one case the user did not specify any key
and in the other the user explicitly specified the key to be None.

Is there any way to tell this difference from within the called function?
And if so, would there be any strong reasons to not rely on this
difference? Would it be maybe a little abusive of what a keyword arg
actually is?

mario



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


Re: Is it explicitly specified?

2008-02-03 Thread Jorge Godoy
mario ruggier wrote:

> Is there any way to tell between whether a keyword arg has been explicitly
> specified (to the same value as the default for it) or not... For example:
> 
> def func(key=None):
> do something with key
> 
> But the following two usages give same results:
> 
> func()
> func(key=None)
> 
> It may sometimes be useful to make use of the conceptual difference
> between these two cases, that is that in one case the user did not specify
> any key and in the other the user explicitly specified the key to be None.
> 
> Is there any way to tell this difference from within the called function?
> And if so, would there be any strong reasons to not rely on this
> difference? Would it be maybe a little abusive of what a keyword arg
> actually is?

If you change the idiom you use to:

>>> def myfunc(**kwargs):
... something = kwargs.get('something', None)
... print something
... 
>>> myfunc()
None
>>> myfunc(something='Something')
Something
>>>

Then you can test if 'something' is in kwargs dict or not.  If it isn't,
then you used the default value.  If it is, then the user
supplied 'something' to you, no matter what its value is.


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


Re: Is it explicitly specified?

2008-02-03 Thread Arnaud Delobelle
On Feb 3, 11:00 am, mario ruggier <[EMAIL PROTECTED]> wrote:
> Is there any way to tell between whether a keyword arg has been explicitly
> specified (to the same value as the default for it) or not... For example:
>
> def func(key=None):
>     do something with key
>
> But the following two usages give same results:
>
> func()
> func(key=None)
>
> It may sometimes be useful to make use of the conceptual difference between
> these two cases, that is that in one case the user did not specify any key
> and in the other the user explicitly specified the key to be None.
>
> Is there any way to tell this difference from within the called function?
> And if so, would there be any strong reasons to not rely on this
> difference? Would it be maybe a little abusive of what a keyword arg
> actually is?
>
> mario

One way is to create an object which is only ever used as the default
arguement:

nokey = object()

def func(key=nokey):
if key is nokey:
# key not given
else:
# key given

--
Arnaud

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


Re: Is it explicitly specified?

2008-02-03 Thread TeroV
Jorge Godoy wrote:
> mario ruggier wrote:
> 
>> Is there any way to tell between whether a keyword arg has been explicitly
>> specified (to the same value as the default for it) or not... For example:
>>
>> def func(key=None):
>> do something with key
>>
>> But the following two usages give same results:
>>
>> func()
>> func(key=None)
>>
>> It may sometimes be useful to make use of the conceptual difference
>> between these two cases, that is that in one case the user did not specify
>> any key and in the other the user explicitly specified the key to be None.
>>
>> Is there any way to tell this difference from within the called function?
>> And if so, would there be any strong reasons to not rely on this
>> difference? Would it be maybe a little abusive of what a keyword arg
>> actually is?
> 
> If you change the idiom you use to:
> 
 def myfunc(**kwargs):
> ... something = kwargs.get('something', None)
> ... print something
> ... 
 myfunc()
> None
 myfunc(something='Something')
> Something
> 
> Then you can test if 'something' is in kwargs dict or not.  If it isn't,
> then you used the default value.  If it is, then the user
> supplied 'something' to you, no matter what its value is.
> 
> 

Exactly, and if you use idiom func(*args, **kwargs) you can distinguish 
all the usage cases:

 >>> def func(*args, **kwargs):
...  print(args, kwargs)
...
 >>> func()
() {}
 >>> func(key='alabama')
() {'key': 'alabama'}
 >>> func('alabama')
('alabama',) {}
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is it explicitly specified?

2008-02-03 Thread mario
On Feb 3, 12:35 pm, TeroV <[EMAIL PROTECTED]> wrote:
> Jorge Godoy wrote:
> > mario ruggier wrote:
>
> >> Is there any way to tell between whether a keyword arg has been explicitly
> >> specified (to the same value as the default for it) or not... For example:
>
> >> def func(key=None):
> >> do something with key
>
> >> But the following two usages give same results:
>
> >> func()
> >> func(key=None)
>
> >> It may sometimes be useful to make use of the conceptual difference
> >> between these two cases, that is that in one case the user did not specify
> >> any key and in the other the user explicitly specified the key to be None.
>
> >> Is there any way to tell this difference from within the called function?
> >> And if so, would there be any strong reasons to not rely on this
> >> difference? Would it be maybe a little abusive of what a keyword arg
> >> actually is?
>
> > If you change the idiom you use to:
>
>  def myfunc(**kwargs):
> > ... something = kwargs.get('something', None)
> > ... print something
> > ...
>  myfunc()
> > None
>  myfunc(something='Something')
> > Something
>
> > Then you can test if 'something' is in kwargs dict or not.  If it isn't,
> > then you used the default value.  If it is, then the user
> > supplied 'something' to you, no matter what its value is.
>
> Exactly, and if you use idiom func(*args, **kwargs) you can distinguish
> all the usage cases:
>
>  >>> def func(*args, **kwargs):
> ...  print(args, kwargs)
> ...
>  >>> func()
> () {}
>  >>> func(key='alabama')
> () {'key': 'alabama'}
>  >>> func('alabama')
> ('alabama',) {}

Nice... but I would still like to be able to specify the key's default
value in the func signature, and in this case this would not be
possible:

>>> def func(key=None, *args, **kwargs):
...   print(key, args, kwargs)
...
>>> func()
(None, (), {})
>>> func(None)
(None, (), {})
>>> func(key=None)
(None, (), {})
>>>

I would still need an additional object, as Arnaud suggests.

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


Re: GUI definition for web and desktop

2008-02-03 Thread Guilherme Polo
2008/2/3, Daniel Fetchinson <[EMAIL PROTECTED]>:
> Hi pythoneans,
>
>  I'm looking for a simple text based GUI definition format and
>  associated python modules to work with it that is capable of defining
>  simple GUI's for *both* the web and the desktop. I have an application
>  that is accessible through the web and also through desktop
>  applications and both clients should be presented a simple dialog GUI.
>  This dialog will only include text fields, radio buttons and a file
>  upload field. The exact list of fields might change from time to time
>  which implies that both clients should immediately know about it.
>
>  My idea is that if there was a lightweight GUI

lightweight GUIs are a very different thing. It means it renders the
widgets itself, provides uniform look and feel and should be slower.

>  definition format then
>  I would define the current list of fields and other GUI elements in
>  this format, expose this file on the web, and both the web client and
>  the desktop client

Do you mean a web server and desktop client, right ?

>  would first fetch this file  and generate the
>  appropriate GUI from that dynamically. If the GUI changes I would only
>  need to modify my definition file and both type of clients would
>  immediately know about it since before they do anything else they grab
>  this definition.
>
>  I haven't yet decided on the desktop client GUI library, it depends on
>  which library has such a dynamically generatable interface from a text
>  file. But it should be cross platform between linux and windows.
>

For wxPython there are xrc files, for PyGtk you could use glade or
gtkbuilder file formats mainly, PyQt uses .ui and .rc files. They all
are cross platform.

>  What would be the best way to do this?
>

The components you listed "text fields, radio buttons and a file
upload field" are very simple ones. You could use XUL, but you could
use one of the toolkits I said earlier. What you will need to do for
the web server is parse the generated ui file and generate a html from
it, this won't be hard considering the kind of interface you are
doing.

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


-- 
-- Guilherme H. Polo Goncalves
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: functools possibilities

2008-02-03 Thread Steve Holden
[EMAIL PROTECTED] wrote:
> On Feb 2, 12:13 pm, Steven Bethard <[EMAIL PROTECTED]> wrote:
>> [EMAIL PROTECTED] wrote:
>>> 1. functools.partialpre: partialpre( f, x, y )( z )-> f( z, x, y )
>>> 2. functools.pare: pare( f, 1 )( x, y )-> f( y )
>>> 3. functools.parepre: parepre( f, 1 )( x, y )-> f( x )
>>> 4. functools.calling_default: calling_default( f, a, DefaultA, b )->
>>> f( a, , b )
>> There are lots of possibilities for functools.  If you actually want
>> anything added, you'll need to back up your suggestions with use cases.
>>   Unless something is currently in widespread use in existing Python
>> code, it's unlikely to be included in the standard library.
>>
>> STeVe
> 
> Feel, hunch, affinity, and instinct are acceptable criteria for
> judging.  Otherwise, you're someone, and you have statistics on what
> constitutes widespread use; I can tell what's good as well as you.
> 
> Guido says, "Programmer time is important."  If it saves time, on the
> whole, writing plus learning plus reading, it's likely to be included.
> 
> urllib was not "in widespread use" prior to inclusion, but they did,
> was it?
> 
> "> There are lots of possibilities for functools."
> 
> So many, in fact, they're thinking of adding a separate "wrappertools"
> module.
> 
> Monarchies are effective on small scales.  Is Python destined for the
> small-time?
> 
> I've seen these suggestions before; they did not receive impartial
> address.
> 
> Functools and the candidate "wrappertools" should be populated fairly
> liberally.

Ultimately you either have to do the work or persuade someone else to do 
it. urllib was, as far as I know, distilled from code that had been 
written to solve real-world problems.

Who knows whether Python is "destined for the small-time"? This kind of 
comment ignores the political and developmental realities: open source 
projects whose leaders don't communicate effectively with the rest of 
the developers tend to do worse. Guido is actually in pretty good touch 
with the developers, and still manages to take an interest in end-users 
of the language.

It's all very well to talk about what "should" be included, but such 
ideas need an effective champion to promote them in the user community 
and collect valid use cases to present to the developers. Without such 
work, advocacy is likely to ineffective.

This may not be ideal, but this is open source and that's by and large 
the way the process works. It does tend to reduce the kind of code bloat 
seen in proprietary products, where features are added to capture small 
individual market segments, and you end up with a monster whose users 
typically only utilize 5% of the feature set.

So roll your sleeves up and make your case! There's work to be done ...

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: Does anyone else use this little idiom?

2008-02-03 Thread Steve Holden
Gabriel Genellina wrote:
[...]
>> On Feb 3, 2008 3:34 AM, Roy Smith <[EMAIL PROTECTED]> wrote:
>>
>>> But, more to the point, I'd try to find variable name which described  
>>> why I was looping, even if I didn't actually use the value in theloop  
>>> body:
> 
> Me too. Government don't collect taxes by the number of variable names  
> used (yet).
> 
And if they did I'd pay the tax to retain my sanity.

no-taxation-without-repr()-ly y'rs  - steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: Does anyone else use this little idiom?

2008-02-03 Thread Steve Holden
Jeff Schwab wrote:
> How [EMAIL PROTECTED] wrote:
>> Ruby has a neat little convenience when writing loops where you don't
>> care about the loop index: you just do n.times do { ... some
>> code ... } where n is an integer representing how many times you want
>> to execute "some code."
>>
>> In Python, the direct translation of this is a for loop.  When the
>> index doesn't matter to me, I tend to write it as:
>>
>> for _ in xrange (1,n):
>>some code
>>
>> An alternative way of indicating that you don't care about the loop
>> index would be
>>
>> for dummy in xrange (1,n):
>>some code
>>
>> But I like using _ because it's only 1 character and communicates well
>> the idea "I don't care about this variable."
>>
>> The only potential disadvantages I can see are threefold:
>>
>> 1. It might be a little jarring to people not used to it.  I do admit
>> it looks pretty strange at first.
>>
>> 2. The variable _ has special meaning at the interactive interpreter
>> prompt.  There may be some confusion because of this.
>>
>> 5.  Five is right out.  (ob Holy Grail reference, of course. :-)
>>
>> So, I guess I'm wondering if anyone else uses a similar idiom and if
>> there are any downsides to it that I'm not aw
> 
> Would something like this be acceptable?  It still requires a loop 
> variable, plus an extra line of code per loop, plus a one-time class 
> definition (and import into each client module), and it's probably 
> slower than "for dummy in range."  The syntax might be more inuitive 
> than "dummy" or "_" in a for loop, though.
> 
> class Go:
>  def __init__(self, count):
>  self.count = count
> 
>  def again(self):
>  if self.count <= 0:
>  return False
>  self.count -= 1
>  return True
> 
> go = Go(3)
> while go.again():
>  print "hello"

One could rename the again() method __call__(), allowing the even more 
horrible but less verbose

while Go(3)():
 print "hello"

That'd confuse the newbies!

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is it explicitly specified?

2008-02-03 Thread Bjoern Schliessmann
mario ruggier wrote:

> It may sometimes be useful to make use of the conceptual
> difference between these two cases, that is that in one case the
> user did not specify any key and in the other the user explicitly
> specified the key to be None.

Do you have an example where this might be useful?
 
> Is there any way to tell this difference from within the called
> function? And if so, would there be any strong reasons to not rely
> on this difference? 

IMHO, it's "magic".

> Would it be maybe a little abusive of what a keyword arg actually
> is? 

No, but you'd have to explain to users why it behaves like this. I
wouldn't expect this behaviour. If the function signature says the
default value for "key" is None, I expect it to behave the same no
matter if I leave out "key" or if I set it explicitly.

Regards,


Björn

-- 
BOFH excuse #307:

emissions from GSM-phones

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


Re: GUI definition for web and desktop

2008-02-03 Thread Steve Holden
Daniel Fetchinson wrote:
> Hi pythoneans,
> 
> I'm looking for a simple text based GUI definition format and
> associated python modules to work with it that is capable of defining
> simple GUI's for *both* the web and the desktop. I have an application
> that is accessible through the web and also through desktop
> applications and both clients should be presented a simple dialog GUI.
> This dialog will only include text fields, radio buttons and a file
> upload field. The exact list of fields might change from time to time
> which implies that both clients should immediately know about it.
> 
> My idea is that if there was a lightweight GUI definition format then
> I would define the current list of fields and other GUI elements in
> this format, expose this file on the web, and both the web client and
> the desktop client would first fetch this file and generate the
> appropriate GUI from that dynamically. If the GUI changes I would only
> need to modify my definition file and both type of clients would
> immediately know about it since before they do anything else they grab
> this definition.
> 
> I haven't yet decided on the desktop client GUI library, it depends on
> which library has such a dynamically generatable interface from a text
> file. But it should be cross platform between linux and windows.
> 
> What would be the best way to do this?
> 
I believe Glade produces XML descriptions of its interfaces, so wxGlade 
would be one possible starting-point.

   http://wxglade.sourceforge.net/

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: GUI definition for web and desktop

2008-02-03 Thread Guilherme Polo
2008/2/3, Steve Holden <[EMAIL PROTECTED]>:
> Daniel Fetchinson wrote:
>  > Hi pythoneans,
>  >
>  > I'm looking for a simple text based GUI definition format and
>  > associated python modules to work with it that is capable of defining
>  > simple GUI's for *both* the web and the desktop. I have an application
>  > that is accessible through the web and also through desktop
>  > applications and both clients should be presented a simple dialog GUI.
>  > This dialog will only include text fields, radio buttons and a file
>  > upload field. The exact list of fields might change from time to time
>  > which implies that both clients should immediately know about it.
>  >
>  > My idea is that if there was a lightweight GUI definition format then
>  > I would define the current list of fields and other GUI elements in
>  > this format, expose this file on the web, and both the web client and
>  > the desktop client would first fetch this file and generate the
>  > appropriate GUI from that dynamically. If the GUI changes I would only
>  > need to modify my definition file and both type of clients would
>  > immediately know about it since before they do anything else they grab
>  > this definition.
>  >
>  > I haven't yet decided on the desktop client GUI library, it depends on
>  > which library has such a dynamically generatable interface from a text
>  > file. But it should be cross platform between linux and windows.
>  >
>  > What would be the best way to do this?
>  >
>
> I believe Glade produces XML descriptions of its interfaces, so wxGlade
>  would be one possible starting-point.
>

Glade does, but dont confuse it with wxGlade. wxGlade can generate
direct python code or XRC files.

>http://wxglade.sourceforge.net/
>
>  regards
>   Steve
>
> --
>  Steve Holden+1 571 484 6266   +1 800 494 3119
>  Holden Web LLC  http://www.holdenweb.com/
>
>
>  --
>  http://mail.python.org/mailman/listinfo/python-list
>


-- 
-- Guilherme H. Polo Goncalves
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: scope

2008-02-03 Thread Guilherme Polo
2008/2/3, Navid Parvini <[EMAIL PROTECTED]>:
> Dear All,
>
> I have the following two methods in a module. I cannot put them in a class,
> as the code is a complicated one.
>
> def a(num):
> found = num in Numlist
> print found
>
> def b():
> scop = {}
> scop['Numlist'] = [1,2,3]
> scop['a'] = a
> exec("a(3)",scop)
>
> How can I access the "Numlist" inside the method a,

a is a function, not a method.

> without using classes or
> defining Numlist as GLOBAL? I prefer using scops in this problem. Is there a
> way?

Pass it as argument to function a

>
> Thank you very much,
> Navid
>
>
>  
> Looking for last minute shopping deals? Find them fast with Yahoo! Search.
>
>
> --
>  http://mail.python.org/mailman/listinfo/python-list
>


-- 
-- Guilherme H. Polo Goncalves
-- 
http://mail.python.org/mailman/listinfo/python-list


scope

2008-02-03 Thread Navid Parvini
Dear All,

I have the following two methods in a module. I cannot put them in a class, as 
the code is a complicated one.

def a(num):
found = num in Numlist
print found

def b():
scop = {}
scop['Numlist'] = [1,2,3]
scop['a'] = a
exec("a(3)",scop)

How can I access the "Numlist" inside the method a, without using classes or 
defining Numlist as GLOBAL? I prefer using scops in this problem. Is there a 
way?

Thank you very much,
Navid

   
-
Looking for last minute shopping deals?  Find them fast with Yahoo! Search.-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Does anyone else use this little idiom?

2008-02-03 Thread Stef Mientki
be careful, "_"  is thé translation function used in Il8N, Il10N 
localization / internationalization
e.g.
 print  _( "hello" )

cheers,
Stef

[EMAIL PROTECTED] wrote:
> Ruby has a neat little convenience when writing loops where you don't
> care about the loop index: you just do n.times do { ... some
> code ... } where n is an integer representing how many times you want
> to execute "some code."
>
> In Python, the direct translation of this is a for loop.  When the
> index doesn't matter to me, I tend to write it as:
>
> for _ in xrange (1,n):
>some code
>
> An alternative way of indicating that you don't care about the loop
> index would be
>
> for dummy in xrange (1,n):
>some code
>
> But I like using _ because it's only 1 character and communicates well
> the idea "I don't care about this variable."
>
> The only potential disadvantages I can see are threefold:
>
> 1. It might be a little jarring to people not used to it.  I do admit
> it looks pretty strange at first.
>
> 2. The variable _ has special meaning at the interactive interpreter
> prompt.  There may be some confusion because of this.
>
> 5.  Five is right out.  (ob Holy Grail reference, of course. :-)
>
> So, I guess I'm wondering if anyone else uses a similar idiom and if
> there are any downsides to it that I'm not aware of.
>
> Thanks
>
> Paul
>   

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


Re: Does anyone else use this little idiom?

2008-02-03 Thread Ivan Illarionov
Plain Python function are very often more powerful than classes:

>>> def go(count):
...   if not hasattr(go, 'count'):
... go.count = count
...   if go.count <= 0:
... del go.count
... return False
...   go.count -= 1
...   return True
...
>>> while go(3):
...   print 'hello'
...
hello
hello
hello
>>>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUI definition for web and desktop

2008-02-03 Thread Diez B. Roggisch
Daniel Fetchinson schrieb:
> Hi pythoneans,
> 
> I'm looking for a simple text based GUI definition format and
> associated python modules to work with it that is capable of defining
> simple GUI's for *both* the web and the desktop. I have an application
> that is accessible through the web and also through desktop
> applications and both clients should be presented a simple dialog GUI.
> This dialog will only include text fields, radio buttons and a file
> upload field. The exact list of fields might change from time to time
> which implies that both clients should immediately know about it.
> 
> My idea is that if there was a lightweight GUI definition format then
> I would define the current list of fields and other GUI elements in
> this format, expose this file on the web, and both the web client and
> the desktop client would first fetch this file and generate the
> appropriate GUI from that dynamically. If the GUI changes I would only
> need to modify my definition file and both type of clients would
> immediately know about it since before they do anything else they grab
> this definition.
> 
> I haven't yet decided on the desktop client GUI library, it depends on
> which library has such a dynamically generatable interface from a text
> file. But it should be cross platform between linux and windows.
> 
> What would be the best way to do this?

Not doing it. Seriously, the problem lies not so much in rendering a 
simple GUI - but the event-system, including things like value-binding 
or whatever the principles behind the actual toolkit of choice are called.

Creating an abstraction that takes into account the
differences of both the toolkit and javascript/HTML/DOM is tedious.

That doesn't mean that you won't be able to produce a quick prototype. 
But the very moment you start getting serious, problems will crop up 
fast. And you'll end up with either something not working the same on 
both platforms, or with a very limited subset.

If you really want browser-delivered GUI, the old java applets might be 
a better choice - there at least the whole GUI + even-stuff is unified 
for stand-alone as well as embedded applets.

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


Re: python for game programming

2008-02-03 Thread Diez B. Roggisch
t3chn0n3rd schrieb:
> Is Python program language popular for game programming?
> 
Yes. For starters, google

pygame
pyglet


And python is used as scripting language in quite a few commercial 
products, such as eve online.

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


Re: GUI definition for web and desktop

2008-02-03 Thread Steve Holden
Guilherme Polo wrote:
> 2008/2/3, Steve Holden <[EMAIL PROTECTED]>:
>> Daniel Fetchinson wrote:
>>  > Hi pythoneans,
>>  >
>>  > I'm looking for a simple text based GUI definition format and
[...]
>> I believe Glade produces XML descriptions of its interfaces, so wxGlade
>>  would be one possible starting-point.
>>
> 
> Glade does, but dont confuse it with wxGlade. wxGlade can generate
> direct python code or XRC files.
> 
So what are you telling me - that XRC files aren't XML?

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: fast method accessing large, simple structured data

2008-02-03 Thread Ivan Illarionov
> Is there some good format that is optimized for search for
> just 1 attribute (title) and then returning the corresponding article?

I would use Durus (http://www.mems-exchange.org/software/durus/) -
simple pythonic object database - and store this data as persistent
python dict with Title keys and Article values.
-- 
http://mail.python.org/mailman/listinfo/python-list


python for game programming

2008-02-03 Thread t3chn0n3rd
Is Python program language popular for game programming?

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


Re: Is it explicitly specified?

2008-02-03 Thread Steve Holden
Diez B. Roggisch wrote:
> Bjoern Schliessmann schrieb:
>> mario ruggier wrote:
>>
>>> It may sometimes be useful to make use of the conceptual
>>> difference between these two cases, that is that in one case the
>>> user did not specify any key and in the other the user explicitly
>>> specified the key to be None.
>> Do you have an example where this might be useful?
> 
> Any situation in which there would otherwise lots of documentation 
> needed to inform the user that the sentinel value is something else than 
> None.
> 
> Take something like this as an example:
> 
> def update_user(some, values, nullable_value=sentinel):
>  # first, work with some and values
>  ...
>  # then, on something actually being passed to nullable_value
>  if nullable_value is not sentinel:
> connection.cursor().execute("update table set value = ?", 
> nullable_value)
> 
> 
> 
> I've seen this before, in code from e.g. Alex Martelli.
> 
Sure, but the OP's question was "Is there any way to tell between 
whether a keyword arg has been explicitly specified (to the same value 
as the default for it)". We've drifted a long way from that, since the 
code you demonstrate doesn't detect an explicit call with 
nullable_value==sentinel -- the reason being, I submit, that there is no 
use case for such code.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Python GUI toolkit

2008-02-03 Thread default
what would be the best python GUI toolkit, it must be cross platform.

i have tried gtk, but it interface are real bad and its coding was difficult
so i dropped it,

the only remaining are qt4 and wx, i would like to know if one of these or
any other toolkit is capable of creating good-looking GUI's, like in other
apps, for e.g, .net apps.

i m a noob, and willing to learn, so difficulty is no problem
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python GUI toolkit

2008-02-03 Thread Grant Edwards
On 2008-02-03, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> [...] was difficult so i dropped it,
>
[...]

> i m a noob, and willing to learn, so difficulty is no problem

On the contrary, it appears that difficulty is a problem. ;)

-- 
Grant Edwards   grante Yow!  Excuse me, but didn't
  at   I tell you there's NO HOPE
   visi.comfor the survival of OFFSET
   PRINTING?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is it explicitly specified?

2008-02-03 Thread Diez B. Roggisch
Bjoern Schliessmann schrieb:
> mario ruggier wrote:
> 
>> It may sometimes be useful to make use of the conceptual
>> difference between these two cases, that is that in one case the
>> user did not specify any key and in the other the user explicitly
>> specified the key to be None.
> 
> Do you have an example where this might be useful?

Any situation in which there would otherwise lots of documentation 
needed to inform the user that the sentinel value is something else than 
None.

Take something like this as an example:

def update_user(some, values, nullable_value=sentinel):
 # first, work with some and values
 ...
 # then, on something actually being passed to nullable_value
 if nullable_value is not sentinel:
connection.cursor().execute("update table set value = ?", 
nullable_value)



I've seen this before, in code from e.g. Alex Martelli.

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


Re: Is it explicitly specified?

2008-02-03 Thread Steve Holden
Bjoern Schliessmann wrote:
> mario ruggier wrote:
> 
>> It may sometimes be useful to make use of the conceptual
>> difference between these two cases, that is that in one case the
>> user did not specify any key and in the other the user explicitly
>> specified the key to be None.
> 
> Do you have an example where this might be useful?
>  
Yes, a use case *would* be interesting.

>> Is there any way to tell this difference from within the called
>> function? And if so, would there be any strong reasons to not rely
>> on this difference? 
> 
> IMHO, it's "magic".
> 
>> Would it be maybe a little abusive of what a keyword arg actually
>> is? 
> 
> No, but you'd have to explain to users why it behaves like this. I
> wouldn't expect this behaviour. If the function signature says the
> default value for "key" is None, I expect it to behave the same no
> matter if I leave out "key" or if I set it explicitly.
> 
Well, quite: the whole point of a default is to provide a value to be 
used when the caller doesn't explicitly provide one. The use of a 
sentinel object() instance is the only sane way to perform this ever so 
slightly insane task. If the argument value isn't the sentinel then the 
function has to set it to the required default.

But this isn't the strict requirement as stated by the OP, of course, 
who wants to be able to explicitly detect when the sentinel object is 
passed in as an actual keyword (or positional) argument. I don't believe 
that's possible without large amounts of heavyweight introspection.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: GUI definition for web and desktop

2008-02-03 Thread Kay Schluehr
On 3 Feb., 04:42, "Daniel Fetchinson" <[EMAIL PROTECTED]>
wrote:
> Hi pythoneans,
>
> I'm looking for a simple text based GUI definition format and
> associated python modules to work with it that is capable of defining
> simple GUI's for *both* the web and the desktop. I have an application
> that is accessible through the web and also through desktop
> applications and both clients should be presented a simple dialog GUI.

I'm not sure if this counts as simple but Adobe has specified MXML for
this purpose and there are competing technologies like XUL or XAML.
For the case of MXML Bruce Eckel wrote an article about combining Flex
and Python via XMLRPC a while ago on Artima. There are also new
directions like Adobe AIR and MS Silverlight ( or Mono Moonlight )
whereas the latter supports Python also as a scripting language on the
client side. I'd recommend to type "RIA" in your preferred search
engine.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python GUI toolkit

2008-02-03 Thread Dotan Cohen
On 03/02/2008, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> what would be the best python GUI toolkit, it must be cross platform.
>
>  i have tried gtk, but it interface are real bad and its coding was difficult
>  so i dropped it,
>
>  the only remaining are qt4 and wx, i would like to know if one of these or
>  any other toolkit is capable of creating good-looking GUI's, like in other
>  apps, for e.g, .net apps.
>
>  i m a noob, and willing to learn, so difficulty is no problem
>

I would recommend Qt, as it is cross-platform and can look native on
all systems. Opera, KDE, GoogleEarth, Acrobat, and lots of other
software are written in Qt.

Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: GUI definition for web and desktop

2008-02-03 Thread Dikkie Dik
>  I have an application
> that is accessible through the web and also through desktop
> applications and both clients should be presented a simple dialog GUI.
> This dialog will only include text fields, radio buttons and a file
> upload field.
> 
> My idea is that if there was a lightweight GUI definition format then
> I would define the current list of fields and other GUI elements in
> this format, expose this file on the web, and both the web client and
> the desktop client would first fetch this file and generate the
> appropriate GUI from that dynamically.

I am very new to Python, and my first python application has a 
"cascading" user interface: if enough is given on the command-line, it 
sticks to being a command-line app, and if more data is needed, it 
presents a GUI. I never did this before, and it taught me a good lesson.

The main thing I learned from it is that the GUI tends to control not 
only the input of the application, but also its flow and modularity 
structure. I was really glad that I did not include a web interface
(which would not have made any sense in my case). The web applications 
are usually totally different because of:
- the stateless nature of HTTP
- the use of HTTP headers (session handlers, redirects, authentication)

So designing a "local" GUI format that can also be used in a web 
environment is not really impossible, but hardly practical. For 
instance, a "local" GUI can hold information, do some validation and 
store the whole input as a batch, or better said, as a transaction.

Web applications do not work this way. Sure, if you rely on javascript 
(not a good idea if you want your app to be portable), you can do some 
basic validation and even make server calls. But still, a well-designed 
web app is more fault tolerant due to the browser variations: In a web 
environment, you would store "half" inputs that can be finished later, 
where in local applications you would not. Local GUIs do not suffer from 
expiring sessions, for example.

So a GUI format is not the main problem. The main problem is the 
"nature" of the whole application.

By the way: my User Interface classes did not share a definition file or 
something. So a simple user interface like yours could easily be 
generated in two varieties, by two different classes or modules. And a 
more complex UI would suffer from the difference in nature, so it would 
even call for two different client applications.


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


Python GUI toolkit

2008-02-03 Thread default
what i meant was, i tried gtk, didnt like it, the main reason was that it
had a very bad gui appeal for me, i did try my hand at wx , and i would have
stuck with it, but then i saw the qt4 screenshot and couple of examples of
its code and i liked it, so i was wondering, if anyone would tell me that i
should stick to wx or go forward with qt4.

also, is qt4 apps better looking in both win/linux than wx apps, coz the
main thing i m looking for is visual appeal of the gui.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is it explicitly specified?

2008-02-03 Thread mario
On Feb 3, 4:19 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
> Diez B. Roggisch wrote:
> > Bjoern Schliessmann schrieb:
> >> mario ruggier wrote:
>
> >>> It may sometimes be useful to make use of the conceptual
> >>> difference between these two cases, that is that in one case the
> >>> user did not specify any key and in the other the user explicitly
> >>> specified the key to be None.
> >> Do you have an example where this might be useful?
>
> > Any situation in which there would otherwise lots of documentation
> > needed to inform the user that the sentinel value is something else than
> > None.
>
> > Take something like this as an example:
>
> > def update_user(some, values, nullable_value=sentinel):
> >  # first, work with some and values
> >  ...
> >  # then, on something actually being passed to nullable_value
> >  if nullable_value is not sentinel:
> > connection.cursor().execute("update table set value = ?",
> > nullable_value)
>
> > I've seen this before, in code from e.g. Alex Martelli.
>
> Sure, but the OP's question was "Is there any way to tell between
> whether a keyword arg has been explicitly specified (to the same value
> as the default for it)". We've drifted a long way from that, since the
> code you demonstrate doesn't detect an explicit call with
> nullable_value==sentinel -- the reason being, I submit, that there is no
> use case for such code.

I think you are all very much on target, and not drifted at all. The
real issue with this situation is None, as there is ambiguity there,
whether a caller wants something to be None or whtehr it is simpy None
because it is not set...

My use case is that I have an object that is part of a collection. The
collection sets what the preferred defaults are for specific object
attributes, but individual objects may override some of these. Thus,
if an object does not set any of these attributes, then the default as
per the collection's settings is to be used.

In one case, the collection attributes a specific meaning to
attr=None, but the actual default for attr is something else. However,
if an object explicitly wants to state that his attr=None (that is a
valid value, and has specific meaning) I would like to use that as
value, but if no value is supplied for attr by the object, then I
would like to use the default value from the collection.

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


Re: Does anyone else use this little idiom?

2008-02-03 Thread Zentrader
> Not to me.  If I read "for _ in ...", I wouldn't be quite sure what _ was.
> Is it some magic piece of syntax I've forgotten about?  Or something new
> added to language while I wasn't paying attention (I still consider most
> stuff added since 1.5 to be new-fangled :-)).

+1 to forgotten about
+1 to new-fangled=added since 1.5   When 3000 comes out I'll have to
break down and buy a new Python book.  Also, it's amazing how much
posting space is spent here replying to someone who is too lazy to key
in a variable name.  Damn!
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: eric4 4.1.0 released

2008-02-03 Thread Detlev Offenbach
Hi,

eric4 4.1.0 was just released. This is a major feature release. Compared
to 4.0.4 it contains these features next to bug fixes.

- Added a plugin system for easy extensibility
- Converted the following interface to plugins available separately
  -- PyLint checker
  -- CxFreeze packager
  -- CharTables tool
  -- CVS version control system
  -- BRM refactoring
- Added new project types
  -- Eric4 Plugin
  -- Django
  -- TurboGears
  -- wxPython
- Added source code exporters for
  -- HTML
  -- PDF
  -- RTF
  -- Latex
- Added subversion repository and log browsers
- Included API files for
  -- eric4
  -- Django
  -- TurboGears
  -- wxPython
  -- Zope 2
  -- Zope 3
- Many enhancements to the functionality already there

What is eric4?
--
eric4 is a Python (and Ruby) IDE with all batteries included. Please see
http://www.die-offenbachs.de/eric for details and screenshots.

Regards,
Detlev
-- 
Detlev Offenbach
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python GUI toolkit

2008-02-03 Thread Torsten Bronger
Hallöchen!

[EMAIL PROTECTED] writes:

> [...]
>
> the only remaining are qt4 and wx, i would like to know if one of
> these or any other toolkit is capable of creating good-looking
> GUI's, like in other apps, for e.g, .net apps.

I think both Qt4 and wx create good-looking GUIs, since Qt4 now
tries to use the widgets from the platform it's running on.
However, their ways of expressing things in the code are very
different.  If you really have no other constraints, I'd just
program a non-trivial but very simple application in both.  Then you
know which fits your brain better.

For example, I've never managed to understand this signal-slot idea
of Qt, so I use wxPython.  However, many love Qt exactly for this.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
  Jabber ID: [EMAIL PROTECTED]
   (See http://ime.webhop.org for further contact info.)
-- 
http://mail.python.org/mailman/listinfo/python-list


interested????

2008-02-03 Thread kaki
click here:
http://kg-azfari.myminicity.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does anyone else use this little idiom?

2008-02-03 Thread Paul McGuire
On Feb 2, 9:48 pm, Jeff Schwab <[EMAIL PROTECTED]> wrote:
> How [EMAIL PROTECTED] wrote:
> > Ruby has a neat little convenience when writing loops where you don't
> > care about the loop index: you just do n.times do { ... some
> > code ... } where n is an integer representing how many times you want
> > to execute "some code."
>
> Would something like this be acceptable?  It still requires a loop
> variable, plus an extra line of code per loop, plus a one-time class
> definition (and import into each client module), and it's probably
> slower than "for dummy in range."  The syntax might be more inuitive
> than "dummy" or "_" in a for loop, though.
>
> class Go:
>      def __init__(self, count):
>          self.count = count
>
>      def again(self):
>          if self.count <= 0:
>              return False
>          self.count -= 1
>          return True
>
> go = Go(3)
> while go.again():
>      print "hello"- Hide quoted text -
>
> - Show quoted text -

Here's something similar, in a decorator:

def iterative(fn):
def times_(n):
i = 0
while i < n:
fn()
i += 1
fn.times = times_
return fn

@iterative
def aFunction():
print "this is a function"

aFunction.times(3)

Prints:
this is a function
this is a function
this is a function

But this still seems like a lot of work to avoid "for x in range(n):".
-- Paul

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


Re: Python GUI toolkit

2008-02-03 Thread Grant Edwards
On 2008-02-03, Dotan Cohen <[EMAIL PROTECTED]> wrote:

> I would recommend Qt, as it is cross-platform and can look native on
> all systems.

Qt doesn't look native on my system. I run XFCE, and "native"
is GTK.

> Opera, KDE, GoogleEarth, Acrobat, and lots of other software
> are written in Qt.

And they don't look native on systems that don't use Qt as the
native widget set.

-- 
Grant Edwards   grante Yow!  I love FRUIT
  at   PICKERS!!
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python GUI toolkit

2008-02-03 Thread Grant Edwards
On 2008-02-03, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> what i meant was, i tried gtk, didnt like it, the main reason was that it
> had a very bad gui appeal for me, i did try my hand at wx , and i would have
> stuck with it,

Wx generally uses GTK on Unix, so if you don't like GTK, then
Wx isn't really an option.  Wx uses native widgets on Win32, so
it'll look just as ugly as a normal Win32 app does.

> but then i saw the qt4 screenshot and couple of examples of
> its code and i liked it, so i was wondering, if anyone would
> tell me that i should stick to wx or go forward with qt4.

Stick with Wx.  It uses GTK, and GTK is "native" on my system.

> also, is qt4 apps better looking in both win/linux than wx
> apps, coz the main thing i m looking for is visual appeal of
> the gui.

If what you care about is your opinion of the looks, what are
you asking us for?

-- 
Grant Edwards   grante Yow!  Do you like "TENDER
  at   VITTLES"?
   visi.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python GUI toolkit

2008-02-03 Thread Grant Edwards
On 2008-02-03, Torsten Bronger <[EMAIL PROTECTED]> wrote:
> Hallöchen!
>
> [EMAIL PROTECTED] writes:
>
>> [...]
>>
>> the only remaining are qt4 and wx, i would like to know if one of
>> these or any other toolkit is capable of creating good-looking
>> GUI's, like in other apps, for e.g, .net apps.
>
> I think both Qt4 and wx create good-looking GUIs, since Qt4 now
> tries to use the widgets from the platform it's running on.

Really? Qt uses GTK when running uder Gnome or XFCE??

-- 
Grant Edwards   grante Yow!  I will SHAVE and
  at   buy JELL-O and bring my
   visi.comMARRIAGE MANUAL!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: "ping" not reconnecting in Python MySQLdb client interface

2008-02-03 Thread John Nagle
JJohn Nagle wrote:
 >I have some long-running Python programs that can be idle
 > for hours, and, of course, the MySQL connection times out.
 > So I call
 >
 > db.ping()
 >
 > at the beginning of a new request cycle.  This should
 > reestablish the connection, but it doesn't.
...
 > I suspect that MySQL has auto-reconnect turned off, but doesn't document
 > this.

That seems to be the case.  MySQLdb.connect turns off auto-reconnect, and
doesn't document "ping".

I'm currently trying this:

if db : # if previously attached
try :
db.ping()   # test connection
except MySQLdb.OperationalError, message: # loss of connection
db = None   # we lost database connection
if db is None : # if no valid database handle
db = MySQLdb.connect(...)   # connect to database

which is a bit ugly.

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


Re: Python GUI toolkit

2008-02-03 Thread Jorge Godoy
Grant Edwards wrote:

> On 2008-02-03, Dotan Cohen <[EMAIL PROTECTED]> wrote:
> 
>> I would recommend Qt, as it is cross-platform and can look native on
>> all systems.
> 
> Qt doesn't look native on my system. I run XFCE, and "native"
> is GTK.
> 
>> Opera, KDE, GoogleEarth, Acrobat, and lots of other software
>> are written in Qt.
> 
> And they don't look native on systems that don't use Qt as the
> native widget set.

But then,  there's no toolkit that does.

GTK based toolkits don't look native on Qt based systems.  Same for a lot of
others.

What you can define is a platform as in operating system and then go with
what the mainstream providers use for that.  For Windows and Mac that is
easy, for *nix this is harder.


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


Re: Python GUI toolkit

2008-02-03 Thread Jorge Godoy
[EMAIL PROTECTED] wrote:

> what i meant was, i tried gtk, didnt like it, the main reason was that it
> had a very bad gui appeal for me, i did try my hand at wx , and i would
> have stuck with it, but then i saw the qt4 screenshot and couple of
> examples of its code and i liked it, so i was wondering, if anyone would
> tell me that i should stick to wx or go forward with qt4.
> 
> also, is qt4 apps better looking in both win/linux than wx apps, coz the
> main thing i m looking for is visual appeal of the gui.

Qt is a the best choice, IMHO.  Nice support, free if you write free
software, very nice API, nice tools to develop with and the best looking
widget system for *nix and mobile phones.

I also don't like GTK that much but unfortunately we have to live with some
apps written with it. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python GUI toolkit

2008-02-03 Thread Dotan Cohen
On 03/02/2008, Grant Edwards <[EMAIL PROTECTED]> wrote:
> On 2008-02-03, Torsten Bronger <[EMAIL PROTECTED]> wrote:
> > Hallöchen!
> >
> > [EMAIL PROTECTED] writes:
> >
> >> [...]
> >>
> >> the only remaining are qt4 and wx, i would like to know if one of
> >> these or any other toolkit is capable of creating good-looking
> >> GUI's, like in other apps, for e.g, .net apps.
> >
> > I think both Qt4 and wx create good-looking GUIs, since Qt4 now
> > tries to use the widgets from the platform it's running on.
>
> Really? Qt uses GTK when running uder Gnome or XFCE??
>

I was under the impression that Qt4 tries to use native widgets when
it can. XFCE installs may be a problem, but Windows || Mac || KDE
should be covered. I say _should_ as I'm not certain. I'm only
dabbling in the little that I need for my own personal use. You'll
notice that I'm mostly a list lurker than poster, for this very
reason.

Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python GUI toolkit

2008-02-03 Thread Torsten Bronger
Hallöchen!

Grant Edwards writes:

> On 2008-02-03, Torsten Bronger <[EMAIL PROTECTED]> wrote:
>> Hallöchen!
>>
>> [EMAIL PROTECTED] writes:
>>
>>> [...]
>>>
>>> the only remaining are qt4 and wx, i would like to know if one
>>> of these or any other toolkit is capable of creating
>>> good-looking GUI's, like in other apps, for e.g, .net apps.
>>
>> I think both Qt4 and wx create good-looking GUIs, since Qt4 now
>> tries to use the widgets from the platform it's running on.
>
> Really? Qt uses GTK when running uder Gnome or XFCE??

I said "try".  You won't find a toolkit which mimics every desktop
environment.  However, Qt used to ignore the current look-and-feel
deliberately.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
  Jabber ID: [EMAIL PROTECTED]
   (See http://ime.webhop.org for further contact info.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python GUI toolkit

2008-02-03 Thread Grant Edwards
On 2008-02-03, Jorge Godoy <[EMAIL PROTECTED]> wrote:

>> And they don't look native on systems that don't use Qt as the
>> native widget set.
>
> But then,  there's no toolkit that does.
>
> GTK based toolkits don't look native on Qt based systems.
> Same for a lot of others.

Quite true.

> What you can define is a platform as in operating system and
> then go with what the mainstream providers use for that.  For
> Windows and Mac that is easy, for *nix this is harder.

*nix users are pretty tolerant of "non-native" wiget sets.  I
imagine that all KDE users have certain non-Qt apps that they
use regularly and Gnome/XFCE users have non-GTK apps they use
regularly.

-- 
Grant Edwards   grante Yow!  Here I am in the
  at   POSTERIOR OLFACTORY LOBULE
   visi.combut I don't see CARL SAGAN
   anywhere!!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does anyone else use this little idiom?

2008-02-03 Thread miller . paul . w
On Feb 3, 10:42 am, Zentrader <[EMAIL PROTECTED]> wrote:
> > Not to me.  If I read "for _ in ...", I wouldn't be quite sure what _ was.
> > Is it some magic piece of syntax I've forgotten about?  Or something new
> > added to language while I wasn't paying attention (I still consider most
> > stuff added since 1.5 to be new-fangled :-)).
>
> +1 to forgotten about
> +1 to new-fangled=added since 1.5   When 3000 comes out I'll have to
> break down and buy a new Python book.  Also, it's amazing how much
> posting space is spent here replying to someone who is too lazy to key
> in a variable name.  Damn!

Lol.  It isn't that I'm too lazy; it's just that the character "_"
looks like "-" to me, and, in the math class I'm taking right now
(category theory), "-" is one of the notations to indicate "whatever"
-- a metasyntactic placeholder, if you will.  (For example, Hom (C, -)
is the covariant hom functor from C -> Sets.  If this makes no sense
to you, don't worry about it.)

After this discussion, it seems that if I'm to write Python for public
consumption, I should prefer

for dummy in xrange (n):
do_stuff()

or one of the other suggestions instead. :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does anyone else use this little idiom?

2008-02-03 Thread miller . paul . w
On Feb 3, 11:20 am, Paul McGuire <[EMAIL PROTECTED]> wrote:

[... some code... some words ... more code, etc. ...]

> But this still seems like a lot of work to avoid "for x in range(n):".

I agree.  The point of me using "for _ in xrange (n)" isn't to avoid
the for loop at all.  What I wanted was a pythonic way to express only
the necessary components of the loop, like the Ruby version "n.times
do { stuff }"  does.  There's no explicit index in the Ruby code,
because you don't care about it.

Now, if you could monkeypatch built-ins, I'd *almost* consider adding
a .times method to integers. But, of course, monkeypatching is evil. :-
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to convert markup text to plain text in python?

2008-02-03 Thread Stefan Behnel
geoffbache wrote:
> I have some marked up text and would like to convert it to plain text,
> by simply removing all the tags. Of course I can do it from first
> principles but I felt that among all Python's markup tools there must
> be something that would do this simply, without having to create an
> XML parser etc.
> 
> I've looked around a bit but failed to find anything, any tips?
> 
> (e.g. convert "Today is Friday" to "Today is Friday")

   >>> import lxml.etree as et
   >>> doc = et.HTML("Today is Friday")
   >>> et.tostring(doc, method='text', encoding=unicode)
   u'Today is Friday'


http://codespeak.net/lxml

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


Re: fast method accessing large, simple structured data

2008-02-03 Thread Stefan Behnel
agc wrote:
> I guess an important feature of what I'm looking for is
> some kind of mapping from *exact* title to corresponding article,
> i.e. if my data set wasn't so large, I would just keep all my
> data in a in-memory Python dictionary, which would be very fast.
> 
> But I have about 2 million article titles mapping to approx. 6-10 GB
> of article bodies, so I think this would be just to big for a
> simple Python dictionary.

Then use a database table that maps titles to articles, and make sure you
create an index over the title column.

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


Re: Does anyone else use this little idiom?

2008-02-03 Thread miller . paul . w
My apologies if any attributions are messed up.

On Feb 3, 1:28 am, Steven D'Aprano <[EMAIL PROTECTED]
cybersource.com.au> wrote:
> On Sun, 03 Feb 2008 15:08:34 +1100, Ben Finney wrote:
> >> But I like using _ because it's only 1 character and communicates well
> >> the idea "I don't care about this variable."
>
> > Not to me. As you noted, '_' is easily ambiguous. Explicit is better
> > than implicit; the name 'dummy' makes it much clearer.

Actually, "_" isn't ambiguous at all.  It's a perfectly well-defined
variable name.  It just seems most people don't know that, probably
because most people never get the urge to name a variable "_".

The whole reason I find myself wanting to use "_" is that "for _ in
xrange (n):" goes beyond explicit to redundant if you're not using the
index variable inside the loop.  Ruby's version is much better in this
respect, because every token matters.

> In
> fact, to me "dummy" implies that it holds a dummy value that will be
> replaced later with the actual value needed.
>
> If you want an explicit name, try a variation of "dontcare". Assuming
> that you're an English speaker.

That reminds me... I saw some code once that used a dummy variable
named "dont_give_a_shit".  I got a few seconds of giggles out of it,
at least. :-)

> People seem to forget that "explicit" just means that there's a
> convention that nearly everybody knows, and if you follow it, nearly
> everybody will know what you mean. Often that convention is nothing more
> than the meanings of words in whatever human language you're speaking,
> but it's still a convention.

Well, I'd argue that's only part of what "explicitness" means.  In
this specific use case, having to write the index variable isn't being
explicit; it's a simple redundancy.  Writing "_", or "dontcare" or
"dont_give_a_shit" doesn't seem more explicit at all.  It seems silly
to have to write it at all if I don't intend to use it.  I'd really
prefer something like the Ruby syntax because all you have to write is
the number of times you want to do something, and then the thing you
want to do.  (I guess, in that respect, I'd even consider the xrange
call a redundancy.)

Thanks, everyone for the replies. :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUI definition for web and desktop

2008-02-03 Thread Guilherme Polo
2008/2/3, Steve Holden <[EMAIL PROTECTED]>:
> Guilherme Polo wrote:
>  > 2008/2/3, Steve Holden <[EMAIL PROTECTED]>:
>  >> Daniel Fetchinson wrote:
>  >>  > Hi pythoneans,
>  >>  >
>  >>  > I'm looking for a simple text based GUI definition format and
>
> [...]
>
> >> I believe Glade produces XML descriptions of its interfaces, so wxGlade
>  >>  would be one possible starting-point.
>  >>
>  >
>  > Glade does, but dont confuse it with wxGlade. wxGlade can generate
>  > direct python code or XRC files.
>  >
>
> So what are you telling me - that XRC files aren't XML?
>

Im telling you to not confuse its format with Glade's format. Both are
xml, but are different things.

>
>  regards
>   Steve
>  --
>  Steve Holden+1 571 484 6266   +1 800 494 3119
>  Holden Web LLC  http://www.holdenweb.com/
>
>  --
>  http://mail.python.org/mailman/listinfo/python-list
>


-- 
-- Guilherme H. Polo Goncalves
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python GUI toolkit

2008-02-03 Thread miller . paul . w
On Feb 3, 10:18 am, [EMAIL PROTECTED] wrote:
> what would be the best python GUI toolkit, it must be cross platform.
>
> i have tried gtk, but it interface are real bad and its coding was difficult
> so i dropped it,
>
[...]

If "cross-platform," and "nice API" are your requirements, I recommend
you investigate Tkinter.  I find it fairly easy to get my head around,
and it's available nearly everywhere Python is.  It doesn't even
depend on gtk or qt.  The widgets are fairly basic, but you can create
compound widgets in Python by composing the basic widgets, and there
are extensions like Tix and Python Megawidgets that give you more
widgets to work with.

If you want to see a couple examples of what can be done with Tkinter,
take a look at idle (the IDE that comes with most Python
distributions), and pysol (a solitaire game written in Python using
Tkinter).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Does anyone else use this little idiom?

2008-02-03 Thread Troels Thomsen

>for action in repeat(f, n): action()
>I don't know how 'Pythonic' this would be...

agree, 
or this:

import itertools

def f1():
  print "hello"

[f() for f in itertools.repeat(f1,6)]


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


psyco question

2008-02-03 Thread miller . paul . w
Say I have a module with a function f in it, and I do

psyco.bind (f)

Is there any simple/easy/elegant way to retain a reference to the
*unoptimized* version of f so I can call them both and compare
performance?I've tried

f2 = copy.deepcopy (f)
psyco.bind (f)

but that doesn't work.  Other ways I've thought of that might work
just seem silly (like putting the definition of f in a string, using
compile() to construct two code objects and using psyco.bind() on one
of them), so I'm wondering if there's a good way.

Thanks!

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


Project naming suggestions?

2008-02-03 Thread miller . paul . w
I'm considering writing a little interpreter for a python-like
language and I'm looking for name suggestions. :-)

Basically, I don't want to change a whole lot about Python.  In fact,
I see myself starting with the compiler module from Python 2.5 and
building from there.

This language would be more or less "Python modulo a few
(incompatible) changes, but it'd be recognizable by Python
programmers.  I'm talking about stuff like "allowing the character '?'
in identifier names," and "a better way to express 'for dummy in
xrange (n):' when the index isn't needed."  I'd also like to
implement  most of the planned Python 3000 changes.

Any suggestions?  I'm thinking "Ophidian," for the snake connection,
or, possibly, "Circus," from "Monty Python's Flying Circus."

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


Re: interested????

2008-02-03 Thread Steve Holden
no
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: GUI definition for web and desktop

2008-02-03 Thread Steve Holden
Guilherme Polo wrote:
> 2008/2/3, Steve Holden <[EMAIL PROTECTED]>:
>> Guilherme Polo wrote:
>>  > 2008/2/3, Steve Holden <[EMAIL PROTECTED]>:
>>  >> Daniel Fetchinson wrote:
>>  >>  > Hi pythoneans,
>>  >>  >
>>  >>  > I'm looking for a simple text based GUI definition format and
>>
>> [...]
>>
 I believe Glade produces XML descriptions of its interfaces, so wxGlade
>>  >>  would be one possible starting-point.
>>  >>
>>  >
>>  > Glade does, but dont confuse it with wxGlade. wxGlade can generate
>>  > direct python code or XRC files.
>>  >
>>
>> So what are you telling me - that XRC files aren't XML?
>>
> 
> Im telling you to not confuse its format with Glade's format. Both are
> xml, but are different things.
> 
Thanks. My original advice still stands.

regards
  Steve
-- 
Steve Holden+1 571 484 6266   +1 800 494 3119
Holden Web LLC  http://www.holdenweb.com/

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


Re: Python GUI toolkit

2008-02-03 Thread Gary Herron
[EMAIL PROTECTED] wrote:
> what would be the best python GUI toolkit, it must be cross platform.
>
> i have tried gtk, but it interface are real bad and its coding was difficult
> so i dropped it,
>
> the only remaining are qt4 and wx, i would like to know if one of these or
> any other toolkit is capable of creating good-looking GUI's, like in other
> apps, for e.g, .net apps.
>   
Not true!  There are *many* more widget toolkits out there.  Dozens! 

See: http://en.wikipedia.org/wiki/List_of_widget_toolkits

Gary Herron

> i m a noob, and willing to learn, so difficulty is no problem
>   

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


Re: Why chdir command doesn't work with client.get_transport() ?

2008-02-03 Thread Charles_hans

Thank you, Martin! I think that you are right.
But I can't use rsh since I am on XP to send commands to UNIX. I used telnet
before. Now I am converting to ssh/sftp, which is my purpose.

I put some more efforts in the following code:

t = paramiko.Transport((hostname, port))
t.connect(username=username, password=password, hostkey=None)
sftp = t.open_sftp_client()
sftp.chdir('temp')
pwd = sftp.getcwd()   # Successful
s = t.open_session()
s.exec_command('ls')
stdout = s.makefile('rb')
for line in stdout:
print '... ' + line.strip('\n') # Find: the default
directory shown

This means the channel s created above has nothing to do with the sftp
client which successfully changed the pwd. Any idea that we can link s and
sftp together?  Thanks!

I can't find something equivalent to Telnet in paramiko.

Charles
2/3/2008



-- 
View this message in context: 
http://www.nabble.com/Why-chdir-command-doesn%27t-work-with-client.get_transport%28%29---tp15248798p15256088.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Re: GUI definition for web and desktop

2008-02-03 Thread Daniel Fetchinson
> >>  >>  > I'm looking for a simple text based GUI definition format and
> >>
> >> [...]
> >>
>  I believe Glade produces XML descriptions of its interfaces, so wxGlade
> >>  >>  would be one possible starting-point.
> >>  >>
> >>  >
> >>  > Glade does, but dont confuse it with wxGlade. wxGlade can generate
> >>  > direct python code or XRC files.
> >>  >
> >>
> >> So what are you telling me - that XRC files aren't XML?
> >>
> >
> > Im telling you to not confuse its format with Glade's format. Both are
> > xml, but are different things.
> >
> Thanks. My original advice still stands.

Thanks everyone for the advice!

It's clear to me that the logic behind a web interface and a desktop
interface are two totally different things. I don't want a magic
method to convert an html/javascript based web app to a desktop app as
this is clearly impossible.

But if both interfaces a specific component, which in the desktop case
is a dialog window, in the web app case a particular page and in both
cases the component is simply a list of text fields, radio buttons and
file selection button then it makes sense to have code that can be
used for both concerning the presentation only. So no business logic,
only the presentation, something that says "we have 3 text fields with
these labels and a radio button with such and such labels". Such a
definition makes perfect sense for both a web app and a desktop app
regardless of the fact that they work totally differently.

If I don't have such a shared widget definition then I have to update
both the web app (which is done using turbogears so essentially python
code) and the desktop app (also python) separately when new text
fields are introduced so they constantly have to be in sync. That is
error prone and will surely introduce bugs.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python GUI toolkit

2008-02-03 Thread James Matthews
Just a side question!

Does QT support Events from multiple threads without any special calls!
Example when i use WX i have to call wx.CallAfter()


Thanks!

On Feb 3, 2008 6:05 PM, Jorge Godoy <[EMAIL PROTECTED]> wrote:

> [EMAIL PROTECTED] wrote:
>
> > what i meant was, i tried gtk, didnt like it, the main reason was that
> it
> > had a very bad gui appeal for me, i did try my hand at wx , and i would
> > have stuck with it, but then i saw the qt4 screenshot and couple of
> > examples of its code and i liked it, so i was wondering, if anyone would
> > tell me that i should stick to wx or go forward with qt4.
> >
> > also, is qt4 apps better looking in both win/linux than wx apps, coz the
> > main thing i m looking for is visual appeal of the gui.
>
> Qt is a the best choice, IMHO.  Nice support, free if you write free
> software, very nice API, nice tools to develop with and the best looking
> widget system for *nix and mobile phones.
>
> I also don't like GTK that much but unfortunately we have to live with
> some
> apps written with it.
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
http://search.goldwatches.com/?Search=Movado+Watches
http://www.jewelerslounge.com
http://www.goldwatches.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python GUI toolkit

2008-02-03 Thread Christian Heimes
James Matthews wrote:
> Just a side question!
> 
> Does QT support Events from multiple threads without any special calls!
> Example when i use WX i have to call wx.CallAfter()

Yes, you can send signal across threads with some precaution.

Christian

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


Re: Python GUI toolkit

2008-02-03 Thread Christian Heimes
Jorge Godoy wrote:
> Qt is a the best choice, IMHO.  Nice support, free if you write free
> software, very nice API, nice tools to develop with and the best looking
> widget system for *nix and mobile phones.

PyQt4 forces you to either release your software under GPL or buy a
license. Qt3 and Qt4 allow many more open source licenses but PyQt's
license module doesn't.

Christian

PS: I also prefer Qt4 over wx and GTK. :)

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


Re: psyco question

2008-02-03 Thread Marc 'BlackJack' Rintsch
On Sun, 03 Feb 2008 10:06:04 -0800, miller.paul.w wrote:

> Say I have a module with a function f in it, and I do
> 
> psyco.bind (f)
> 
> Is there any simple/easy/elegant way to retain a reference to the
> *unoptimized* version of f so I can call them both and compare
> performance?

What about `psyco.unbind()`?

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python for game programming

2008-02-03 Thread miller . paul . w
On Feb 3, 9:05 am, t3chn0n3rd <[EMAIL PROTECTED]> wrote:
> Is Python program language popular for game programming?

Well, Python is at the center of my favorite game, Sid Meier's
Civilization 4. :-)

Another poster mentioned the pygame and pyglet libraries.  I'd suggest
you look into them if you want to code a game in Python.  Also keep in
mind the "alternate hard and soft layers" design pattern (as much as I
hate the phrase "design pattern," there's no better way to describe
this particular one.)

The essence of "alternate hard and soft layers" is to design your
application in one of two ways:

* Most of your code is in Python, with C or C++ extensions for
performance-critical areas, or
* Your main app is in C, C++, or some other language that can embed a
Python interpreter.  The embedded Python interpreter provides a
scripting interface that can be used by level/scenario designers or
end users to customize the game.  The scripting interface can be as
simple as a wrapper around functions in the main code, so you can
choose how much functionality you want to expose.

These two patterns are basically equivalent, but I prefer to use the
first, because it lets me write more Python and less C.  In the second
approach, you end up writing most of the game in C and exposing a few
of those C functions to Python.

If you only want to expose a subset of game functionality to Python
(for example, AI or level generation), I'd guess the second way is the
way to go.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python GUI toolkit

2008-02-03 Thread Guilherme Polo
2008/2/3, Christian Heimes <[EMAIL PROTECTED]>:
> Jorge Godoy wrote:
>  > Qt is a the best choice, IMHO.  Nice support, free if you write free
>  > software, very nice API, nice tools to develop with and the best looking
>  > widget system for *nix and mobile phones.
>
>
> PyQt4 forces you to either release your software under GPL or buy a
>  license. Qt3 and Qt4 allow many more open source licenses but PyQt's
>  license module doesn't.
>

PyQt follows same licensing as Qt, so what licenses does Qt4 supports
besides GPL and Qt commercial license ?

>
>  Christian
>
>
>  PS: I also prefer Qt4 over wx and GTK. :)
>
>
>  --
>  http://mail.python.org/mailman/listinfo/python-list
>


-- 
-- Guilherme H. Polo Goncalves
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUI definition for web and desktop

2008-02-03 Thread Jorge Godoy
Daniel Fetchinson wrote:

> It's clear to me that the logic behind a web interface and a desktop
> interface are two totally different things. I don't want a magic
> method to convert an html/javascript based web app to a desktop app as
> this is clearly impossible.

But it is not impossible to embed a server on your desktop and make it
render HTML on some windows.  Then you'd have to code just the web app and
the desktop would also use it...

If Internet is a requirement, you can even render the HTML from a remote
server. 

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


Re: ANN: eric4 4.1.0 released

2008-02-03 Thread dmitrey
Hi all,
I prefer the Eric Python IDE to all other, however, unfortunately,
Eric4.x (as well as the latest snapshot mentioned in the ann) fails to
debug any py-file (while Eric3.9.5 from Kubuntu software channel works
ok):

The debugged program raised the exception unhandled TypeError
"not all arguments converted during string formatting"
File: /usr/lib/python2.5/site-packages/eric4/DebugClients/Python/
DebugBase.py, Line: 515

Could you fix the issue?
Kubuntu 7.10, AMD Athlon, Python 2.5.
Regards, D.

On Feb 3, 5:45 pm, Detlev Offenbach <[EMAIL PROTECTED]> wrote:
> Hi,
>
> eric4 4.1.0 was just released. This is a major feature release. Compared
> to 4.0.4 it contains these features next to bug fixes.
>
> - Added a plugin system for easy extensibility
> - Converted the following interface to plugins available separately
>   -- PyLint checker
>   -- CxFreeze packager
>   -- CharTables tool
>   -- CVS version control system
>   -- BRM refactoring
> - Added new project types
>   -- Eric4 Plugin
>   -- Django
>   -- TurboGears
>   -- wxPython
> - Added source code exporters for
>   -- HTML
>   -- PDF
>   -- RTF
>   -- Latex
> - Added subversion repository and log browsers
> - Included API files for
>   -- eric4
>   -- Django
>   -- TurboGears
>   -- wxPython
>   -- Zope 2
>   -- Zope 3
> - Many enhancements to the functionality already there
>
> What is eric4?
> --
> eric4 is a Python (and Ruby) IDE with all batteries included. Please 
> seehttp://www.die-offenbachs.de/ericfor details and screenshots.
>
> Regards,
> Detlev
> --
> Detlev Offenbach
> [EMAIL PROTECTED]

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


Re: Python GUI toolkit

2008-02-03 Thread miller . paul . w
On Feb 3, 10:39 am, [EMAIL PROTECTED] wrote:

> also, is qt4 apps better looking in both win/linux than wx apps, coz the
> main thing i m looking for is visual appeal of the gui.

Well, well... this wasn't in your original post.  I had assumed ease
of programming and cross-platform-ness were the only requirements.  If
"looks good" is the main criterion, then I don't think Tkinter makes
the top of many peoples' lists.  It isn't that Tkinter can't be *made*
to look good, it's just that it takes quite a bit of work, and if
you're going to put that much effort into a GUI, you're probably
better off with qt, gtk, or wx.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python GUI toolkit

2008-02-03 Thread Thomas Pani
Guilherme Polo wrote:
> PyQt follows same licensing as Qt, so what licenses does Qt4 supports
> besides GPL and Qt commercial license ?
Qt4 has a special exception to the GPL, allowing the use of free
software licenses not compatible with the GPL:
http://trolltech.com/products/qt/gplexception/

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


Re: Python GUI toolkit

2008-02-03 Thread miller . paul . w
I'd like to offer you one suggestion about coding your app.  You'll be
best served if you can either write it as a command-line app and write
a separate GUI-front end for it, or use an abstraction layer between
your app and the display logic that allows you to easily plug in other
GUI toolkits.  That way, you can support qt, GTK, wx, Tkinter, or any
combination of those just by modifying your display abstraction
layer.  Your main app code never needs to be touched.

Depending on the scope of your project, this may or may not be worth
your time, but you should at least consider it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: eric4 4.1.0 released

2008-02-03 Thread Antoni Aloy
El Diumenge, 03-02-08 a les 16:45 escrigueres:
> Hi,
>
> eric4 4.1.0 was just released. This is a major feature release. Compared
> to 4.0.4 it contains these features next to bug fixes.
>
Hello!

This is the first version in many month on which I have no problems with dead 
key characters, suc as á, ñ and so on.
Version 4 is impressive and having support for Django projects and api makes 
even better for my needs.

Thank you for your great job.

Best regards,
-- 
Antoni Aloy López
http://trespams.com
http://apsl.net
Soci de bulma #34
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUI definition for web and desktop

2008-02-03 Thread Daniel Fetchinson
> > It's clear to me that the logic behind a web interface and a desktop
> > interface are two totally different things. I don't want a magic
> > method to convert an html/javascript based web app to a desktop app as
> > this is clearly impossible.
>
> But it is not impossible to embed a server on your desktop and make it
> render HTML on some windows.

That's true, that is why I'm looking for a format that is
html/javascript/desktop/guitoolkit agnostic. It's ideally simply a
text file listing the widgets in whatever format (xml, plain text,
json, etc). And the python web app takes this file, parses it and
spits out the right html/javascript while the desktop app takes the
same file, parses it, and spits out GUI-toolkit specific code that
renders a window with those widgets using the GUI-toolkit in question.
The web app code that spits out html and the desktop app code that
renders a dialog window are different and have to be maintained
separately but the *definition file* can be shared.

> Then you'd have to code just the web app and
> the desktop would also use it...
>
> If Internet is a requirement, you can even render the HTML from a remote
> server.

The internet is assumed to be accessible so this is an interesting
possibility what you mention. Which GUI toolkit would be able to do
this? And so it would work in a way that the desktop app grabs an html
page and renders that in a dialog window? If this was possible then
maybe this would solve all my problems.

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


Re: Python GUI toolkit

2008-02-03 Thread Guilherme Polo
2008/2/3, Thomas Pani <[EMAIL PROTECTED]>:
> Guilherme Polo wrote:
>  > PyQt follows same licensing as Qt, so what licenses does Qt4 supports
>  > besides GPL and Qt commercial license ?
>
> Qt4 has a special exception to the GPL, allowing the use of free
>  software licenses not compatible with the GPL:
>  http://trolltech.com/products/qt/gplexception/
>

Thank you, I wasn't aware of that.

>  Cheers,
>
> thomas pani
>


-- 
-- Guilherme H. Polo Goncalves
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: psyco question

2008-02-03 Thread miller . paul . w
Thanks for your reply.  It's been a while since I've used psyco, and
it seems either some functions have been added, or I've never needed
the other ones. :-)

For the record, it looks like

psyco.bind (f)
f2 = psyco.unproxy(f)

would leave me with an optimized f and a function f2 which is the
unoptimized version of f.  In any case, it looks like I need to RTFM a
little more.

Thanks

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


Re: psyco question

2008-02-03 Thread bearophileHUGS
miller:
> Is there any simple/easy/elegant way to retain a reference to the
> *unoptimized* version of f so I can call them both and compare
> performance?

A simple solution is to defer the optimization. That is test the
original code, call Psyco, then test it again:

def somefunc():
...

from time import clock
t0 = clock()
somefunc()
print clock() - t0
import psyco
psyco.bind(somefunc)
t0 = clock()
somefunc()
print clock() - t0

Bye,
bearophile
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Project naming suggestions?

2008-02-03 Thread Wildemar Wildenburger
[EMAIL PROTECTED] wrote:
> I'm considering writing a little interpreter for a python-like
> language and I'm looking for name suggestions. :-)
> 
How about "Whython"?

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


Re: Python GUI toolkit

2008-02-03 Thread Thomas Dybdahl Ahle
On Sun, 2008-02-03 at 15:18 +, [EMAIL PROTECTED] wrote:
> what would be the best python GUI toolkit, it must be cross platform.
> 
> i have tried gtk, but it interface are real bad and its coding was
difficult
> so i dropped it,

I came from Sving to Gtk, so for me also it was a real brainbreak.
However I must say I got used to it.
I have a good list of links if you still have some corruage.

> the only remaining are qt4 and wx, i would like to know if one of
these or
> any other toolkit is capable of creating good-looking GUI's, like in
other
> apps, for e.g, .net apps.

Well, I've always hated wx apps. It might be a good toolkit for writing,
but I've never seen a good-looking app written in it.

For Qt there is also distance between the good looking apps. However
with qt4 I've started to see some. They still don't fit good into gnome
of cource, but it's not as bad as it used to. I also think the toolkit
is nice for writing.

Another toolkit you might look into is Tkinter. I think it is something
like the "official" toolkit for python. I also think it is an adapter
for other toolkits, so it will use gtk widgets on gnome, qt widgets on
kde and some other strange widgets on windows.

> i m a noob, and willing to learn, so difficulty is no problem

In that case I think you should give gtk another try. The way it is
build is very much based on GObject, which is also used in a number of
other gnome libraries + stuff like Clutter.

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


Re: GUI definition for web and desktop

2008-02-03 Thread Stefan Behnel
Daniel Fetchinson wrote:
> I'm looking for a simple text based GUI definition format and
> associated python modules to work with it that is capable of defining
> simple GUI's for *both* the web and the desktop. I have an application
> that is accessible through the web and also through desktop
> applications and both clients should be presented a simple dialog GUI.
[...]
> I haven't yet decided on the desktop client GUI library, it depends on
> which library has such a dynamically generatable interface from a text
> file. But it should be cross platform between linux and windows.

That sounds a lot like XUL to me. That's the language that Mozilla browsers
use for their GUI. AFAIR, it had Python bindings through XPCOM the last time I
looked into it.

http://www.mozilla.org/why/framework.html

On the other hand, if you want pure HTML for your web app, maybe you should
consider making the desktop app HTML-based, too?

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


Re: Project naming suggestions?

2008-02-03 Thread miller . paul . w
On Feb 3, 2:36 pm, Wildemar Wildenburger
<[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > I'm considering writing a little interpreter for a python-like
> > language and I'm looking for name suggestions. :-)
>
> How about "Whython"?
>
> /W

I like it. :P

If you were wondering why I was thinking of doing this project, the
reason is basically that I want to tinker with a programming language,
and Python is the one I know best.  The fact that there is a compiler
module written in Python  that I can modify is a huge plus.  I don't
necessarily intend for anything in the language to be incorporated in
Python.  I just see it as a playground type project.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: GUI definition for web and desktop

2008-02-03 Thread Daniel Fetchinson
> > I'm looking for a simple text based GUI definition format and
> > associated python modules to work with it that is capable of defining
> > simple GUI's for *both* the web and the desktop. I have an application
> > that is accessible through the web and also through desktop
> > applications and both clients should be presented a simple dialog GUI.
> [...]
> > I haven't yet decided on the desktop client GUI library, it depends on
> > which library has such a dynamically generatable interface from a text
> > file. But it should be cross platform between linux and windows.
>
> That sounds a lot like XUL to me. That's the language that Mozilla browsers
> use for their GUI. AFAIR, it had Python bindings through XPCOM the last time
> I looked into it.
>
> http://www.mozilla.org/why/framework.html

Thanks, I've looked into XUL but it looks too heavyweight to me.

> On the other hand, if you want pure HTML for your web app, maybe you should
> consider making the desktop app HTML-based, too?

Jorge Godoy brought that up too, sounds pretty good, but how would
that work? The desktop app would launch a mini webserver and the user
would use his/her browser that connnects to the local web server? Or
is there a GUI toolkit library for python which can render html?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python GUI toolkit

2008-02-03 Thread Guilherme Polo
2008/2/3, Guilherme Polo <[EMAIL PROTECTED]>:
> 2008/2/3, Thomas Pani <[EMAIL PROTECTED]>:
>
> > Guilherme Polo wrote:
>  >  > PyQt follows same licensing as Qt, so what licenses does Qt4 supports
>  >  > besides GPL and Qt commercial license ?
>  >
>  > Qt4 has a special exception to the GPL, allowing the use of free
>  >  software licenses not compatible with the GPL:
>  >  http://trolltech.com/products/qt/gplexception/
>  >
>
>
> Thank you, I wasn't aware of that.
>

After rereading PyQt license model, it clearly states that in order to
use the free version you need to use it in compatibility with GPL.

For me being compatible with GPL, also means you could any of the
GPL-compatible licenses.

>  >  Cheers,
>  >
>  > thomas pani
>  >
>
>
>
>  --
>  -- Guilherme H. Polo Goncalves
>


-- 
-- Guilherme H. Polo Goncalves
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: psyco question

2008-02-03 Thread miller . paul . w
On Feb 3, 2:19 pm, [EMAIL PROTECTED] wrote:

> simple solution is to defer the optimization. That is test the
> original code, call Psyco, then test it again:

I had thought of that, but it didn't really meet my requirements.  I
might want the unoptimized function back at some point after I call
the unoptimized function.  psyco.unbind() does the trick for this. :-)

Thanks for your reply


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


  1   2   >