Re: Python 3.5 amd64 and win32service

2016-10-05 Thread Nagy László Zsolt

>
> The MWE I provided is so simple. By now, It should be obvious what is
> missing from it. :-(
>
>
The problem is NOT with my code. I just installed a new virtual machine,
and installed python3.5 amd64 + pypiwin32 on it. On that machine, the
test service works perfectly!

So it is with my machine. My machine has Python2.7 32bit, Python 3.5
32bit and Python 3.5 64bit installed. Can this be the problem? But how?

What to do next?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue24459] Mention PYTHONFAULTHANDLER in the man page

2016-10-05 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

Hi Joshua,
Seems like your latest patch doesn't apply cleanly to the default branch.
Can you rebase and upload a new patch?

Thanks.

--
nosy: +Mariatta

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Python 3.5 amd64 and win32service

2016-10-05 Thread Nagy László Zsolt



> On Wed, Oct 5, 2016 at 7:43 AM, Nagy László Zsolt  
> wrote:
>> It did not help. I still get the same error message (service did not
>> respond in time).
> Can you run the service executable directly? From the command line
> check `sc qc TestService`. Run the BINARY_PATH_NAME executable, e.g.
>
> for /f "tokens=1* delims=: " %i in (
> 'sc qc TestService ^| findstr BINARY_PATH_NAME') do @%j
>
> output:
>
> C - Python Service Manager
> Options:
>  -register - register the EXE - this should generally not be necessary.
>  -debug servicename [parms] - debug the Python service.
>
> NOTE: You do not start the service using this program - start the
> service using Control Panel, or 'net start service_name'
All of the commands below were executed in cmd.exe running in elevated
mode (as administrator):

c:\Users\Laci\Python\Projects\gateway>service_test.py install
Installing service TestService
Service installed

c:\Users\Laci\Python\Projects\gateway>sc qc TestService
[SC] QueryServiceConfig SUCCESS

SERVICE_NAME: TestService
TYPE   : 10  WIN32_OWN_PROCESS
START_TYPE : 3   DEMAND_START
ERROR_CONTROL  : 1   NORMAL
BINARY_PATH_NAME   :
"C:\Users\Laci\AppData\Local\Programs\Python\Python35\lib\site-packages\win32\PythonService.exe"
LOAD_ORDER_GROUP   :
TAG: 0
DISPLAY_NAME   : Test Service
DEPENDENCIES   :
SERVICE_START_NAME : LocalSystem



It seems to be the correct executable:

c:\Users\Laci\Python\Projects\gateway>py -3
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64
bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'C:\\Users\\Laci\\AppData\\Local\\Programs\\Python\\Python35\\python.exe'

The service starts to fail in any way:

* service_test.py start
* net start testservice
* from the services.msc with the start button

The error message suggest that the service does not respont to the start
request.

The MWE I provided is so simple. By now, It should be obvious what is
missing from it. :-(


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


[issue28201] dict: perturb shift should be done when first conflict

2016-10-05 Thread INADA Naoki

Changes by INADA Naoki :


Added file: http://bugs.python.org/file44981/dict-perturb-shift4.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27859] argparse - subparsers does not retain namespace

2016-10-05 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

Seems like this can be closed.
Thanks.

--
nosy: +Mariatta

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28201] dict: perturb shift should be done when first conflict

2016-10-05 Thread INADA Naoki

Changes by INADA Naoki :


Added file: http://bugs.python.org/file44980/dict-perturb-shift3.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28201] dict: perturb shift should be done when first conflict

2016-10-05 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Added comments on Rietveld.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: I am comfused about the name behavior of Python in recursion

2016-10-05 Thread Gregory Ewing

38016226...@gmail.com wrote:

def rec(a):
a+=1
if a<10:
rec(a)
print(a)

rec(0) gives me 101 normally.Why it works? Because of the stack memory 
management?


Yes. There isn't just one 'a' here, there's a different one
each time rec is called.


Thank you

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


[issue28201] dict: perturb shift should be done when first conflict

2016-10-05 Thread Tim Peters

Tim Peters added the comment:

LGTM!  Ship it :-)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Assignment versus binding

2016-10-05 Thread Gregory Ewing

Chris Angelico wrote:

Hence my
query about how variadic functions and automatic currying work - how
does it know whether to curry or run?


Calling it "automatic" was probably a bad choice of words.
I don't mean to imply that Haskell goes around currying
things behind your back when you don't want it to.

Rather, Haskell provides a very concise syntax for
defining and using curried functions -- so concise that
it's easier to use it than not, so it tends to get used
by default even when currying isn't strictly necessary.

The Haskell definition

f x y z = x + y + z

is equivalent to the Python definition

f = lambda x: lambda y: lambda z: x + y + z

To call it, you write

f 1 2 3

Function application associates to the left, so that's
equivalent to

((f 1) 2) 3)

or in Python,

f(1)(2)(3)

If you don't want currying, there are various options.
For example, you could define it to take a tuple:

f (x, y, z) = x + y + z

which is equivalent to the Python

def f(args):
  x, y, z = args
  return x + y + z

Then you would call it as

f (1, 2, 3)

i.e. construct a tuple of values and then pass it as the
single argument.

For a variable number of arguments, you could use a list
instead of a tuple, but again you would need to explicitly
construct the list when calling.

I hope you can see from this that there's no confusion over
"whether to curry or run". It all depends on how you define
the function.

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


[issue28201] dict: perturb shift should be done when first conflict

2016-10-05 Thread INADA Naoki

INADA Naoki added the comment:

While I think this patch is safe, I need LGTM from another committer
because I'm new committer.

Could Tim or Raymond review the patch before 3.6beta2?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21140] Idle: saving Shell or an OutputWindow should default to .txt

2016-10-05 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I am closing #28365 in favor of this.  As noted there, Shell is a subclass of 
OutputWindow is a subclass of EditorWindow, so Shell should inherit new 
behavior from OutputWindow instead of both from EW.

Change to the patch: I think .py should not even be a selectable option as 
Shell cannot be edited down to code, and it would make no sense to do so.  And 
anyone who did want to save as .py could select 'all types' and type '.py' 
explicitly.

I was thinking that filetype should be set in OutputWindow, but that does not 
include text files in an editor window (with 
editwin.ispythonsource(self.filename) False).  Another reason is that I want to 
change the editor class structure.

Currently. the editor window used for all files is the confusingly named 
PyShellEditorWindow in pyshell.py, which adds breakpoints to EditorWindow.  In 
long run, EditorWindow should be used for non-python editing.  The current 
PyShellEditorWindow should become PythonEditor and have all the attributes and 
methods specific to python code.  Then EditorWindow.filetypes would have .txt 
and *.* and .py would be added in PythonEditor.  It would also, then, not be 
necessary to disable code stuff in OutputWindow (like the Run menu).  (In fact, 
it might turn out that EditorWindow and OutputWindow would be the same, a base 
TextEditor

--
assignee:  -> terry.reedy
stage: needs patch -> patch review
versions: +Python 3.6, Python 3.7 -Python 2.7, Python 3.4, Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27825] Make the documentation for statistics' data argument clearer.

2016-10-05 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

Updated the docs and updated the example codes as well.

Please review :)

--
keywords: +patch
nosy: +Mariatta
Added file: http://bugs.python.org/file44979/issue27825.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24452] Make webbrowser support Chrome on Mac OS X

2016-10-05 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

Well... I created a patch based on Ned's code :)

This now works in the default branch

Python 3.7.0a0 (default:f2204eaba685+, Oct  5 2016, 20:43:44) 
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import webbrowser
>>> webbrowser.get("chrome")

>>> webbrowser.open_new("https://www.python.org;)
True


Please review :)

--
keywords: +patch
nosy: +Mariatta
Added file: http://bugs.python.org/file44978/issue24452.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue10716] Modernize pydoc to use better HTML and separate CSS

2016-10-05 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Since David added me as nosy, I will address the IDLE issues raised above.

But first, a question.  Does 'deprecating HTML output' merely mean deprecating 
the old output in favor of new and better HTML output, or deprecating having 
any html output, which would also mean deprecating the html doc server?  I am 
strongly against the latter.

Currently, IDLE, in both pyshell and run.py, imports pydoc and sets 
"pydoc.pager = pydoc.plainpager".  Bypassing pydoc.getpager this way is not 
documented, but seems perhaps necessary.  Other than this, I believe 
'help(xyz)' is treated by IDLE just like any other user code.

Serhiy, msg278126 > "It would be nice if IDLE use this feature"

There are actually two features: hmtl output, and the html server, which uses 
the default browser to display the output.

Since a year ago, IDLE help displays the html IDLE doc produced by sphinx in a 
subclass of tkinter Text that feeds the page to a subclass of HTMLParser.  The 
code is in help.py.  Sphinx's html seems to follow Frédéric's guidelines in 
msg246917.  I suspect the CSS files are ignored.  We might want to do something 
similar with pydocs html output.

Raymond: is sphinx's pydoctheme anything like the css you are looking for?  
Could it be used as a starting point?
  
  


There have been requests that 'long' help output (for modules and classes) be 
displayed separately from Shell itself so that it does not obscure history and 
be easier to refer to.  If we do this, using html instead of plain text would 
be nice, especially if new features were added.

Serhiy, cont. > "I think we should enhance HTML output not just by making it 
looking better, but by adding more interactivity. For example add the ability 
to collapse classes, methods, etc, add more hyperlinks."

I mainly use pydoc server for tkinter.  I would *love* have the repetitive 
'inherited methods' section for each class collapsed by default.  Ditto for 
when I use help interactively.  To me, this is the single worst feature of 
pydoc output.

David msg278127 > "If Terry would like to see pydoc enhanced to support idle, 
then I think that would decide the issue."

I am not sure what you mean by 'the issue' and I can't currently think of 
anything IDLE-specific that pydoc should do, other than be consistent.  
However, producing modern, decent looking html output would make html use 
possible.  Incorporating the current output, as displayed in the server, might 
be a net negative PR move.


Side note: thinking about how to make a clickable link in a Text widget, I 
realized that that IDLE already does some syntax tagging for colors (keywords, 
builtins, def and class identifiers).  The same tags could be bound to 
double-click or right-click to display help popups, such as
--
The "if" statement is used for conditional execution:

   if_stmt ::= "if" expression ":" suite
   ( "elif" expression ":" suite )*
   ["else" ":" suite]

It selects exactly one of the suites by evaluating the expressions one
by one until one is found to be true (see section Boolean operations
for the definition of true and false); then that suite is executed
(and no other part of the "if" statement is executed or evaluated).
If all expressions are false, the suite of the "else" clause, if
present, is executed.

Related help topics: TRUTHVALUE

with the grammar chunk highlighted and the related topics clickable.  What IDLE 
would need here is consistency in the format of the help texts.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Assignment versus binding

2016-10-05 Thread Rustom Mody
On Thursday, October 6, 2016 at 1:06:07 AM UTC+5:30, BartC wrote:
> On 05/10/2016 14:43, Rustom Mody wrote:
> > On Wednesday, October 5, 2016 at 7:05:02 PM UTC+5:30, BartC wrote:
> 
> >> That's the one it can't find. Actually it can't seem to import any
> >> standard libraries, so the implementation must be screwed up.
> >>
> >> Or is it because I downloaded the Minimal** rather Full version? The
> >> minimal version is already 1.7GB! Can it really be that big and yet not
> >> include such basic stuff? If so, what on earth is taking up all the
> >> space! (The full version was 10-15% bigger.)
> >>
> >> (**
> >> https://downloads.haskell.org/~platform/8.0.1/HaskellPlatform-8.0.1-minimal-x86_64-setup-a.exe)
> >
> > Minimal means only compiler: NO libraries except what the compiler needs to 
> > compile.
> > Almost certainly wrong for a beginner’s testing the waters.
> >
> > You should probably download haskell-platform (full)
> 
> (I've downloaded the full version. Now I have 25,000 files in 2200MB. 
> And it still doesn't work.

We are now crossing the fuzzy OT boundary! Wont persist too much
on list about this. Just a few comments:

Many noobs (to programming/Python/computers/life!) appear out here with
similar questions — it doesn’t work!!! I would guess most of them feel similar
to you. I would like to believe that most of them get out of their difficulty 
with the help of more experienced responders out here.

Likewise Haskell. Go to haskell-cafe or haskell-beginners mailing-lists
and you should cross this roadblock easily enough
https://mail.haskell.org/mailman/listinfo/haskell-cafe
https://mail.haskell.org/mailman/listinfo/beginners

You can write to me also — off-list! Just that I dont consider myself a
haskell expert. Still less a haskell-on-windows expert

For now I will only reiterate haskell-platform without System.* does not
seem reasonable. You took a wrong turning somewhere.

Is haskell large? Yes!
Should it be? OT discussion, relevance of which asymptotically vanishes
thanks to Moore’s law
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I am comfused about the name behavior of Python in recursion

2016-10-05 Thread Ben Finney
38016226...@gmail.com writes:

> Google told me Python name is a label attaching to the object.

Well, “Google told me” has no necessary bearing on whether it's true :-)
so that's not a good citation to give.

If you need to know what Python terminology means, the Python
documentation is better.



so, I don't think “name” has a technical meaning for Python.

Rather, Python has an assignment operation, which binds a name (or some
other reference) to an object.

> But in this recursive function,the name 'a' will point to different number 
> object.
>
> def rec(a):
>   a+=1
>   if a<10:
>   rec(a)
>   print(a)
>
> rec(0) gives me 101 normally.

Yes. What would you expect instead, and why?

Maybe you think the *name* is passed around. That doesn't happen; in
Python, names are not tractable in that way.

By referencing the name ‘a’, you immediately have the object referred to
by that name. You don't have the name itself, and when you pass that
object, the name you happened to use does not come with it.

-- 
 \ “Science is a way of trying not to fool yourself. The first |
  `\ principle is that you must not fool yourself, and you are the |
_o__)   easiest person to fool.” —Richard P. Feynman, 1964 |
Ben Finney

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


Re: Python and ssh for remote login

2016-10-05 Thread Michael Torrie
On 10/05/2016 11:46 AM, Noah wrote:
> Hello folk,
> 
> I would like to use a python script to ssh into a server using a username
> and password and perhaps ass port.
> 
> Any ideas on how to script that.

If paramiko doesn't fit your needs, traditionally this sort of work was
done with the pexpect module for drying a TTY. There is a submodule of
pexpect called pxssh for automating things.

http://pexpect.readthedocs.io/en/stable/api/pxssh.html

Note that pexpect uses your normal ssh binary.  Paramiko is a complete
implementation of the ssh protocol in python.  Both modules are useful
and fill certain needs.
-- 
https://mail.python.org/mailman/listinfo/python-list


I am comfused about the name behavior of Python in recursion

2016-10-05 Thread 380162267qq
Google told me Python name is a label attaching to the object.
But in this recursive function,the name 'a' will point to different number 
object.

def rec(a):
a+=1
if a<10:
rec(a)
print(a)

rec(0) gives me 101 normally.Why it works? Because of the stack memory 
management?

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


Re: User Interface Suggestions? (newbie)

2016-10-05 Thread Beverly Howard
Thanks guys...

I'm getting overwhelmed with good info, so, I am going to disappear
for a while and will comeback with questions when I get far enough to
ask them.

Again, thanks!

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


[issue25292] ssl socket gets into broken state when client exits during handshake

2016-10-05 Thread Yury Selivanov

Yury Selivanov added the comment:

Christian, would you be able to look into this before b2?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24697] Add CoroutineReturn and CoroutineExit builtin exceptions for coroutines

2016-10-05 Thread Yury Selivanov

Yury Selivanov added the comment:

Closing this one. Seems we can live just fine without these new exceptions.

--
resolution:  -> wont fix
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27168] Comprehensions and await need more unittests

2016-10-05 Thread Yury Selivanov

Yury Selivanov added the comment:

Closing this one. We added a lot of tests as part of the PEP 530 implementation.

--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23749] asyncio missing wrap_socket (starttls)

2016-10-05 Thread Yury Selivanov

Yury Selivanov added the comment:

With the latest change it's possible to implement starttls
as a separate package on PyPI, or even by copying/pasting a small
snipped of code in your project.

It's expected that we'll figure out the API design for starttls
during 3.6, so that we can add it in 3.7.

This issue should be kept open until we have a full public API
for starttls in asyncio.

--
versions:  -Python 3.5, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23749] asyncio missing wrap_socket (starttls)

2016-10-05 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 3771a6326725 by Yury Selivanov in branch '3.5':
asyncio: Add "call_connection_made" arg to SSLProtocol.__init__
https://hg.python.org/cpython/rev/3771a6326725

New changeset 3e6739e5c2d0 by Yury Selivanov in branch '3.6':
Merge 3.5 (issue #23749)
https://hg.python.org/cpython/rev/3e6739e5c2d0

New changeset f2204eaba685 by Yury Selivanov in branch 'default':
Merge 3.6 (issue #23749)
https://hg.python.org/cpython/rev/f2204eaba685

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28372] Fix asyncio to support formatting of non-python coroutines

2016-10-05 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 7bacd209ac4f by Yury Selivanov in branch '3.5':
Issue #28372: Fix asyncio to support formatting of non-python coroutines
https://hg.python.org/cpython/rev/7bacd209ac4f

New changeset f7550d535878 by Yury Selivanov in branch '3.6':
Merge 3.5 (issue #28372)
https://hg.python.org/cpython/rev/f7550d535878

New changeset 8bc3e9754b3d by Yury Selivanov in branch 'default':
Merge 3.6 (issue #28372)
https://hg.python.org/cpython/rev/8bc3e9754b3d

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28372] Fix asyncio to support formatting of non-python coroutines

2016-10-05 Thread Yury Selivanov

Changes by Yury Selivanov :


--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28372] Fix asyncio to support formatting of non-python coroutines

2016-10-05 Thread Yury Selivanov

New submission from Yury Selivanov:

Like the ones that were compiled with Cython.

--
assignee: yselivanov
components: asyncio
messages: 278159
nosy: gvanrossum, yselivanov
priority: normal
severity: normal
stage: resolved
status: open
title: Fix asyncio to support formatting of non-python coroutines
type: enhancement
versions: Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27286] str object got multiple values for keyword argument

2016-10-05 Thread Łukasz Langa

Łukasz Langa added the comment:

The magic number change in a minor release was a mistake. Let's not do that 
with 3.6.x releases. Since Python doesn't check if there's a corresponding .py 
file that can be used to rebuild the .pyc file, we shouldn't reject existing 
.pyc files on the basis that they *might* be broken.

--
nosy: +lukasz.langa

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Assignment versus binding

2016-10-05 Thread Chris Angelico
On Thu, Oct 6, 2016 at 9:45 AM, BartC  wrote:
> On 05/10/2016 22:34, Chris Angelico wrote:
>>
>> On Thu, Oct 6, 2016 at 6:35 AM, BartC  wrote:
>>>
>>> This is exactly why I persist with my own language implementations. My
>>> current one is only 1/5000th the size but standard libraries are
>>> included!)
>>
>>
>> Yes, it has all the standard library that *you* expect. Does it have
>> what some random person on the internet will expect? Here are a few
>> examples from the standard library of Python:
>>
>> * Unicode character names and categories
>> * Date/time manipulation
>> * Arbitrary-precision rationals
>> * Statistical functions
>> * zlib (zip/gzip) compression and decompression
>> * sqlite3 databasing
>> * BSD sockets
>> * Various internet protocols  (HTTP, FTP, SMTP, IMAP)
>>
>> And that's not even counting the stuff that, if it were proposed
>> today, would probably be pushed to PyPI. Standard libraries tend to be
>> fairly large because they're catering to a lot of people's needs. Mind
>> you, two gig is still a lot, I'm not denying that; but you're saying
>> that yours is half a meg, and I doubt that a full-featured language of
>> today can exist inside a floppy disk.
>
>
> No, it doesn't have all that. But believe me, even with all those things,
> and even if it worked, a 2GB language implementation is *MASSIVE*, not just
> a lot.

Yeah - I agreed with you on that. 2GB+ is huge. But if you try to keep
your language ubertiny, you're going to have a _lot_ of people
complaining that your stdlib doesn't have .

> Even Python, not exactly small, is only 2.5% the size (for 3.4 and
> presumably including all the libraries in your list).

Right. I didn't calculate the percentages, but my cpython/Lib
directory is something like 40MB. You could shrink that down a ton by
eliminating the tests and zipping the rest up, without losing primary
functionality, but it'd still be a good solid bit - about 5MB.

> As to what it consists of, well it doesn't include any How-To videos which
> would account for much of it. But it does seem to have MSYS (ie. half a Unix
> system, 200MB); Mingw (a gcc C compiler, 350MB); docs (180MB); and a library
> (1300MB, but looking at it much of it seems to be useless junk).
>
>> (Also, does your implementation compile directly to machine code, or
>> does it depend on something else? It's easy to make something small if
>> it depends on another compiler/interpreter.)
>
> The language in question is interpreted. It depends on a
> compiler/interpreter which is currently a 300KB executable but could end up
> a bit bigger. The most basic libraries are another 60KB (which will probably
> end up inside the executable). The only dependencies are what is already
> present in an OS (msvcrt.dll for example).

Ignoring OS-provided deps is perfectly fine. But if, for instance,
your program emits C code, then it depends on a C compiler, which adds
to the effective download.

> Small languages are perfectly viable: the JIT version of Lua, for example,
> is only about 225KB, and is very fast.
>
> If I wanted to send you program.lua, and you didn't have Lua, I only need to
> add luajit.exe and lus51.dll (for Windows). With my system, it would be
> program.q and r.exe, even for multi-module apps.

See above about how restricted the stdib is. Lua, on its own, is not a
full-featured language for writing general-purpose applications. It's
designed to be embedded in something else, and it's great at that, but
it doesn't have all the features of a modern apps language. You could
write an Ook interpreter in a handful of bytes of code, but it's not
what you would write an app in. Since you're talking about Windows, I
grabbed file sizes for Windows installers; for Pike, the .msi file is
a 24MB download, and Python clocks in variously at 18MB (32-bit
2.7.12) up to 28MB (64-bit 3.5.2 full installation). Those kinds of
figures are pretty reasonable for full-featured language interpreters.
You get enough for it to actually be usable as-is, but you're not
getting a full C dev environment.

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


Re: Assignment versus binding

2016-10-05 Thread BartC

On 05/10/2016 22:34, Chris Angelico wrote:

On Thu, Oct 6, 2016 at 6:35 AM, BartC  wrote:

This is exactly why I persist with my own language implementations. My
current one is only 1/5000th the size but standard libraries are included!)


Yes, it has all the standard library that *you* expect. Does it have
what some random person on the internet will expect? Here are a few
examples from the standard library of Python:

* Unicode character names and categories
* Date/time manipulation
* Arbitrary-precision rationals
* Statistical functions
* zlib (zip/gzip) compression and decompression
* sqlite3 databasing
* BSD sockets
* Various internet protocols  (HTTP, FTP, SMTP, IMAP)

And that's not even counting the stuff that, if it were proposed
today, would probably be pushed to PyPI. Standard libraries tend to be
fairly large because they're catering to a lot of people's needs. Mind
you, two gig is still a lot, I'm not denying that; but you're saying
that yours is half a meg, and I doubt that a full-featured language of
today can exist inside a floppy disk.


No, it doesn't have all that. But believe me, even with all those 
things, and even if it worked, a 2GB language implementation is 
*MASSIVE*, not just a lot.


Even Python, not exactly small, is only 2.5% the size (for 3.4 and 
presumably including all the libraries in your list).


As to what it consists of, well it doesn't include any How-To videos 
which would account for much of it. But it does seem to have MSYS (ie. 
half a Unix system, 200MB); Mingw (a gcc C compiler, 350MB); docs 
(180MB); and a library (1300MB, but looking at it much of it seems to be 
useless junk).


> (Also, does your implementation compile directly to machine code, or
> does it depend on something else? It's easy to make something small if
> it depends on another compiler/interpreter.)

The language in question is interpreted. It depends on a 
compiler/interpreter which is currently a 300KB executable but could end 
up a bit bigger. The most basic libraries are another 60KB (which will 
probably end up inside the executable). The only dependencies are what 
is already present in an OS (msvcrt.dll for example).


Small languages are perfectly viable: the JIT version of Lua, for 
example, is only about 225KB, and is very fast.


If I wanted to send you program.lua, and you didn't have Lua, I only 
need to add luajit.exe and lus51.dll (for Windows). With my system, it 
would be program.q and r.exe, even for multi-module apps.


What would I need for program.hs? (I already know of some solutions for 
program.py; that's not so straightforward either. But Python 
installations are more common.)


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


[issue28371] Deprecate passing asyncio.Handles to run_in_executor

2016-10-05 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c8e71ddf1db5 by Yury Selivanov in branch '3.5':
Issue #28371: Deprecate passing asyncio.Handles to run_in_executor.
https://hg.python.org/cpython/rev/c8e71ddf1db5

New changeset c0d84c091db0 by Yury Selivanov in branch '3.6':
Merge 3.5 (issue #28371)
https://hg.python.org/cpython/rev/c0d84c091db0

New changeset 893f65369fea by Yury Selivanov in branch 'default':
Merge 3.6 (issue #28371)
https://hg.python.org/cpython/rev/893f65369fea

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28371] Deprecate passing asyncio.Handles to run_in_executor

2016-10-05 Thread Yury Selivanov

Changes by Yury Selivanov :


--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28371] Deprecate passing asyncio.Handles to run_in_executor

2016-10-05 Thread Yury Selivanov

New submission from Yury Selivanov:

Proxy issue for https://github.com/python/asyncio/issues/334

--
assignee: yselivanov
components: asyncio
messages: 278156
nosy: gvanrossum, yselivanov
priority: normal
severity: normal
stage: resolved
status: open
title: Deprecate passing asyncio.Handles to run_in_executor
type: enhancement
versions: Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: working with ctypes and complex data structures

2016-10-05 Thread eryk sun
On Wed, Oct 5, 2016 at 9:03 PM, Michael Felt  wrote:
>
>> +80  args = (1, "name", None), (2, "buff", None), (1, "size",
>> 0), (1, "count", 1)
>
> error #1. paramater type 2 (the buffer might be where data is being put, but
> for the call, the pointer is INPUT)

An output parameter (type 2) has ctypes implicitly create the buffer
and insert it in the argument list. It gets returned as the call's
result. Here's a contrived example:

class Buf(ctypes.Structure):
_fields_ = (('value', ctypes.c_char * 100),)

LP_Buf = ctypes.POINTER(Buf)

proto = ctypes.CFUNCTYPE(ctypes.c_int,
LP_Buf, ctypes.c_char_p, ctypes.c_int)
flags = ((2, 'buf'), (1, 'fmt'), (1, 'arg', 42))
sprintf = proto(('sprintf', ctypes.CDLL(None)), flags)

>>> r = sprintf(b'The answer is %d.')
>>> r.value
b'The answer is 42.'

This works best when combined with an errcheck function. This lets you
see the actual arguments that were passed in the call and the original
result:

def errcheck(result, func, args):
print('result:', result)
print('args:', args)
return args

sprintf.errcheck = errcheck

>>> r = sprintf(b'The answer is %d.')
result: 17
args: (<__main__.Buf object at 0x7fede840bb70>, b'The answer is %d.', 42)

When the errcheck function returns "args", this tells ctypes to
continue with its normal post-processing, so instead of the actual 17
result, it returns the "buf" output parameter:

>>> r.value
b'The answer is 42.'

Notice that I declared the output parameter's type as a pointer type,
but ctypes is smart enough to create a Buf instance for me instead of
just a pointer. Also, because the argument type is a pointer type, its
from_param method implicitly passes the Buf instance by reference.

> class perfstat_xxx:
> def init(self):
> # AIX member in an archive
> _perflib = ctypes.CDLL("libperfstat.a(shr_64.o)")
> _fn_xxx = _perflib.xxx
> # ALL AIX perfstat routines have 4 arguments:
> # (name, buff, sizeof_buff, count)
> # the buff is a pointer to where the information will be stored
> _fn = CFUNCTYPE(c_int, c_void_p, POINTER(xxx_t), c_int, c_int)
> _args = ((1, "name", None), (1, "buff", None), (1, "size", 0),
>  (1, "count", 1))
> _xxx = _fn(("xxx", _fn_xxx), _args)

You should really do this work at the class or module level. Every
time this init() method is called, you're needlessly incrementing the
reference count on the "libperfstat.a(shr_64.o)" shared library and
needlessly creating and instantiating the function pointer type.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28370] Speedup asyncio.StreamReader.readexactly

2016-10-05 Thread Roundup Robot

Roundup Robot added the comment:

New changeset b3ef922e6f26 by Yury Selivanov in branch '3.5':
Issue #28370: Speedup asyncio.StreamReader.readexactly
https://hg.python.org/cpython/rev/b3ef922e6f26

New changeset b76553de3a29 by Yury Selivanov in branch '3.6':
Merge 3.5 (issue #28370)
https://hg.python.org/cpython/rev/b76553de3a29

New changeset 5913c2b1d80a by Yury Selivanov in branch 'default':
Merge 3.6 (issue #28370)
https://hg.python.org/cpython/rev/5913c2b1d80a

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: User Interface Suggestions? (newbie)

2016-10-05 Thread Akira Li
Beverly Howard  writes:

>...snip...
> A primary question would be, "What are options for building a display
> that would update displayed values without scrolling?"

To rewrite only the last character, you could use '\b':

  import os
  import itertools
  import time
  for c in map(str.encode, itertools.cycle('\-/|')):
  os.write(1, b'\b'+c)
  time.sleep(.3)

To rewrite only the last line, you could use '\r':

  for i in range(1, 101):
  time.sleep(.1)
  print('\r{:4.0%}'.format(i/100), flush=True, end='')

To control the full screen in the terminal e.g., to change the position,
you could use *blessings* module [1]:

  from blessings import Terminal  # $ pip install blessings

  line = 'Line in the middle of the terminal.'
  term = Terminal()
  with term.hidden_cursor(), term.fullscreen():
  x = (term.width - len(line)) // 2
  y = (term.height - 1) // 2
  with term.location(x, y):
  print(term.bold_white_on_black(line))
  
  with term.location(0, term.height - 1):
  input('press  to exit..')
  
For interactive command-line applications from a simple prompt to full
screen terminal applications, you could use *prompt_toolkit* module [2].

> My first goal is to build a program that would interface with a
> Raspberry Pi to control a heating process.
>

For flexibility, you could split your program into a server and a client
that controls it (text, GUI, web).

To control the Raspberry Pi from your mobile device, you could try Kivy
[3] or just create something quick in Pythonista 3 on iOS [4].  To create
a GUI on desktop, you could try Tkinter, Gtk, Qt frameworks [5,6].

For the web part on the server, you could try *flask*, *bottle* modules
[7], to return json data to a client using http protocol:

  from bottle import route # $ pip install bottle

  @route('/data')
  def data():
  return dict(data=[1,2,3])

On the (text/GUI) client in Python:

  import requests # $ pip install requests

  data = requests.get('https://your.server.example.com/data').json()

Or in the browser using jQuery [8]:

  $.getJSON('https://your.server.example.com/data', function(data) {
  //use data here
  });

To make the interaction more responsive, you could use WebSocket protocol e.g., 
via
Flask-SocketIO on the server [9].

[1]: https://pypi.python.org/pypi/blessings/
[2]: https://python-prompt-toolkit.readthedocs.io/
[3]: https://kivy.org
[4]: http://omz-software.com/pythonista/
[5]: http://www.tkdocs.com/tutorial/onepage.html
[6]: http://doc.qt.io/qt-4.8/gallery-gtk.html
[7]: http://bottlepy.org/docs/stable/
[8]: http://api.jquery.com/jquery.getjson/
[9]: https://flask-socketio.readthedocs.io

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


Re: Assignment versus binding

2016-10-05 Thread Gregory Ewing

BartC wrote:
This is exactly why I persist with my own language implementations. My 
current one is only 1/5000th the size but standard libraries are included!)


You might like to try a different Haskell implementation,
such as Hugs:

https://wiki.haskell.org/Hugs

According to the web page, it comes with most of the same
libraries as ghc. It's based on an older version of the
Haskell standard, though, so I'm not sure if it's up to
date with modern practice regarding monads, etc.

Hugs is what I used last time I messed around with functional
programming, and it seemed to work very nicely. I don't
remember exactly how big it was, but it certainly wasn't
measured in gigabytes! That's just ridiculous.

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


[issue28370] Speedup asyncio.StreamReader.readexactly

2016-10-05 Thread Yury Selivanov

Changes by Yury Selivanov :


--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28370] Speedup asyncio.StreamReader.readexactly

2016-10-05 Thread Yury Selivanov

New submission from Yury Selivanov:

Proxy for https://github.com/python/asyncio/pull/395

--
assignee: yselivanov
components: asyncio
messages: 278154
nosy: gvanrossum, yselivanov
priority: normal
severity: normal
stage: resolved
status: open
title: Speedup asyncio.StreamReader.readexactly
type: performance
versions: Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: User Interface Suggestions? (newbie)

2016-10-05 Thread Brendan Abel
You should look into using PyQt or PySide.  They are python bindings for
the very popular Qt GUI framework.



On Wed, Oct 5, 2016 at 2:33 PM, Beverly Howard  wrote:

> >> if it is a pi controlling the system I would tend towards controlling it
> from a web page via the network. to keep it updating would require AJAX
> style programming of the web page. <<
>
> Thanks.  I am interested in eventually doing that, but it seems that
> learning how to do it on a local console first would be to my advantage...
> especially during initial testing stages.
>
> fwiw, this project is to transfer (actually re-create) a basic program
> that I wrote for a Tandy Model 100 portable back in the early 80's to
> control ceramic kilns which get to over 2,000 degrees F.
>
> Worked perfectly until a few years ago when there were no longer any Tandy
> Model 100s available at any cost ;-)  (In case anyone is interested in
> fossilized projects, see http://bevhoward.com/kiln/KilnCtrl.htm)
>
> Thanks again for the response and pointers,
> Beverly Howard
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28369] Raise RuntimeError when transport's FD is used with add_reader etc

2016-10-05 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 2b502f624753 by Yury Selivanov in branch '3.5':
Issue #28369: Raise an error when transport's FD is used with add_reader
https://hg.python.org/cpython/rev/2b502f624753

New changeset f3c1d8869dd5 by Yury Selivanov in branch '3.6':
Merge 3.5 (issue #28369)
https://hg.python.org/cpython/rev/f3c1d8869dd5

New changeset 745e0ff513c2 by Yury Selivanov in branch 'default':
Merge 3.6 (issue #28369)
https://hg.python.org/cpython/rev/745e0ff513c2

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28369] Raise RuntimeError when transport's FD is used with add_reader etc

2016-10-05 Thread Yury Selivanov

New submission from Yury Selivanov:

Proxy issue for https://github.com/python/asyncio/pull/420

--
assignee: yselivanov
components: asyncio
messages: 278152
nosy: gvanrossum, yselivanov
priority: normal
severity: normal
stage: resolved
status: open
title: Raise RuntimeError when transport's FD is used with add_reader etc
type: enhancement
versions: Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: User Interface Suggestions? (newbie)

2016-10-05 Thread Beverly Howard
I _think_ I see what I need... 

window.move(new_y, new_x)
Move cursor to (new_y, new_x)

...even if not, I now know it's there somewhere.

Thanks for the specific links... they are very valuable.

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


[issue28369] Raise RuntimeError when transport's FD is used with add_reader etc

2016-10-05 Thread Yury Selivanov

Changes by Yury Selivanov :


--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: User Interface Suggestions? (newbie)

2016-10-05 Thread Beverly Howard
>> I would recommend the 'curses' library: <<

Great!  Thanks!

I'll be back... I'm sure.

Beverly Howard

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


Re: User Interface Suggestions? (newbie)

2016-10-05 Thread Beverly Howard
>> if it is a pi controlling the system I would tend towards controlling it
from a web page via the network. to keep it updating would require AJAX
style programming of the web page. <<

Thanks.  I am interested in eventually doing that, but it seems that learning 
how to do it on a local console first would be to my advantage... especially 
during initial testing stages.

fwiw, this project is to transfer (actually re-create) a basic program that I 
wrote for a Tandy Model 100 portable back in the early 80's to control ceramic 
kilns which get to over 2,000 degrees F.

Worked perfectly until a few years ago when there were no longer any Tandy 
Model 100s available at any cost ;-)  (In case anyone is interested in 
fossilized projects, see http://bevhoward.com/kiln/KilnCtrl.htm)

Thanks again for the response and pointers,
Beverly Howard

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


Re: Assignment versus binding

2016-10-05 Thread Chris Angelico
On Thu, Oct 6, 2016 at 6:35 AM, BartC  wrote:
> This is exactly why I persist with my own language implementations. My
> current one is only 1/5000th the size but standard libraries are included!)

Yes, it has all the standard library that *you* expect. Does it have
what some random person on the internet will expect? Here are a few
examples from the standard library of Python:

* Unicode character names and categories
* Date/time manipulation
* Arbitrary-precision rationals
* Statistical functions
* zlib (zip/gzip) compression and decompression
* sqlite3 databasing
* BSD sockets
* Various internet protocols  (HTTP, FTP, SMTP, IMAP)

And that's not even counting the stuff that, if it were proposed
today, would probably be pushed to PyPI. Standard libraries tend to be
fairly large because they're catering to a lot of people's needs. Mind
you, two gig is still a lot, I'm not denying that; but you're saying
that yours is half a meg, and I doubt that a full-featured language of
today can exist inside a floppy disk.

(Also, does your implementation compile directly to machine code, or
does it depend on something else? It's easy to make something small if
it depends on another compiler/interpreter.)

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


Re: User Interface Suggestions? (newbie)

2016-10-05 Thread Chris Angelico
On Thu, Oct 6, 2016 at 8:19 AM, Beverly Howard  wrote:
> Thanks for the responses... appreciated.
>
>>> print("value value data data data", end="\r") <<
>
> That makes sense, but it also seems to suggest that there is no other way to 
> position the cursor prior to printing.
>
> For example, if that line is halfway down the screen, is there any way to 
> position the cursor two lines above it?
>
> fwiw, I am open to creating functions if there are positioning options, both 
> to meet the need, but, more importantly, to learn.

What I showed you was the very simplest way of doing things. If you
want to move the cursor around, I would recommend the 'curses'
library:

https://docs.python.org/3/library/curses.html
https://docs.python.org/3/howto/curses.html

There are other ways, too; with more info on what you're trying to
accomplish, we could better advise. It might be that a GUI will serve
you well, particularly if you have several pieces of information that
you want to update.

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


[issue28361] BETA report: Python3.6 names pip pip3.6 (and why is the other name pip3)

2016-10-05 Thread Michael Felt

Michael Felt added the comment:

On 04-Oct-16 21:11, Zachary Ware wrote:
> Zachary Ware added the comment:
>
> Pip is a third party project, so if you'd like to pursue this please open an 
> issue on the pip issue tracker at https://github.com/pypa/pip/issues.
I stand corrected.
> Anyway, pip installs links named the way it does so that you can be (more) 
> sure that you're invoking the correct pip.  'pip3.6' will invoke the pip 
> installed with python3.6, 'pip3' will (or at least should) invoke the pip 
> installed with whatever 'python3' points to, and 'pip' will point to whatever 
> 'python' points to.  When installed in a Python 3 venv, pip also installs a 
> 'pip' link to 'pip3', just as there's also a 'python' link to 'python3'.  In 
> 2.7, pip is also installed as 'pip2.7' and 'pip2' along with 'pip'; again 
> mirroring the version tags on the interpreter links.
So, I guess I should rename my python-3.X packages python3-3.X so they 
can install side.by.side rather than only one or the other. Good point.
>
> --
> nosy: +zach.ware
> resolution:  -> third party
> stage:  -> resolved
> status: open -> closed
>
> ___
> Python tracker 
> 
> ___

--
nosy: +aixto...@gmail.com

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: User Interface Suggestions? (newbie)

2016-10-05 Thread Beverly Howard
Thanks for the responses... appreciated.

>> print("value value data data data", end="\r") <<

That makes sense, but it also seems to suggest that there is no other way to 
position the cursor prior to printing.

For example, if that line is halfway down the screen, is there any way to 
position the cursor two lines above it?

fwiw, I am open to creating functions if there are positioning options, both to 
meet the need, but, more importantly, to learn.

Beverly Howard

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


Re: working with ctypes and complex data structures

2016-10-05 Thread Michael Felt

Never said thank you - so, thanks!

What I need to do was add the .v at the end so I was accessing the value 
of the structure.


Unlilke Linux, AIX - for reasons unknown to all, they have the time_t 
definition that is specific to the ABI size, at least for these 
performance libraries that probably originated before 64-bit was a 
concern. So my guess is that the dual size in the struct, depending on 
the application size (not the kernel) is to maintain compatibility with 
32-bit applications that had been built against/on a 32-bit kernel.


So, lucky for me it did not work intiallly - because it made me pause 
and understand better what I had written.


And now the real thankyou for the detail you shared!

M


On 03-Oct-16 17:53, eryk sun wrote:

On Mon, Oct 3, 2016 at 2:35 PM, Michael Felt  wrote:

On 02-Oct-16 23:44, eryk sun wrote:

   On Sun, Oct 2, 2016 at 5:50 PM, Michael Felt 
wrote:


b) what I am not understanding - as the basic documentation shows
FOO.value as the way to set/get the value of a _field_

You may be surprised when accessing simple-type fields such as c_int
and c_char_p. These simple types have getter and setter functions that
get called automatically whenever the type is used as a function
result, array index, or struct field. For example:

OK - so lucky me - it "does not work" like earlier examples because I am
referencing, generally, c_ulonglong - and these do not have a automatic
getter/setter function? If not, how do I go about making one (preferably
without needing to right a "method" for each and every _field_ in a class.

No, c_ulonglong is a simple (fundamental) type, which behaves just
like other simple types such as c_int or c_char_p.

On platform's with a 64-bit long, c_ulonglong is an alias for c_ulong
(i.e. type "L"). On the other hand, on 64-bit Windows, c_ulonglong is
an unsigned quad word (i.e. type "Q").

All simple types subclass ctypes._SimpleCData and define a `_type_`
code such as "c" for c_char. On 64-bit Linux the simple types are
defined as follows:

 ?: c_bool
 c: c_char
 z: c_char_p
 u: c_wchar
 Z: c_wchar_p
 P: c_void_p

 b: c_int8, c_byte
 B: c_uint8, c_ubyte
 h: c_int16, c_short
 H: c_uint16, c_ushort
 i: c_int32, c_int
 I: c_uint32, c_uint
 l: c_int64, c_long, c_longlong, c_ssize_t
 L: c_uint64, c_ulong, c_ulonglong, c_size_t

 f: c_float
 d: c_double
 g: c_longdouble

For convenience, simple types are automatically converted when
accessed as a function result, struct field, or array index. As I
mentioned previously, the only way around this behavior is to use a
subclass. A subclass doesn't get automatically converted because it
might define custom methods and attributes that need to be preserved.


I'd alias the type instead of defining a struct, e.g. `time_t =
c_long`. This preserves automatic conversion of the simple type.

The reason for the not using alias is because a) I was trying to be more
inline with the text of the include file. I will have to check the sizeof
c_long (i.e., sizeof(long) in both 32 and 64-bit modes

I don't follow. Currently you wrap a c_int or c_long in a struct when
you could just use those types directly. You have to check the pointer
size, but then it's up to you what assumptions to make about the
target platform's integer sizes. Currently on a 64-bit system you're
assuming a Unix-style LP64 data model [1], in which a long is 64-bit.
That should be fine if you're writing Unix-specific code that doesn't
care about LLP64 Windows systems.

Wrapping the type in a struct provides more type safety, but if I
wanted that I'd create my own simple subclass. For example, assuming
time_t should be a signed integer that's the same size as a pointer:

 class time_t(ctypes._SimpleCData):
 if ctypes.sizeof(ctypes.c_void_p) == ctypes.sizeof(ctypes.c_longlong):
 _type_ = ctypes.c_longlong._type_
 elif ctypes.sizeof(ctypes.c_void_p) == ctypes.sizeof(ctypes.c_long):
 _type_ = ctypes.c_long._type_
 elif ctypes.sizeof(ctypes.c_void_p) == ctypes.sizeof(ctypes.c_int):
 _type_ = ctypes.c_int._type_
 # else raise AttributeError for missing _type_

[1]: https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models


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


[issue27998] Bytes paths now are supported in os.scandir() on Windows

2016-10-05 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Tests are passed on Windows.

Now we need to document that bytes paths are supported in os.scandir() on 
Windows since 3.6.

--
assignee: serhiy.storchaka -> docs@python
components: +Documentation -Extension Modules
nosy: +docs@python
stage: patch review -> needs patch
versions: +Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: working with ctypes and complex data structures

2016-10-05 Thread Michael Felt



On 05-Oct-16 22:29, Emile van Sebille wrote:
Thanks for the reply!

After a shirt coffeebreak - back into the fray - and I found the following:


+76  class cpu_total:
   +77  def __init__(self):
   +78  __perfstat__ = CDLL("libperfstat.a(shr_64.o)")
   +79  prototype = CFUNCTYPE(c_int, c_void_p, c_void_p, c_int,
c_int)

error #2 - see below

+80  args = (1, "name", None), (2, "buff", None), (1, "size",
0), (1, "count", 1)
error #1. paramater type 2 (the buffer might be where data is being put, 
but for the call, the pointer is INPUT)

+81  cpu_total = prototype(("perfstat_cpu_total",
__perfstat__), args)
   +82
   +83  buff = perfstat_cpu_total_t()
   +84  cpu_total(buff=buff, size=sizeof(buff))
   +85 
The error #2 is #2, because only after I corrected the inputs did I get 
Type Exceptions. I had hoped that c_void_p was a "typeless" type, mainly 
the right size, but the ctypes interface is more particular when you use 
the CFUNCTYPE() - so now I have my boilerplate for what I hope
can be a tutorial for interfacing - by hand - with complex functions, 
i.e., using one class as the data aka typedef defintion, and a second 
class to work

on it.

In template form:

class perfstat_xxx_t:
_fields_ = ( ... )

class perfstat_xxx:
def init(self):
_perflib = ctypes.CDLL("libperfstat.a(shr_64.o)") # AIX member 
in an archive

_fn_xxx = _perflib.xxx
# ALL AIX perfstat routines have 4 arguments: (name, buff, 
sizeof_buff, count)

# the buff is a pointer to where the information will be stored
_fn = CFUNCTYPE(c_int, c_void_p, POINTER(xxx_t), c_int, c_int)
_args = (1, "name", None), (1, "buff", None), (1, "size", 0), 
(1, "count", 1)

_xxx = _fn(("xxx", _fn_xxx), _args)

_buff = perfstat_cpu_total_t()
_xxx(buff=_buff, size=sizeof(_buff))
self._v = _buff

So, the next question/test will be to move the _fields_ into the 
"second" class definition. I just need to find what "self" attribute 
that is.


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


[issue28368] Refuse monitoring processes if the child watcher has no loop attached

2016-10-05 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 2110dcef5892 by Yury Selivanov in branch '3.5':
Issue #28368: Refuse monitoring processes if the child watcher has no loop 
attached.
https://hg.python.org/cpython/rev/2110dcef5892

New changeset fb6b60955d62 by Yury Selivanov in branch '3.6':
Merge 3.5 (issue #28368)
https://hg.python.org/cpython/rev/fb6b60955d62

New changeset 83cc47533e4e by Yury Selivanov in branch 'default':
Merge 3.6 (issue #28368)
https://hg.python.org/cpython/rev/83cc47533e4e

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28368] Refuse monitoring processes if the child watcher has no loop attached

2016-10-05 Thread Yury Selivanov

New submission from Yury Selivanov:

Proxy issue for https://github.com/python/asyncio/pull/391

--
assignee: yselivanov
components: asyncio
messages: 278148
nosy: gvanrossum, yselivanov
priority: normal
severity: normal
stage: resolved
status: open
title: Refuse monitoring processes if the child watcher has no loop attached
type: enhancement
versions: Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28368] Refuse monitoring processes if the child watcher has no loop attached

2016-10-05 Thread Yury Selivanov

Changes by Yury Selivanov :


--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: working with ctypes and complex data structures

2016-10-05 Thread Emile van Sebille

On 10/05/2016 01:06 PM, Michael Felt wrote:



On 02-Oct-16 19:50, Michael Felt wrote:

I am trying to understand the documentation re: ctypes and interfacing
with existing libraries.

I am reading the documentation, and also other sites that have largely
just copied the documentation - as well as the "free chapter" at
O'Reilly (Python Cookbook).


Using O'Reilly and the standard documentation I now have these two
excerpts. The second def works, the first does not.

Someone helping me understand what I am not reading properly in this bit
of documentation - is much appreciated.


from  ctypes  import  c_int,  WINFUNCTYPE,  windll
from  ctypes.wintypes  import  HWND,  LPCSTR,  UINT
prototype  =  WINFUNCTYPE(c_int,  HWND,  LPCSTR,  LPCSTR,  UINT)
paramflags  =  (1,  "hwnd",  0),  (1,  "text",  "Hi"),  (1,
"caption",  None),  (1,  "flags",  0)
MessageBox  =  prototype(("MessageBoxA",  windll.user32),  paramflags)



The MessageBox foreign function can now be called in these ways:






MessageBox()
MessageBox(text="Spam, spam, spam")
MessageBox(flags=2,  text="foo bar")



Note that MessageBox() may give two arguments.

My code: note both def init() are meant to do the same thing, just
different call syntax.

   +76  class cpu_total:
   +77  def __init__(self):
   +78  __perfstat__ = CDLL("libperfstat.a(shr_64.o)")
   +79  prototype = CFUNCTYPE(c_int, c_void_p, c_void_p, c_int,
c_int)
   +80  args = (1, "name", None), (2, "buff", None), (1, "size",
0), (1, "count", 1)
   +81  cpu_total = prototype(("perfstat_cpu_total",
__perfstat__), args)
   +82
   +83  buff = perfstat_cpu_total_t()
   +84  cpu_total(buff=buff, size=sizeof(buff))
   +85
   +86  class perfstat_cpu_total:
   +87  def __init__(self):
   +88  __perfstat__ = CDLL("libperfstat.a(shr_64.o)")
   +89  cpu_total = __perfstat__.perfstat_cpu_total
   +90
   +91  _perfstat_cpu_total = perfstat_cpu_total_t()
   +92  ret = cpu_total(None,
   +93  byref(_perfstat_cpu_total),
   +94  sizeof(perfstat_cpu_total_t), 1)
   +95  self.boot = _perfstat_cpu_total.lbolt.v / 100
   +96  self.ncpus = _perfstat_cpu_total.ncpus
   +97  self._v = _perfstat_cpu_total


When I call the second I can print values and even call functions,
reload the _v, etc..

The first class fails with this message:

a = cpu_total()
Traceback (most recent call last):
  File "", line 135, in 
  File "", line 84, in __init__
TypeError: call takes exactly 1 arguments (2 given)

Thanks for your attention.


the line it's objecting to is:

>+84  cpu_total(buff=buff, size=sizeof(buff))

because the expectation is defined as:

>+77  def __init__(self):

HTH,

Emile

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


Re: Problem with install of Python 3.5.2 on Windows Vista

2016-10-05 Thread eryk sun
On Wed, Oct 5, 2016 at 7:18 PM, Mike Adams  wrote:
> The install seemed to be going well up to near the end when I got the msg 
> 'Python
> has stopped working', I clicked the button then I got the msg 'Setup was 
> successful'.
> I then clicked 'IDLE' and it says it can't find 
> 'api-msi-win-crt-runtime-11-1-0.dll'.  I
> checked Python Tracker and saw that there was a similar issue with Python 
> 3.5.0
> which has been fixed.  So, what do I need to do now to correct this problem?

Make sure your OS is up to date via Windows Update. Microsoft is
supposed to be distributing the Universal CRT as an OS component for
Vista SP2. If you're up to date and the system still can't find CRT
DLLs, then try manually installing the CRT update. It's available for
download here:

https://support.microsoft.com/en-us/kb/3118401
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27998] Bytes paths now are supported in os.scandir() on Windows

2016-10-05 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 7c36e6fd0232 by Serhiy Storchaka in branch '3.6':
Issue #27998: Removed workarounds for supporting bytes paths on Windows in
https://hg.python.org/cpython/rev/7c36e6fd0232

New changeset bcee710c42fe by Serhiy Storchaka in branch 'default':
Issue #27998: Removed workarounds for supporting bytes paths on Windows in
https://hg.python.org/cpython/rev/bcee710c42fe

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



python and dos files question

2016-10-05 Thread Xristos Xristoou
hello

some programs allow to export tools to dos .bat files for running from command 
line.
my question is how can i do to running .bat files and how can i do to define 
some variables from the .bat file before the running.

for example i want to define 4 variable and run this .bat file with the python
variables can be strings paths,images and text.

.bat file like this :

@ECHO OFF

REM SET program1=C:\program1\Modules
REM SET PATH=%PATH%;C:\program1

REM Tool: Tool1

program1_cmd tool1 0 -variable1=NULL -variable2=NULL -variable3=NULL 
-variable4=NULL -

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


[issue27998] Bytes paths now are supported in os.scandir() on Windows

2016-10-05 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka
stage: needs patch -> patch review
title: Remove support of bytes paths in os.scandir() -> Bytes paths now are 
supported in os.scandir() on Windows

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: working with ctypes and complex data structures

2016-10-05 Thread Michael Felt



On 02-Oct-16 19:50, Michael Felt wrote:
I am trying to understand the documentation re: ctypes and interfacing 
with existing libraries.


I am reading the documentation, and also other sites that have largely 
just copied the documentation - as well as the "free chapter" at 
O'Reilly (Python Cookbook).


Using O'Reilly and the standard documentation I now have these two 
excerpts. The second def works, the first does not.


Someone helping me understand what I am not reading properly in this bit 
of documentation - is much appreciated.



from  ctypes  import  c_int,  WINFUNCTYPE,  windll
from  ctypes.wintypes  import  HWND,  LPCSTR,  UINT
prototype  =  WINFUNCTYPE(c_int,  HWND,  LPCSTR,  LPCSTR,  UINT)
paramflags  =  (1,  "hwnd",  0),  (1,  "text",  "Hi"),  (1,  "caption",  None),  (1,  
"flags",  0)
MessageBox  =  prototype(("MessageBoxA",  windll.user32),  paramflags)



The MessageBox foreign function can now be called in these ways:






MessageBox()
MessageBox(text="Spam, spam, spam")
MessageBox(flags=2,  text="foo bar")



Note that MessageBox() may give two arguments.

My code: note both def init() are meant to do the same thing, just different 
call syntax.

   +76  class cpu_total:
   +77  def __init__(self):
   +78  __perfstat__ = CDLL("libperfstat.a(shr_64.o)")
   +79  prototype = CFUNCTYPE(c_int, c_void_p, c_void_p, c_int, c_int)
   +80  args = (1, "name", None), (2, "buff", None), (1, "size", 0), (1, 
"count", 1)
   +81  cpu_total = prototype(("perfstat_cpu_total", __perfstat__), 
args)
   +82
   +83  buff = perfstat_cpu_total_t()
   +84  cpu_total(buff=buff, size=sizeof(buff))
   +85
   +86  class perfstat_cpu_total:
   +87  def __init__(self):
   +88  __perfstat__ = CDLL("libperfstat.a(shr_64.o)")
   +89  cpu_total = __perfstat__.perfstat_cpu_total
   +90
   +91  _perfstat_cpu_total = perfstat_cpu_total_t()
   +92  ret = cpu_total(None,
   +93  byref(_perfstat_cpu_total),
   +94  sizeof(perfstat_cpu_total_t), 1)
   +95  self.boot = _perfstat_cpu_total.lbolt.v / 100
   +96  self.ncpus = _perfstat_cpu_total.ncpus
   +97  self._v = _perfstat_cpu_total


When I call the second I can print values and even call functions, reload the 
_v, etc..

The first class fails with this message:

a = cpu_total()
Traceback (most recent call last):
  File "", line 135, in 
  File "", line 84, in __init__
TypeError: call takes exactly 1 arguments (2 given)

Thanks for your attention.


 



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


Problem with install of Python 3.5.2 on Windows Vista

2016-10-05 Thread Mike Adams
The install seemed to be going well up to near the end when I got the msg 
'Python has stopped working', I clicked the button then I got the msg 'Setup 
was successful'.  I then clicked 'IDLE' and it says it can't find 
'api-msi-win-crt-runtime-11-1-0.dll'.  I checked Python Tracker and saw that 
there was a similar issue with Python 3.5.0 which has been fixed.  So, what do 
I need to do now to correct this problem?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28364] Windows - Popen (subprocess.py) does not call _handle.Close() at all

2016-10-05 Thread Eryk Sun

Eryk Sun added the comment:

In 2.7, the _handle attribute is a _subprocess_handle object, which 
automatically calls CloseHandle when deallocated. For example:

>>> p = subprocess.Popen('python -c "import time; time.sleep(120)"')

CreateProcess returns both the process handle and the thread handle. Python 
doesn't use the thread handle, so it explicitly closes it by calling ht.Close():

Breakpoint 0 hit
KERNELBASE!CloseHandle:
7ffb`a32fdf70 4883ec28sub rsp,28h
0:000> kc 5
Call Site
KERNELBASE!CloseHandle
python27!sp_handle_close
python27!PyCFunction_Call
python27!call_function
python27!PyEval_EvalFrameEx
0:000> g

(IMO, it should skip this step if creationflags contains CREATE_SUSPENDED. The 
thread handle makes it simpler to call ResumeThread.)

On the other hand, the process handle is deallocated implicitly when it's no 
longer referenced:

>>> type(p._handle)

>>> hex(int(p._handle))
'0x164L'

>>> p.terminate()
>>> del p

Breakpoint 0 hit
KERNELBASE!CloseHandle:
7ffb`a32fdf70 4883ec28sub rsp,28h
0:000> kc 5
Call Site
KERNELBASE!CloseHandle
python27!sp_handle_dealloc
python27!dict_dealloc
python27!subtype_dealloc
python27!PyDict_DelItem
0:000> r rcx
rcx=0164

If the process handles aren't being closed in your case, then you're probably 
keeping a reference to the Popen instances.

P.S. A Windows handle is not a "file descriptor". Kernel handles are user-mode 
references to kernel objects. They aren't "files" unless the object happens to 
be a File object. A process handle references a kernel Process object.

--
nosy: +eryksun

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Code complexity analysis of Python code (was: Quick way to calculate lines of code/comments in a collection of Python scripts?)

2016-10-05 Thread Ben Finney
Malcolm Greene  writes:

> Looking for a quick way to calculate lines of code/comments in a
> collection of Python scripts. This isn't a LOC per day per developer
> type analysis - I'm looking for a metric to quickly judge the complexity
> of a set of scripts I'm inheriting.

Prospector  is a static analysis
tool for Python code.

Its documentation promises to do what you're asking, please let us know
how it works for you.

-- 
 \  “[Entrenched media corporations will] maintain the status quo, |
  `\   or die trying. Either is better than actually WORKING for a |
_o__)  living.” —ringsnake.livejournal.com, 2007-11-12 |
Ben Finney

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


Re: rocket simulation game with just using tkinter

2016-10-05 Thread Irmen de Jong
On 5-10-2016 2:43, Dennis Lee Bieber wrote:
>   Or do what I once did with the Lunar Lander game on my college
> computer... Target accuracy: Excellent... Landing gear? somewhere on the
> other side of the moon. My vertical velocity was sub-inches per second --
> the horizontal velocity was in multi-feet per second.

My lander game takes the magnitude of the velocity into account and not the 
direction,
so you will still crash when going down a pixel per second but strafing like 
mad :)


>   I also used to crash with more fuel than I started with... Game didn't
> do a sign check on "lbs of fuel to burn", so -10lbs @ 180deg had the same
> effect as 10lbs @ 0deg, but gained fuel.

I forgot to add a fuel gauge! My rocket can fly for all eternity if you manage 
to keep
it in the air :P

The first rocket landing game I ever came across must have been a text only 
version
running on my commodore 64 where it was only printing your current altitude and 
velocity
and fuel level, and then stopped to ask for input. I think it asked for values 
for how
long to burn the engine and for how many seconds. Then it recomputed everything 
and
stopped again for input until you landed safely or crashed...
It must have been a short BASIC listing I copied over from a magazine or 
something.


Irmen

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


Re: Assignment versus binding

2016-10-05 Thread BartC

On 05/10/2016 14:43, Rustom Mody wrote:

On Wednesday, October 5, 2016 at 7:05:02 PM UTC+5:30, BartC wrote:



That's the one it can't find. Actually it can't seem to import any
standard libraries, so the implementation must be screwed up.

Or is it because I downloaded the Minimal** rather Full version? The
minimal version is already 1.7GB! Can it really be that big and yet not
include such basic stuff? If so, what on earth is taking up all the
space! (The full version was 10-15% bigger.)

(**
https://downloads.haskell.org/~platform/8.0.1/HaskellPlatform-8.0.1-minimal-x86_64-setup-a.exe)


Minimal means only compiler: NO libraries except what the compiler needs to 
compile.
Almost certainly wrong for a beginner’s testing the waters.

You should probably download haskell-platform (full)


(I've downloaded the full version. Now I have 25,000 files in 2200MB. 
And it still doesn't work.


This is exactly why I persist with my own language implementations. My 
current one is only 1/5000th the size but standard libraries are included!)


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


Re: Passing Variable to Function

2016-10-05 Thread alister
On Wed, 05 Oct 2016 19:17:33 +, John McKenzie wrote:

> Hello, all.
> 
>  I have a function that takes three arguments, arguments to express an
>  RGB
> colour. The function controls an LED light strip (a Blinkytape).
> 
>  Sometimes I might need to be change what colour is sent to the
>  function,
> so I set a variable with the idea that I can change just the variable
> later if I need to instead of changing a bunch of different lines.
> 
> So I have variables along the lines of this:
> 
> colour ="255, 0, 0"
> colour2 ="100, 0, 0"
> 
> 
> My function, written by the Blinkytape people:
> 
> 
> def changeColor(r, g, b):
>  serialPorts = glob.glob("/dev/ttyACM0*")
>  port = serialPorts[0]
> 
>  if not port:
>  sys.exit("Could not locate a BlinkyTape.")
> 
>  print "BlinkyTape found at: %s" % port
> 
>  bt = BlinkyTape.BlinkyTape(port)
>  bt.displayColor(r, g, b)
>  time.sleep(.1)  # Give the serial driver some time to actually send
> the data
>  bt.close()
> 
> 
>  Later, I have conditional statements like:
> 
> 
> if latitude > maxNetural and latitude < NorthLine:
> changeColor(colour)
> elif latitude > NorthLine:
> changeColor(colour2)
> 
> 
> 
> (There is a GPS device connected, there are variables defined based on
> latitude earlier in the script.)
> 
>  I get an error stating that changeColor takes three arguments and I am
> just giving it one (either "colour1" or "colour2").
> 
> 
>  Is there a way to format the "colour" variable so that the changeColor
> function takes it as the three numbers it is meant to be defined as?
> 
> 
> Entire script:
> http://hastebin.com/qaqotusozo.py
> 
> 
>  Thanks.

use a list & pythons parameter expansion options (I am sure the experts 
here will be able to provide the correct name)

colour1=[100,0,255]

def set_colour(r,g,b):



set_colour(*colour1)



-- 
Come live with me and be my love,
And we will some new pleasures prove
Of golden sands and crystal brooks
With silken lines, and silver hooks.
There's nothing that I wouldn't do
If you would be my POSSLQ.

You live with me, and I with you,
And you will be my POSSLQ.
I'll be your friend and so much more;
That's what a POSSLQ is for.

And everything we will confess;
Yes, even to the IRS.
Some day on what we both may earn,
Perhaps we'll file a joint return.
You'll share my pad, my taxes, joint;
You'll share my life - up to a point!
And that you'll be so glad to do,
Because you'll be my POSSLQ.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Passing Variable to Function

2016-10-05 Thread Brendan Abel
Define your colors as actual number variables instead of a string

color = (255,0,0)
color2 = (0,0,255)

Then use argument expansion to pass them in as separate arguments to the
function

colorFunction(*color)

Brendan

On Wed, Oct 5, 2016 at 12:17 PM, John McKenzie 
wrote:

>
>  Hello, all.
>
>  I have a function that takes three arguments, arguments to express an RGB
> colour. The function controls an LED light strip (a Blinkytape).
>
>  Sometimes I might need to be change what colour is sent to the function,
> so I set a variable with the idea that I can change just the variable
> later if I need to instead of changing a bunch of different lines.
>
> So I have variables along the lines of this:
>
> colour ="255, 0, 0"
> colour2 ="100, 0, 0"
>
>
> My function, written by the Blinkytape people:
>
>
> def changeColor(r, g, b):
>  serialPorts = glob.glob("/dev/ttyACM0*")
>  port = serialPorts[0]
>
>  if not port:
>  sys.exit("Could not locate a BlinkyTape.")
>
>  print "BlinkyTape found at: %s" % port
>
>  bt = BlinkyTape.BlinkyTape(port)
>  bt.displayColor(r, g, b)
>  time.sleep(.1)  # Give the serial driver some time to actually send
> the data
>  bt.close()
>
>
>  Later, I have conditional statements like:
>
>
> if latitude > maxNetural and latitude < NorthLine:
> changeColor(colour)
> elif latitude > NorthLine:
> changeColor(colour2)
>
>
>
> (There is a GPS device connected, there are variables defined based on
> latitude earlier in the script.)
>
>  I get an error stating that changeColor takes three arguments and I am
> just giving it one (either "colour1" or "colour2").
>
>
>  Is there a way to format the "colour" variable so that the changeColor
> function takes it as the three numbers it is meant to be defined as?
>
>
> Entire script:
> http://hastebin.com/qaqotusozo.py
>
>
>  Thanks.
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28367] Add more standard baud rate constants to "termios"

