Re: Fibonacci series recursion error

2011-05-02 Thread Hans Georg Schaathun
On Mon, 2 May 2011 06:49:41 +1000, Chris Angelico
  ros...@gmail.com wrote:
:  Sure. Serialize this Python object in a way that can be given to, say, PHP:
:  foo={asdf:qwer,zxcv:1234}; foo[self]=[1,2,3,foo]
:  Recurse from self into the list, recurse from there into a
:  dictionary... Okay, that's a rather naive recursion and fraught with
:  risk, but there are more complex examples. And watching for cyclic
:  references would be O(N*N) as you'd need to maintain a full list of
:  every PyObject* that you've sighted (talking here from the C API, but
:  the same consideration applies whichever way you do it).

Wouldn't cyclic references give infinite recursion?  And remain
infinitive if you recode it iteratively?

:  I'm not sure that recursion is clearer. Recursion is a way of
:  expressing the two rules:
: 
:  1! = 1
:  n! = n * (n-1)!
: 
:  But iteration is a way of expressing this equivalent rule:
: 
:  n! = 1 * 2 * 3 * ... * n-1 * n
: 
:  It really depends what you're trying to say.

True.  There is a place for everything.  However, in the example
above, you can map the recursive definition directly into python
without further ado.  In order to express the one-liner in python,
as iteration, you need to introduce additional elements, namely
a state (index variable).  Hence, recursion is clearer by being
close to the language you would normally use to describe the
problem.

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


Re: Fibonacci series recursion error

2011-05-02 Thread Chris Angelico
On Mon, May 2, 2011 at 3:36 PM, Hans Georg Schaathun h...@schaathun.net wrote:
 On Mon, 2 May 2011 06:49:41 +1000, Chris Angelico
  ros...@gmail.com wrote:
 :  Sure. Serialize this Python object in a way that can be given to, say, PHP:
 :  foo={asdf:qwer,zxcv:1234}; foo[self]=[1,2,3,foo]

 Wouldn't cyclic references give infinite recursion?  And remain
 infinitive if you recode it iteratively?

Well, I don't know of a decent non-recursive way to process a
recursive structure. Incidentally, this example is almost directly
from some working code of ours; I have a C function that recurses over
a Python dictionary and aborts as soon as it's found too much data
(for a fairly arbitrary definition of too much, but one that's
deliberately designed to prevent infinite recursion). Since every
element in the dictionary can be a list/dict, and every element of
those can be too, there's no non-recursive way to do it, other than by
doing the recursion yourself:

# partly pseudocode
searchme=[foo]
while len(searchme):
  cur=get_next_elem(searchme[-1])
  if cur==end_of_list: searchme[-1:]=[]
  else: if can_be_recursed_into(cur): searchme.append(cur)
  else: output(cur)

This would work, more or less, but it merely trades true recursion
for the searchme[] stack. Yes, it's iterative. No, it hasn't abolished
recursion.

 True.  There is a place for everything.  However, in the example
 above, you can map the recursive definition directly into python
 without further ado.  In order to express the one-liner in python,
 as iteration, you need to introduce additional elements, namely
 a state (index variable).  Hence, recursion is clearer by being
 close to the language you would normally use to describe the
 problem.

True, and you could abolish a lot of temporary variables by turning
them into parameters to recursive calls. But you've abolished nothing.

The recursive factorial is very similar to:
reduce(`*,range(1,n+1))
The iterative is very similar to:
reduce(`*,xrange(1,n+1))
One of 'em stacks up all the numbers and the other gets 'em as it
needs 'em. Fundamentally, there's really not a lot of difference. By
piling up the numbers on your stack, you just change the format of
your saved state, you don't actually save anything.

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


Re: Fibonacci series recursion error

2011-05-02 Thread Chris Angelico
On Mon, May 2, 2011 at 4:28 PM, Chris Angelico ros...@gmail.com wrote:
 reduce(`*,range(1,n+1))
 reduce(`*,xrange(1,n+1))

Whoops, forgot which language I was using. Back-tick functions not
being available, these need to be:

reduce(operator.mul,range(1,n+1))
reduce(operator.mul,xrange(1,n+1))

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


Re: Py_INCREF() incomprehension

2011-05-02 Thread Hegedüs , Ervin
hello,

Thomas, Gregory,

thank you for your ansrwers,

 I guess this is the point where yo should start printf programing.


oh', already done :)
 
 * What happens during module initialization?
successfully initialized,

 * What happens n the functions?
 * Where does the stuff fail?
 * What are the reference counts of the involved objects?

sorry for the dumb question: how can I controll number of
reference in C?
 
  PyModule_AddObject(o, error, cibcrypt_error_nokey);
  Py_INCREF(cibcrypt_error_nokey);
 
 and now if there is some expected exception, I get it.
 
 Any explanation?
 
 I don't have one - I would think that if the module object exists
 for all the time, it would be enough to have one reference there.
 
 But obviously it is not enough - did you at any time del something
 related to here? The module or one of its attributes?
 
 Anyway, it seems safer to do INCREF here - so do it. (As Gregory
 already stated - it looks cleaner if you do INCREF before
 AddObject.)

ok,
 
 
 ps: this is just for my passion, but I would like to understand
 it very-very much :)
 
 Understandable. That's that the printf debugging of the refcounts
 can be good for - even if you don't really have a problem.

thanks, I'll go to read the docs :)

bye:

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


Re: Compile 32bit C-lib on 64 bit

2011-05-02 Thread Hegedüs , Ervin
Hello,

thanks for all reply,

On Mon, May 02, 2011 at 03:20:40AM +0100, Nobody wrote:
 You need to build your module for a 32-bit version of Python.

ok, I believed it, I was hoping there is another solution,

 On a 64-bit system, each process is either 32-bit or 64-bit process. You
 can't mix 32-bit code and 64-bit code in a single process. If you have to
 use that library and you only have a 32-bit version of it, then everything
 else must also be 32-bit: the Python interpreter, your binary module, and
 all of the libraries which it uses.

ok, thank you,


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


Re: Py_INCREF() incomprehension

2011-05-02 Thread Stefan Behnel

Hegedüs, Ervin, 02.05.2011 08:41:

Thomas,

I guess this is the point where yo should start printf programing.


oh', already done :)


FWIW, Cython 0.14+ has special support for gdb now, so, in addition to 
print and printf debugging, you can also use gdb to explore the state of 
your application, be it at the Python, Cython or C level.


http://docs.cython.org/src/userguide/debugging.html

Stefan

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


Re: Development tools and practices for Pythonistas

2011-05-02 Thread Algis Kabaila
On Monday 02 May 2011 13:22:44 Ben Finney wrote:
 rusi rustompm...@gmail.com writes:
  You may want to look at rcs if you are in the space where
 
 But today, Bazaar or Mercurial fill that role just as well:
 quick simple set up, good tool support (yes, even in Emacs
 using VC mode), and easy to use for easy things.
 

Actually, Bazaar is more convenient than rcs for a single user, 
as the repository can be the working directory (with a hidden 
.bzr directory that stores diffs).  

I had to use git, too, because some projects use git for their 
version control (viz PySide, Nokia's tool to replace PyQt). IMHO 
there is not much to pick between git and Bazaar and hg is also 
rather similar.  The remaining doubts are betwwed the 
Distributed Version Control and the more traditional Subversion, 
which is also quite nice, even for  a single user.

OldAl.
-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fibonacci series recursion error

2011-05-02 Thread rusi
On Apr 30, 11:14 am, Peter Otten __pete...@web.de wrote:

 For the record, the one true way to implement the Fibonacci series in Python
 is

  def fib():

 ...     a = b = 1
 ...     while True:
 ...             yield a
 ...             a, b = b, a+b # look ma, no temporary variable

Not any claim to 'the one true pythonic way' but fib can be written in
a clean recursive way with linear space-time behavior asz follows:

Dijkstra explained that fib is an 2nd order recurrence
-- fib(n) defined in terms of fib (n-1) and fib(n-2)
whereas programming loops and recursion are 1st order -- state at
iteration n defines state at iteration n+1.

Converting the 2nd order fib relation to a 1st order one trivially
gives a linear program.
The key insight from Dijkstra is that all we need to do is to move
from a recursive function returning fibonacci nos to one returning
pairs of adjacent ones.

def fibpair(n):
# returns (fib(n), fib(n+1))
if n==0:
return (1,1)
else:
(a,b) = fibpair(n-1)
return (b, a+b)

After that fib is just this:

def fib(n):
a,b = fibpair(n)
return a;

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


Re: Development tools and practices for Pythonistas

2011-05-02 Thread rusi
On May 2, 12:08 pm, Algis Kabaila akaba...@pcug.org.au wrote:

 Actually, Bazaar is more convenient than rcs for a single user,
 as the repository can be the working directory (with a hidden
 .bzr directory that stores diffs).  

Dont exactly understand...
Is it that you want it specifically hidden?
Otherwise rcs will look inside an RCS directory just as bzr will
with .bzr git will with .git and so on.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PIL Question

2011-05-02 Thread nirinA raseliarison

[PyNewbie]


Question: I can't seem to find the captured image, where does it go?


for me, it just goes to the current working directory:

  $ python -i
  Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit  
(Intel)] on win32

  Type help, copyright, credits or license for more information.
   from PIL import ImageGrab
   ImageGrab.grab().save(screen_capture.jpg, JPEG)
   import os
   os.listdir(os.getcwd())
  ['.appcfg_cookies', '.appcfg_nag', '.bash_history', '.idlerc',  
'.inputrc', '.povray',
  'bootex.log', 'buildBasicDemo.txt', 'glsample.cpp', 'glsample.o',  
'log.txt',

  'screen_capture.jpg', 'test.c']
  

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


Re: Development tools and practices for Pythonistas

2011-05-02 Thread Algis Kabaila
On Monday 02 May 2011 17:19:57 rusi wrote:
 On May 2, 12:08 pm, Algis Kabaila akaba...@pcug.org.au 
wrote:
  Actually, Bazaar is more convenient than rcs for a single
  user, as the repository can be the working directory (with
  a hidden .bzr directory that stores diffs).
 
 Dont exactly understand...
 Is it that you want it specifically hidden?
 Otherwise rcs will look inside an RCS directory just as bzr
 will with .bzr git will with .git and so on.

Sorry for not being clear - ls will not show directories that 
start with . - in that sense these directories are hidden.  
They are not really really hidden, as ls  -l will show them.  
They simply are not in the way and keep the progressive versions 
of the program (in form of diffs).

Does that make better sense?. 
-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What other languages use the same data model as Python?

2011-05-02 Thread Jorgen Grahn
On Sun, 2011-05-01, Terry Reedy wrote:
 On 5/1/2011 4:45 AM, Steven D'Aprano wrote:
...
 What other languages use the same, or mostly similar, data model as
 Python?

 Natural languages. That is why I think it is better to think of Python 
 as an algorithm language or information-object manipulation language 
 rather than as just a linear-memory machine language.A linear memory 
 with bytes addressed from 0 to max-int or max-long is an explicit part 
 of the definition of assembly languages and C. It is no part of the 
 definition of Python.

It's not part of the definition of C either -- C supports segmented
memory (pre-386 Intel) and separate code/data address spaces. (Even if
most C users tend not to think of it that way.)

/Jorgen

-- 
  // Jorgen Grahn grahn@  Oo  o.   .  .
\X/ snipabacken.se   O  o   .
-- 
http://mail.python.org/mailman/listinfo/python-list


build the sql where cause dynamic

2011-05-02 Thread christian
Hi,

from some radio buttons in a django app i concat  string like that:
But have no idea how i get the or when there different values
for a specified p column (# is currently my intended splitter maybe i
can concat a better input?).

