Re: [OT] Altair

2016-09-01 Thread Gregory Ewing

Christopher Reimer wrote:


The first time I came across a paper tape reader when I
visited the university as a teenager in 1984. A CNC machine read the paper
tape to drill six holes in a piece of metal.


I think that would have just been called NC (Numerical
Control). CNC (Computer Numerical Control) is where
a computer drives the machine directly.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: C Python extension to export an Function

2016-09-01 Thread dieter
Ganesh Pal  writes:

> Iam pretty new to C Python extension , I was able to export few simple
> modules to python and it look like the cool thing to do ...

Maybe, it is a good idea to have a look at "cython".

"cython" is a compiler. It translates Python code enhanced with
special annotations into C. The annotations mostly tell the compiler
that something ("object", "method", "function", ...) should be at "C"
rather than "Python" level, thus avoiding much of Python's overhead
and allows to do things possible in "C" but not in "Python".


Developing safe "C" extensions for Python is difficult. You
need some quite deep understanding of the Python-C interface
and must be very careful to observe all requirements (especially
those related to proper reference management).

Developing "C" extensions with "cython" is much easier as
"cython" hides many of the complexities and takes care of most
requirements.

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


Re: [OT] Altair

2016-09-01 Thread Gregory Ewing

Grant Edwards wrote:


The file containing the list of coordinates generated by a CAD program
for holes in a circuit board is still often referred to as a "drill
tape".


Yep, and we talk about "core" memory, use a "tape archive"
program to produce compressed files, and have "drives"
with no moving parts. Terminological fossils abound!

(When I first heard the term "core" used to refer to
RAM, I thought it just meant that it was a central part
of the machine... until I realised it was actually
talking about those little magnetic doughnuts!)

(And I suppose a "core dump" is what would happen if
any of the fragile little wires broke...)

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: What's the best way to minimize the need of run time checks?

2016-09-01 Thread Gregory Ewing

Chris Angelico wrote:


You might have won the 100m dash, except that we couldn't verify your
velocity of locomotion without a... run time check. Badumtish.


All is not lost. You just need to devise a type system
capable of proving that his time is faster than any
other runner in all possible races.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: What's the best way to minimize the need of run time checks?

2016-09-01 Thread Chris Angelico
On Thu, Sep 1, 2016 at 5:12 PM, Gregory Ewing
 wrote:
> Chris Angelico wrote:
>
>> You might have won the 100m dash, except that we couldn't verify your
>> velocity of locomotion without a... run time check. Badumtish.
>
>
> All is not lost. You just need to devise a type system
> capable of proving that his time is faster than any
> other runner in all possible races.

Wouldn't that be rather racist?

Or maybe racy. I'm not sure.

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


Re: The Joys Of Data-Driven Programming

2016-09-01 Thread Gregory Ewing

Paul Moore wrote:

Is there any "make replacement"
out there that focuses more on named sets of actions (maybe with
prerequisite/successor type interdependencies), and less on building file
dependency graphs?


Possibly Gradle might qualify. I only have a hazy
understanding of it (basically just what I was forced to
learn for Minecraft modding) but it seems to be based
on "tasks" that can have prerequisites.

This seems to work okay in the context of Java, where
the usual practice seems to be to throw all your source
files at the compiler and let it churn away, rather
than try to figure out exactly which files need
compiling -- which is hard to do for Java based on
timestamps alone, and since the compiler is pretty
fast, probably not worth the effort.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


how to set paramiko to use ssh version 1?

2016-09-01 Thread meInvent bbird
how to set paramiko to use ssh version 1?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Variables visibility for methods

2016-09-01 Thread juraseg
среда, 31 августа 2016 г., 14:09:16 UTC+7 пользователь ast написал:
> Hello
> 
> I made few experiments about variables visibility
> for methods.
> 
> class MyClass:
> a = 1
> def test(self):
> print(a)
> 
> obj = MyClass()
> obj.test()
> 
> Traceback (most recent call last):
>   File "", line 1, in 
> obj.test()
>   File "", line 4, in test
> print(a)
> NameError: name 'a' is not defined
> 
> === RESTART: Shell ==
> 
> a = 1
> 
> class MyClass:
> def test(self):
> print(a)
> 
> obj = MyClass()
> obj.test()
> 1
> 
> So it seems that when an object's méthod is executed, variables
> in the scope outside the object's class can be read (2nd example),
> but not variables inside the class (1st example).
> 
> For 1st example, I know that print(MyClass.a) or print(self.a)
> would have work.
> 
> Any comments are welcome.

Class construction in Python does not have scope in usual way. In fact "class" 
construct is essentially a syntactic sugar to call of "type" built-in function 
(https://docs.python.org/3.5/library/functions.html#type) and then adding all 
the parts manually. 

When you put a variable inside class definition but outside of any method body 
the variable becomes class attribute (so can be accessed by using MyClass.var 
or self.var if inside method body, keep in mind though that assigning to 
self.var creates instance attribute instead of changing class attribute)
-- 
https://mail.python.org/mailman/listinfo/python-list


Issues with "twistd" in Twisted 16.4.0

2016-09-01 Thread juraseg
Hi all

I couldn't find Twisted-specific group, so posting here.

Recently Twisted 16.4.0 got released. Yesterday I've tried to upgrade it for my 
apps and got an error.

I've created simple example, which demonstrates it.
File service.tac:

# You can run this .tac file directly with:
#twistd -ny service.tac

import os
from twisted.application import service, internet

import mymodule

application = service.Application("Demo application")



File mymodule.py:

def myfunction(asd):
""" Stub function """


If you try to run it with twistd -y service.tac you'll get an error:
>>> Failed to load application: No module named mymodule


The errors comes down to this: twistd script does not add current working 
directory to python path, so it fails to import any packages/modules from it. 
It works just fine on previous version (Twisted 16.3.2).

The strange thing here is that it was working before just fine, and I did not 
find anything related to this in release notes 
(http://labs.twistedmatrix.com/2016/08/twisted-1640-released.html), except that 
twistd now is a Setuptools console script (which I honestly don't know how can 
affect python path).

Any ideas?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Issues with "twistd" in Twisted 16.4.0

2016-09-01 Thread juraseg
Also, I've tried to find anything in Twisted bug tracker, but I can't find my 
way in there.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: C Python extension to export an Function

2016-09-01 Thread Ganesh Pal
On Thu, Sep 1, 2016 at 12:32 PM, dieter  wrote:

> Ganesh Pal  writes:
>
> > Iam pretty new to C Python extension , I was able to export few simple
> > modules to python and it look like the cool thing to do ...
>
> Maybe, it is a good idea to have a look at "cython".
>
> "cython" is a compiler. It translates Python code enhanced with
> special annotations into C. The annotations mostly tell the compiler
> that something ("object", "method", "function", ...) should be at "C"
> rather than "Python" level, thus avoiding much of Python's overhead
> and allows to do things possible in "C" but not in "Python".
>
>
> Developing safe "C" extensions for Python is difficult. You
> need some quite deep understanding of the Python-C interface
> and must be very careful to observe all requirements (especially
> those related to proper reference management).
>
> Developing "C" extensions with "cython" is much easier as
> "cython" hides many of the complexities and takes care of most
> requirements.
>

Dear  Dieter ,

Really appreciate the reply and your suggestion on  trying to use "cython"
,  but my whole idea of using  "C" extension is to regular C codes .  We
have bunch of C code that's already available and   C -Python seems to suit
me better

Regards,
Ganesh
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: C Python extension to export an Function

2016-09-01 Thread Stefan Behnel
Ganesh Pal schrieb am 01.09.2016 um 14:30:
> On Thu, Sep 1, 2016 at 12:32 PM, dieter wrote:
>> Ganesh Pal writes:
>>> Iam pretty new to C Python extension , I was able to export few simple
>>> modules to python and it look like the cool thing to do ...
>>
>> Maybe, it is a good idea to have a look at "cython".
>>
>> "cython" is a compiler. It translates Python code enhanced with
>> special annotations into C. The annotations mostly tell the compiler
>> that something ("object", "method", "function", ...) should be at "C"
>> rather than "Python" level, thus avoiding much of Python's overhead
>> and allows to do things possible in "C" but not in "Python".
>>
>> Developing safe "C" extensions for Python is difficult. You
>> need some quite deep understanding of the Python-C interface
>> and must be very careful to observe all requirements (especially
>> those related to proper reference management).
>>
>> Developing "C" extensions with "cython" is much easier as
>> "cython" hides many of the complexities and takes care of most
>> requirements.
> 
> Really appreciate the reply and your suggestion on  trying to use "cython"
> ,  but my whole idea of using  "C" extension is to regular C codes .  We
> have bunch of C code that's already available and   C -Python seems to suit
> me better

>From your response it's not obvious whether you are aware that Cython also
makes it substantially easier to *interface* CPython with external C code,
in the same way that it makes it easy (but not necessary) to *avoid*
writing C in the first place. So I thought I'd just mention that this is
not a reason to rule it out as an excellent option.

Stefan


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


Re: C Python extension to export an Function

2016-09-01 Thread Christian Gollwitzer

Am 01.09.16 um 14:30 schrieb Ganesh Pal:

On Thu, Sep 1, 2016 at 12:32 PM, dieter  wrote:


Ganesh Pal  writes:


Iam pretty new to C Python extension , I was able to export few simple
modules to python and it look like the cool thing to do ...


Maybe, it is a good idea to have a look at "cython".

"cython" is a compiler. It translates Python code enhanced with
special annotations into C. The annotations mostly tell the compiler
that something ("object", "method", "function", ...) should be at "C"
rather than "Python" level, thus avoiding much of Python's overhead
and allows to do things possible in "C" but not in "Python".


Developing safe "C" extensions for Python is difficult. You
need some quite deep understanding of the Python-C interface
and must be very careful to observe all requirements (especially
those related to proper reference management).

Developing "C" extensions with "cython" is much easier as
"cython" hides many of the complexities and takes care of most
requirements.



Dear  Dieter ,

Really appreciate the reply and your suggestion on  trying to use "cython"
,  but my whole idea of using  "C" extension is to regular C codes .  We
have bunch of C code that's already available and   C -Python seems to suit
me better


Yet another option is to try SWIG. SWIG is a special compiler, you feed 
C header files which declare your functions, and it writes the wrapper 
code for you. In simple cases (standa data types like int, float, 
string,...), it might be enough. In more advanced cases, you can add 
your wrappers as "typemaps".


Christian

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


Re: Issues with "twistd" in Twisted 16.4.0

2016-09-01 Thread Kevin Conway
Hi, you might not get much of an answer for this on the Python mailing
list. I suggest sending your question to the Twisted mailing list instead:
https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python.

On Thu, Sep 1, 2016 at 7:12 AM juraseg  wrote:

> Also, I've tried to find anything in Twisted bug tracker, but I can't find
> my way in there.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Issues with "twistd" in Twisted 16.4.0

2016-09-01 Thread Yuri

On 01/09/16 20:17, Kevin Conway wrote:

Hi, you might not get much of an answer for this on the Python mailing
list. I suggest sending your question to the Twisted mailing list instead:
https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python.

On Thu, Sep 1, 2016 at 7:12 AM juraseg  wrote:


Also, I've tried to find anything in Twisted bug tracker, but I can't find
my way in there.
--
https://mail.python.org/mailman/listinfo/python-list



Thanks! I'll try there

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


Re: C Python extension to export an Function

2016-09-01 Thread Ganesh Pal
Thanks stefan and  Gollwitzer  , good to know there are many ways to do this
i.e via cython or SWIG   but  the C/Python API
 is probably the most widely used method
- not for it’s simplicity but for the fact that you can manipulate python
objects in your C code.

I want to use C/Python API 

On Thu, Sep 1, 2016 at 6:32 PM, Stefan Behnel  wrote:

> Ganesh Pal schrieb am 01.09.2016 um 14:30:
> > On Thu, Sep 1, 2016 at 12:32 PM, dieter wrote:
> >> Ganesh Pal writes:
> >>> Iam pretty new to C Python extension , I was able to export few simple
> >>> modules to python and it look like the cool thing to do ...
> >>
> >> Maybe, it is a good idea to have a look at "cython".
> >>
> >> "cython" is a compiler. It translates Python code enhanced with
> >> special annotations into C. The annotations mostly tell the compiler
> >> that something ("object", "method", "function", ...) should be at "C"
> >> rather than "Python" level, thus avoiding much of Python's overhead
> >> and allows to do things possible in "C" but not in "Python".
> >>
> >> Developing safe "C" extensions for Python is difficult. You
> >> need some quite deep understanding of the Python-C interface
> >> and must be very careful to observe all requirements (especially
> >> those related to proper reference management).
> >>
> >> Developing "C" extensions with "cython" is much easier as
> >> "cython" hides many of the complexities and takes care of most
> >> requirements.
> >
> > Really appreciate the reply and your suggestion on  trying to use
> "cython"
> > ,  but my whole idea of using  "C" extension is to regular C codes .  We
> > have bunch of C code that's already available and   C -Python seems to
> suit
> > me better
>
> From your response it's not obvious whether you are aware that Cython also
> makes it substantially easier to *interface* CPython with external C code,
> in the same way that it makes it easy (but not necessary) to *avoid*
> writing C in the first place. So I thought I'd just mention that this is
> not a reason to rule it out as an excellent option.
>
> Stefan
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: C Python extension to export an Function

2016-09-01 Thread Stefan Behnel
Ganesh Pal schrieb am 01.09.2016 um 17:24:
> Thanks stefan and  Gollwitzer  , good to know there are many ways to do this
> i.e via cython or SWIG   but  the C/Python API
>  is probably the most widely used method

It certainly was, years ago, but I honestly doubt that it still is. I don't
think there is still that much manually written C-API code out there that
is actively maintained. Often enough, it's easier to rewrite the code in
Cython at some point, than to keep maintaining it in C over years.

Manually written C-API code is simply too difficult to maintain, and also
too difficult to get right in the first place. There are just too many ways
to introduce reference leaks, crashes and long standing unnoticed bugs
(believe me, I know what I'm talking about). Even experienced CPython core
devs still make mistakes here from time to time.


> - not for it’s simplicity but for the fact that you can manipulate python
> objects in your C code.

Neither SWIG nor Cython prevent you from doing that, although you'd usually
leave these things to Cython since it already generates faster code for
many operations than you would (or could) write by hand.

Stefan


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


Re: C Python extension to export an Function

2016-09-01 Thread Pavel S
If you're familiar with C++, I recommend to have a look at Boost::Python. 

Sample program:

#include 

#include 

void world()
{
std::cout << "hello world" << std::endl;
}


BOOST_PYTHON_MODULE( hello )
{
using namespace ::boost::python;

def( "world", &world );
}

Usage:

python -c "import hello; hello.world()"

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


Re: C Python extension to export an Function

2016-09-01 Thread Christian Gollwitzer

Hi Ganesh,

Am 01.09.16 um 17:24 schrieb Ganesh Pal:

Thanks stefan and  Gollwitzer  , good to know there are many ways to do this
i.e via cython or SWIG   but  the C/Python API
 is probably the most widely used method
- not for it’s simplicity but for the fact that you can manipulate python
objects in your C code.


I'm not sure you understood what SWIG or Cython do - they are not 
circumventing the C/Python API, they merely write some of the code for 
you (as a C file). With both you can add manually written C code if the 
generated code is insufficient, and you can also ship the generated 
code, so that SWIG or Cython are not needed to rebuild the module, 
unless the API of your C coded functions changes.



I want to use C/Python API 


You may have good reasons to do it manually anyway, in this case look at 
the PyArg_ParseTuple and Py_BuildValue functions documented here

https://docs.python.org/2/c-api/arg.html

Christian




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


Python 3 at Facebook

2016-09-01 Thread Terry Reedy

https://www.youtube.com/watch?v=nRtp9NgtXiA
Jason Fried explains how he helped advance 'modern Python', 3.x, from
'impossible' in 2013 to the 'default for new code' today.

--
Terry Jan Reedy

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


Re: C Python extension to export an Function

2016-09-01 Thread dieter
Ganesh Pal  writes:
> ...
> Thanks stefan and  Gollwitzer  , good to know there are many ways to do this
> i.e via cython or SWIG   but  the C/Python API
>  is probably the most widely used method
> - not for it’s simplicity but for the fact that you can manipulate python
> objects in your C code.
>
> I want to use C/Python API 

I have used both Python's C API (to implement "dm.incrementalsearch")
and (later) "cython" (to implement "dm.xmlsec.binding"). I can tell
you from personal experience
that the "cython" approach is much easier (and even more straight forward).

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