2016-10-05 Thread Andrey Smirnov

New submission from Andrey Smirnov:

Termios magic constants for the following baud rates:

  - B50
  - B576000
  - B921600
  - B100
  - B1152000
  - B150
  - B200
  - B250
  - B300
  - B350
  - B400

in Linux are different between various architectures (i. e. PowerPC and Alpha 
are different from the rest of them). And because they are defined as 
per-processor symbols the only way to access them is if they are built-in as a 
part of CPython during its compilation.

Attached is the patch implementing that

--
components: Library (Lib)
files: add-more-termios-baudrates.patch
keywords: patch
messages: 278145
nosy: Andrey Smirnov, twouters
priority: normal
severity: normal
status: open
title: Add more standard baud rate constants to "termios"
type: enhancement
Added file: http://bugs.python.org/file44977/add-more-termios-baudrates.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Passing Variable to Function

2016-10-05 Thread John McKenzie

 Hello, all.

 I have a function that takes three arguments, arguments to express an RGB 
colour. The function controls an LED light strip (a Blinkytape).

 Sometimes I might need to be change what colour is sent to the function, 
so I set a variable with the idea that I can change just the variable 
later if I need to instead of changing a bunch of different lines.

So I have variables along the lines of this:

colour ="255, 0, 0"
colour2 ="100, 0, 0"


My function, written by the Blinkytape people:


def changeColor(r, g, b):
 serialPorts = glob.glob("/dev/ttyACM0*")
 port = serialPorts[0]

 if not port:
 sys.exit("Could not locate a BlinkyTape.")

 print "BlinkyTape found at: %s" % port

 bt = BlinkyTape.BlinkyTape(port)
 bt.displayColor(r, g, b)
 time.sleep(.1)  # Give the serial driver some time to actually send 
the data
 bt.close()


 Later, I have conditional statements like:


if latitude > maxNetural and latitude < NorthLine:
changeColor(colour)
elif latitude > NorthLine:
changeColor(colour2)



(There is a GPS device connected, there are variables defined based on 
latitude earlier in the script.)

 I get an error stating that changeColor takes three arguments and I am 
just giving it one (either "colour1" or "colour2").


 Is there a way to format the "colour" variable so that the changeColor 
function takes it as the three numbers it is meant to be defined as?


Entire script:
http://hastebin.com/qaqotusozo.py


 Thanks.


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


Re: Python and ssh for remote login

2016-10-05 Thread Noah
On 5 Oct 2016 22:02, "Ethan Furman"  wrote:
>
> On 10/05/2016 10:46 AM, Noah wrote:
>
>> I would like to use a python script to ssh into a server using a username
>> and password [...]
>
>
> I've written a module called scription to help with scripts; it supports
giving passwords to programs like ssh.
>

Hi Ethan and for writting this script.

> Here's an example from one of my utility scripts:
>
> -- 8< ---
> #!/usr/local/bin/python
>
> from getpass import getpass
> from antipathy import Path
> from scription import Command, Execute, Main, OPTION, REQUIRED
>
> ...
>
> @Command(
> repo=('repository to pull [default: all]', OPTION),
> path=('base path to search', OPTION, 'p', Path),
> )
> def pull(repo, *path):
> '''
> retrieve remote change sets
> '''
> password = getpass('[mercurial] password: ')
> target = repo
> for repo in workhorse(*path):
> if target and repo.filename != target:
> continue
> history = Execute(('hg', 'pull'), cwd=repo, password=password,
pty=True)
>
> -- 8< 
>
> and in use:
>
> ==
>
> $ hgc --help
> Available commands/options in hgc
>incoming  displays changesets in remote repo not present locally
>list  displays all repos
>log-date  displays all log entries for matching date
>outgoing  displays changesets in remote repo not present locally
>parentdisplays parent of active branch
>pull  retrieve remote change sets
>push  send local changesets to remote repo
>statusdisplay status for each repo
>updateupdate active files to latest version
>
> $ hgc pull
> [mercurial] password:
>
> ...
> ===
>
> It's available via pip.  Feedback welcome.  :)
>

I will pip it too and try it out and give some feedback based on my use
case.

Thanks a lot.

> --
> ~Ethan~
> --

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


Re: Python and ssh for remote login

2016-10-05 Thread Ethan Furman

On 10/05/2016 10:46 AM, Noah wrote:


I would like to use a python script to ssh into a server using a username
and password [...]


I've written a module called scription to help with scripts; it supports giving 
passwords to programs like ssh.

Here's an example from one of my utility scripts:

-- 8< ---
#!/usr/local/bin/python

from getpass import getpass
from antipathy import Path
from scription import Command, Execute, Main, OPTION, REQUIRED

...

@Command(
repo=('repository to pull [default: all]', OPTION),
path=('base path to search', OPTION, 'p', Path),
)
def pull(repo, *path):
'''
retrieve remote change sets
'''
password = getpass('[mercurial] password: ')
target = repo
for repo in workhorse(*path):
if target and repo.filename != target:
continue
history = Execute(('hg', 'pull'), cwd=repo, password=password, pty=True)

-- 8< 

and in use:

==

$ hgc --help
Available commands/options in hgc
   incoming  displays changesets in remote repo not present locally
   list  displays all repos
   log-date  displays all log entries for matching date
   outgoing  displays changesets in remote repo not present locally
   parentdisplays parent of active branch
   pull  retrieve remote change sets
   push  send local changesets to remote repo
   statusdisplay status for each repo
   updateupdate active files to latest version

$ hgc pull
[mercurial] password:

...
===

It's available via pip.  Feedback welcome.  :)

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


[issue28363] -D_LARGE_FILES not exported to modules (for AIX)

2016-10-05 Thread Michael Felt

Michael Felt added the comment:

Now they notice the defines are coming from their project.

closing...

--
resolution:  -> third party
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28365] idle forgets that saved console session is not a python file after restart

2016-10-05 Thread Zachary Ware

Changes by Zachary Ware :


--
assignee:  -> terry.reedy
components: +IDLE -Windows

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28364] Windows - Popen (subprocess.py) does not call _handle.Close() at all

2016-10-05 Thread SilentGhost

Changes by SilentGhost :


--
components: +Windows
nosy: +paul.moore, steve.dower, tim.golden, zach.ware
type:  -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Python and ssh for remote login

2016-10-05 Thread Noah
Hi Rob

Thank you for your email.

I am guessing that is some module. Ok i will pip it and see how it goes.

Noah

On 5 Oct 2016 21:32, "Rob Gaddi"  wrote:

> Noah wrote:
>
> > Hello folk,
> >
> > I would like to use a python script to ssh into a server using a username
> > and password and perhaps ass port.
> >
> > Any ideas on how to script that.
> >
> > Thanks
> >
> > Noah
>
> paramiko
>
> --
> Rob Gaddi, Highland Technology -- www.highlandtechnology.com
> Email address domain is currently out of order.  See above to fix.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python and ssh for remote login

2016-10-05 Thread Rob Gaddi
Noah wrote:

> Hello folk,
>
> I would like to use a python script to ssh into a server using a username
> and password and perhaps ass port.
>
> Any ideas on how to script that.
>
> Thanks
>
> Noah

paramiko

-- 
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
-- 
https://mail.python.org/mailman/listinfo/python-list


Python and ssh for remote login

2016-10-05 Thread Noah
Hello folk,

I would like to use a python script to ssh into a server using a username
and password and perhaps ass port.

Any ideas on how to script that.

Thanks

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


[issue28259] Ctypes bug windows

2016-10-05 Thread Aristotel

Aristotel added the comment:

I will write (as short as possible) example. Hope to finish it in ~ 1 week.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Quick way to calculate lines of code/comments in a collection of Python scripts?

2016-10-05 Thread Chris Angelico
On Thu, Oct 6, 2016 at 4:56 AM, Malcolm Greene  wrote:
> Looking for a quick way to calculate lines of code/comments in a
> collection of Python scripts. This isn't a LOC per day per developer
> type analysis - I'm looking for a metric to quickly judge the complexity
> of a set of scripts I'm inheriting.

Post the code to GitHub, then click on the file. Up the top, you'll
see something like this:

https://github.com/Rosuav/LetMeKnow/blob/master/letmeknow.py
231 lines (212 sloc)

The first figure is the raw line count. The second is, in theory at
least, the number of lines of "actual code".

Cheating? Totally. Effective? Yup.

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


Quick way to calculate lines of code/comments in a collection of Python scripts?

2016-10-05 Thread Malcolm Greene
Looking for a quick way to calculate lines of code/comments in a
collection of Python scripts. This isn't a LOC per day per developer
type analysis - I'm looking for a metric to quickly judge the complexity
of a set of scripts I'm inheriting.

Thank you,
Malcolm
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28365] idle forgets that saved console session is not a python file after restart

2016-10-05 Thread R. David Murray

R. David Murray added the comment:

I'm retitling the issue.  The new title doesn't necessary represent the "bug" 
that needs to be fixed, but it does seem to represent the *apparent* error.

--
nosy: +r.david.murray
title: 3.5.2 syntax issue -> idle forgets that saved console session is not a 
python file after restart

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28365] 3.5.2 syntax issue

2016-10-05 Thread Steven D'Aprano

Changes by Steven D'Aprano :


--
nosy: +terry.reedy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Has any one automated the vmware-vra setup using python?

2016-10-05 Thread Robert Clove

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


[issue28365] 3.5.2 syntax issue

2016-10-05 Thread Paul Moore

Paul Moore added the comment:

I can recreate this (based on the screenshots from #28366).

To reproduce, open IDLE. You get the console banner and prompt. Save that file 
using File-Save. The close IDLE. Reopen it, do File-Open to open your saved 
console session, then use the "Run" menu to run it. (You need to close IDLE, so 
it "forgets" the .py file came from a console session.)

That's incorrect usage, of course (not "of course" to the OP - that's the real 
point here) as the text of a console session isn't a valid Python file, and 
doesn't syntax check. The error is saying precisely that - what is in the file 
isn't valid Python.

So in one sense, this is simply user error. But I wonder, is there something 
about how IDLE presents things that could be improved? Either in the 
documentation or in the UI? I'm not exactly sure what the point of "file-save" 
in a console window is, and certainly it would be better to save the transcript 
as text so it couldn't be inadvertently be read back in as a Python module.

I'm not an IDLE user, though, so I don't really have the background to know the 
best solution.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25720] Fix curses module compilation with ncurses6

2016-10-05 Thread Mark Dickinson

Mark Dickinson added the comment:

> Mark, do you have relation to this?

Sorry, no. Whatever ncurses knowledge I may once have had has long since 
vanished.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28366] Syntax issue

2016-10-05 Thread Zachary Ware

Zachary Ware added the comment:

Let's consolidate this to #28365.

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> 3.5.2 syntax issue

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28366] Syntax issue

2016-10-05 Thread Steven D'Aprano

Changes by Steven D'Aprano :


--
components: +Windows
nosy: +paul.moore, steve.dower, tim.golden, zach.ware
versions: +Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28365] 3.5.2 syntax issue

2016-10-05 Thread Steven D'Aprano

Steven D'Aprano added the comment:

See #28366

--
nosy: +steven.daprano

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28366] Syntax issue

2016-10-05 Thread Steven D'Aprano

New submission from Steven D'Aprano:

Did you take a picture of the screen with your iPhone? Why didn't you take a 
screenshot? Or better still, since this is a text-based medium not a graphics 
error, copy and paste the text involved? That's easier for people to work with, 
including those who are blind or visually impaired.

Your images are fuzzy, clipped, and almost impossible to make out what is going 
on. The closest I can determine is that you are running Python successfully, 
because I can see what looks like a call to:

print('example of error')

working successful: the string is printed, as expected, and no SyntaxError 
occurs. That's image1.

image2 is even harder to make out, some of the text is so out of focus I cannot 
read it, but again it shows the same line of code successfully executed, but a 
mystery dialog box that says "syntax error".

To start with, please explain how you are running Python. Are you running it in 
the basic Windows terminal? What command did you give to run Python? Or are you 
running IDLE? Did you run it from the Start Menu? What *exact* sequence of 
commands did you give to run Python?

Try to answer using words, not pictures, and ESPECIALLY not out-of-focus photos 
taken with your phone.

And don't start a new ticket, either respond to this one or #28365.

--
nosy: +steven.daprano

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: I can't run python on my computer

2016-10-05 Thread MRAB

On 2016-10-05 15:19, Camille Benoit via Python-list wrote:

Hi,it has been about a week since the last time I was able to use Python. Most of the 
time, the interpreter doesn't show up and when it does and I am trying to run a program 
it displayed the following message: "IDLE's subprocess didn't make connection. 
Either IDLE can't start a subprocess or personal firewall software is blocking the 
connection."  Can you please help me with this. It'd be a huge help.

Thank you very much.


There are plenty of answers on StackOverflow, e.g.:

Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess 
didn't make connection

http://stackoverflow.com/questions/15888186/cant-run-python-via-idle-from-explorer-2013-idles-subprocess-didnt-make-c

Python error - IDLE's subprocess didn't make connection. Either IDLE 
can't start or personal firewall software is blocking connection

http://stackoverflow.com/questions/29567051/python-error-idles-subprocess-didnt-make-connection-either-idle-cant-start


It might be caused by trying to run a program whose name is the same as 
one of Python's standard modules, so that when Python tries to use the 
module, it gets your program instead.


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


Re: Python -Simplebool

2016-10-05 Thread MRAB

On 2016-10-05 16:01, priya@gmail.com wrote:

Hi,
   I am new to Python and I am learning it. Need some help. I downloaded 
SimpleBool (https://github.com/lujunyan1118/SimpleBool) for simulating Boolean 
models. SimpleBool works in Python. I downloaded the Canopy and executed 
Boolmutation.py file. Below is the Boolmutation.py file


[snip]


After running this file, I got the following 
error:/home/JPJ/Priya_Ph.D/simple_bool/simplebool/SimpleBool-master/BoolMutation.py 
in ()
383 para=ParaParser(sys.argv[1])
384 except:
--> 385 para=ParaParser('mutation.in')
386 simu_mutation(para)

/home/JPJ/Priya_Ph.D/simple_bool/simplebool/SimpleBool-master/BoolMutation.py 
in ParaParser(ParaFile)
254 }  # define parameters
255
--> 256 for each_line in open(ParaFile).readlines():
257 para_name = each_line.split('=')[0].strip()
258 para_value = each_line.split('=')[1].strip()

IOError: [Errno 2] No such file or directory: 'mutation.in'


I can't understand, the problem here. Should I specify anything in the 
Boolmutation.py file. Any help would be appreciated

The traceback says what the problem is: """No such file or directory: 
'mutation.in'""".


You haven't given it the path to the input file on the command line, so 
it's defaulting to 'mutation.in', which it can't find or doesn't exist.


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


[issue2897] Deprecate structmember.h

2016-10-05 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

I am attaching a proposed doc patch for Python 3.5+.  For 2.7 we should 
probably just add a versionchanged note explaining "restricted mode" has been 
deprecated in Python 2.3.

--
Added file: http://bugs.python.org/file44976/issue2897-docs-3x.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Looking for the best way to make this

2016-10-05 Thread mr . marydavid
Here is another example 
http://www.codetwo.com/media/images/exchange-sync-screencast-5.jpg 
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28366] Syntax issue

2016-10-05 Thread A.J.

Changes by A.J. :


--
files: image1.jpeg, image2.jpeg, unnamed, unnamed
nosy: radialbeast
priority: normal
severity: normal
status: open
title: Syntax issue
Added file: http://bugs.python.org/file44972/image1.jpeg
Added file: http://bugs.python.org/file44973/unnamed
Added file: http://bugs.python.org/file44974/image2.jpeg
Added file: http://bugs.python.org/file44975/unnamed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28365] 3.5.2 syntax issue

2016-10-05 Thread Tim Golden

Tim Golden added the comment:

This sometimes happens when someone copies from a book or a tutorial and
includes as though code the banner header which is only meant to
illustrate the context.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28365] 3.5.2 syntax issue

2016-10-05 Thread Zachary Ware

Zachary Ware added the comment:

Hi A.J.,

What you're describing isn't really possible, so you're going to need to 
provide some more detail.  Please copy and paste your Command Prompt session 
into a message here to show us what's going on.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Looking for the best way to make this

2016-10-05 Thread mr . marydavid
http://www.qualicode.com/EN/images/ScheduleGrid.png

looking to add schedule like that to my software trying with Qt but not sure 
how to .

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


  1   2   >