input: p2=1#p2=2#p1=3#p1=1#p1=5#pc=1#py=1

output: p2 in ('1','2') and p1 in ('3','1','5') and pc in ('1') and
py in ('1')


Many thanks for any starting point
Christian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: build the sql where cause dynamic

2011-05-02 Thread Chris Angelico
On Mon, May 2, 2011 at 5:48 PM, christian oz...@web.de wrote:
 Hi,

 from some radio buttons in a django app i concat  string like that:
 But have no idea how i get the or when there different values
 for a specified p column (# is currently my intended splitter maybe i
 can concat a better input?).

 input: p2=1#p2=2#p1=3#p1=1#p1=5#pc=1#py=1

 output: p2 in ('1','2') and p1 in ('3','1','5') and pc in ('1') and
 py in ('1')

Start by splitting the string and iterating:
for el in input.split('#'):

(obviously your variable won't want to be called 'input' but you knew
that already)

Then split on the = sign and add to a list or dictionary. Be wary of
elements that don't have an equals sign in them.

That looks like the querystring straight from the GET form, where
you're using tickboxes. You could quite happily use '' as your
primary delimiter, if that's the case.

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


Re: How to build an application in Django which will handle Multiple servers accross network

2011-05-02 Thread Anurag Agarwal
Hi All,

Thanks for the resposes.

I think I was not able to communicate my problem very well.

Here I am not managing any network devices, what i am doing is getting
some info from various servers on netowrk. I don't know how to explain
what kind of info is needed, but for the time if you just assume that
a driver for windows and linux is already written which has command
line interface too which gets certain info about server. Now the
information returned by this driver software from each server is to be
shown at a common place. For this I am planning a web based
application that can connect to each individual server and get the
info and show it on UI.

For this to happen i need some interface to which my web based
application (to be developed in Django and Python) can connect to each
server in network and call the driver methods on that server to get
the info.

I hope now i am clear with my thoughts. Please mail me back if still I
am not clear.

The solutions I got
1. Using WMI on windows but how it will work on Linux?.
2. Pyro which supports remote objects.
3. Open NMS - it is a java based open source project, we don't have
any expertise in java... I want something that can be integrated with
python and django.
4. ZenOSS - It is for managing some IP based devices on network.. I
don't know how it will help me.


Please give me some ideas on python even it needs some development
effort.

Regards,
Anurag



On Apr 29, 5:21 pm, Adam Tauno Williams awill...@whitemice.org
wrote:
 On Fri, 2011-04-29 at 13:24 +0200, Paul Kölle wrote:
  Am 29.04.2011 12:01, schrieb Adam Tauno Williams:
   3. The web based application will be used internally in the network to
   moniter servers in that network only.
   You mean like OpenNMS or ZenOSS?
   4. Web based application will be a real time application with a
   Database.
   Like OpenNMS or ZenOSS?
  How can they be realtime if they generate static images?

 All images are static regardless of how much they pretend not to be.
 You can refresh as much as you like.  But a graph shows a progression
 over time so there is always an interval.

   5. Technology I am thingking for web based application is Django and
   Python as this web application can also be installed on Windows or
   Linux based OS.
   If you want real-time monitoring you *must* build a service; a 'web app'
   can *not* do that.
  Do you mean an agent?

 No, just use WMI over the wire.  Agents are terrible, hard to develop,
 unreliable, and everyone hates agents.  The systems already provide you
 access to the information you are talking about.

   6. Also please suggest which third party tool for chatrs and graphs I
   should use with Django (open source + paid)
   ZenOSS and OpenNMS do graphs using RRD.
  I know this is the standard but IMO it's totally backward these days.
  Correlating or selecting/deselecting certain values is painful
 (you have to write a graph def)

 How is it painful?  Of course you have to create a graph definition - in
 your case you are creating a graph definition BY WRITING CODE!  There
 couldn't be a more painful way to just create a graph.

 Have you used recent versions of ZenOSS?  Graph definitions can be
 created right in the UI.

  . With canvas and modern JS libs like raphael
  there are better ways to do this. Just look at google analytics.

 I've seen it.  I don't see how it is better.  It's a graph.

  It looks like PCP (http://oss.sgi.com/projects/pcp/features.html) will
  gain a JSON interface shortly. That would be awesome because PCP is
  developed by real engineers and has a proper architecture and is NOT a
  CPU sucking monstrosity of PERL-line-noise + a few hacked-together PHP
  frontends.

 I have no idea where the PERL-line-noise + a few hacked-together PHP
 frontend comment comes from.  RRD is written in C.  OpenNMS is Java and
 ZenOSS is Python/ZOPE.

 And as for CPU sucking monstrosity that is what everyone says... until
 they try to build a monitoring application... and thus create their own
 CPU sucking monstrosity.  This is a case of
 those-who-refuse-to-use-are-doomed-to-reinvent.

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


HI

2011-05-02 Thread anvar
Hello,

Could you please help me with the modeling in Python the following
problem: (e.g., g_t means g with index t)

Min∑_(i=1)^n▒∑_(t=1)^l▒[s_i (t)-min[s ̂_i (t)×α_t×exp(g_t ),C_i
(t) ] ]^2
subject to
s_i (t)=f_i (t)[S_i+f_(i-1) (t)[S_(i-1)+f_(i-2) (t)[S_(i-2)+⋯f_2 (t)
[S_2+f_1 (t) S_1 ]…] ] ][1-f_(i+1) (t)]
f_i (t)=F_i (t)-F_i (t-1)
F_i (t)=(((1-e^(-(X_i (t)-X_i (0) )(p_i+q_i ) )))/(((q_i⁄p_i ) e^(-
(X_i (t)-X_i (0) )(p_i+q_i ) )+1)), if t≥τ_i and F_i (t)=0  if
tτ_i
X_i (t)=(t-τ_i+1)+ln(〖pr〗_i (t)/〖pr〗_i (0))β
α_t≥0,   g_t=const
0p_i1,   0q_i1
S_i0,
∀i=1,2,…,n
Where
s ̂_i (t)=p_i S_i  +(q_i-p_i ) s_i (t-1)-(q_i/S_i ) [s_i (t-1) ]^2,
S_i=μ_i (t)M_i
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: HI

2011-05-02 Thread anvar
Here we need to estimate p_i, q_i, and β.

Thank you,

 Min∑_(i=1)^n▒∑_(t=1)^l▒[s_i (t)-min[s ̂_i (t)×α_t×exp(g_t ),C_i
 (t) ] ]^2
 subject to
 s_i (t)=f_i (t)[S_i+f_(i-1) (t)[S_(i-1)+f_(i-2) (t)[S_(i-2)+⋯f_2 (t)
 [S_2+f_1 (t) S_1 ]…] ] ][1-f_(i+1) (t)]
 f_i (t)=F_i (t)-F_i (t-1)
 F_i (t)=(((1-e^(-(X_i (t)-X_i (0) )(p_i+q_i ) )))/(((q_i⁄p_i ) e^(-
 (X_i (t)-X_i (0) )(p_i+q_i ) )+1)), if t≥τ_i     and F_i (t)=0  if
 tτ_i
 X_i (t)=(t-τ_i+1)+ln(〖pr〗_i (t)/〖pr〗_i (0))β
 α_t≥0,       g_t=const
 0p_i1,               0q_i1
 S_i0,
 ∀i=1,2,…,n
 Where
 s ̂_i (t)=p_i S_i  +(q_i-p_i ) s_i (t-1)-(q_i/S_i ) [s_i (t-1) ]^2,
 S_i=μ_i (t)M_i

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


Re: Fibonacci series recursion error

2011-05-02 Thread rusi
On Apr 30, 12:18 pm, Steven D'Aprano steve
+comp.lang.pyt...@pearwood.info wrote:

 The number of calls is given by a recursive function with a similar form
 as that of Fibonacci. As far as I know, it doesn't have a standard name,
 but I'll call it R(n):

 R(n) = R(n-1) + R(n-2) + 1, where R(0) = R(1) = 1

Changing your definition slightly to the following:

def r(n):
if n==0 or n==1: return 0
else: return r(n-1) + r(n-2) + 1


This r counts the number of times the '+' is done in the original
(naive) fib.

We see it is the same as fib (off by 1)

 [fib(n) for n in range(10)]
[1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
 [r(n) for n in range(10)]
[0, 0, 1, 2, 4, 7, 12, 20, 33, 54]


So it does not need a new name :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compile 32bit C-lib on 64 bit

2011-05-02 Thread Jorgen Grahn
On Sun, 2011-05-01, Hegedüs Ervin wrote:
 Hello,

 this is not a clear Python question - I've wrote a module in C,
 which uses a 3rd-party lib - it's a closed source, I just get the
 .so, .a and a header file.

 Looks like it works on 32bit (on my desktop), but it must be run
 on 64bit servers.


 When I'm compiling it on 64bit, gcc says:

 /usr/bin/ld: skipping incompatible /lib32/lib3rdpartyCrypt.so when searching 
 for -l3rdpartyCrypt

A different angle: if you need to use closed-source, non-standard
crypto, and the suppliers cannot even be bothered to compile it for
the CPU architecture that has been standard for at least 6--7 years,
start planning to replace it *now*.

/Jorgen

-- 
  // Jorgen Grahn grahn@  Oo  o.   .  .
\X/ snipabacken.se   O  o   .
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What other languages use the same data model as Python?

2011-05-02 Thread Duncan Booth
Dennis Lee Bieber wlfr...@ix.netcom.com wrote:

 As I recall from my programming language design class (only and
 intro, it was so small we met in a meeting room rather than classroom),
 ALGOL was described as call by name;

It is true that Algol had 'call by name', but (at least the Algol-W that I 
learned) also supported 'call by value' and 'call by reference'. The danger 
of course was that call by name was the default mechanism so you could end 
up using it accidentally.

I remember we had one class where we had to work out (by hand) the output 
of a program which used call by name to alias I and A[I] in some recursive 
calls. Not nice. Fortunately even at that time it was mostly being taught 
as an oddity; real programming was of course done in Algol 68C or BCPL.

-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fibonacci series recursion error

2011-05-02 Thread Steven D'Aprano
On Mon, 02 May 2011 01:27:39 -0700, rusi wrote:

 On Apr 30, 12:18 pm, Steven D'Aprano steve
 +comp.lang.pyt...@pearwood.info wrote:
 
 The number of calls is given by a recursive function with a similar
 form as that of Fibonacci. As far as I know, it doesn't have a standard
 name, but I'll call it R(n):

 R(n) = R(n-1) + R(n-2) + 1, where R(0) = R(1) = 1
 
 Changing your definition slightly to the following:
 
 def r(n):
 if n==0 or n==1: return 0
 else: return r(n-1) + r(n-2) + 1

Except that's not the same as my R(n). The base cases should be 1, not 
0. That makes rather a big difference to the value: by n = 35, you have 

R(35) = 29860703 
fib(35) = 9227465

or nearly 2.25 times greater. And the difference just keeps getting 
bigger...


 We see it is the same as fib (off by 1)
[...]
 So it does not need a new name :-)

I see your smiley, but there are a number of similar series as Fibonacci, 
with the same recurrence but different starting values, or similar but 
slightly different recurrences. E.g. Lucas, primefree, Pell, Padovan and 
Perrin numbers.

(The fact that most of those start with P is almost certainly a 
coincidence.)



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


Re: Development tools and practices for Pythonistas

2011-05-02 Thread jacek2v
On May 2, 9:48 am, Algis Kabaila akaba...@pcug.org.au wrote:
 On Monday 02 May 2011 17:19:57 rusi wrote:

  On May 2, 12:08 pm, Algis Kabaila akaba...@pcug.org.au
 wrote:
   Actually, Bazaar is more convenient than rcs for a single
   user, as the repository can be the working directory (with
   a hidden .bzr directory that stores diffs).

  Dont exactly understand...
  Is it that you want it specifically hidden?
  Otherwise rcs will look inside an RCS directory just as bzr
  will with .bzr git will with .git and so on.

 Sorry for not being clear - ls will not show directories that
 start with . - in that sense these directories are hidden.  
 They are not really really hidden, as ls  -l will show them.  
 They simply are not in the way and keep the progressive versions
 of the program (in form of diffs).

ls -l will not show directories that start with ..
ls -a will.

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


codec for UTF-8 with BOM

2011-05-02 Thread Ulrich Eckhardt
Hi!

I want to write a file starting with the BOM and using UTF-8, and stumbled 
across some problems:

1. I would have expected one of the codecs to be 'UTF-8 with BOM' or 
something like that, but I can't find the correct name. Also, I can't find a 
way to get a list of the supported codecs at all, which strikes me as odd.


2. I couldn't find a way to write the BOM either. Writing codecs.BOM doesn't 
work, as it is an already encoded byte string. Of course, I can write 
u'\ufeff', but I'd rather avoid such magic numbers in my code.


3. The docs mention encodings.utf_8_sig, available since 2.5, but I can't 
locate that thing there either. What's going on here?


What would you do?

Uli

-- 
Domino Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

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


Re: Deditor

2011-05-02 Thread Alec Taylor
Yes

On Mon, May 2, 2011 at 2:12 AM, Kruptein darragh@gmail.com wrote:
 On 1 mei, 17:50, Alec Taylor alec.tayl...@gmail.com wrote:
 Traceback (most recent call last):
  File O:\deditor\deditor\deditor.py, line 7, in modul
 e
    import wx, os, datetime, sys, ConfigParser, wx.aui, wx.lib.scrolledpanel
  File C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx\__init__.py, 
 line 4
 5, in module
    from wx._core import *
  File C:\Python27\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py, line 
 4, i
 n module
    import _core_
 ImportError: DLL load failed: %1 is not a valid Win32 application.



 On Mon, May 2, 2011 at 12:33 AM, Kruptein darragh@gmail.com wrote:
  On 1 mei, 10:59, Alec Taylor alec.tayl...@gmail.com wrote:
  Maybe I'm missing something, but I downloaded the zip file and ran
  each .py and .pyc file in turn, but none brought up the nicededitor
  GUI I've seen screenshots of...

  On the other subject, did you have a preference to what installer I
  should code for it? - InnoSetup (exe), NSIS (exe) or MSI (.msi)

  not a msi, for the rest it doesn't matter :),  on my windows if you
  rundeditor.py   it should launch however you need to have the
  wxpython-2.8 package installed,   what happens if you rundeditor.py
  from console?
  --
 http://mail.python.org/mailman/listinfo/python-list

 that looks like you have installed the wxpython module wrongly.  Have
 you downloaded the version that matches your python version?
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: codec for UTF-8 with BOM

2011-05-02 Thread Chris Rebert
On Mon, May 2, 2011 at 1:34 AM, Ulrich Eckhardt
ulrich.eckha...@dominolaser.com wrote:
 Hi!

 I want to write a file starting with the BOM and using UTF-8, and stumbled
 across some problems:

 1. I would have expected one of the codecs to be 'UTF-8 with BOM' or
 something like that, but I can't find the correct name. Also, I can't find a
 way to get a list of the supported codecs at all, which strikes me as odd.

If nothing else, there's
http://docs.python.org/library/codecs.html#standard-encodings

The correct name, as you found below and as is corroborated by the
webpage, seems to be utf_8_sig:
 uFOøbar.encode('utf_8_sig')
'\xef\xbb\xbfFO\xc3\xb8bar'

This could definitely be documented more straightforwardly.

snip
 3. The docs mention encodings.utf_8_sig, available since 2.5, but I can't
 locate that thing there either. What's going on here?

Works for me™:
Python 2.6.6 (r266:84292, Jan 12 2011, 13:35:00)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type help, copyright, credits or license for more information.
 from encodings import utf_8_sig


Cheers,
Chris
--
http://rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fibonacci series recursion error

2011-05-02 Thread Hans Georg Schaathun
On 02 May 2011 01:09:21 GMT, Steven D'Aprano
  steve+comp.lang.pyt...@pearwood.info wrote:
:  Ah, I see where you're coming from now! You think I'm arguing *against* 
:  the use of recursion. Not at all. Earlier in this thread, I said:

Fair enough.  Somebody said something about recursion mainly being
a beginner's error.  I don't think it was you, but I felt that your
argument in context mainly served to reinforce such a view, whether
intended or not.

:  Consequently, the naive recursive function is ridiculously slow and 
:  memory-hungry.
: 
:  This seems to have give rise to a myth that recursion should be avoided. 
:  What needs to be avoided is *badly thought out* recursion.

Then we agree.

And badly thought-out iteration is as bad as badly thought-out
recursion.

:  To be honest, I don't know what Python does with local variables. But I 
:  *guess* it uses a constant-sized record which points to the locals, 
:  because that's how I'd do it :)

Maybe, but would it be able to treat specially C API functions with 
a large chunk of stack memory used for local variables?

:  Given a choice between a complicated iterative algorithm and a simple 
:  recursive version, there's no prima facie reason to expect the recursive 
:  version to *necessarily* be slower than iteration in Python *merely* 
:  because it uses recursion. As always, if speed is an issue, profile and 
:  identify the bottlenecks before deciding how to fix them.

Then we are on the same page.

And it is becoming increasingly clear how bizarre this discussion is in 
a python context.  The overhead which may be caused by recursion in
hardware is only one of many sources of overhead which one accepts when 
opting to use python in order to gain other benefits.

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


Re: Fibonacci series recursion error

2011-05-02 Thread Hans Georg Schaathun
On 02 May 2011 08:56:57 GMT, Steven D'Aprano
  steve+comp.lang.pyt...@pearwood.info wrote:
:  I see your smiley, but there are a number of similar series as Fibonacci, 
:  with the same recurrence but different starting values, or similar but 
:  slightly different recurrences. E.g. Lucas, primefree, Pell, Padovan and 
:  Perrin numbers.

Well, Fibonacci isn't one unique sequence.  Any sequence satisfying
f(n) = f(n-1) + f(n-2) is /a/ Fibonacci sequence.  Regardless of 
starting values.  At least according to some authors.

Ian Andersen (A First Course in Combinatorial Mathematics) prefer 
the sequence 1,2,3,5 ...

Cormen, Leiserson, Rivest (Introduction to Algorithms) prefer
0,1,1,2, ... (although they also start the indexing at 0).

Penguin, Dict. of Mathematics prefer 1,1,2,3,5 but they also
suggest 0,1,1,2,3, ...

In short, don't assume that a person talking about Fibonacci
numbers assume the same base cases as you do.

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


Re: codec for UTF-8 with BOM

2011-05-02 Thread John Machin
On Monday, 2 May 2011 19:47:45 UTC+10, Chris Rebert  wrote:
 On Mon, May 2, 2011 at 1:34 AM, Ulrich Eckhardt
 ulrich@dominolaser.com wrote:

 The correct name, as you found below and as is corroborated by the
 webpage, seems to be utf_8_sig:
  uFOøbar.encode('utf_8_sig')
 '\xef\xbb\xbfFO\xc3\xb8bar'

To complete the picture, decoding swallows the BOM:

  '\xef\xbb\xbfFO\xc3\xb8bar'.decode('utf_8_sig')
 u'FO\xf8bar'

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


Re: build the sql where cause dynamic

2011-05-02 Thread christian
On 2 Mai, 10:13, Chris Angelico ros...@gmail.com wrote:
 On Mon, May 2, 2011 at 5:48 PM, christian oz...@web.de wrote:
  Hi,

  from some radio buttons in a django app i concat  string like that:
  But have no idea how i get the or when there different values
  for a specified p column (# is currently my intended splitter maybe i
  can concat a better input?).

  input: p2=1#p2=2#p1=3#p1=1#p1=5#pc=1#py=1

  output: p2 in ('1','2') and p1 in ('3','1','5') and pc in ('1') and
  py in ('1')

 Start by splitting the string and iterating:
 for el in input.split('#'):

 (obviously your variable won't want to be called 'input' but you knew
 that already)

 Then split on the = sign and add to a list or dictionary. Be wary of
 elements that don't have an equals sign in them.

 That looks like the querystring straight from the GET form, where
 you're using tickboxes. You could quite happily use '' as your
 primary delimiter, if that's the case.

 Chris Angelico

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


Re: Development tools and practices for Pythonistas

2011-05-02 Thread Algis Kabaila
On Monday 02 May 2011 19:09:38 jacek2v wrote:
 On May 2, 9:48 am, Algis Kabaila akaba...@pcug.org.au wrote:
  On Monday 02 May 2011 17:19:57 rusi wrote:
   On May 2, 12:08 pm, Algis Kabaila akaba...@pcug.org.au
  
  wrote:
Actually, Bazaar is more convenient than rcs for a
single user, as the repository can be the working
directory (with a hidden .bzr directory that stores
diffs).
   
   Dont exactly understand...
   Is it that you want it specifically hidden?
   Otherwise rcs will look inside an RCS directory just as
   bzr will with .bzr git will with .git and so on.
  
  Sorry for not being clear - ls will not show directories
  that start with . - in that sense these directories are
  hidden. They are not really really hidden, as ls  -l
  will show them. They simply are not in the way and keep
  the progressive versions of the program (in form of
  diffs).
 
 ls -l will not show directories that start with ..
 ls -a will.
 
 Regards
 Jacek

Thanks - you are right - pardon my absent mindedness.

-- 
Algis
http://akabaila.pcug.org.au/StructuralAnalysis.pdf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fibonacci series recursion error

2011-05-02 Thread rusi
On May 2, 2:53 pm, Hans Georg Schaathun h...@schaathun.net wrote:
 On 02 May 2011 08:56:57 GMT, Steven D'Aprano  
 steve+comp.lang.pyt...@pearwood.info wrote:

 :  I see your smiley, but there are a number of similar series as Fibonacci,
 :  with the same recurrence but different starting values, or similar but
 :  slightly different recurrences. E.g. Lucas, primefree, Pell, Padovan and
 :  Perrin numbers.

 Well, Fibonacci isn't one unique sequence.  Any sequence satisfying
 f(n) = f(n-1) + f(n-2) is /a/ Fibonacci sequence.  Regardless of
 starting values.  At least according to some authors.

And they all will, when expressed in closed form, be of the form
f(n) = phi^n + something of a smaller order
where phi = (1 + sqrt(5))/2

Since phi  1 they are exponential, ignoring lower order terms.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: codec for UTF-8 with BOM

2011-05-02 Thread Ulrich Eckhardt
Chris Rebert wrote:
 3. The docs mention encodings.utf_8_sig, available since 2.5, but I can't
 locate that thing there either. What's going on here?
 
 Works for me™:
 Python 2.6.6 (r266:84292, Jan 12 2011, 13:35:00)
 [GCC 4.2.1 (Apple Inc. build 5664)] on darwin
 Type help, copyright, credits or license for more information.
 from encodings import utf_8_sig


This works for me, too. What I tried and what failed was

  import encodings
  encodings.utf_8_sig

which raises an AttributeError or dir(encodings), which doesn't show the 
according element. If I do it your way, the encoding then shows up in the 
content of the module.

Apart from the encoding issue, I don't understand this behaviour. Is the 
module behaving badly or are my expectations simply flawed?


Thanks!

Uli

-- 
Domino Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

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


Re: HI

2011-05-02 Thread Ulrich Eckhardt
anvar wrote:
 Could you please help me with the modeling in Python the following
 problem: (e.g., g_t means g with index t)

Typically, you would use either a list or a dict to simulate something like 
that:

  # list
  g = [1, 2, 4, 8, 16]
  print g[3]

  # dictionary
  h = {}
  h[0] = 1
  h[1] = 2
  h[2] = 4
  h[3] = 8
  h[4] = 16
  print h[3]

The difference is that a list needs elements starting at index 0 and without 
any gaps, while a dictionary can contain holes. Please refer to any 
beginners' Python tutorial for info on these types.

Concerning the other formulas you posted, those ended up as completely 
illegible here for the complete lack of formatting. Explaining things in 
plain English along with the mathematics would be a good idea, IMHO.


Good luck!


Uli

-- 
Domino Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

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


Re: codec for UTF-8 with BOM

2011-05-02 Thread Peter Otten
Ulrich Eckhardt wrote:

 Chris Rebert wrote:
 3. The docs mention encodings.utf_8_sig, available since 2.5, but I
 can't locate that thing there either. What's going on here?
 
 Works for me™:
 Python 2.6.6 (r266:84292, Jan 12 2011, 13:35:00)
 [GCC 4.2.1 (Apple Inc. build 5664)] on darwin
 Type help, copyright, credits or license for more information.
 from encodings import utf_8_sig

 
 This works for me, too. What I tried and what failed was
 
   import encodings
   encodings.utf_8_sig
 
 which raises an AttributeError or dir(encodings), which doesn't show the
 according element. If I do it your way, the encoding then shows up in the
 content of the module.
 
 Apart from the encoding issue, I don't understand this behaviour. Is the
 module behaving badly or are my expectations simply flawed?

This is standard python package behaviour:

 import logging
 logging.handlers
Traceback (most recent call last):
  File stdin, line 1, in module
AttributeError: 'module' object has no attribute 'handlers'
 import logging.handlers
 logging.handlers
module 'logging.handlers' from '/usr/lib/python2.6/logging/handlers.pyc'

You wouldn't see the AttributeError only if encodings/__init__.py contained 
a line

from . import utf_8_sig

or similar. The most notable package that acts this way is probably os which 
eagerly imports a suitable path module depending on the platform.

As you cannot foresee which encodings are actually needed in a script it 
makes sense to omit a just-in-case import.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fibonacci series recursion error (slightly OT)

2011-05-02 Thread Dave Angel

On 01/-10/-28163 02:59 PM, Chris Angelico wrote:

On Mon, May 2, 2011 at 3:36 PM, Hans Georg Schaathunh...@schaathun.net  wrote:

On Mon, 2 May 2011 06:49:41 +1000, Chris Angelico
  ros...@gmail.com  wrote:
:  Sure. Serialize this Python object in a way that can be given to, say, PHP:
:  foo=asdf:qwer,zxcv:1234}; foo[self]=[1,2,3,foo]

Wouldn't cyclic references give infinite recursion?  And remain
infinitive if you recode it iteratively?


Well, I don't know of a decent non-recursive way to process a
recursive structure. Incidentally, this example is almost directly
from some working code of ours; I have a C function that recurses over
a Python dictionary and aborts as soon as it's found too much data
(for a fairly arbitrary definition of too much, but one that's
deliberately designed to prevent infinite recursion).
snip

Chris Angelico



When iterating over a repeatable, potentially infinite sequence of 
distinguishable values, you can safely detect infinitude ;-)  (cycles) 
with a linear overhead (rather than n-squared).


Given a sequence, create two iterators for it.  Start them both at the 
same point, but iterate the second one twice for every time you iterate 
the first one.  If the two ever get the same value, you have a cycle.


In the case of Python objects, you probably want to use an 'is' 
comparison, rather than comparing id() for equal.  But the concept 
works, and easily.


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


Re: HI

2011-05-02 Thread Jean-Michel Pichavant

anvar wrote:

Hello,

Could you please help me with the modeling in Python the following
problem: (e.g., g_t means g with index t)

Min∑_(i=1)^n▒∑_(t=1)^l▒[s_i (t)-min[s ̂_i (t)×α_t×exp(g_t ),C_i
(t) ] ]^2
subject to
s_i (t)=f_i (t)[S_i+f_(i-1) (t)[S_(i-1)+f_(i-2) (t)[S_(i-2)+⋯f_2 (t)
[S_2+f_1 (t) S_1 ]…] ] ][1-f_(i+1) (t)]
f_i (t)=F_i (t)-F_i (t-1)
F_i (t)=(((1-e^(-(X_i (t)-X_i (0) )(p_i+q_i ) )))/(((q_i⁄p_i ) e^(-
(X_i (t)-X_i (0) )(p_i+q_i ) )+1)), if t≥τ_i and F_i (t)=0  if
tτ_i
X_i (t)=(t-τ_i+1)+ln(〖pr〗_i (t)/〖pr〗_i (0))β
α_t≥0,   g_t=const
0p_i1,   0q_i1
S_i0,
∀i=1,2,…,n
Where
s ̂_i (t)=p_i S_i  +(q_i-p_i ) s_i (t-1)-(q_i/S_i ) [s_i (t-1) ]^2,
S_i=μ_i (t)M_i
  

Hi,

Nice joke.

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


Re: What other languages use the same data model as Python?

2011-05-02 Thread Grant Edwards
On 2011-05-02, Jorgen Grahn grahn+n...@snipabacken.se wrote:
 On Sun, 2011-05-01, Terry Reedy wrote:
 On 5/1/2011 4:45 AM, Steven D'Aprano wrote:
 ...
 What other languages use the same, or mostly similar, data model as
 Python?

 Natural languages. That is why I think it is better to think of Python 
 as an algorithm language or information-object manipulation language 
 rather than as just a linear-memory machine language.A linear memory 
 with bytes addressed from 0 to max-int or max-long is an explicit part 
 of the definition of assembly languages and C. It is no part of the 
 definition of Python.

 It's not part of the definition of C either -- C supports segmented
 memory (pre-386 Intel) and separate code/data address spaces. (Even if
 most C users tend not to think of it that way.)

Indeed.  All the C compilers I used for many years (on both PDP-11 and
80286 under Unix) assumed a segmented memory space with separate data
and text addresses spaces.  More recently, the same can be said for
AVR and many other Harvard architecture machines.

The linear memory with bytes addressed from 0 to max-int or max-long
thing is merely an implicit assumption made by bad C programmers.

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


Re: HI

2011-05-02 Thread anvar
Dear Ulrich Eckhardt and Jean-Michel Pichavant!

First of all thank you for your attention. I'have never expected to
receive response.

Actually, I am doing my internship in Marketing Division in small
company., I got this assignment yesterday morning. My boss wants
perfect technology diffusion based forecasting model. I found the
required model, modified it..but cannot solve it (university friend
suggested Python because it had special tools for optimization). I
will appreciate if you help me to find right tools and give some more
advises.

Thank you for your precious time.

As to problem, I should use nonlinear least-square estimation
methodology (to estimate p_i, q_i, and β parameters) where the
objective of the estimation procedure is minimization of the sum of
squared error. Here in problem:
F_i (t) the cumulative density function at time t for technology
generation i
f_i (t) the probability density function at time t for technology
generation i
p_i the proportion of mass media communication for generation i
q_i the proportion of word of mouth for generation i
μ_i (t) the market share at time t for generation i  (data exists)
M_i total market potential for generation i,   (data exists)
S_i total sales potential for generation i, S_i=μ_i (t)M_i
τ_i the introduction time for generation i, τ_i≥1  (data exists)
s_i (t) the actual sales of products at time t for generation
i  (data exists)
s ̂_i (t) the estimated sales of products at time t for generation i
X_i (t) the cumulative market effects
β   the effectiveness of the price
〖pr〗_i (t)  the price at time t for generation i  (data exists)
α_t the seasonal factor at time t (data exists)
g_t the growth rate at time t   (data exists)
n   the number of generations (data exists)
l   the number of periods  (data exists)
C_i (t) the capacity restriction regarding the product at time t for
generation i (data exists)

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


Re: Fibonacci series recursion error

2011-05-02 Thread Hans Georg Schaathun
On Sun, 01 May 2011 18:24:30 -0400, Terry Reedy
  tjre...@udel.edu wrote:
:  This does not make linear recursion 'bad', just impractical for general 
:  use on finite-memory machines. While I consider it very useful for 
:  learning, it is unnecessary because it is easy to write an iterative 
:  version. So called tail-recursion optimization saves memory by REMOVING 
:  RECURSION and replacing it with iteration.
: (...)
:  Python does not do this automatically because 1) it can be a semantic 
:  change under some circumstances; 2) one who wants the iterative version 
:  can just as easily write it directly;

That's the silliest argument I ever heard.  The programmer should write
the code the way he and application domain experts think, i.e. very
often recursively.  The compiler should generate code the way the CPU
thinks (most optimally), i.e. iteratively.

Of course, I am not saying that one should always model problems
recursively, and thus also not that one should implement them
recursively.  Just that when a model is agreed recursively between
the stakeholders, one should get a compiler to do the optimisation,
not a programmer.

I always thought of python as a step forward, in the way it allows 
direct expression of so many alternative modes of thinking (imperative,
functional, recursion, iterators, etc).  If what you say is python
philosophy, it is a step backward in requiring the programmer to
think more about low-level technical matters which even C has managed
to leave for the compiler.

:and 3) Python has a better way to 
:  process collections that removes essentially all the boilerplate in the 
:  recursive-call and while-loop versions:


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


Development software

2011-05-02 Thread Petey
Hi!

I'm new to programming. I started with php earlier and I dropped it for Python.
I use Eclipse+PyDev for python, html and css.

Which programmes should I start using because they might be useful in the 
future? Which functions of eclipse are useful but unused/unnoticed by beginners.

What do you use and why :) ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python competitions and learnings

2011-05-02 Thread Alexander Lyabah
On May 1, 7:22 pm, Alexander Lyabah alexan...@lyabah.com wrote:
 On May 1, 3:26 am, harrismh777 harrismh...@charter.net wrote:









  Alexander Lyabah wrote:
   What do you think about it?

   I'm also have a not a very good English, so I need help with it too,

  Alexander, your site is very interesting. I spent some time this
  afternoon appreciating your work. Nice job.

  Be encouraged, your English is much better than my Russian! I also
  looked over the orphanage site and I appreciate how much you are doing
  there in Ukraine for the children. Keep up the good work.

  I too am a little disappointed that Python3 is not being used. I want to
  encourage you to work in that direction as well. I may have some time to
  volunteer to checkio.org; for help with the English, and maybe with some
  help as a tester. We'll see... I have a lot of my own fish to fry here,
  as we say in America.

  Blessings on your work, friend.

  m harris

 I spend a lot of time to make a almost full support of python 2.7 from
 sandbox.

 If somebody help me this sandboxed python 3.* i will add support of it
 on checkio.org with big pleasure.

Notice about the python 2.7 on main page was added.
thanks for advice
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fibonacci series recursion error

2011-05-02 Thread Steven D'Aprano
On Mon, 02 May 2011 10:53:52 +0100, Hans Georg Schaathun wrote:

 On 02 May 2011 08:56:57 GMT, Steven D'Aprano
   steve+comp.lang.pyt...@pearwood.info wrote:
 :  I see your smiley, but there are a number of similar series as
 Fibonacci, :  with the same recurrence but different starting values, or
 similar but :  slightly different recurrences. E.g. Lucas, primefree,
 Pell, Padovan and :  Perrin numbers.
 
 Well, Fibonacci isn't one unique sequence.  Any sequence satisfying f(n)
 = f(n-1) + f(n-2) is /a/ Fibonacci sequence.  Regardless of starting
 values.  At least according to some authors.

According to the references I have, there is one and only one Fibonacci 
sequence, the usual one invented by Fibonacci to talk about rabbits. 
(Actually, we should talk about Fibonacci *numbers*, rather than 
sequence.)

Wolfram Mathworld is typical, defining *the* Fibonacci numbers as those 
with starting conditions f(1)=1, f(2)=1 (or f(0)=0 if you prefer).

http://mathworld.wolfram.com/FibonacciNumber.html

The Collins Dictionary of Mathematics agrees with Mathworld.

The Lucas numbers (related to, but not the same as, the Lucas sequence) 
obey the same recurrence as the Fibonacci numbers, but with a different 
set of starting values. So there is certainly precedent in the 
mathematical literature for giving different names to the same recurrence 
with different starting values.

In any case, whatever you call them, what I call R(n) is not one, as the 
recurrence is different:

R(n) = R(n-1) + R(n-2) + 1


 Penguin, Dict. of Mathematics prefer 1,1,2,3,5 but they also suggest
 0,1,1,2,3, ...

This depends on whether you start counting from n=0 or n=1.

Even the sequence you quote, from Anderson: 

1,2,3,5...

is just the usual Fibonacci numbers starting at n=2 instead of 1 or 0. 
(No matter how confusing something is, there's always at least one person 
who will try to make it *more* confusing.)


 In short, don't assume that a person talking about Fibonacci numbers
 assume the same base cases as you do.

As far as I'm concerned, there are only two definitions of Fibonacci 
numbers that have widespread agreement in the mathematical community:

0,1,1,2,3 ... (starting from n=0)
1,1,2,3,5 ... (starting from n=1)

Any other definition is rather, shall we say, idiosyncratic.



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


Re: Python competitions and learnings

2011-05-02 Thread Alexander Lyabah
On May 2, 1:33 am, Terry Reedy tjre...@udel.edu wrote:
 On 5/1/2011 12:49 PM, Alexander Lyabah wrote:

  And what do you think about Score Games and competitions?

 The rules of the first score game were not clear to me. I could not
 figure out how to play it interactively myself so I could see how it
 actually played.

 --
 Terry Jan Reedy

I will add a more detail information how competitions and score games
goes.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fibonacci series recursion error

2011-05-02 Thread Steven D'Aprano
On Mon, 02 May 2011 14:14:20 +0100, Hans Georg Schaathun wrote:

 On Sun, 01 May 2011 18:24:30 -0400, Terry Reedy
   tjre...@udel.edu wrote:
 :  This does not make linear recursion 'bad', just impractical for
 general :  use on finite-memory machines. While I consider it very
 useful for :  learning, it is unnecessary because it is easy to write an
 iterative :  version. So called tail-recursion optimization saves memory
 by REMOVING :  RECURSION and replacing it with iteration. : (...)
 :  Python does not do this automatically because 1) it can be a semantic
 :  change under some circumstances; 2) one who wants the iterative
 version :  can just as easily write it directly;
 
 That's the silliest argument I ever heard.

You must be new to the Internet then :)


 The programmer should write
 the code the way he and application domain experts think, i.e. very
 often recursively.  The compiler should generate code the way the CPU
 thinks (most optimally), i.e. iteratively.

Perhaps so, but there can be a huge gulf between what should happen and 
what does happen. The CPython implementation is deliberately a naive, not-
very clever compiler. (PyPy seems to be the implementation aiming at 
cutting-edge cleverness.)

Even such simple optimizations as constant folding are very controversial 
among the CPython developers. They have good reasons for their caution: 
optimizing compilers are renowned for breaking code, especially floating 
point code, and there have been cases in Python's history where 
optimizations have broken existing code and needed to be backed out.

The problem is, once you include side-effects, recursion and iteration 
are *not* identical. Specifically, the opposition to tail-recursion 
optimization in Python is that it plays havoc with the tracebacks you get 
in the event of an exception. The argument goes:

* Debugging is harder than writing code in the first place, so it is more 
important to simplify debugging, even at the cost of making some code 
slightly harder to write.

* Recursion doesn't just mean simple recursion where a function calls 
itself, but mutually recursive functions. You could have (say) five 
functions that mutually called each other recursively, and in the event 
of a traceback you need to see the exact calling chain, but that's 
precisely the information that is blown away by tail-recursion 
optimization.

* Tail-recursion is only a special case of recursion, and not a very 
common special case either, so it is hardly worth the extra complexity of 
the compiler to treat it specially.

Regardless of whether you agree with the arguments or not, they're hardly 
silly.


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


setup.py rebuilds EVERYTHING on windows?

2011-05-02 Thread Mathew
Hi
I'm trying to build an extension (spice-0.12) on windows. Whenever I change 
a single file, everything gets rebuilt.

??

Python2.7.1
Windows XP Visual Studio 9
setuptools 0.6c11

-Mathew 


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


Re: Composition instead of inheritance

2011-05-02 Thread Alan Meyer

On 4/28/2011 1:15 PM, Ethan Furman wrote:

For anybody interested in composition instead of multiple inheritance, I
have posted this recipe on ActiveState (for python 2.6/7, not 3.x):

http://code.activestate.com/recipes/577658-composition-of-classes-instead-of-multiple-inherit/


Comments welcome!

~Ethan~


That looks pretty clever.  I tried adding this method to Spam:

def test_eggs_02(self):
print('testing eggs_02 from spam')

and it did just what we wanted.

I'm going to have to study this one.

Thanks.

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


Coolest Python recipe of all time

2011-05-02 Thread Raymond Hettinger
I think it is time to give some visibility to some of the instructive
and very cool recipes in ActiveState's python cookbook.

My vote for the coolest recipe of all time is:


http://code.activestate.com/recipes/365013-linear-equations-solver-in-3-lines/

What are your favorites?


Raymond
twitter: @raymondh
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: setup.py rebuilds EVERYTHING on windows?

2011-05-02 Thread Stefan Behnel

Mathew, 02.05.2011 18:45:

I'm trying to build an extension (spice-0.12) on windows. Whenever I change
a single file, everything gets rebuilt.


Did you report this to the authors? I suppose there's a project mailing list?

Stefan

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


Re: Development tools and practices for Pythonistas

2011-05-02 Thread Dietmar Schwertberger

Am 02.05.2011 01:33, schrieb David Boddie:

After noting the warnings it contains, see the following page for a
description of the Python API for Mercurial:

   http://mercurial.selenic.com/wiki/MercurialApi

Ah, yes, no need to use os.sytem(), but all in all not much difference
from doing so (and usage of CLI is recommended instead of using the
API).
I had a look at this page in 2009 and came to the conclusion that it's
no good idea to use Mercurial as library. Seems that this still holds
true.


Git also has a Python API, which is fairly reasonable to use, though a bit
different to the Mercurial one:

   http://www.samba.org/~jelmer/dulwich/

That looks more promising to me.
I think I will try this and Bazaar to find which fits my needs better.


Regards,

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


Re: Running a script with command line arguments

2011-05-02 Thread MRAB

 Hi,
 I'm new to python and trying to run a borrowed script. The error I
 get suggests that I need to give a proper command to run it. The
 input file is c26_1plus.csv and the intended output file is
 c26_1plus_backbone.csv.

 Can anyone help?

The usage string in the script says that the required arguments are:

input_file output_file backbone_alpha [file delimiter]

You're providing input_file and output_file but not backbone_alpha.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fibonacci series recursion error

2011-05-02 Thread Terry Reedy

On 5/2/2011 9:14 AM, Hans Georg Schaathun wrote:

On Sun, 01 May 2011 18:24:30 -0400, Terry Reedy



:  Python does not do this automatically because 1) it can be a semantic
:  change under some circumstances; 2) one who wants the iterative version
:  can just as easily write it directly;

That's the silliest argument I ever heard.


Calling something silly when you have not really read it and perhaps 
asked questions to really understand it is, to me, silly.


If you want a compiler that can introduce bugs into your program by 
doing what it thinks you meant, rather than what you said, don't use 
CPython.



:and 3) Python has a better way to
:  process collections that removes essentially all the boilerplate in the
:  recursive-call and while-loop versions:


To properly use modern Python, one should know and use for loops and 
iterators.


--
Terry Jan Reedy

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


Re: ctypes and twain_32.dll

2011-05-02 Thread Michel Claveau - MVP
Hi!

On my system, thera are not twain32.dll or twain_32.dll, but twain.dll

@+
--
Michel Claveau 

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


raise (type, value, traceback) and raise type, value, traceback

2011-05-02 Thread Jack Bates
Hi, anyone know why these two statements aren't equivalent?

raise (type, value, traceback)

raise type, value, traceback
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: raise (type, value, traceback) and raise type, value, traceback

2011-05-02 Thread Ian Kelly
On Mon, May 2, 2011 at 11:23 AM, Jack Bates ms...@freezone.co.uk wrote:
 Hi, anyone know why these two statements aren't equivalent?

 raise (type, value, traceback)

 raise type, value, traceback

The latter is the syntax of the raise statement: up to 3 expressions,
separated by commas.

The former has a single expression that evaluates to a tuple.  It's
equivalent to this:

t = (type, value, traceback)
raise t

That it accepts the tuple and raises a value-less expression of type
`type` surprises me.  The docs don't say anything about this, and I
would have expected a TypeError, but it appears to be extracting the
first element of the tuple and using that as the value of the first
expression.
-- 
http://mail.python.org/mailman/listinfo/python-list


Pushing for Pythoncard 1.0

2011-05-02 Thread John Henry
Attempt to push Pythoncard to a 1.0 status is now underway.  A
temporary website has been created at:

http://code.google.com/p/pythoncard-1-0/

The official website continues to be http://pythoncard.sourceforge.net/

Pythoncard is such a wonderful package that it would be a shame to
allow development for the package to go stagnant.   The Python
community deserves to continue enjoying the simplicity of Pythoncard
for creating a GUI Python application.

In the last few years, I've added a number of widgets and functions to
the package.  The present effort is to simply incorporate all of the
changes I've made to the package, create an installer, push it out the
door and announce to the world that Pythoncard 1.0 is here, and is
here to stay.

Here's a partial list of widgets and functions added:

Widgets:

PDFWindow, FlashWindow, MatplotlibCanvasWindow, MultiSelectionList,
Drag--drop enabled tree control, IEHTMLWindow

Backgrounds:

MDIParentWindow, MDIChildWindow, MDISashWindow, multi-panel Background
Window,

Tools:

Updated layoutmanager supporting the newly added widgets, and a
revived action manager (provide list of actions or events associated
with widgets in a context-sensitive fashion - no more needs to
memorize which widget can do what).

and others.

I realize that there are other GUI packages that enjoyed far more
support from the Python community in the last few years and have, as a
result, a more extensive feature list, and more modern looks.  My hats
off to those developers.  So, please re-frame from responding to this
message or send me emails regarding xyz package and how that one is
better, more modern than Pythoncard, or that xyz package had xxx
feature already.

I like Pythoncard because it's so simple for most GUI applications I
build that it's almost laughable.  I've benefited tremendously from
having Pythoncard around and now it's my turn to chip in and repay a
small debt to Pythoncard.

For x-Pythoncard users (and particularly developers), if you are
unable to lend a helping hand, please at least join or re-join the
Pythoncard mailing list and let your voice be heard.



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


Re: Fibonacci series recursion error

2011-05-02 Thread Hans Georg Schaathun
On 02 May 2011 16:41:37 GMT, Steven D'Aprano
  steve+comp.lang.pyt...@pearwood.info wrote:
:  You must be new to the Internet then :)

OK.  Maybe I heard something worse last time I was an active news users,
years ago.

Anyway, most of the silly things I hear do not qualify as arguments :-)

:  The problem is, once you include side-effects, recursion and iteration 
:  are *not* identical. Specifically, the opposition to tail-recursion 
:  optimization in Python is that it plays havoc with the tracebacks you get 
:  in the event of an exception. The argument goes:

Thanks for the comprehensive background.  I can see the point that
python may be harder to optimise correctly during compilation than
many other languages.

:  Regardless of whether you agree with the arguments or not, they're hardly 
:  silly.

I only called one argument silly, namely the one about iterative 
rewriting being so simple that it is not an issue.  Sometimes it isn't,
but sometimes it is.

The other arguments are valid.  And they make me lean more towards
more static, compiled languages without the excessive run-time 
dynamism of python.

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


Re: Coolest Python recipe of all time

2011-05-02 Thread David Monaghan
On Mon, 2 May 2011 10:33:31 -0700 (PDT), Raymond Hettinger pyt...@rcn.com
wrote:

I think it is time to give some visibility to some of the instructive
and very cool recipes in ActiveState's python cookbook.

My vote for the coolest recipe of all time is:


 http://code.activestate.com/recipes/365013-linear-equations-solver-in-3-lines/

Really cool, but wrong. x = 3234.667, not 3236.0

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


Re: Coolest Python recipe of all time

2011-05-02 Thread Ian Kelly
On Mon, May 2, 2011 at 2:48 PM, David Monaghan
monaghand.da...@gmail.com wrote:
 On Mon, 2 May 2011 10:33:31 -0700 (PDT), Raymond Hettinger pyt...@rcn.com
 wrote:

I think it is time to give some visibility to some of the instructive
and very cool recipes in ActiveState's python cookbook.

My vote for the coolest recipe of all time is:

    
 http://code.activestate.com/recipes/365013-linear-equations-solver-in-3-lines/

 Really cool, but wrong. x = 3234.667, not 3236.0

Nope, I get 3236.  Maybe you made a mistake somewhere.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fibonacci series recursion error

2011-05-02 Thread Mark Dickinson
On May 2, 5:24 pm, Steven D'Aprano steve
+comp.lang.pyt...@pearwood.info wrote:

 As far as I'm concerned, there are only two definitions of Fibonacci
 numbers that have widespread agreement in the mathematical community:

 0,1,1,2,3 ... (starting from n=0)
 1,1,2,3,5 ... (starting from n=1)

 Any other definition is rather, shall we say, idiosyncratic.

And a concrete reason for preferring the above definition (in either
form) is that divisibility properties of the sequence are much neater
with this choice:

gcd(F_m, F_n) = F_{gcd(m, n)}

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


Re: Coolest Python recipe of all time

2011-05-02 Thread David Monaghan
On Mon, 2 May 2011 14:58:50 -0600, Ian Kelly ian.g.ke...@gmail.com wrote:

On Mon, May 2, 2011 at 2:48 PM, David Monaghan
monaghand.da...@gmail.com wrote:
 On Mon, 2 May 2011 10:33:31 -0700 (PDT), Raymond Hettinger pyt...@rcn.com
 wrote:

I think it is time to give some visibility to some of the instructive
and very cool recipes in ActiveState's python cookbook.

My vote for the coolest recipe of all time is:

    
 http://code.activestate.com/recipes/365013-linear-equations-solver-in-3-lines/

 Really cool, but wrong. x = 3234.667, not 3236.0

Nope, I get 3236.  Maybe you made a mistake somewhere.

Oops. What a plonker .Three times I checked and got the same result each
time. Now it works fine. Sorry!

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


Re: Fibonacci series recursion error

2011-05-02 Thread harrismh777

Thomas Rachel wrote:

... because each recursion level 'return' calls fib() twice, and each of
those calls fib() twice, and you get the point...


yes - but they are called one after the other, so the twice call
counts only for execution speed, not for recursion depth.

 def fib(n):
 if n == 1:
 return(n)
 else:
 return (fib(n-1)+fib(n-2))

They *are not* called one after the other in the sense that there is 
ever only one level of recursion with each call (not at all). Take a 
closer look. Each call to fib() forces a double head, and each of those 
forces another double head (now four), and so on...  the recursion depth 
exception of the OP testifies against your theory.


The thing about this problem that puzzles me, is why we might consider 
recursion for a possible solution in the first place. In other words, 
normally we consider using recursion when we need information further 
down the stack then we have now... so that recursion is necessary 
because each head call will not have the information it needs for 
completion until the tail clean-up (coming back up the stack) provides 
that information.


In the case of the fib() numbers (or the fib sequence) recursion is not 
necessary for correctly handling of the problem. The simple 
straight-forward obvious way to handle the problem is to calculate the 
sequence outright in a straight-forward way. On the other hand, Otten's 
use of yield (making a generator) makes some sense too, in the case that 
we want to get the fib numbers over time without taking the time to 
calculate the entire sequence up-front.

Just saying...

kind regards,
m harris

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


Re: Fibonacci series recursion error

2011-05-02 Thread Chris Angelico
On Mon, May 2, 2011 at 11:14 PM, Hans Georg Schaathun h...@schaathun.net 
wrote:
 That's the silliest argument I ever heard.  The programmer should write
 the code the way he and application domain experts think, i.e. very
 often recursively.  The compiler should generate code the way the CPU
 thinks (most optimally), i.e. iteratively.

The CPU can function iteratively or recursively. The main difference
between the programmer and the CPU there is that the CPU is always
imperative, while a programmer might want to think functionally, or in
an event-driven model, and then under the covers the compiler
translates that into imperative code.

But in my opinion, the programmer and the interpreter/compiler are
teammates. If you allow programmers to be stupid, you will get a lot
of stupid programmers writing code. (I think that's one of PHP's
biggest downsides.) If the human and the machine know each other well
enough, the resulting code can be orders of magnitude more efficient
to run, *without taking any more tme to code* because the programmer
already knew the right things to do.

Perhaps it will take you four hours to read through something, study
it, maybe eyeball the compiler's source code, maybe do some
disassembly. If you have a few years of career ahead of you, you'll
benefit many times over from those few hours, and without spending
extra time, you'll produce better code. THAT is what distinguishes the
master from the novice.

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


(beginner question) ConfigParser nuances

2011-05-02 Thread Unknown Moss
Hi - Beginner question here. I'm working with ConfigParser. I'd like
to take a multiline variable and convert it directly to an array.
Seems like a common  problem, but I don't see how I can do it without
doing a little parsing in my own code. Here's what I'm doing ...

 import ConfigParser
 import io
 sample = 
... [Example]
... fruit = apple
... orange
... pear
... 
 config = ConfigParser.RawConfigParser()
 config.readfp(io.BytesIO(sample))
 config.get(Example, fruit)
'apple\norange\npear'
 temp = config.get(Example, fruit)
 temp.split()
['apple', 'orange', 'pear']

I'm thinking there's a way to avoid this intermediate temp.split()
step. Is there not a way to move a multiline value straight into an
array using ConfigParser?

Thanks for the help.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fibonacci series recursion error

2011-05-02 Thread Chris Angelico
On Tue, May 3, 2011 at 7:50 AM, harrismh777 harrismh...@charter.net wrote:
 They *are not* called one after the other in the sense that there is ever
 only one level of recursion with each call (not at all). Take a closer look.
 Each call to fib() forces a double head, and each of those forces another
 double head (now four), and so on...  the recursion depth exception of the
 OP testifies against your theory.

def fib(n):
if n==1:
return n
return fib(n-1)+fib(n-2)


dis.dis(fib)
  2   0 LOAD_FAST0 (n)
  3 LOAD_CONST   1 (1)
  6 COMPARE_OP   2 (==)
  9 JUMP_IF_FALSE5 (to 17)
 12 POP_TOP

  3  13 LOAD_FAST0 (n)
 16 RETURN_VALUE
   17 POP_TOP

  4  18 LOAD_GLOBAL  0 (fib)
 21 LOAD_FAST0 (n)
 24 LOAD_CONST   1 (1)
 27 BINARY_SUBTRACT
 28 CALL_FUNCTION1
 31 LOAD_GLOBAL  0 (fib)
 34 LOAD_FAST0 (n)
 37 LOAD_CONST   2 (2)
 40 BINARY_SUBTRACT
 41 CALL_FUNCTION1
 44 BINARY_ADD
 45 RETURN_VALUE

The recursion is in the last block. Note that it calls a function,
then keeps going. It doesn't fork. There are two CALL_FUNCTION
opcodes, called *sequentially*. In terms of the call stack, there is
only ever one of those two calls active at any given time. Also, as
earlier pointed out, the reason for the stack overflow is that fib(2)
will call fib(1) and fib(0), and fib(0) will call fib(-1) and fib(-2),
etc. Changing the operator from == to = in the conditional return
will solve this.

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


Re: (beginner question) ConfigParser nuances

2011-05-02 Thread Chris Rebert
On Mon, May 2, 2011 at 3:04 PM, Unknown Moss unknownm...@gmail.com wrote:
 Hi - Beginner question here. I'm working with ConfigParser. I'd like
 to take a multiline variable and convert it directly to an array.
 Seems like a common  problem, but I don't see how I can do it without
 doing a little parsing in my own code. Here's what I'm doing ...

 import ConfigParser
 import io
 sample = 
 ... [Example]
 ... fruit = apple
 ...     orange
 ...     pear
 ... 
 config = ConfigParser.RawConfigParser()
 config.readfp(io.BytesIO(sample))
 config.get(Example, fruit)
 'apple\norange\npear'
 temp = config.get(Example, fruit)
 temp.split()
 ['apple', 'orange', 'pear']

 I'm thinking there's a way to avoid this intermediate temp.split()
 step. Is there not a way to move a multiline value straight into an
 array using ConfigParser?

Nope, there is not. I think some might instead use several numbered
options to similar effect:

# config file
[Example]
fruit1: apple
fruit2: orange
fruit3: pear

# Python
from itertools import count
fruits = []
names = (fruit + str(i) for i in count(1))
for name in names:
if not config.has_option(Example, name):
break
fruits.append(config.get(Example, name))


Cheers,
Chris
--
http://rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fibonacci series recursion error

2011-05-02 Thread Ian Kelly
On Mon, May 2, 2011 at 3:50 PM, harrismh777 harrismh...@charter.net wrote:
 Thomas Rachel wrote:

 ... because each recursion level 'return' calls fib() twice, and each of
 those calls fib() twice, and you get the point...

 yes - but they are called one after the other, so the twice call
 counts only for execution speed, not for recursion depth.

 def fib(n):
     if n == 1:
         return(n)
     else:
         return (fib(n-1)+fib(n-2))

 They *are not* called one after the other in the sense that there is ever
 only one level of recursion with each call (not at all). Take a closer look.
 Each call to fib() forces a double head, and each of those forces another
 double head (now four), and so on...

The branching factor has nothing to do with the maximum stack depth.
If you don't believe me, consider this little script:

import inspect
def maxstack(n):
if n = 0:
return len(inspect.stack())
else:
return max(maxstack(n-1), maxstack(n-2))
print maxstack(15)

This prints 17.

Now consider this script, which is similar but singly-recursive:

import inspect
def maxstack(n):
if n = 0:
return len(inspect.stack())
else:
return maxstack(n-1)
print maxstack(15)

This also prints 17.  Note: they're the same.

  the recursion depth exception of the
 OP testifies against your theory.

The OP's recursion depth exception was because a malformed base case
made the recursion infinite.  It had nothing to do with the branching
factor.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fibonacci series recursion error

2011-05-02 Thread Chris Angelico
On Tue, May 3, 2011 at 8:22 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
 They *are not* called one after the other in the sense that there is ever
 only one level of recursion with each call (not at all). Take a closer look.
 Each call to fib() forces a double head, and each of those forces another
 double head (now four), and so on...

 The branching factor has nothing to do with the maximum stack depth.


Side point: In a massively parallel environment, branching like this
COULD be implemented as a fork. I just don't know of any
implementations of Python that do so. (And of course, it works for
fib() because it needs/uses no global state, which makes the
recursions completely independent. Not all functions are so courteous,
and the compiler can't necessarily know the difference.)

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


Re: Development software

2011-05-02 Thread Chris Angelico
On Tue, May 3, 2011 at 1:23 AM, Petey efri...@gmail.com wrote:
 Which programmes should I start using because they might be useful in the 
 future? Which functions of eclipse are useful but unused/unnoticed by 
 beginners.

 What do you use and why :) ?

You're going to get some extremely disparate responses to that! I'll
open with the disclaimer that will apply to everyone's posts: This is
personal opinion, not Gospel truth. :)

For my development (which is quite polyglot - at the moment,
C++/Python/PHP/makefile/Pike/text all up in tabs), I use SciTE and a
good makefile. I hit F7 and Scite runs make in the current file's
directory. Is it an IDE or an editor? I'm not really sure; it's an
editor that lets me scroll through compiler errors with F4/Shift-F4.

A well-made makefile is an awesome tool. I strongly recommend getting
familiar with your make utility (if you don't currently have one, get
GNU make). My make will build either the production or debug version
of my code, upload changed files to our deployment server, and in fact
do everything except push changes into our git repo (I prefer to do
that manually, as I usually want to build lots of times and only then
commit the change in git).

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


Re: Fibonacci series recursion error

2011-05-02 Thread Steven D'Aprano
On Mon, 02 May 2011 21:02:43 +0100, Hans Georg Schaathun wrote:

 The other arguments are valid.  And they make me lean more towards more
 static, compiled languages without the excessive run-time dynamism of
 python.

If you value runtime efficiency over development time, sure. There are 
plenty of languages which have made that decision: Pascal, C, Java, Lisp, 
Forth, and many more.

Python aims at acceptable performance (between 10 and 100 times slower 
than C) and much easier development (between 10 and 100 times faster than 
C *wink*). If that tradeoff doesn't suit you, perhaps Python is not the 
language for you.


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


Py / VNC Automation

2011-05-02 Thread PyNewbie
Hi,
I'm looking for a python class or open source code that is tightly integrated 
with VNC protocols - any ideas?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Py / VNC Automation

2011-05-02 Thread Chris Angelico
On Tue, May 3, 2011 at 10:23 AM, PyNewbie ryan.morr...@gmail.com wrote:
 Hi,
 I'm looking for a python class or open source code that is tightly integrated 
 with VNC protocols - any ideas?

It's not a complex protocol; you could fairly readily work it
manually. The protocol itself is called RFB - see
http://en.wikipedia.org/wiki/RFB_protocol which has links to the
official protocol spec. Working it from Python is as simple as
creating a socket (import socket; vnc=socket.socket();
vnc.connect(('address',5900))) and sending and receiving binary data.

If you're setting things up as a test, I recommend playing around with
authentication disabled - it's a lot easier to master the protocol in
its simplest form.

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


Re: Py / VNC Automation

2011-05-02 Thread Dan Stromberg
On Mon, May 2, 2011 at 5:23 PM, PyNewbie ryan.morr...@gmail.com wrote:

 Hi,
 I'm looking for a python class or open source code that is tightly
 integrated with VNC protocols - any ideas?
 --
 http://mail.python.org/mailman/listinfo/python-list


I've not updated this in a while, but it's got a python vnc viewer in the
list:

http://stromberg.dnsalias.org/~dstromberg/vnc.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Recursion or iteration (was Fibonacci series recursion error)

2011-05-02 Thread rusi
On May 3, 2:50 am, harrismh777 harrismh...@charter.net wrote:
 The thing about this problem that puzzles me, is why we might consider
 recursion for a possible solution in the first place

This can be answered directly but a bit lengthily.
Instead let me ask a seemingly unrelated (but actually much the same)
question.

Here are two power functions:

def powI(x,n):
result = 1
for i in range(0,n):
result = result * x
return result

def powR(x,n): return 1 if (n==0) else (x * powR(x, n-1))

What are their space/time complexities?
Which do you prefer?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Development software

2011-05-02 Thread rusi
On May 2, 8:23 pm, Petey efri...@gmail.com wrote:
 Hi!

 I'm new to programming. I started with php earlier and I dropped it for 
 Python.
 I use Eclipse+PyDev for python, html and css.

 Which programmes should I start using because they might be useful in the 
 future?
 Which functions of eclipse are useful but unused/unnoticed by beginners.

 What do you use and why :) ?

Chris talked of a good make tool. Yes this is necessary for more 'in-
the-large' programming.
But for a beginner its very important to have tight development cycle
-- viz.
a. Write a function
b. Check the function
c. Change the definition
d. Check that
etc
with a minimum of keystrokes

If eclipse gives that its good...
For me its emacs with python-mode:
python in one window
python file in other
jump between the two with one keystroke.

Ive heard very good things about ipython (especially for
introspection) but not tried it extensively myself
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Recursion or iteration (was Fibonacci series recursion error)

2011-05-02 Thread Chris Angelico
On Tue, May 3, 2011 at 11:48 AM, rusi rustompm...@gmail.com wrote:
 What are their space/time complexities?
 Which do you prefer?

They're pretty similar actually. If you rework the first one to not
use range() but instead have a more classic C style of loop, they'll
be almost identical:

def powI(x,n):
   result = 1
   while n  0:
   result *= x
   n-=1
   return result

There's a subtle difference in that powR as you've coded it will
infinite-loop if given a negative exponent, while powI in any form
will simply return 1 (neither is technically correct, fwiw). Other
than that, the only difference is that one keeps its state on the call
stack, the other uses a temporary variable.

Performance would probably benefit from a special syntax meaning
recurse, which would avoid the LOAD_GLOBAL for the function's name
(plus, things break if you pass recursive functions around after
compiling them - for instance, powR2=powR; def powR(x,n): os.exit() -
but if you do that, then you should expect to see nice bullet-holes in
your foot). However, I do not believe that Python would overall
benefit from any such thing.

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


Re: Development software

2011-05-02 Thread Chris Angelico
On Tue, May 3, 2011 at 12:04 PM, rusi rustompm...@gmail.com wrote:
 Chris talked of a good make tool. Yes this is necessary for more 'in-
 the-large' programming.
 But for a beginner its very important to have tight development cycle
 -- viz.
 a. Write a function
 b. Check the function
 c. Change the definition
 d. Check that
 etc
 with a minimum of keystrokes

a. Write a code file
b. Press F7 and see the output in the other window.
c, d. Iterate.

Most IDEs will give you some such facility. F7 happens to be SciTE's
keystroke, others may use Ctrl-F9 or F5 or C-x M-x butterfly, but it's
almost certainly going to be there.

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


complex data structures in python

2011-05-02 Thread Rita
Hello,

I was wondering if anyone has any documentation/recipes for implementing
complex data structures. For instance, if you had a dictionary with a list
inside a list inside a set.

-- 
--- Get your facts first, then you can distort them as you please.--
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: (beginner question) ConfigParser nuances

2011-05-02 Thread Unknown Moss
On May 2, 3:25 pm, Chris Rebert c...@rebertia.com wrote:
 On Mon, May 2, 2011 at 3:04 PM, Unknown Moss unknownm...@gmail.com wrote:
  Hi -Beginnerquestionhere. I'm working with ConfigParser. I'd like
  to take a multiline variable and convert it directly to an array.
  Seems like a common  problem, but I don't see how I can do it without
  doing a little parsing in my own code. Here's what I'm doing ...

  import ConfigParser
  import io
  sample = 
  ... [Example]
  ... fruit = apple
  ...     orange
  ...     pear
  ... 
  config = ConfigParser.RawConfigParser()
  config.readfp(io.BytesIO(sample))
  config.get(Example, fruit)
  'apple\norange\npear'
  temp = config.get(Example, fruit)
  temp.split()
  ['apple', 'orange', 'pear']

  I'm thinking there's a way to avoid this intermediate temp.split()
  step. Is there not a way to move a multiline value straight into an
  array using ConfigParser?

 Nope, there is not. I think some might instead use several numbered
 options to similar effect:

 # config file
 [Example]
 fruit1: apple
 fruit2: orange
 fruit3: pear

 # Python
 from itertools import count
 fruits = []
 names = (fruit + str(i) for i in count(1))
 for name in names:
     if not config.has_option(Example, name):
         break
     fruits.append(config.get(Example, name))

 Cheers,
 Chris
 --http://rebertia.com

Ok, thanks Chris. Maybe I'm getting too lazy in my old age.  :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fibonacci series recursion error

2011-05-02 Thread rusi
On May 3, 5:21 am, Steven D'Aprano steve
+comp.lang.pyt...@pearwood.info wrote:
 On Mon, 02 May 2011 21:02:43 +0100, Hans Georg Schaathun wrote:
  The other arguments are valid.  And they make me lean more towards more
  static, compiled languages without the excessive run-time dynamism of
  python.

 If you value runtime efficiency over development time, sure. There are
 plenty of languages which have made that decision: Pascal, C, Java, Lisp,
 Forth, and many more.

Or Haskell:

Succinctness like python
Type safety better than C, C++, Java with a minimum of type
declarations
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: complex data structures in python

2011-05-02 Thread Chris Rebert
On Mon, May 2, 2011 at 7:46 PM, Rita rmorgan...@gmail.com wrote:
 Hello,
 I was wondering if anyone has any documentation/recipes for implementing
 complex data structures. For instance, if you had a dictionary with a list
 inside a list inside a set.

Er, there's no special magic. The datatypes just nest normally. Pretty
much the only thing to look out for is immutability/hashability.
Dictionary keys and set elements should typically be immutable (and
thus sensibly hashable). For this reason, tuples and frozensets are
used instead of lists and non-frozen sets (respectively) in those
situations (and in other cases where mutability should be disallowed).
When creating a custom immutable type, one should override the
__eq__(), __ne__(), and __hash__() special methods so that the type's
instances can be used as dict keys and set elements.

Your particular example combination doesn't work since it violates the
aforementioned immutability rule.

One should also be aware of the datatypes in the `collections` module,
particularly `defaultdict`:
http://docs.python.org/library/collections.html

Cheers,
Chris
--
http://rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Coolest Python recipe of all time

2011-05-02 Thread Stefan Behnel

David Monaghan, 02.05.2011 23:45:

On Mon, 2 May 2011 14:58:50 -0600, Ian Kelly wrote:


On Mon, May 2, 2011 at 2:48 PM, David Monaghan wrote:

On Mon, 2 May 2011 10:33:31 -0700 (PDT), Raymond Hettinger wrote:


I think it is time to give some visibility to some of the instructive
and very cool recipes in ActiveState's python cookbook.

My vote for the coolest recipe of all time is:


http://code.activestate.com/recipes/365013-linear-equations-solver-in-3-lines/


Really cool, but wrong. x = 3234.667, not 3236.0


Nope, I get 3236.  Maybe you made a mistake somewhere.


Oops. What a plonker .Three times I checked and got the same result each
time. Now it works fine. Sorry!


The bad thing about this recipe is that it requires quite a bit of 
background knowledge in order to infer that the code the developer is 
looking at is actually correct. At first sight, it looks like an evil hack, 
and the lack of documentation doesn't help either.


Stefan

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


Re: Coolest Python recipe of all time

2011-05-02 Thread Ian Kelly
On Mon, May 2, 2011 at 11:04 PM, Stefan Behnel stefan...@behnel.de wrote:
 The bad thing about this recipe is that it requires quite a bit of
 background knowledge in order to infer that the code the developer is
 looking at is actually correct. At first sight, it looks like an evil hack,
 and the lack of documentation doesn't help either.

What do you mean, looks like?  For crying out loud, it abuses
complex numbers to represent 2-element vectors, and it passes
unvalidated input to eval().  It is *absolutely* an evil hack!  Albeit
a clever one...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Recursion or iteration (was Fibonacci series recursion error)

2011-05-02 Thread Dan Stromberg
On Mon, May 2, 2011 at 7:13 PM, Chris Angelico ros...@gmail.com wrote:

 On Tue, May 3, 2011 at 11:48 AM, rusi rustompm...@gmail.com wrote:
  What are their space/time complexities?
  Which do you prefer?

 They're pretty similar actually. If you rework the first one to not
 use range() but instead have a more classic C style of loop, they'll
 be almost identical:

 def powI(x,n):
   result = 1
while n  0:
   result *= x
   n-=1
   return result

 There's a subtle difference in that powR as you've coded it will
 infinite-loop if given a negative exponent, while powI in any form
 will simply return 1 (neither is technically correct, fwiw). Other
 than that, the only difference is that one keeps its state on the call
 stack, the other uses a temporary variable.


The recursive solution uses more stack.  That is true.

But the recursive solution has time complexity of O(logn).  The iterative
solution has time complexity of O(n).  That's a significant difference for
large n - a significant benefit of the recursive version.

However, an iterative version of a function can always be created from a
recursive version.  In this case, an iterative version can be constructed
that is O(logn) time and O(1) stack.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Recursion or iteration (was Fibonacci series recursion error)

2011-05-02 Thread Chris Angelico
On Tue, May 3, 2011 at 3:27 PM, Dan Stromberg drsali...@gmail.com wrote:

 But the recursive solution has time complexity of O(logn).  The iterative
 solution has time complexity of O(n).  That's a significant difference for
 large n - a significant benefit of the recursive version.

Are you sure? It will produce n function calls and n multiplications,
how is that O(log n)?

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


Hello Friends

2011-05-02 Thread Ashraf Ali
What are you lookink for. Just visit to see what you want
www.bollywoodhotactresswallpapers.blogspot.com

www.bollywoodhotwallpaperz.blogspot.com

www.bollywoodhotactresspicz.blogspot.com

www.hottesthitsbollywood.blogspot.com

www.bollywoodhotphotoz.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Recursion or iteration (was Fibonacci series recursion error)

2011-05-02 Thread Ian Kelly
On Mon, May 2, 2011 at 11:27 PM, Dan Stromberg drsali...@gmail.com wrote:
 But the recursive solution has time complexity of O(logn).  The iterative
 solution has time complexity of O(n).  That's a significant difference for
 large n - a significant benefit of the recursive version.


It's linear as written.  I think you're talking about an
implementation like this one:

def powR(x,n):
  if n  0:
return 1.0 / powR(x, -n)
  elif n == 0:
return 1
  else:
half_n = n // 2
root = powR(x, half_n)
result = root * root
if half_n + half_n == n - 1:
  result = result * x
return result

That's O(log n), but it was harder to write, and it could just as
easily be iterative.  In fact it might actually have been a bit
simpler to write it iteratively.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Recursion or iteration (was Fibonacci series recursion error)

2011-05-02 Thread Dan Stromberg
On Mon, May 2, 2011 at 10:29 PM, Chris Angelico ros...@gmail.com wrote:

 On Tue, May 3, 2011 at 3:27 PM, Dan Stromberg drsali...@gmail.com wrote:
 
  But the recursive solution has time complexity of O(logn).  The iterative
  solution has time complexity of O(n).  That's a significant difference
 for
  large n - a significant benefit of the recursive version.

 Are you sure? It will produce n function calls and n multiplications,
 how is that O(log n)?


Doh.

Usually when someone gives a recursive solution to this problem, it's
O(logn), but not this time.

Here's a logn one:

def power(x, n):
   if n == 0:
  return 1
   else:
  half, remainder = divmod(n, 2)
  if remainder == 1:
 return power(x, half) ** 2 * x
  else:
 return power(x, half) ** 2
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue11975] Fix intersphinx-ing of built-in types (list, int, ...)

2011-05-02 Thread Ezio Melotti

Ezio Melotti ezio.melo...@gmail.com added the comment:

See also #4966 and #11976.

--
nosy: +ezio.melotti

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11975
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4966] Improving Lib Doc Sequence Types Section

2011-05-02 Thread Ezio Melotti

Ezio Melotti ezio.melo...@gmail.com added the comment:

See also #11975 and #11976.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4966
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11967] Left shift and Right shift for floats

2011-05-02 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

Ok, I'm closing this as won't fix. Mark is our authority on these matters, and 
having two spellings for this fairly uncommon operation seems enough.

--
resolution:  - wont fix
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11967
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11887] unittest fails on comparing str with bytes if python has the -bb option

2011-05-02 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

Le lundi 02 mai 2011 07:05:28, vous avez écrit :
   * the patch introduces code/complexity in _baseAssertEqual and other
 places, using catch_warnings to change and restore the warning filters at
 every call;

Yes, and what is the problem? I think that it is cheap: it copies a list, 
prepends an item to a short list, and then copies a reference (the previous 
list).

I think that the patch is simple (it adds 3 with+simplefilter) and it 
doesn't add complexity, or you should define what complexity is :-)

 * this is needed only when Python is run with -b/-bb and that
 is quite uncommon (afaik);

Buildbots use make buildbottest which run python with -bb (which is a good 
idea!). So all buildbots already use -bb since long time.

I forgot the explain the usecase: I don't remember correctly, but a test 
failed on a buildbot, and I was unable to get more information because 
unittest failed too.

 * even if this is not fixed, a test suite that
 passes all the tests without -b/-bb will most likely pass with -b/-bb[0];

No. You have usually more failures with -bb than without any -b flag. Not in 
the test itself, but in a function called by the test.

 * if there are failing tests with -b/-bb, it's usually possible to remove
 the -b/-bb and fix them before re-adding -bb[1];

A test may only fail with -bb.

Anyway, my problem is to be able to get more informations on a failure in a 
buildbot. I cannot change (easily) -bb flags on the buildbots (and I don't 
want to do that). When something goes wrong on a buildbot, in some cases it is 
very hard to reproduce the failure on my own computer. I want as much 
information as possible.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11887
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11839] argparse: unexpected behavior of default for FileType('w')

2011-05-02 Thread Stefan Pfeiffer

Stefan Pfeiffer stefan.pfeif...@gmail.com added the comment:

Happens in 3.2, too...

Would be nice to see that fixed.

Stefan

--
nosy: +Stefan.Pfeiffer

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11839
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11975] Fix referencing of built-in types (list, int, ...)

2011-05-02 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

I changed the title: intersphinx is a Sphinx extension used to links to foreign 
documentation, not create links inside one doc (as I understand the request is).

--
nosy: +eric.araujo
stage:  - needs patch
title: Fix intersphinx-ing of built-in types (list, int, ...) - Fix 
referencing of built-in types (list, int, ...)
versions: +Python 2.7, Python 3.1, Python 3.2, Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11975
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11935] MMDF/MBOX mailbox need utime

2011-05-02 Thread Steffen Daode Nurpmeso

Steffen Daode Nurpmeso sdao...@googlemail.com added the comment:

On Sun,  1 May 2011 00:15:11 +0200, R. David Murray rep...@bugs.python.org 
wrote:
 The problem with this patch is that it would also show 'new
 mail' if what had in fact happened was that a message had been
 *deleted* (see the comments at the beginning of the flush
 method).  So actually fixing this is a bit more complicated.

Well i don't think so because MUA's do some further checks,
like checking the size and of course the status of each mail;
some indeed use the mtime as an entry-gate for further inspection.
And deleting an entry should surely pass that gate, too.

Please do see the file mbox.c of the mutt(1) source repository,
which in fact seems to have been used as an almost copy-and-paste
template for the implementation of large parts of mailbox.py.

But note that i just search less than five minutes in mailbox.py
to find a place where i can add the code of the patch (after
i've added an identical workaround for my S-Postman), so of course
it may not catch all cases.  One error is obvious: it also sets the
mtime for that Babylon format.  I don't use emacs and i'm
a buddhist so i don't care about that Babylon mess anyway.
Right?

 A proper fix for this should also consider fixing issue 7359.

Hm.  #7359 refers to misconfiguration, not to Python or
mailbox.py.  Maybe Doc/library/mailbox.rst should be adjusted to
give users which are new to UNIX a hint about ,group mail` and the
set-group-ID on directories?  I think this would really be a good
thing?!?!  Should i open an issue on that?

But again, mailbox.py reflects almost one-to-one (except for the
naive file lock handling in comparison and AFAIK) mutt(1)'s
mbox.c, and i think that if mutt(1) does
create-temp-work-work-work-rename then this should be ok for
mailbox.py, too.

Did you know that ,bin Laden` ment ,am loading` in german?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11935
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11935] MMDF/MBOX mailbox need utime

2011-05-02 Thread Steffen Daode Nurpmeso

Steffen Daode Nurpmeso sdao...@googlemail.com added the comment:

I'll attach a patch with a clearer comment (entry-gate instead
new mail), i.e. the comment now reflects what MUAs really do.

--
Added file: http://bugs.python.org/file21850/11935.2.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11935
___diff --git a/Lib/mailbox.py b/Lib/mailbox.py
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -692,6 +692,13 @@
 self._file = open(self._path, 'rb+')
 self._toc = new_toc
 self._pending = False
+# Set modification time to be after access time so that MMDF and MBOX
+# mail readers detect changes (or perform further inspection to do so)
+try:
+currtime = time.time()
+os.utime(self._path, (currtime-3, currtime))
+except:
+pass
 if self._locked:
 _lock_file(self._file, dotlock=False)
 
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11935] MMDF/MBOX mailbox need utime

2011-05-02 Thread Steffen Daode Nurpmeso

Changes by Steffen Daode Nurpmeso sdao...@googlemail.com:


Removed file: http://bugs.python.org/file21795/mailbox.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11935
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11975] Fix referencing of built-in types (list, int, ...)

2011-05-02 Thread Jonas H.

Jonas H. jo...@lophus.org added the comment:

Actually I need to be able to intersphinx (because my documentation work is not 
the Python docs :-) but I guess it boils down to the same problem of incomplete 
Sphinx module/class indices.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11975
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10252] Fix resource warnings in distutils

2011-05-02 Thread Roundup Robot

Roundup Robot devnull@devnull added the comment:

New changeset c02c78d93a2e by Éric Araujo in branch '2.7':
Fix double use of f.close().
http://hg.python.org/cpython/rev/c02c78d93a2e

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue10252
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8498] Cannot use backlog = 0 for sockets

2011-05-02 Thread Daniel Evers

Daniel Evers derm...@googlemail.com added the comment:

To revive this issue, I tried to write a unit test to verify the behaviour. 
Onfurtunately, the test doesn't work and I don't understand why. I hope, 
someone here is more enlightend than me...
(files: server.py, client.py)

--
Added file: http://bugs.python.org/file21851/server.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8498
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8498] Cannot use backlog = 0 for sockets

2011-05-02 Thread Daniel Evers

Daniel Evers derm...@googlemail.com added the comment:

(client.py)

--
Added file: http://bugs.python.org/file21852/client.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8498
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >