Re: which one do you prefer? python with C# or java?

2012-06-15 Thread Alec Taylor
On Sun, Jun 10, 2012 at 8:44 AM, Yesterday Paid
 wrote:
>
> I'm planning to learn one more language with my python.
> Someone recommended to do Lisp or Clojure, but I don't think it's a
> good idea(do you?)
> So, I consider C# with ironpython or Java with Jython.
> It's a hard choice...I like Visual studio(because my first lang is VB6
> so I'm familiar with that)
> but maybe java would be more useful out of windows.
>
> what do you think?

Learn C and Python.

They work well together... you can write Python modules in C (using
Cython or CTypes), and the most popular implementation is written in C
(CPython).

Alternatively learn C++ and Python.

You can can generate C++ from Python using ShedSkin
(http://shed-skin.blogspot.com.au/), and you can write extension to
Python in C++ 
(http://docs.python.org/extending/extending.html#writing-extensions-in-c).
-- 
http://mail.python.org/mailman/listinfo/python-list


Komodo, Python

2012-06-15 Thread Isaac@AU
I just started learning python. I have komodo2.5 in my computer. And I 
installed python2.7. I tried to write python scripts in komodo. But every time 
I run the code, there's always the error:

Traceback (most recent call last):
  File "C:\Program Files\ActiveState Komodo 2.5\callkomodo\kdb.py", line 920, in
 
requestor, connection_port, cookie = ConnectToListener(localhost_addr, port)

  File "C:\Program Files\ActiveState Komodo 2.5\callkomodo\kdb.py", line 872, in
 ConnectToListener
cookie = makeCookie()
  File "C:\Program Files\ActiveState Komodo 2.5\callkomodo\kdb.py", line 146, in
 makeCookie
generator=whrandom.whrandom()
NameError: global name 'whrandom' is not defined

Is it the compatibility problem? Can anybody tell how to fix this problem? 
Because komodo is not free, so I don't want to uninstall komodo. 
-- 
http://mail.python.org/mailman/listinfo/python-list


is the same betweent python3 and python3.2?

2012-06-15 Thread contro opinion
when i download python-3.2.3.tgz
extract
./configure  prefix=/usr/lib/python-3.2
make
make install
when ls  /usr/lib/python-3.2.3/bin/
/usr/lib/python-3.2.3/bin/python3.2m
/usr/lib/python-3.2.3/bin/python3-config
/usr/lib/python-3.2.3/bin/python3
/usr/lib/python-3.2.3/bin/python3.2m-config
/usr/lib/python-3.2.3/bin/python3.2
/usr/lib/python-3.2.3/bin/python3.2-config

is the  /usr/lib/python-3.2.3/bin/python3 same as
/usr/lib/python-3.2.3/bin/python3.2?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Academic citation of Python

2012-06-15 Thread Alec Taylor
I think it's more like when you see articles with a passage like:


The C programming language[1] or the C++ programming language[2] are both
> examples of...
>


Are both easy to find the proper reference for.

On Sat, Jun 16, 2012 at 2:13 PM, Ben Finney wrote:

> Mark Livingstone  writes:
>
> > I wish to properly cite Python in an academic paper I am writing.
> >
> > Is there a preferred document etc to cite?
>
> I think you're best positioned to answer that. Python isn't a document,
> so what specifically are you citing it as?
>
> --
>  \   “A ‘No’ uttered from deepest conviction is better and greater |
>  `\   than a ‘Yes’ merely uttered to please, or what is worse, to |
> _o__)  avoid trouble.” —Mohandas K. Gandhi |
> Ben Finney
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Academic citation of Python

2012-06-15 Thread Ben Finney
Mark Livingstone  writes:

> I wish to properly cite Python in an academic paper I am writing.
>
> Is there a preferred document etc to cite?

I think you're best positioned to answer that. Python isn't a document,
so what specifically are you citing it as?

-- 
 \   “A ‘No’ uttered from deepest conviction is better and greater |
  `\   than a ‘Yes’ merely uttered to please, or what is worse, to |
_o__)  avoid trouble.” —Mohandas K. Gandhi |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: which one do you prefer? python with C# or java?

2012-06-15 Thread Tomasz Rola
On Fri, 15 Jun 2012, Terry Reedy wrote:

> On 6/15/2012 1:03 PM, Tomasz Rola wrote:
> 
> > Last time I checked, Python didn't have linked lists - arrayed lists are
> > nice, but their elements can't be automatically GC-ed (or, this requires
> > very nontrivial GC algorithm), the easiest way I can think would be
> > replacing them with None manually. I'm not sure if del is
> > performance-nice.
> 
> Python does not come with a linked-list class, but one can easily use tuples
> or lists with two items as linked-list cells. One can optionally wrap such
> cell in a linked-list class. However, if array lists do the job, which they
> usually do, using linked-lists will take more time and space. The problem
> being discussed may be a case where they are useful and make it easier to save
> space.

Yes. I made linked lists in Python few years ago, just to test something. 
At the time Python was my main algorithmic toy, so I couldn't resist.

However, handling the list felt half Pascal-y and half unnatural. Later 
on, I felt I didn't like cramming everything into arrays and switched to 
something else.

> > Also, around the same time, Python couldn't do tail-call,
> 
> Nonsense. A tail call is a call temporally followed by a return. In CPython
> bytecode, it would be a call followed by return. In Python code, it is a call
> spatially preceded by 'return'. Any "return f(whatever)", a common operation
> is a tail call.

Actually I was wrong.

http://code.activestate.com/recipes/474088-tail-call-optimization-decorator/

Now I am intrigued because this code just worked a minute ago, on 2.6.

Given this was written for 2.4, I was wrong.

Definitely something I would like to experiment with a bit. The need for 
adding decorator takes some joy away but it is interesting.

> In practice, should_loop, A, and B will usually be in-line expressions rather
> than calls. There may be additional statements after if, else, and while
> headers. In while_equiv, move b=start into the body. Else is typically omitted
> from the while version, but I prefer it in the recursive version.

You see, I spend quite a lot of time playing with concepts etc. Code 
performance is nice to have, but I prefer to maximize my performance as I 
write something and move on. If I feel (from my own point of view) 
something would be nicer to write with recursion, so be it - even though
 some Common Lisp manual advises to use loops because they are faster. 
Actually, from what I have tested, this not always is true - both 
recursion and loops were comparable speed wise in some simple cases I 
checked. This manual is a bit old, and new compiler had its own say about 
optimisation, maybe that's the truth behind it.

For cases where I really want speed, proper algorithm (if only I can think
it) and compilation rule. If algorithm codes better with loops, this is 
ok. But if it codes better with recursion, this should be ok too, because 
if I feel better while coding it, I make less errors.

> > Even more cool, with lazy evaluation (like in Haskell) one can generate
> > lists on a fly and process them like they were statically allocated.
> 
> Python iterators can do lazy evaluation. All the builtin classes come with a
> corresponding iterator.

This is fine, but I don't mind having more, like the whole language 
supporting the idea of being lazy.

http://stackoverflow.com/questions/265392/why-is-lazy-evaluation-useful

> > Yes, you could also run it in a loop or simulate lazy-eval manually (with
> > yield)
> 
> There is nothing simulated about yield.

Yes, yield is real and not simulated. And one can use it to do tricks with 
how/when Python evaluates/generates/performs. It is nicer than if I had to 
write lazy code in, say, C or Pascal, but it doesn't mean one should only 
use one language rather than choose language according to the task,

> Python mostly does what you tell it to do. You just have to learn how to 
> tell it to do what you want.

Well I believe I have already learnt some of it. I am not using Python on 
a daily basis nowadays, and I am stuck somewhere in 2.x land. To stay in 
this semicurrent state I read this group and, from time to time, some 
shorter PEPs. So I think I can tell Python a thing or two, but at the same 
time I don't want to tell it everything, everytime. :-) I like telling 
things in a language that sounds better, which depends on what I tell, 
actually.

Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
** **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Academic citation of Python

2012-06-15 Thread Alec Taylor
Maybe quote the "Programming Python" book, since Guido wrote the forward?

http://www.python.org/doc/essays/foreword2/

On Sat, Jun 16, 2012 at 1:24 PM, Mark Livingstone
 wrote:
> Hello!
>
> I wish to properly cite Python in an academic paper I am writing.
>
> Is there a preferred document etc to cite?
>
> Thanks in advance,
>
> MArkL
> --
> http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Academic citation of Python

2012-06-15 Thread Mark Livingstone

Hello!

I wish to properly cite Python in an academic paper I am writing.

Is there a preferred document etc to cite?

Thanks in advance,

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


Re: which one do you prefer? python with C# or java?

2012-06-15 Thread Terry Reedy

On 6/15/2012 3:04 PM, Paul Rubin wrote:

Terry Reedy  writes:

Python iterators can do lazy evaluation. All the builtin classes come
with a corresponding iterator. ...


I wouldn't say iterators do lazy evaluation in the Scheme or Haskell
sense.  Lazy evaluation imho means evaluation is deferred until you
actually try to use the value, and when you use it, it is computed and
kept around for later re-use (until it becomes gc-able).  Python
iterators simply generate one value at a time and leave retention of old
values to be managed by the programmer.


Ok, I see the difference. You are talking about something like a 
memoized __getitem__  that computes and store values as needed.



There is nothing simulated about yield. Python mostly does what you
tell it to do. You just have to learn how to tell it to do what you
want.


I'd be interested in seeing a clean implementation of that algorithm
using python iterators.


I already wrote "The problem being discussed may be a case where [linked 
lists] are useful and make it easier to save space" -- because, from 
what I understood, a moving buffer of temporarily saved buffers is needed.


--
Terry Jan Reedy

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


Re: python3 raw strings and \u escapes

2012-06-15 Thread Jason Friedman
>> This is a related question.
>>
>> I perform an octal dump on a file:
>> $ od -cx file
>> 000   h   e   l   l   o       w   o   r   l   d  \n
>>            6568    6c6c    206f    6f77    6c72    0a64
>>
>> I want to output the names of those characters:
>> $ python3
>> Python 3.2.3 (default, May 19 2012, 17:01:30)
>> [GCC 4.6.3] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>
>  import unicodedata
>  unicodedata.name("\u0068")
>>
>> 'LATIN SMALL LETTER H'
>
>  unicodedata.name("\u0065")
>>
>> 'LATIN SMALL LETTER E'
>>
>> But, how to do this programatically:
>
>  first_two_letters = "6568    6c6c    206f    6f77    6c72
>  0a64".split()[0]
>  first_two_letters
>>
>> '6568'
>
>  first_letter = "00" + first_two_letters[2:]
>  first_letter
>>
>> '0068'
>>
>> Now what?

 hex_code = "65"
 unicodedata.name(chr(int(hex_code, 16)))
> 'LATIN SMALL LETTER E'

Very helpful, thank you MRAB.

The finished product:  http://pastebin.com/4egQcke2.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python3 raw strings and \u escapes

2012-06-15 Thread MRAB

On 16/06/2012 00:42, Jason Friedman wrote:

This is a related question.

I perform an octal dump on a file:
$ od -cx file
000   h   e   l   l   o   w   o   r   l   d  \n
65686c6c206f6f776c720a64

I want to output the names of those characters:
$ python3
Python 3.2.3 (default, May 19 2012, 17:01:30)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

 import unicodedata
 unicodedata.name("\u0068")

'LATIN SMALL LETTER H'

 unicodedata.name("\u0065")

'LATIN SMALL LETTER E'

But, how to do this programatically:

 first_two_letters = "65686c6c206f6f776c720a64".split()[0]
 first_two_letters

'6568'

 first_letter = "00" + first_two_letters[2:]
 first_letter

'0068'

Now what?


>>> hex_code = "65"
>>> unicodedata.name(chr(int(hex_code, 16)))
'LATIN SMALL LETTER E'
--
http://mail.python.org/mailman/listinfo/python-list


Re: python3 raw strings and \u escapes

2012-06-15 Thread Jason Friedman
This is a related question.

I perform an octal dump on a file:
$ od -cx file
000   h   e   l   l   o   w   o   r   l   d  \n
   65686c6c206f6f776c720a64

I want to output the names of those characters:
$ python3
Python 3.2.3 (default, May 19 2012, 17:01:30)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import unicodedata
>>> unicodedata.name("\u0068")
'LATIN SMALL LETTER H'
>>> unicodedata.name("\u0065")
'LATIN SMALL LETTER E'

But, how to do this programatically:
>>> first_two_letters = "65686c6c206f6f776c72
>>> 0a64".split()[0]
>>> first_two_letters
'6568'
>>> first_letter = "00" + first_two_letters[2:]
>>> first_letter
'0068'

Now what?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

2012-06-15 Thread CM
Dietmar quotes:

> With Python not having an easy-to-use GUI builder,

> The point is, that if you want to promote Python as replacement
> for e.g. VB, Labview etc., then an easy-to-use GUI builder is required.
> The typical GUI programs will just have an input mask, a button and one
> or two output fields.

> On the other hand, I need to know wx very well to be able to create
> a GUI using wxGlade as otherwise I will never find where to add
> e.g. the handlers.
> But when I know wx very well, then there's no point in using wxGlade.

In response to all of these and the general heavily repeated mantra
here that "there is no easy to use GUI builder for Python", OK, tell
you what:  describe what the "GUI that an engineer would want to make"
should look like--give all widgets and their bindings--and I will see
about making a video that shows how easy this is to do with a GUI
builder, even with the user having a very rudimentary (or perhaps
zero) knowledge of wxPython.  And it will be timed.  Let's test your
idea for real. (I should note, I don't know what an "input mask"
refers to above).



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


RE: Hashable object with self references OR how to create a tuple that refers to itself

2012-06-15 Thread Prasad, Ramit
> > I am trying to create a collection of hashable objects, where each
> > object contains references to
> > other objects in the collection.  The references may be circular.
> >
> > To simplify, one can define
> > x= list()
> > x.append(x)
> > which satisfies x == [x].
> > Can I create a similar object for tuples which satisfies x == (x,)?
> 
> You can create a tuple in "C" and then put a reference to itself into it,
> but I am quite convinced that you cannot do it in Python itself.
> (Of course, you could use "cython" to generate C code with a source
> language
> very similar to Python).
> 
> But, you do not need tuples; You could use a standard class:
> 
> >>> class C(object): pass
> ...
> >>> c=C()
> >>> c.c=c
> >>> d=dict(c=c)
> >>> d
> {'c': <__main__.C object at 0xb737f86c>}
>

Using a class is a good approach. You can also override __contains__ 
for the custom classes internal collection so instead of x==[x,] you 
would use x in obj where obj is a collection with the equivalent [x,].

Not entirely sure why Dieter is bringing up C code / Cython... 

Just as a note, if you store references to an object A in the collection
in another object B in the collection and then try to remove A from the
collection it will not get garbage collected nor removed from B. To
allow for garbage collection you should store a weakref instead.
http://docs.python.org/library/weakref.html 

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: usenet reading

2012-06-15 Thread Albert van der Horst
In article ,
Colin Higwell   wrote:
>On Fri, 25 May 2012 15:38:55 -0700, Jon Clements wrote:
>
>>
>> Is there a server out there where I can get my news groups? I use to be
>> with an ISP that hosted usenet servers, but alas, it's no longer
>> around...
>>
>I use Albasani.net (free and very reliable), as well as gmane.org.
>
>Google Groups is an abomination IMHO, and I find it much easier to read
>mailing lists via a newsreader. I highly recommend Pan, by the way.

I still use UUCP. This machine is a UUCP node (spenarnc.xs4all.nl). I
fetch my mail and news using a UUCP-feed (login over the internet with
ADSL to a machine of xs4all). From that moment on it is a newsserver.
I can access it from other machines on my network or I could make it
available to friends over the internet. (Not that I plan to do that.)
I can use any newsreader, and it is fast/instantaneous.

Set this stuff up in 1994 with Coherent. Upgraded to Linux, and upgraded
the hardware a couple of times. Running on a Pentium 120 Mhz now.

I take it for granted but last time I heard, UUCP was down to less
than a dozen users with this service.

Groetjes Albert
>


--
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

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


Re: PyDoc - Python Documentation Plugin for Eclipse

2012-06-15 Thread Alexey Gaidamaka
On Sun, 10 Jun 2012 15:37:50 +, Alexey Gaidamaka wrote:

> On Sun, 10 Jun 2012 05:02:35 -0500, Andrew Berg wrote:
> 
>> On 6/10/2012 4:22 AM, Alexey Gaidamaka wrote:
>>> Practically the plugin  is a simple html archive from python
>>> documentation website running
>>> inside Eclipse so you can call it using Eclipse help system. As for
>>> now it is pretty large (~7 mb), but i'm planning to optimize it in
>>> near future.
>> Rather than archive documentation, why not use a simple static page
>> that points to the different sections for each version of Python on
>> docs.python.org? The 2.7.3 documentation is mostly useless to me since
>> I'm using 3.3 (and of course there are some using 2.6 or 3.2 or
>> 3.1...), but I can easily access it from a link in the page you've
>> archived. Not only would this reduce the size of the plugin to almost
>> nothing, but it would prevent the documentation from being outdated.
>> 
>>> For more information, please visit:
>>> https://sourceforge.net/projects/pydoc/
>> Why isn't it installed like other Eclipse plugins? Is it even possible
>> to update the plugin via Eclipse?
>> 
>> 
>> This does look like a very useful plugin, though. Great idea.
> 
> Thanx! All that you've mentioned is planned in the next versions of the
> plugin.

http://pydoc.tk/news.html

TBD: 

1. updating and installing plugin through standard Eclipse "work with..." 
dialogue
2. reduce size of the original plugin that utilizes static content

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


Re: PyDoc - Python Documentation Plugin for Eclipse

2012-06-15 Thread Alexey Gaidamaka
On Sun, 10 Jun 2012 12:14:15 +0300, Alexey Gaidamaka wrote:

> Greets!
> 
> Since i'm new to Python, i've decided to create a handy plugin for
> Elipse SDK which is my primary dev environment. Practically the plugin 
> is a simple html archive from python documentation website running
> inside Eclipse so you can call it using Eclipse help system. As for now
> it is pretty large (~7 mb), but i'm planning to optimize it in near
> future.
> 
> For more information, please visit:
> 
> http://pydoc.tk/
> 
> or
> 
> https://sourceforge.net/projects/pydoc/
> 
> 
> Advices are appreciated!
> 
> Contact e-mail: 
> 
> ahaidam...@gmail.com 

Hi there again!

I've made up some minor changes in plugin. Now it works with online 
documentation from docs.python.org and supports online doc for 2.6, 2.7, 
3.2, 3.3. Plugin weights around 8KB because all the static content was 
deleted.

Additional infos are here: http://pydoc.tk/news.html

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


Re: Installing numpy over an older numpy

2012-06-15 Thread Miki Tebeka
> Any ideas on how to install a newer version over an older version?
pip uninstall numpy
pip install numpy
-- 
http://mail.python.org/mailman/listinfo/python-list


Installing numpy over an older numpy

2012-06-15 Thread Tom Kacvinsky
I am having problems installing a newer version of numpy over an older 
installation.  The general problem is that the older version's distutils code 
is being used instead of the distutils code in the newer version, no matter how 
much I play around with sys.path in setup.py and the like.

Any ideas on how to install a newer version over an older version?

Thanks,

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


Re: which one do you prefer? python with C# or java?

2012-06-15 Thread Paul Rubin
Terry Reedy  writes:
> Python iterators can do lazy evaluation. All the builtin classes come
> with a corresponding iterator. ...

I wouldn't say iterators do lazy evaluation in the Scheme or Haskell
sense.  Lazy evaluation imho means evaluation is deferred until you
actually try to use the value, and when you use it, it is computed and
kept around for later re-use (until it becomes gc-able).  Python
iterators simply generate one value at a time and leave retention of old
values to be managed by the programmer.

> There is nothing simulated about yield. Python mostly does what you
> tell it to do. You just have to learn how to tell it to do what you
> want.

I'd be interested in seeing a clean implementation of that algorithm
using python iterators.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Use of internal ctypes objects

2012-06-15 Thread Terry Reedy

On 6/15/2012 4:28 AM, RICHARD MOSELEY wrote:

To check whether the function has been previously converted, I make use

of internal objects within the ctypes module, namely, _SimpleCData and
_CFuncPtr. Is this a safe thing to do, bearing in mind that the objects
are documentated as internal?


It depends on what you mean by 'safe'. "Internal" generally means 'use 
at your own risk' and 'subject to change (in future releases) without 
notification'. On the other hand, they should not silently reformat your 
disk ;-).


--
Terry Jan Reedy

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


Re: which one do you prefer? python with C# or java?

2012-06-15 Thread Terry Reedy

On 6/15/2012 1:03 PM, Tomasz Rola wrote:


Last time I checked, Python didn't have linked lists - arrayed lists are
nice, but their elements can't be automatically GC-ed (or, this requires
very nontrivial GC algorithm), the easiest way I can think would be
replacing them with None manually. I'm not sure if del is
performance-nice.


Python does not come with a linked-list class, but one can easily use 
tuples or lists with two items as linked-list cells. One can optionally 
wrap such cell in a linked-list class. However, if array lists do the 
job, which they usually do, using linked-lists will take more time and 
space. The problem being discussed may be a case where they are useful 
and make it easier to save space.



Also, around the same time, Python couldn't do tail-call,


Nonsense. A tail call is a call temporally followed by a return. In 
CPython bytecode, it would be a call followed by return. In Python code, 
it is a call spatially preceded by 'return'. Any "return f(whatever)", a 
common operation is a tail call.


I presume you actually mean that CPython does not automatically convert 
tail calls into local assignments and a jump to reuse the existing 
execution frame instead of a new one. True. A Python interpreter could 
easily detect all tail calls at either compilation or execution, but 
such conversions would erase call history, leaving gaps in exception 
tracebacks and make debugging harder. Depending on your viewpoint, such 
conversion might be considered a semantic change.


Selectively converting recursive tail calls has specific problems that 
have been discussed on other threads, and it would *still* erase the 
call history that one might need to debug. If you do branching 
recursion, as with a tree, and there is an unexpected exception, you 
most likely really do want to see the complete call path leading up to 
the exception. In addition, it is a feature that non-terminating 
recursions such as "def forever(): return forever()" get stopped.


In any case, a properly written linear tail-recursive function is, 
usually, easily converted to an explicit while loop. So if you want 
within-frame looping, write it explicitly. To illustrate one general 
pattern:


def tail_rec(a, b=start): # use default arg to avoid nesting
  if should_loop(a, b):
return tail_rec(A(a,b), B(a,b))
  else:
return term(a, b)

def while_equiv(a, b=start):
  while should_loop(a, b):
a, b = A(a,b), B(a,b)
  else:
return term(a, b)

In practice, should_loop, A, and B will usually be in-line expressions 
rather than calls. There may be additional statements after if, else, 
and while headers. In while_equiv, move b=start into the body. Else is 
typically omitted from the while version, but I prefer it in the 
recursive version.


One downside of the space saving is that the history of a,b values is 
invisible unless one add a debug print statement. Another is that the 
forever function becomes


def forever():
  while True: pass

and Python will never stop it without intervention.


Even more cool, with lazy evaluation (like in Haskell) one can generate
lists on a fly and process them like they were statically allocated.


Python iterators can do lazy evaluation. All the builtin classes come 
with a corresponding iterator.



Yes, you could also run it in a loop or simulate lazy-eval manually (with
yield)


There is nothing simulated about yield. Python mostly does what you tell 
it to do. You just have to learn how to tell it to do what you want.


--
Terry Jan Reedy

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


Re: Need a Python Developer...

2012-06-15 Thread Chris Withers

On 05/06/2012 19:18, o2kcompliant wrote:

Hi Guys,

I have a need for a Python Developer...


How about using the Python job board rather than spamming the mailing list:

http://www.python.org/community/jobs/howto/

cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list


RE: Threads vs subprocesses

2012-06-15 Thread Prasad, Ramit
> > > My question is, on a single core machine, what are the pros and cons of
> > > threads vs subprocesses in a setup like this?
> > >
> [...]
> >
> > Two key phrases in your message;   CPU-intensive,
> > single-core-machine.  If these have the conventional meaning, you're
> > better off doing all the processing in your main executable, without
> > threads at all.
> >
> > Neither threads nor separate process speed up CPU-intensive execution on
> > a single-core machine.
> [...]
> 
> I should have made it clear that I'm not using threads to speed anything
> up;
> each thread produces an independently controlled, timed stream of musical
> events. I think it would be hard to achieve that in a single process. The
> streams need to run simultaneously without getting out of sync or dropping
> notes, which begins to happen if there are a lot of them, or they are run
> very
> fast or are very calculation-intensive to produce.
> 
> So I guess what I'm really asking is, given that I need to use threads or
> subprocesses, which approach slows the processing down the least?

Threads to do not really run simultaneously (in CPython) and without 
multiple CPUs/HT neither do subprocesses. Your machine might be fast 
enough to *look* like they are but they are not. Technically they might 
be running "simultaneously" but the CPU will have to keep switching from 
one calculation to another which just slows all of the calculations down. 
I would imagine the fastest way to proceed would be to iteratively do 
the calculations; thread and subprocess creation have their own 
memory/CPU overheads. 

In summary a single process/thread on a single core machine would 
be fastest.

Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--

This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Hashable object with self references OR how to create a tuple that refers to itself

2012-06-15 Thread Dieter Maurer
"Edward C. Jones"  writes:

> I am trying to create a collection of hashable objects, where each
> object contains references to
> other objects in the collection.  The references may be circular.
>
> To simplify, one can define
> x= list()
> x.append(x)
> which satisfies x == [x].
> Can I create a similar object for tuples which satisfies x == (x,)?

You can create a tuple in "C" and then put a reference to itself into it,
but I am quite convinced that you cannot do it in Python itself.
(Of course, you could use "cython" to generate C code with a source language
very similar to Python).

But, you do not need tuples; You could use a standard class:

>>> class C(object): pass
... 
>>> c=C()
>>> c.c=c
>>> d=dict(c=c)
>>> d
{'c': <__main__.C object at 0xb737f86c>}

--
Dieter

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


Re: which one do you prefer? python with C# or java?

2012-06-15 Thread Paul Rubin
Alexander Blinne  writes:
> An Element of s could be discarded, after every one of the three (k*j
> for k in s)-generators went over it. I don't think that this is possible
> with one deque (at least with the built-in merger of heapq, a
> self-written one could be adapted). Storing everything three times (one
> deque for every generator) would be a mess as well.

I think for 3 lists I'd have just merged manually instead of figuring
out the heapq merge.  The deque approach sounds straightforward but
often there is subtlety, so I'll have to try it.

> How do Haskell or Scheme determine when elements are not longer needed?

Normal gc, once there is no reference to an elemeent it is released.
Actually again there may be a subtlety, if there is a symbol pointing
to the stream.  I'll check into this but I think when I tested it in
Haskell, it did the right thing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Threads vs subprocesses

2012-06-15 Thread John O'Hagan

On Fri, 15 Jun 2012 11:51:01 -0400
Dave Angel  wrote:

> On 06/15/2012 09:49 AM, John O'Hagan wrote:
> > I have a program in which the main thread launches a number of CPU-intensive
> > worker threads. For each worker thread two python subprocesses are started,
[...]
> >
> > So far so good, but it occurred to me that instead of launching all these
> > worker threads, I could just put their target code in separate executable
> > files and launch them as subprocesses. That way there would be fewer
> > threads, but each subprocess would be doing more work. 
> >
> > My question is, on a single core machine, what are the pros and cons of
> > threads vs subprocesses in a setup like this? 
> >
[...]
> 
> Two key phrases in your message;   CPU-intensive,  
> single-core-machine.  If these have the conventional meaning, you're
> better off doing all the processing in your main executable, without
> threads at all.
> 
> Neither threads nor separate process speed up CPU-intensive execution on
> a single-core machine.
[...]

I should have made it clear that I'm not using threads to speed anything up;
each thread produces an independently controlled, timed stream of musical
events. I think it would be hard to achieve that in a single process. The
streams need to run simultaneously without getting out of sync or dropping
notes, which begins to happen if there are a lot of them, or they are run very
fast or are very calculation-intensive to produce. 

So I guess what I'm really asking is, given that I need to use threads or
subprocesses, which approach slows the processing down the least?


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


Re: which one do you prefer? python with C# or java?

2012-06-15 Thread Tomasz Rola
On Fri, 15 Jun 2012, Alexander Blinne wrote:

> How do Haskell or Scheme determine when elements are not longer needed?

Just like Python, they use garbage collection - in one sentence, if it can 
be proved the object (not a OO-object, just a piece of data) will no 
longer be needed, it can be safely deleted - and the code will work as if 
nothing happened, because the proof said it won't need this data in the 
future (so you need a right proving technique).

Now, the difference is, Scheme (and Lisps AFAIK) and Haskell (and those 
functional langs I heard of) posess one neat data type, linked list. They 
also allow for tail-call recursion, which - if one organises one's code 
properly - means infinite recursion, if one needs it. Some problems are 
expressed in an elegant and natural manner as linked lists (head to be 
processed now and rest/tail to be processed later). Such linked lists are 
ideal fit for tail-call recursion - you process a head and recurse with 
results and tail in place of original list (thus becoming a next level 
head+tail list). If no other piece of code stores your current head in a 
variable (simply speaking), it can be proven that head is no longer 
needed. Once you call your function recursively, head is waiting to be 
GC-ed. Your code does not need to worry about this.

Last time I checked, Python didn't have linked lists - arrayed lists are 
nice, but their elements can't be automatically GC-ed (or, this requires 
very nontrivial GC algorithm), the easiest way I can think would be 
replacing them with None manually. I'm not sure if del is 
performance-nice.

Also, around the same time, Python couldn't do tail-call, so the whole 
point of having linked lists was kind of theoretical.

Even more cool, with lazy evaluation (like in Haskell) one can generate 
lists on a fly and process them like they were statically allocated. Say, 
you only have a 2GB of ram but would like to process 128GB of list, 
generated ad hoc as your program runs? Like, counting all even numbers 
less than 2**39 - this is trivial, I know (2**38), but you could run such 
code with 2GB of ram. Your code processes head and when it recurses with 
tail, the new head (next number) is generated, so it can be processed. And 
so on. And thanks to lazy evaluation, you don't need to think about it, 
this is the job of compiler to organize your program in such way.

Yes, you could also run it in a loop or simulate lazy-eval manually (with 
yield) but the point here is you can have more choice for your algorithm 
with some languages and in some other languages (Ruby belongs here, too, 
AFAIK) you don't use recursion (too much) even if you'd like to.

Myself, I love more choice, but of course everybody can have his own 
preferences.

Regards,
Tomasz Rola

--
** A C programmer asked whether computer had Buddha's nature.  **
** As the answer, master did "rm -rif" on the programmer's home**
** directory. And then the C programmer became enlightened...  **
** **
** Tomasz Rola  mailto:tomasz_r...@bigfoot.com **
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

2012-06-15 Thread Dietmar Schwertberger

Am 13.06.2012 18:30, schrieb rdst...@mac.com:

about Google's "Blockly" a drag and drop tool for building apps that
outputs Python or Javascript code (among others) and it might be
usable along these lines...I'm sure serious programmers would not use
it but maybe engineers looking to make web front ends
for data acquisition or data base apps might use it...

Actually, there are mouse based tools for engineers, but they are
more focused on data flow. For the low level they need to fall back to
something similar to Blockly. That's the reason why I don't want to
use them. Still they have a significant market share. With Python not
having an easy-to-use GUI builder, I don't see how to get people
to move from such tools to Python. For the data acquisition and
processing itself I could well imagine them to see the potential,
but when it comes to implementation of a complete program...
(Most people consider a software without GUI as incomplete.)


Regards,

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


tiffany 0.4 released

2012-06-15 Thread Christian Tismer

Tiffany - Read/Write Multipage-Tiff with PIL without PIL


Tiffany stands for any tiff. The tiny module solves a large set of
problems, has no dependencies and just works wherever Python works.
Tiffany was developed in the course of the *DiDoCa* project and will
now appear on PyPi.

Version 0.4
---

This is a compatibility update for Python 2.6.

I hope to submit Python 3.2 compatibility with version 0.5.

Please let me know if this stuff works for you, and send requests to
 or use the links in the bitbucket website:

https://bitbucket.org/didoca/tiffany

cheers -- Chris

--
Christian Tismer :^)
tismerysoft GmbH : Have a break! Take a ride on Python's
Karl-Liebknecht-Str. 121 :*Starship* http://starship.python.net/
14482 Potsdam: PGP key ->  http://pgp.uni-mainz.de
work +49 173 24 18 776  mobile +49 173 24 18 776  fax n.a.
PGP 0x57F3BF04   9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
  whom do you want to sponsor today?   http://www.stackless.com/

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


Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

2012-06-15 Thread Dietmar Schwertberger

Am 15.06.2012 01:07, schrieb Dennis Lee Bieber:

Visual Basic was essentially developed as a unified whole (drop a

Sure. I prefer modular approaches. I don't see why this should not be
possible (e.g. an IDE like Wing integrates well with other tools and
frameworks; I'm sure it could also integrate with a GUI builder).


VB6 "form" module into a pure text editor and look at how much hidden
code was embedded)...

I did so several times before. It's nothing that you want to create
manually, but you can fix small items there and also, being text based,
it works with revision control systems and can be printed for
documentation purposes.



Have you ever seen the crud created by Visual C++? I'd rather create

No. And I don't have plans to. C/C++ is good as a system-level language
but I don't see the point in using it for implementation of a GUI or
business logic.


a GUI using Fujitsu COBOL version 4 (unfortunately, the installer that
came with my Y2K COBOL book(s) doesn't work on WinXP and I no longer
have a Win98 system; wonder if it can run under Win7 using one of the
compatibility modes; I think v4 itself would work -- it is just the
installer doing something odd; v3, OTOH, is a 16-bit application)

If you have access to a Win98 system, you could try to install there
an move only the installed program to your current PC (including any
DLLs from the system folder).
Well-written software does not need an installer. Just move where you
want to have it and execute (works well with Python; you can e.g.
run a shared installation from the network, even though I would not
recommend this for processes requiring highest reliability).
IMHO under Windows installers and the crappy start menus are a side
effect of the initial decision to separate into File Manager and
Program Manager. Other platforms did things better from a UI and
technical point of view, but not from a commercial one...
(E.g. Acorn's RISC OS where you could even run software from
within zip archives as it had the equivalent of user-space file
systems twenty years ago already.)

Regards,

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


Re: Threads vs subprocesses

2012-06-15 Thread Dave Angel
On 06/15/2012 09:49 AM, John O'Hagan wrote:
> I have a program in which the main thread launches a number of CPU-intensive
> worker threads. For each worker thread two python subprocesses are started,
> each of which runs in its own terminal: one displays output received from the
> worker thread via a socket, the other takes text input to control the thread
> (this is done by having another thread receive the input via a socket and 
> write
> to the worker thread's arguments).
>
> So far so good, but it occurred to me that instead of launching all these
> worker threads, I could just put their target code in separate executable
> files and launch them as subprocesses. That way there would be fewer threads,
> but each subprocess would be doing more work. 
>
> My question is, on a single core machine, what are the pros and cons of
> threads vs subprocesses in a setup like this? 
>
> Thanks,
>
> John

Two key phrases in your message;   CPU-intensive,  
single-core-machine.  If these have the conventional meaning, you're
better off doing all the processing in your main executable, without
threads at all.

Neither threads nor separate process speed up CPU-intensive execution on
a single-core machine.

Now, your single core is probably hyper-threaded, so you MIGHT get some
improvement from one extra thread.

Or you might have other reasons for multiple threads, such as ease of
dealing with multiple processes.  But if you let them compete for a
single core, they'll slow things down.

DaveA


-- 

DaveA

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


Re: Python script for device automatic update.

2012-06-15 Thread Michael Hrivnak
Let udev run your script when the appropriate device is connected.

http://www.reactivated.net/writing_udev_rules.html

Then you just need to run an ssh command against the correct mount point.

Honestly, python might be overkill for this.  Consider writing a very
small bash script.

Michael

On Fri, Jun 15, 2012 at 6:41 AM, LoadWalker  wrote:
> Hi,
> I am completly new to python.
> I need to create and script that needs to do the following steps and would 
> apreciate if someone can give me the guidelines to do it as will be my first 
> python script:
>
> The script will be in a linux machine.
> Will wait for a device to conect on the usb. So needs to constantly check for 
> a new driver usb connection.
> At the same time looks for new .zip files in a remote URL that contains a 
> file to be copied to the device.
> So that one a device connectets to the machine it gets copied via ssh the 
> last content of the .zip file.
>
>
> Is it possible to do it in Python?
> --
> http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: does python have bright future?

2012-06-15 Thread Prasad, Ramit
> I'm very new to programing though I learn very little of java,C
> I love python and have fun to do something with it
> but some people said python's future perhaps not that bright.
> I know this question maybe looks like an idiot:(
> I really hope the python rules long~ time.
> what do you think about future of this lang
> or famous lang like C, JAVA, C#, LISP &C

Well, some people think the world will end in 2012 so I would
say that Python's future is pretty dim. :)

On a more serious note, it really depends on what you mean by
future. 1 year, 5 years, 20 years or 100 years? At the moment
I do not see any of the mentioned languages going away in the
next 2-3 or even 5 years but technology can change rapidly.
I am not sure there is really a dominant LISP language so
that might change but as a family I doubt it goes away.

As for Python, it has been around for two decades and seems to 
be growing in popularity (just my opinion, not based on fact). 
I expect it will be around for another decade or two.


Ramit


Ramit Prasad | JPMorgan Chase Investment Bank | Currencies Technology
712 Main Street | Houston, TX 77002
work phone: 713 - 216 - 5423

--
This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Python script for device automatic update.

2012-06-15 Thread LoadWalker
Hi,
I am completly new to python. 
I need to create and script that needs to do the following steps and would 
apreciate if someone can give me the guidelines to do it as will be my first 
python script:

The script will be in a linux machine.
Will wait for a device to conect on the usb. So needs to constantly check for a 
new driver usb connection.
At the same time looks for new .zip files in a remote URL that contains a file 
to be copied to the device.
So that one a device connectets to the machine it gets copied via ssh the last 
content of the .zip file.


Is it possible to do it in Python?
-- 
http://mail.python.org/mailman/listinfo/python-list


Hashable object with self references OR how to create a tuple that refers to itself

2012-06-15 Thread Edward C. Jones
I am trying to create a collection of hashable objects, where each 
object contains references to

other objects in the collection.  The references may be circular.

To simplify, one can define
x= list()
x.append(x)
which satisfies x == [x].
Can I create a similar object for tuples which satisfies x == (x,)?

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


Re: which one do you prefer? python with C# or java?

2012-06-15 Thread Alexander Blinne
On 15.06.2012 09:00, Paul Rubin wrote:
> Alexander Blinne  writes:
>>> def gen_s():
>>>   s = [1]
>>>   m = skipdups(heapq.merge(*[(lambda j: (k*j for k in s))(n) for n in 
>>> [2,3,5]]))
>>>   yield s[0]
>>>   while True:
>>>   k = m.next()
>>>   s.append(k)
>>>   yield k
> 
> Nice.  I wouldn't have been sure that "for k in s" worked properly when
> s was changing like that.

I just tried it and it worked. Not sure if it is guaranteed.

> There is a space complexity problem compared to the Scheme or Haskell
> version: all the s[i]'s are saved in the s array, instead of being
> discarded once they are yielded.  That means generating n elements needs
> O(n) space instead of O(n**0.7) or something like that.  I guess you can
> get around it with collections.deque instead of a list.

An Element of s could be discarded, after every one of the three (k*j
for k in s)-generators went over it. I don't think that this is possible
with one deque (at least with the built-in merger of heapq, a
self-written one could be adapted). Storing everything three times (one
deque for every generator) would be a mess as well.

"Manual" garbage collection could be done by discarding all elements
smaller one fifth of the current element of s, because the three
generators already went by them. This could be done with a deque.

How do Haskell or Scheme determine when elements are not longer needed?

Greetings


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


Re: python's future?

2012-06-15 Thread Michael Torrie
On 06/15/2012 01:04 AM, Yesterday Paid wrote:
> I'm very new to programing though I learn very little of java,C
> I love python and have fun to do something with it
> but some people said python's future perhaps not that bright.
> I know this question maybe looks like an idiot:(
> I really hope the python rules long~ time.
> what do you think about future of this lang
> or famous lang like C, JAVA, C#, LISP &C

If it works for you, use, it.  If not, move on to a more appropriate
language.  Python may be more appropriate for some tasks than others.
And as others have said, it's well-supported by its developers, and has
a rich library to draw on.  So there's no reason not to use it now.
Either Python 2.x or Python 3.x, though it appears that targeting Python
3 maybe wisest.

If in the future Python fades away, you will simply move onto another
language.  A good programmer should be able to rapidly transition from
language to language as appropriate.  And even if in fact Python should
die, there are other languages that have been inspired by Python, and
will hopefully continue a semblance of Pythonic goodness.

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


PyPyODBC 0.5 alpha released! (A Pure Python ODBC module)

2012-06-15 Thread 江文
PyPyODBC - A Pure Python ctypes ODBC module

Features
-Pure Python, compatible with PyPy (tested on Win32)
-Almost totally same usage as pyodbc

You can simply try pypyodbc in your existing pyodbc powered script
with the following changes:

   #import pyodbc                <-- Comment out
the original pyodbc importing line
   import pypyodbc as pyodbc     # Let pypyodbc "pretend" the pyodbc
   pyodbc.connect(...)          # This is pypyodbc
pretending pyodbc! They have same APIs!
...


Homepage:http://code.google.com/p/pypyodbc/

Demo Script:
http://code.google.com/p/pypyodbc/source/browse/trunk/pypyodbc/test.py
-- 
http://mail.python.org/mailman/listinfo/python-list


Threads vs subprocesses

2012-06-15 Thread John O'Hagan
I have a program in which the main thread launches a number of CPU-intensive
worker threads. For each worker thread two python subprocesses are started,
each of which runs in its own terminal: one displays output received from the
worker thread via a socket, the other takes text input to control the thread
(this is done by having another thread receive the input via a socket and write
to the worker thread's arguments).

So far so good, but it occurred to me that instead of launching all these
worker threads, I could just put their target code in separate executable
files and launch them as subprocesses. That way there would be fewer threads,
but each subprocess would be doing more work. 

My question is, on a single core machine, what are the pros and cons of
threads vs subprocesses in a setup like this? 

Thanks,

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


Re: PIL for the Python 3.2.3

2012-06-15 Thread Alec Taylor
On Fri, Jun 15, 2012 at 10:18 PM, Gonzalo de Soto wrote:

> Dear Python Org,
>
> It wanted to know if already PIL's
> version is available for Python 3.2.3.
>
> ** **
>
> Thanks.
>
>Gonzalo
>
>   
>
> ** **
>
> * *
>
> ** **
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
Looks like the PIL fork "Pillow" is coming close to support for Python 3:
https://github.com/collective/Pillow/pull/25
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PIL for the Python 3.2.3

2012-06-15 Thread Emile van Sebille

On 6/15/2012 5:18 AM Gonzalo de Soto said...

Dear Python Org,

It wanted to know if already PIL's version is available for Python 3.2.3.


Not yet.  See http://www.pythonware.com/products/pil/

Emile


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


Re: PIL for the Python 3.2.3

2012-06-15 Thread Mark Lawrence

On 15/06/2012 13:18, Gonzalo de Soto wrote:

Dear Python Org,

 It wanted to know if already PIL's
version is available for Python 3.2.3.



Thanks.

Gonzalo



Please refer to Matthew 7:7 for a way forward.

--
Cheers.

Mark Lawrence.

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


PIL for the Python 3.2.3

2012-06-15 Thread Gonzalo de Soto
Dear Python Org,

It wanted to know if already PIL's
version is available for Python 3.2.3.

 

Thanks.

   Gonzalo

  

 

 

 

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


Use of internal ctypes objects

2012-06-15 Thread RICHARD MOSELEY
I have a module which makes use of ctypes to interface to the IBM C-ISAM
library under linux. I have created a libpyisam.so library which combines
the two official libraries, libifisam.so and libifisamx.so and provides a
SONAME for the ctypes module (if that is still required).

My main object uses a dictionary in which the keys are the external
functions that can be called from the externl library, and the values are
initially tuples which define the arguments and return type for the
functions. The first time that a function is called, the __getattr__
function locates the function in the library then modifies the return type
and arguments according to the tuple stored in the value, this object is
then stored in place of the tuple so that subsequent calls simply use the
previous object.

To check whether the function has been previously converted, I make use of
internal objects within the ctypes module, namely, _SimpleCData and
_CFuncPtr. Is this a safe thing to do, bearing in mind that the objects are
documentated as internal?

In order to make the above paragraphs clear, I provide a cutdown version of
the object in question with a sample of the functions and the calling
convention used. Is there a better way to do this using ctypes:

from ctypes import *

class ISAMobject(dict):
  """
  The _func dictionary initially consists of:
(args,...)where the return type is c_int and arguments
are passed,
(None,) where the return type is c_int but no arguments
are passed,
(ret,(args,...))where the return type is not c_int and
arguments are passed,
(ret,None) where the return type is not c_int and no
arguments are passed,
None where there is no return type and no arguments
are passed
  """
  _func = {
'isbegin'  : (None,),
'iscluster' : (c_int, byref(keydesc)),
'islangchk' : None,
'islanginfo' : (c_char_p, (c_char_p,))
  }

  _const = {
'iserrno' : c_int,
'iscopyright' : c_char_p
  }

  _lib = cdll.LoadLibrary('./libpyisam.so')

  def __getattr__(self, name):
func_info = self._func.get(name, 'NONE')
if func_info == 'NONE':
   const_info = self._const.get(name, 'NONE')
   if const_info == 'NONE':
  raise AttributeError('Underlying ISAM library does not have %s
attribute' % name)
   if not isinstance(const_info, ctypes._SimpleCData):
  const_info = const_info.in_dll(self._lib, name)
  self._const[name] = const_info
   return const_info.value if hasattr(const_info, 'value') else
const_info
elif not instance(func_info, ctypes._CFuncPtr):
   real_func = getattr(self._lib, name)
   if real_func is None:
  raise AttributeError('Underlying ISAM library does not support %s
function' % name)
   if func_info is None:
  real_func.restype = real.argtypes = None
   elif isinstance(func_info, list):
  real_func.restype, real_func.argtypes = func_info
   elif len(func_info) > 1 and isinstance(func_info[1], tuple):
  real_func.restype, real_func.argtypes = func_info
   elif isinstance(func_info, tuple):
  real_func.argtypes = func_info
   else:
  real_func.restype = func_info
   self._func[name] = func_info = real_func
return func_info

Thank you in advance,
Richard Moseley
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python's future?

2012-06-15 Thread Chris Angelico
On Fri, Jun 15, 2012 at 6:05 PM, Mark Lawrence  wrote:
> "an active and helpful mailing list/newsgroup (hi!)"?  Gmane lists 322
> entries under comp.python :)

Sorry, should have said: A set of active and helpful mailing
lists/newsgroups! You're quite right, there's a lot of them :)  I
wonder... is there anyone insane enough to have them all subscribed
and to actually read every post...

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


does python have bright future?

2012-06-15 Thread Yesterday Paid
I'm very new to programing though I learn very little of java,C
I love python and have fun to do something with it
but some people said python's future perhaps not that bright.
I know this question maybe looks like an idiot:(
I really hope the python rules long~ time.
what do you think about future of this lang
or famous lang like C, JAVA, C#, LISP &C
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python's future?

2012-06-15 Thread Mark Lawrence

On 15/06/2012 08:30, Chris Angelico wrote:

On Fri, Jun 15, 2012 at 5:04 PM, Yesterday Paid
  wrote:

I'm very new to programing though I learn very little of java,C
I love python and have fun to do something with it
but some people said python's future perhaps not that bright.
I know this question maybe looks like an idiot:(
I really hope the python rules long~ time.
what do you think about future of this lang
or famous lang like C, JAVA, C#, LISP&C


Python's future is looking pretty bright at the moment. It's extremely
well supported, has an active and helpful mailing list/newsgroup (hi!)
and issue tracker and so on, it's found pre-installed on several
Linuxes, it's easy to get for Windows, and lots of Python software is
around and being developed all the time. There's big companies who
have pledged support, including Google, who employ Guido van Rossum
(the project head).

As a language, Python has its issues, but overall it's awesome. I have
no hesitation in recommending it as a first language, a scripting
language, and an application language. There's things I dislike about
it (design choices like the lack of declared variables), but that's
true of pretty much everything.

There's no need to fear its imminent demise :)

ChrisA


"an active and helpful mailing list/newsgroup (hi!)"?  Gmane lists 322 
entries under comp.python :)  I believe that some manufacturers 
pre-install on Windows, and I know that it's also pre-installed on OS X. 
 It's just a pity that Python is no longer maintained on the finest OS 
ever, i.e. VMS :(


--
Cheers.

Mark Lawrence.

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


Re: python's future?

2012-06-15 Thread Mark Lawrence

On 15/06/2012 08:04, Yesterday Paid wrote:

I'm very new to programing though I learn very little of java,C
I love python and have fun to do something with it
but some people said python's future perhaps not that bright.
I know this question maybe looks like an idiot:(
I really hope the python rules long~ time.
what do you think about future of this lang
or famous lang like C, JAVA, C#, LISP&C


I believe that this still holds true 
http://www.gossamer-threads.com/lists/python/python/129650?do=post_view_threaded


--
Cheers.

Mark Lawrence.

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


PyCon Australia 2012 Conference Programme Revealed!

2012-06-15 Thread Chris Neugebauer
(Hobart Tasmania, 15 June 2012) With both of our keynotes announced, PyCon
Australia is very proud to be able to reveal the programme for the 2012
conference, to be held on Saturday 18 and Sunday 19 August 2012 in Hobart,
Tasmania.

Following an impressive response to our Call for Proposals the conference
will feature three full tracks of presentations and tutorials, across two
days, covering all aspects of the Python ecosystem, presented by experts
and core developers of key Python technology.

Our keynote presenters, Mark Ramm, Engineering Manager on Juju at Canonical
[1], and Kenneth Reitz, Python lead at Heroku [2] will be joined by a wide
array of presenters covering a broad range of backgrounds, including
industry, research, government and academia.

As ever, PyCon Australia is a great place to keep up-to-date with the
latest trends in Python web technology: From Heroku, Lincoln Stoll will be
presenting on the 12 Factor Method for building software-as-a-service apps
[3]. Other web related topics include deployment and testing techniques for
Django applications and techniques for asynchronous web programming.

There's also a wide range of talks for the rapidly growing community of
developers using Python in science. Edward Schofield's survey of the latest
developments in Python for Science and Engineering [4] will get you up to
scratch on what tools and techniques are shaping the Python world for
scientists. From there, case studies and introductory talks will delve into
all aspects of Python in science: including techniques for handling large
scientific data sets, natural language processing, and data visualisation
-- attendees working with Python in all fields of science will gain
something from PyCon Australia 2012.

Finally, for newcomers to Python looking to quickly enhance their Python
skillset, Graeme Cross' tutorials [5] in our Classroom stream will help you
to rapidly enhance your knowledge of Python -- you can then attend our
general stream talks to glean a snapshot of the state of the art in Python.

PyCon Australia 2012 programme committee chair, Richard Jones, was
impressed with the level of response to the Call for Proposals, which
closed in early May: "We had an unprecedented response to our Call for
Proposals this year, and this has helped us to put together one of the
strongest programmes ever at PyCon Australia. There's something for every
developer working with Python in this year's programme -- be they working
in web technology, in research, or even if they're just a Python enthusiast
who wants to learn more about their favourite language."

The full schedule for PyCon Australia 2012 can be found at
http://2012.pycon-au.org/programme/schedule

Registrations for PyCon Australia 2012 are now open, with prices starting
at AU$44 for students, and tickets for the general public starting at
AU$198. All prices include GST, and more information can be found at
http://2012.pycon-au.org/register/prices

We're looking forward to seeing this excellent programme brought to life at
PyCon Australia 2012, in Hobart, in August.

[1] http://2012.pycon-au.org/media/news/24
[2] http://2012.pycon-au.org/media/news/18
[3] http://2012.pycon-au.org/schedule/59/view_talk?day=sunday
[4] http://2012.pycon-au.org/schedule/67/view_talk?day=saturday
[5] http://2012.pycon-au.org/schedule/56/view_talk?day=saturday

=== About PyCon Australia ===

PyCon Australia is the national conference for the Python Programming
Community. The third PyCon Australia will be held on August 18 and 19, 2012
in Hobart, Tasmania, bringing together professional, student and enthusiast
developers with a love for developing with Python. PyCon Australia informs
the country’s Python developers with presentations, tutorials and panel
sessions by experts and core developers of Python, as well as the libraries
and frameworks that they rely on.

To find out more about PyCon Australia 2012, visit our website at
http://pycon-au.org or e-mail us at cont...@pycon-au.org.

PyCon Australia is presented by Linux Australia (www.linux.org.au) and
acknowledges the support of our Gold sponsors: Google Australia (
www.google.com.au), and the Australian Computer Society (Tasmanian Branch) (
www.acs.org.au); our Event partners: Kogan, and Secret Lab; and our Silver
sponsors: the Python Software Foundation, the Django Software Foundation,
Anchor Systems, 99designs, Red Hat, ekit, RimuHosting, and CSIRO.

--
--Christopher Neugebauer
Conference Coordinator and Sponsor Liaison

PyCon Australia: Hobart 2012 -- http://2012.pycon-au.org -- @pyconau
Conference registration and accommodation deals now available! See our
website for details.

Jabber: chris...@gmail.com -- IRC: chrisjrn on irc.freenode.net -- WWW:
http://chris.neugebauer.id.au -- Twitter/Identi.ca: @chrisjrn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python's future?

2012-06-15 Thread Chris Angelico
On Fri, Jun 15, 2012 at 5:04 PM, Yesterday Paid
 wrote:
> I'm very new to programing though I learn very little of java,C
> I love python and have fun to do something with it
> but some people said python's future perhaps not that bright.
> I know this question maybe looks like an idiot:(
> I really hope the python rules long~ time.
> what do you think about future of this lang
> or famous lang like C, JAVA, C#, LISP &C

Python's future is looking pretty bright at the moment. It's extremely
well supported, has an active and helpful mailing list/newsgroup (hi!)
and issue tracker and so on, it's found pre-installed on several
Linuxes, it's easy to get for Windows, and lots of Python software is
around and being developed all the time. There's big companies who
have pledged support, including Google, who employ Guido van Rossum
(the project head).

As a language, Python has its issues, but overall it's awesome. I have
no hesitation in recommending it as a first language, a scripting
language, and an application language. There's things I dislike about
it (design choices like the lack of declared variables), but that's
true of pretty much everything.

There's no need to fear its imminent demise :)

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


python's future?

2012-06-15 Thread Yesterday Paid
I'm very new to programing though I learn very little of java,C
I love python and have fun to do something with it
but some people said python's future perhaps not that bright.
I know this question maybe looks like an idiot:(
I really hope the python rules long~ time.
what do you think about future of this lang
or famous lang like C, JAVA, C#, LISP &C
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: which one do you prefer? python with C# or java?

2012-06-15 Thread Paul Rubin
Alexander Blinne  writes:
>> def gen_s():
>>   s = [1]
>>   m = skipdups(heapq.merge(*[(lambda j: (k*j for k in s))(n) for n in 
>> [2,3,5]]))
>>   yield s[0]
>>   while True:
>>   k = m.next()
>>   s.append(k)
>>   yield k

Nice.  I wouldn't have been sure that "for k in s" worked properly when
s was changing like that.

There is a space complexity problem compared to the Scheme or Haskell
version: all the s[i]'s are saved in the s array, instead of being
discarded once they are yielded.  That means generating n elements needs
O(n) space instead of O(n**0.7) or something like that.  I guess you can
get around it with collections.deque instead of a list.
-- 
http://mail.python.org/mailman/listinfo/python-list