Re: [Tutor] constructing semi-arbitrary functions

2014-02-19 Thread Oscar Benjamin
On 18 February 2014 17:59, Peter Otten <__pete...@web.de> wrote:
>
> I don't know if the OP may use it, but there seems to be a version of minuit
> that allows to override the function signature:
>
> """
> forced_parameters: tell Minuit not to do function signature detection and
> use this argument instead. (Default None (automagically detect signature)
> """

Interesting. I don't really understand why it works that way though.
Looking here

   http://iminuit.github.io/iminuit/api.html#function-sig-label

I find the suggestion to do instead:

"""
f = lambda x,m,c: m*x+c
#the beauty here is that all you need to build
#a Chi^2 is just your function and data
class GenericChi2:
def __init__(self, f, x, y):
self.f = f
args = describe(f)#extract function signature
self.func_code = Struct(
co_varnames = args[1:],#dock off independent param
co_argcount = len(args)-1
)
def __call__(self, *arg):
return sum((self.f(x,*arg)-y)**2 for x,y in zip(self.x, self.y))

m = Minuit(GenericChi2(f,x,y))
"""

But that just seems a bit ridiculous to me.

If it were my library I would probably be aiming to handle complex
cases with a closure-based solution like this:

def make_chisq(f, xdata, ydata):
def chisq(m, c):
return sum((self.f(x,m, c)-y)**2 for x,y in zip(xdata, ydata))
return chisq

f = lambda x,m,c: m*x+c
m = Minuit(make_chisq(xdata, ydata), names=['m', 'c'])

At the least I don't understand why it needs both the argument names
and the number of arguments as independent quantities. Surely
len(names) would be the number of arguments... Or am I missing
something?

BTW to the OP the functions in scipy.optimize don't do any of this.
You just pass in the function and an initial guess at the parameter
values. It doesn't care about the names and infers the number of
parameters from the initial guess. Also numpy has a polyfit function
that you can just call with polyfit(xdata, ydata, deg) where deg is
the degree of the polynomial you want to fit. Under the hood it solves
the scaled Vandermonde matrix as I described earlier:
https://github.com/numpy/numpy/blob/master/numpy/polynomial/polynomial.py#L1351


Oscar
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] constructing semi-arbitrary functions

2014-02-19 Thread Dave Angel

On 02/19/2014 07:33 AM, Oscar Benjamin wrote:



At the least I don't understand why it needs both the argument names
and the number of arguments as independent quantities. Surely
len(names) would be the number of arguments... Or am I missing
something?



In the standard library, the attributes are
  func_code.co_varnames

and
  func_code.co_argcount

Note that varnames will include all the locals, not just the formal 
parameters.  So the count tells you how many of them are parameters.


--
DaveA

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] constructing semi-arbitrary functions

2014-02-19 Thread eryksun
On Wed, Feb 19, 2014 at 7:33 AM, Oscar Benjamin
 wrote:
> I don't really understand why it works that way though.
> Looking here
>
>http://iminuit.github.io/iminuit/api.html#function-sig-label

This API is unusual, but co_argcount and co_varnames should be
available and defined as per the spec:

http://docs.python.org/2/reference/datamodel#index-59

CPython/PyPy  Jython
=
co_name   *
co_argcount   *
co_nlocals*
co_varnames   *
co_cellvars   *
co_freevars   *
co_filename   *
co_firstlineno*
co_flags  *
co_code
co_consts
co_names
co_lnotab
co_stacksize

The last few attributes aren't relevant to Jython since it's using the JVM.

To its credit, util.better_arg_spec does fall back on
inspect.getargspec. But then, its ultimate fallback is regex magic:
util.arguments_from_docstring. Wow. I guess it's convenient to specify
initial values, step size, limits, etc, as keyword arguments for named
parameters.

I haven't read this whole thread, but here are some source links if
the OP is using this iminuit package. The `describe` function is in
util.py.

https://github.com/iminuit/iminuit/blob/master/iminuit/util.py
https://github.com/iminuit/iminuit/blob/master/iminuit/_libiminuit.pyx

Some snippets from Minuit.__init__:

args = describe(fcn) if forced_parameters is None\
   else forced_parameters

# ...

self.initialvalue = {x:maplookup(kwds,x,0.) for x in args}
self.initialerror = \
{x:maplookup(kwds,'error_'+x,1.) for x in args}
self.initiallimit = \
{x:maplookup(kwds,'limit_'+x,None) for x in args}
self.initialfix = \
{x:maplookup(kwds,'fix_'+x,False) for x in args}

# ...

self.parameters = args
self.args = tuple(self.initialvalue[k] for k in args)
self.values = {k:self.initialvalue[k] for k in args}
self.errors = {k:self.initialerror[k] for k in args}
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] How to write Sikuli scripts using Python in Eclipse (Pydev Environment.)

2014-02-19 Thread Nupur Goel
Hi,

Could you please tell me how to write Sikuli scripts using Python in Eclipse 
(Pydev Environment.)
For Example:
I want to open Adobe Reader using Sikuli and wants to perform different 
action on it.

I had already integrated Python in Eclipse and also provide path for Jython 
Interpreter. Please provide me steps to import Sikuli Api's or other extra 
things needed to do my assignment.

Thanks a lot in advance.
Nupur___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to write Sikuli scripts using Python in Eclipse (Pydev Environment.)

2014-02-19 Thread Alan Gauld

On 19/02/14 13:22, Nupur Goel wrote:


Could you please tell me how to write *Sikuli* scripts using *Python in
Eclipse (Pydev Environment.)*


This list is for teaching the core Python language and its standard 
library. For support for third party libraries and tools you are usually 
better off asking on a dedicated forum or list.



I want to open Adobe Reader using Sikuli and wants to perform different
action on it.
I had already integrated Python in Eclipse and also provide path for
Jython Interpreter.


Sikuli, Eclipse and Jython are all off topic for this list.
You might be lucky enough to find somebody with some experience
but I suspect you will be better off asking elsewhere, possibly
even on the main python mailing list/newsgroup.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] constructing semi-arbitrary functions

2014-02-19 Thread André Walker-Loud
Hi Oscar,

>> Is there a benefit to this method vs a standard linear least squares?
> 
> It's the same except that you're using an analytic solution rather
> than a black box solver.

OK.  Interesting.  I usually construct the analytic solution by just 
differentiating the chi^2, which sets up, I am guessing, a similar matrix 
equation.  When I solve with chi^2, I see clearly how to put the uncertainties 
in, and use them for estimating the uncertainties on the coefficients.  The 
parameter uncertainties are simply related to the double-derrivatives of the 
chi^2 for linear least squares.  But it is not clear to me if knowing the 
Vandermonde matrix automatically gives these parameter uncertainties as well.

>> The most common problem I am solving is fitting a sum of real exponentials 
>> to noisy data, with the model function
>> 
>> C(t) = sum_n A_n e^{- E_n t}
>> 
>> the quantities of most interest are E_n, followed by A_n so I solve this 
>> with non-linear regression.
>> To stabilize the fit, I usually do a linear-least squares for the A_n first, 
>> solving as a function of the E_n, and then do a non-linear fit for the E_n.
> 
> That doesn't sound optimal to me. Maybe I've misunderstood but fitting
> over one variable and then over another is not in any way guaranteed
> to produce an optimal fit.

I have not been precise enough.
The first solve for A_n is using an analytic linear-least squares algorithm, so 
it is gauranteed to be correct.  The solution will depend upon the E_n, but in 
a known way.

The point is that the numerical minimization of sums of exponentials is a hard 
problem.  So why ask the numerical minimizer to do all the extra work of also 
minimizing the coefficients?  This can make it very unstable.  So by first 
applying the analytic linear-least squares to the coefficients, the numerical 
minimization over the smaller set of E_n is more likely to converge.  Usually, 
in my cases, we have of order 2-10 times more A_n than E_n, as we really solve 
a matrix

C_{ij}(t) = sum_n A^n_{ij} exp(-E_n t)

the linear least squares gives

A^n_{ij} = analytically solvable matrix function (E_n)

> Well it sounds like your approach so far is working for now but as I
> say the real fix is to improve or bypass the interface you're using.
> One limitation that you may at some point hit is that in Python you
> can't have an unbounded number of formal parameters for a function:
> 
> $ python3 tmp2.py
>  File "tmp2.py", line 1
>def f(x0,  x1,  x2,  x3,  x4,  x5,  x6,  x7,  x8,  x9,  x10,  x11,
> x12,  x13,  x14,
> ^
> SyntaxError: more than 255 arguments

In my work, it is unlikely I will ever need to minimize in so many parameters.
I’ll worry about that when I run into it.

Thanks for the info.

Andre
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] constructing semi-arbitrary functions

2014-02-19 Thread André Walker-Loud
Hi eryksun,

Indeed, I am using iminuit to interface with Minuit.
That is where I am learning to make my own classes to set up my functions to 
pass into the minimizer.  I also happened to get the string-hack to work (which 
requires using global variables). Instead of just copying (since it works) I am 
also trying to improve my programming knowledge at the same time - hence this 
whole thread.

Minuit is a sophisticated minimizer, which means it is important to set initial 
values, expected uncertainties on the parameters, etc.  Minuit uses your 
estimate of the parameter uncertainties to set up the grid step-size it uses to 
search the parameter space.  So sloppiness here can screw up the minimization 
getting one stuck in a local min (to small error estimate) or spend too much 
time wondering around (too large error estimate).


Cheers,

Andre


On Feb 19, 2014, at 10:17 AM, eryksun  wrote:

> On Wed, Feb 19, 2014 at 7:33 AM, Oscar Benjamin
>  wrote:
>> I don't really understand why it works that way though.
>> Looking here
>> 
>>   http://iminuit.github.io/iminuit/api.html#function-sig-label
> 
> This API is unusual, but co_argcount and co_varnames should be
> available and defined as per the spec:
> 
> http://docs.python.org/2/reference/datamodel#index-59
> 
>CPython/PyPy  Jython
>=
>co_name   *
>co_argcount   *
>co_nlocals*
>co_varnames   *
>co_cellvars   *
>co_freevars   *
>co_filename   *
>co_firstlineno*
>co_flags  *
>co_code
>co_consts
>co_names
>co_lnotab
>co_stacksize
> 
> The last few attributes aren't relevant to Jython since it's using the JVM.
> 
> To its credit, util.better_arg_spec does fall back on
> inspect.getargspec. But then, its ultimate fallback is regex magic:
> util.arguments_from_docstring. Wow. I guess it's convenient to specify
> initial values, step size, limits, etc, as keyword arguments for named
> parameters.
> 
> I haven't read this whole thread, but here are some source links if
> the OP is using this iminuit package. The `describe` function is in
> util.py.
> 
> https://github.com/iminuit/iminuit/blob/master/iminuit/util.py
> https://github.com/iminuit/iminuit/blob/master/iminuit/_libiminuit.pyx
> 
> Some snippets from Minuit.__init__:
> 
>args = describe(fcn) if forced_parameters is None\
>   else forced_parameters
> 
># ...
> 
>self.initialvalue = {x:maplookup(kwds,x,0.) for x in args}
>self.initialerror = \
>{x:maplookup(kwds,'error_'+x,1.) for x in args}
>self.initiallimit = \
>{x:maplookup(kwds,'limit_'+x,None) for x in args}
>self.initialfix = \
>{x:maplookup(kwds,'fix_'+x,False) for x in args}
> 
># ...
> 
>self.parameters = args
>self.args = tuple(self.initialvalue[k] for k in args)
>self.values = {k:self.initialvalue[k] for k in args}
>self.errors = {k:self.initialerror[k] for k in args}

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] constructing semi-arbitrary functions

2014-02-19 Thread eryksun
On Wed, Feb 19, 2014 at 2:56 PM, "André Walker-Loud
"  wrote:
>
> I also happened to get the string-hack to work (which requires
> using global variables).

Functions load unassigned names from the global/builtins scopes, so
there's no need to declare the g* variables global in chisq_mn. Also,
implicit string concatenation and string formatting will make the
definition easier to read, IMO:

def make_chisq_mn(pars, x, y, dy):
global _gx, _gy, _gdy
_gx, _gy, _gdy = x, y, dy
names = ['c_%d' % i for i in xrange(len(pars))]
src = ('def chisq_mn(%(p)s):\n'
   'return chisq([%(p)s], _gx, _gy, _gdy)' %
   {'p': ', '.join(names)})
print 'funcdef=\n', src
exec src in globals()


You can use a custom dict with exec to avoid contaminating the
module's global namespace:

def make_chisq_mn(pars, x, y, dy):
ns = {'x': x, 'y': y, 'dy': dy, 'chisq': chisq}
names = ['c_%d' % i for i in xrange(len(pars))]
src = ('def chisq_mn(%(p)s):\n'
   'return chisq([%(p)s], x, y, dy)' %
   {'p': ', '.join(names)})
print 'funcdef=\n', src
exec src in ns
return ns['chisq_mn']


This version of chisq_mn uses the ns dict as its func_globals:

>>> chisq = lambda *a: None # dummy
>>> chisq_mn = make_chisq_mn([1,2,3], 10, 20, 30)
funcdef=
def chisq_mn(c_0, c_1, c_2):
return chisq([c_0, c_1, c_2], x, y, dy)

>>> sorted(chisq_mn.func_globals)
['__builtins__', 'chisq', 'chisq_mn', 'dy', 'x', 'y']

>>> dis.dis(chisq_mn)
  2   0 LOAD_GLOBAL  0 (chisq)
  3 LOAD_FAST0 (c_0)
  6 LOAD_FAST1 (c_1)
  9 LOAD_FAST2 (c_2)
 12 BUILD_LIST   3
 15 LOAD_GLOBAL  1 (x)
 18 LOAD_GLOBAL  2 (y)
 21 LOAD_GLOBAL  3 (dy)
 24 CALL_FUNCTION4
 27 RETURN_VALUE
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] constructing semi-arbitrary functions

2014-02-19 Thread André Walker-Loud
Hi eryksun,

Thanks - this is great.
Also, since you are chiming in, do you have an opinion in general about which 
approach you prefer?  The string hacking vs class method (for lack of better 
way to describe them)?


Cheers,

Andre



On Feb 19, 2014, at 4:56 PM, eryksun  wrote:

> On Wed, Feb 19, 2014 at 2:56 PM, "André Walker-Loud
> "  wrote:
>> 
>> I also happened to get the string-hack to work (which requires
>> using global variables).
> 
> Functions load unassigned names from the global/builtins scopes, so
> there's no need to declare the g* variables global in chisq_mn. Also,
> implicit string concatenation and string formatting will make the
> definition easier to read, IMO:
> 
>def make_chisq_mn(pars, x, y, dy):
>global _gx, _gy, _gdy
>_gx, _gy, _gdy = x, y, dy
>names = ['c_%d' % i for i in xrange(len(pars))]
>src = ('def chisq_mn(%(p)s):\n'
>   'return chisq([%(p)s], _gx, _gy, _gdy)' %
>   {'p': ', '.join(names)})
>print 'funcdef=\n', src
>exec src in globals()
> 
> 
> You can use a custom dict with exec to avoid contaminating the
> module's global namespace:
> 
>def make_chisq_mn(pars, x, y, dy):
>ns = {'x': x, 'y': y, 'dy': dy, 'chisq': chisq}
>names = ['c_%d' % i for i in xrange(len(pars))]
>src = ('def chisq_mn(%(p)s):\n'
>   'return chisq([%(p)s], x, y, dy)' %
>   {'p': ', '.join(names)})
>print 'funcdef=\n', src
>exec src in ns
>return ns['chisq_mn']
> 
> 
> This version of chisq_mn uses the ns dict as its func_globals:
> 
 chisq = lambda *a: None # dummy
 chisq_mn = make_chisq_mn([1,2,3], 10, 20, 30)
>funcdef=
>def chisq_mn(c_0, c_1, c_2):
>return chisq([c_0, c_1, c_2], x, y, dy)
> 
 sorted(chisq_mn.func_globals)
>['__builtins__', 'chisq', 'chisq_mn', 'dy', 'x', 'y']
> 
 dis.dis(chisq_mn)
>  2   0 LOAD_GLOBAL  0 (chisq)
>  3 LOAD_FAST0 (c_0)
>  6 LOAD_FAST1 (c_1)
>  9 LOAD_FAST2 (c_2)
> 12 BUILD_LIST   3
> 15 LOAD_GLOBAL  1 (x)
> 18 LOAD_GLOBAL  2 (y)
> 21 LOAD_GLOBAL  3 (dy)
> 24 CALL_FUNCTION4
> 27 RETURN_VALUE

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to write Sikuli scripts using Python in Eclipse (Pydev Environment.)

2014-02-19 Thread Alan Gauld

On 19/02/14 17:34, Alan Gauld wrote:


Sikuli, Eclipse and Jython are all off topic for this list.


Correcting myself.
Jython is not off topic if it's about how to program with Jython.
It's the details of using Jython in the context of Eclipse etc
that is off topic for tutor.

I don't want to scare away any Jython lurkers out there. :-)


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Looking for IAC solutions in Python

2014-02-19 Thread Aurélien DESBRIÈRES

Hi,

I am looking for IAC - Intelligent Adaptive Curiosity solutions in
Python.

Have you got any idea of project / algorithm / source code based on that
type of things ?

Best regards


-- 
Aurélien DESBRIÈRES
Run Free - Run GNU.org
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Looking for IAC solutions in Python

2014-02-19 Thread Mark Lawrence

On 19/02/2014 19:53, Aurélien DESBRIÈRES wrote:


Hi,

I am looking for IAC - Intelligent Adaptive Curiosity solutions in
Python.

Have you got any idea of project / algorithm / source code based on that
type of things ?

Best regards




Haven't a clue to be quite blunt, I suggest that you try the main Python 
mailing list/newsgroup rather than this tutor list.


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] constructing semi-arbitrary functions

2014-02-19 Thread eryksun
On Wed, Feb 19, 2014 at 6:59 PM, "André Walker-Loud
"  wrote:
>
> Also, since you are chiming in, do you have an opinion in general about
> which approach you prefer?  The string hacking vs class method (for lack
> of better way to describe them)?

I've never used iminuit before. I'd ask on a support forum to see what
other people are doing. That said, if possible I'd use a closure like
Peter showed:

def make_chisq_mn(x, y, dy):
def chisq_mn(*args):
return chisq(args, x, y, dy)
return chisq_mn

Then combine that with the forced_parameters option that Peter
mentioned. This seems simplest to me.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] constructing semi-arbitrary functions

2014-02-19 Thread André Walker-Loud
OK - I have not seen an email from Peter.
So I looked up the thread online, and see I did not receive half the emails on 
this thread :O

My first inclination was to blame my mac mavericks mail gmail syncing problem.  
but logging into gmail, I see no record of the emails there either.

I currently receive the tutor emails in the digest mode - thought I was paying 
attention to all the digests - but I seems to have missed many.

I apologize to all those who offered input whose emails I missed - I certainly 
wasn’t ignoring them.


Andre




On Feb 19, 2014, at 7:21 PM, eryksun  wrote:

> On Wed, Feb 19, 2014 at 6:59 PM, "André Walker-Loud
> "  wrote:
>> 
>> Also, since you are chiming in, do you have an opinion in general about
>> which approach you prefer?  The string hacking vs class method (for lack
>> of better way to describe them)?
> 
> I've never used iminuit before. I'd ask on a support forum to see what
> other people are doing. That said, if possible I'd use a closure like
> Peter showed:
> 
>def make_chisq_mn(x, y, dy):
>def chisq_mn(*args):
>return chisq(args, x, y, dy)
>return chisq_mn
> 
> Then combine that with the forced_parameters option that Peter
> mentioned. This seems simplest to me.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] constructing semi-arbitrary functions

2014-02-19 Thread André Walker-Loud
On Feb 19, 2014, at 7:45 PM, André Walker-Loud  wrote:

> OK - I have not seen an email from Peter.
> So I looked up the thread online, and see I did not receive half the emails 
> on this thread :O
> 
> My first inclination was to blame my mac mavericks mail gmail syncing 
> problem.  but logging into gmail, I see no record of the emails there either.
> 
> I currently receive the tutor emails in the digest mode - thought I was 
> paying attention to all the digests - but I seems to have missed many.
> 
> I apologize to all those who offered input whose emails I missed - I 
> certainly wasn’t ignoring them.

and as a follow up - is there a way to download a thread from the tutor archive?
I am guessing the answers are one of 
1) write a python script to grab the emails associated with the threads from 
the web
2) download the whole gzip’d text and use python to grab only the parts I want

but 1) I haven’t done that before and unfortunately don’t have time to learn now
2) some combination of being too busy and lazy prevents me from this option…


cheers,

andre
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] constructing semi-arbitrary functions

2014-02-19 Thread Mark Lawrence

On 20/02/2014 00:56, "André Walker-Loud " wrote:

On Feb 19, 2014, at 7:45 PM, André Walker-Loud  wrote:


OK - I have not seen an email from Peter.
So I looked up the thread online, and see I did not receive half the emails on 
this thread :O

My first inclination was to blame my mac mavericks mail gmail syncing problem.  
but logging into gmail, I see no record of the emails there either.

I currently receive the tutor emails in the digest mode - thought I was paying 
attention to all the digests - but I seems to have missed many.

I apologize to all those who offered input whose emails I missed - I certainly 
wasn’t ignoring them.


and as a follow up - is there a way to download a thread from the tutor archive?
I am guessing the answers are one of
1) write a python script to grab the emails associated with the threads from 
the web
2) download the whole gzip’d text and use python to grab only the parts I want

but 1) I haven’t done that before and unfortunately don’t have time to learn now
2) some combination of being too busy and lazy prevents me from this option…


cheers,

andre



See here for where this list is archived 
https://mail.python.org/mailman/listinfo/tutor, looks as if your choices 
are activestate or gmane, I'm unsure as to whether or not you can grab 
gzip'd text.


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] constructing semi-arbitrary functions

2014-02-19 Thread Oscar Benjamin
On 20 February 2014 00:56, "André Walker-Loud "
 wrote:
> On Feb 19, 2014, at 7:45 PM, André Walker-Loud  wrote:
>
>> OK - I have not seen an email from Peter.
>> So I looked up the thread online, and see I did not receive half the emails 
>> on this thread :O
>>
>> My first inclination was to blame my mac mavericks mail gmail syncing 
>> problem.  but logging into gmail, I see no record of the emails there either.
>>
>> I currently receive the tutor emails in the digest mode - thought I was 
>> paying attention to all the digests - but I seems to have missed many.
>>
>> I apologize to all those who offered input whose emails I missed - I 
>> certainly wasn't ignoring them.
>
> and as a follow up - is there a way to download a thread from the tutor 
> archive?
> I am guessing the answers are one of
> 1) write a python script to grab the emails associated with the threads from 
> the web
> 2) download the whole gzip'd text and use python to grab only the parts I want
>
> but 1) I haven't done that before and unfortunately don't have time to learn 
> now
> 2) some combination of being too busy and lazy prevents me from this option...

I'm sure there is a way to do it (I don't know how exactly) but for
now you have the archive here:
https://mail.python.org/pipermail/tutor/2014-February/100213.html

I would suggest not to receive the digest. Peter's messages were sent
to the list and not CC'ed to you (which is often considered the
correct way) so you would only have seen them in the digest but it's
not so easy to follow a thread that way.

I also use gmail and what I do is to set a filter that sends all the
tutor emails into a particular folder (skip inbox, don't mark as read)
and then there's no problem with the emails cluttering up my inbox and
no need to receive a digest. When I feel like looking at tutor emails
they're in a particular folder for me to look at. When I feel like
processing work-related emails etc. then they're in different folders.
When I do look at the messages they are threaded by gmail so I don't
miss anything in a particular thread.


Oscar
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Programmatic access to email archives (was: constructing semi-arbitrary functions)

2014-02-19 Thread Ben Finney
"André Walker-Loud "  writes:

> and as a follow up - is there a way to download a thread from the
> tutor archive?

You've indicated you know this, but for other readers: The mailing list
archives are available https://mail.python.org/pipermail/tutor/> in
compressed “mbox” format, by month.

> 2) download the whole gzip’d text and use python to grab only the
> parts I want

A decent email client (such as Mutt, Gnus, Thunderbird, etc.) will be
able to open an mbox-format archive as a folder, and from there you can
filter and reply to messages as normal.

For programmatic access, the Python standard library ‘mailbox’ module
http://docs.python.org/3/library/mailbox.html> supports reading
“mbox”, and you then have all the Mailbox methods to select and extract
messages.

-- 
 \“Human reason is snatching everything to itself, leaving |
  `\ nothing for faith.” —Saint Bernard, 1090–1153 |
_o__)  |
Ben Finney

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor