Re: CURSES WINDOWS

2018-09-05 Thread Anssi Saari
[email protected] (shinobi) writes:

> Hello All,
>
> can anyone please let me know what's the path to port linux python curses
> program to Windows?

Is there really anything that needs to be done? At least a simple hello
world python curses program runs on Windows and Linux with no changes.

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


Re: CURSES WINDOWS

2018-09-05 Thread Dotan Cohen
Your subject line will sure draw attention to the topic!
On Tue, Sep 4, 2018 at 8:33 PM shinobi  wrote:
>
> Hello All,
>
> can anyone please let me know what's the path to port linux python curses
> program to Windows?
>
> Thanks
>
> --
> https://mail.python.org/mailman/listinfo/python-list



-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: CURSES WINDOWS

2018-09-05 Thread Abhiram R
And here I thought this was a rant :D

On Tue, Sep 4, 2018 at 8:33 PM shinobi  wrote:
> >
> > Hello All,
> >
> > can anyone please let me know what's the path to port linux python curses
> > program to Windows?
> >
> > Thanks
> >
> > --
> > https://mail.python.org/mailman/listinfo/python-list
>
>
-- 
Abhiram R

abhiramr.github.io
-- 
https://mail.python.org/mailman/listinfo/python-list


How to drop six support and go to Python 3 only?

2018-09-05 Thread Fabio Zadrozny
My scenario is having an app which was on Py 2, ported to Python 2 and 3
(using six) and will become Python 3 only in a few months.

So, my question is: when Python 2 is no longer needed, is there some tool
which helps removing the six compatibility layer (as well as the if
six.PY2/six.PY3 checks) so that the codebase becomes pythonic again?

Thanks,

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


Can't drop files on python scripts in a fresh installation of Windows

2018-09-05 Thread Random832
Python itself runs fine, but when I try to drop a file on a script it just
doesn't work.

If I try to regsvr32 the shell extension, it says: The module
"c:\windows\pyshellext.amd64.dll" failed to load.

There was no indication of any problem until this. Apparently it is linked
against "VCRUNTIME140.dll", not (or in addition to? peview shows both) the
universal CRT.

Installing the Visual C++ 2015 redistributable resolved it, but there was no
instruction for this.

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


Re: Anaconda with Python 3.7

2018-09-05 Thread Thomas Jollans
On 2018-09-03 11:38, gvim wrote:
> Anyone have any idea when Anaconda might ship a version compatible with
> Python 3.7. I sent them 2 emails but no reply.
>
> gvim

You can install Python 3.7 in a conda environment right now. Most packages
(certainly all the ones I use) appear to be available for Python 3.7 at least
on Windows and Linux already.

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


Error installing libraries

2018-09-05 Thread ojas gupta
I am having trouble with installation of one library â £mysqlclientâ Ø and it
keeps on showing the same message  (copied below as it is
 ) .

THE MESSAGE :

C:\>pip install mysqlclient
Collecting mysqlclient
  Using cached https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d
1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... error
Complete output from command "c:\users\ojas
gupta\appdata\local\programs\python\python37\python.exe" -u -c "import
setuptools, tokenize;__file__='C:\\Users\\OJASGU~1\\AppData\\Local\\Temp\\pip-i
 nstall-1d03ayeg\\mysqlclient\\setup.py';f=getattr(tokenize, 'open',
open)(__file__);code=f.read().replace('\r\n',
'\n');f.close();exec(compile(code, __file__, 'exec'))" install --record
C:\Users\OJASGU~1\AppData\Local\Temp\pip-record-wauonuy1\install-record.txt
--single-version-externally-managed --compile:
c:\users\ojas gupta\appdata\local\programs\python\python37\lib\distutils\di
st.py:274: UserWarning: Unknown distribution option:
'long_description_content_type'
  warnings.warn(msg)
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
copying _mysql_exceptions.py -> build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win-amd64-3.7\MySQLdb
copying MySQLdb\compat.py -> build\lib.win-amd64-3.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win-amd64-3.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win-amd64-3.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win-amd64-3.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win-amd64-3.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win-amd64-3.7\MySQLdb
creating build\lib.win-amd64-3.7\MySQLdb\constants
copying MySQLdb\constants\__init__.py ->
build\lib.win-amd64-3.7\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py ->
build\lib.win-amd64-3.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.7\MySQLdb\constant
s
copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.7\MySQLdb\constant
s
copying MySQLdb\constants\FIELD_TYPE.py ->
build\lib.win-amd64-3.7\MySQLdb\constants
copying MySQLdb\constants\FLAG.py ->
build\lib.win-amd64-3.7\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py ->
build\lib.win-amd64-3.7\MySQLdb\constants
running build_ext
building '_mysql' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual
C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools


Command ""c:\users\ojas gupta\appdata\local\programs\python\python37\python.exe
 " -u -c "import setuptools,
tokenize;__file__='C:\\Users\\OJASGU~1\\AppData\\Lo
cal\\Temp\\pip-install-1d03ayeg\\mysqlclient\\setup.py';f=getattr(tokenize,
'open', open)(__file__);code=f.read().replace('\r\n',
'\n');f.close();exec(compile(code, __file__, 'exec'))" install --record
C:\Users\OJASGU~1\AppData\Local\Temp\pip-record-wauonuy1\install-record.txt
--single-version-externally-managed --compile" failed with error code 1 in
C:\Users\OJASGU~1\AppData\Local\Temp\pip-install-1d03ayeg\mysqlclient\


And the link provided to install Visual C++ 14.0 doesnâ Öt  work . I installed
Visual Studio 2017 and C++ Redistributable 2017 but same issue still .

It will be extremely appreciated if u help me . Thanks .

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


Re: Anaconda with Python 3.7

2018-09-05 Thread Thomas Jollans
On 2018-09-03 16:07, Alex Kaye wrote:
> When one downloads Anaconda, doesn't it
> bring Pyhon with it ?

It does, but one of the main features is the ability to create additional
virtual environments which can use different versions of Python. You can even
upgrade these environments to a different Python version, and all the
conda-installed (Python) packages will be installed in the new Python version.

https://conda.io/docs/user-guide/tasks/manage-environments.html

-- Thomas

PS: Please always make sure you reply on-list.

>
> AK
>
> On Mon, Sep 3, 2018 at 6:13 AM Thomas Jollans  > wrote:
>
> On 2018-09-03 11:38, gvim wrote:
> > Anyone have any idea when Anaconda might ship a version compatible
> with
> > Python 3.7. I sent them 2 emails but no reply.
> >
> > gvim
>
> You can install Python 3.7 in a conda environment right now. Most
> packages (certainly all the ones I use) appear to be available for
> Python 3.7 at least on Windows and Linux already.
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

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


Cross platform mutex to prevent script running more than instance?

2018-09-05 Thread Malcolm Greene
Use case: Want to prevent 2+ instances of a script from running ... ideally in
a cross platform manner. I've been researching this topic and am surprised how
complicated this capability appears to be and how the diverse the solution set
is. I've seen solutions ranging from using directories, named temporary files, 
 named sockets/pipes, etc. Is there any consensus on best practice here? Thank
you,
Malcolm

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


Re: Cross platform mutex to prevent script running more than instance?

2018-09-05 Thread D'Arcy Cain
On 09/03/18 09:45, Malcolm Greene wrote:
> Use case: Want to prevent 2+ instances of a script from running ...
> ideally in a cross platform manner. I've been researching this topic and
> am surprised how complicated this capability appears to be and how the
> diverse the solution set is. I've seen solutions ranging from using
> directories, named temporary files,  named sockets/pipes, etc. Is there
> any consensus on best practice here?

Here's my simple method which works in pure Python so I guess that makes it
cross-platform.  Well, as long as it has process IDs anyway.  There's a small
window between reading the file and writing the new one but for most purposes
that should be OK.  If you have to worry about those nano-second situations you
 will need to use one of those more complicated methods.

import os, sys

def ok2run(lockfile):
mypid = os.getpid()

try: pid = int(open(lockfile).read())
except FileNotFoundError: pass
else:
try: os.kill(pid, 0)
except OSError: pass
else: return False

print(mypid, file=open(lockfile, 'w'))
return True

if not ok2run("/tmp/lockfile"): sys.exit(0)

--
D'Arcy J.M. Cain
Vybe Networks Inc.
http://www.VybeNetworks.com/
IM:[email protected] VoIP: sip:[email protected]

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


Anaconda with Python 3.7

2018-09-05 Thread gvim
Anyone have any idea when Anaconda might ship a version compatible with Python
3.7. I sent them 2 emails but no reply.

gvim

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


Why list.reverse() modifies the list, but name.replace() does not

2018-09-05 Thread C W
Hello all,

I am learning the basics of Python. How do I know when a method modifies the
original object, when it does not. I have to exmaples: Example 1:
> L = [3, 6, 1,4]
> L.reverse()
> L
[4, 1, 6, 3]
This changes the original list.

Example 2:
> name = "John Smith"
> name.replace("J", j")
> name
'John Smith'
This does not change the original string.

Why the two examples produce different results? As a beginner, I find this
confusing. How do you do it?

Thank you!

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


Re: Why list.reverse() modifies the list, but name.replace() does not

2018-09-05 Thread Joel Goldstick
On Mon, Sep 3, 2018 at 1:50 PM C W  wrote:
>
> Hello all,
>
> I am learning the basics of Python. How do I know when a method modifies
> the original object, when it does not. I have to exmaples:
> Example 1:
> > L = [3, 6, 1,4]
> > L.reverse()
> > L
> [4, 1, 6, 3]
> This changes the original list.
>
> Example 2:
> > name = "John Smith"
> > name.replace("J", j")
> > name
> 'John Smith'
> This does not change the original string.
>
> Why the two examples produce different results? As a beginner, I find this
> confusing. How do you do it?
>
> Thank you!
> --
> https://mail.python.org/mailman/listinfo/python-list

Learn about help.  Go to python command line and type help(L) it will show that
 this method reverses in place.  Type help(name) and it will show that this
method returns the result, but does not change your list.

--
Joel Goldstick
http://joelgoldstick.com/blog
http://cc-baseballstats.info/stats/birthdays

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


Re: Error installing libraries

2018-09-05 Thread Thomas Jollans
On 2018-09-03 09:10, ojas gupta wrote:
> error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft
Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-to
 ols
>
> 
> Command ""c:\users\ojas gupta\appdata\local\programs\python\python37\python.e
xe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\OJASGU~1\\AppData\\
 Local\\Temp\\pip-install-1d03ayeg\\mysqlclient\\setup.py';f=getattr(tokenize,
'open', open)(__file__);code=f.read().replace('\r\n',
'\n');f.close();exec(compile(code, __file__, 'exec'))" install --record
C:\Users\OJASGU~1\AppData\Local\Temp\pip-record-wauonuy1\install-record.txt
--single-version-externally-managed --compile" failed with error code 1 in
C:\Users\OJASGU~1\AppData\Local\Temp\pip-install-1d03ayeg\mysqlclient\
>
>
> And the link provided to install Visual C++ 14.0 doesnâ Öt  work . I
installed Visual Studio 2017 and C++ Redistributable 2017 but same issue still
.


mysqlclient binary packages for Windows are available from Christoph Gohlke:
https://www.lfd.uci.edu/~gohlke/pythonlibs/ If you use these you won't need a C
 compiler.


As for the C compiler issue, I'd expect installing Visual Studio 2017 to work,
but I've only ever used the standalone "build tools" with Python on Windows
myself...
See:
https://wiki.python.org/moin/WindowsCompilers#Compilers_Installation_and_config
uration

>
> It will be extremely appreciated if u help me . Thanks .
>

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


Re: Why list.reverse() modifies the list, but name.replace() does not

2018-09-05 Thread Chris Angelico
On Tue, Sep 4, 2018 at 3:49 AM, C W  wrote:
> Hello all,
>
> I am learning the basics of Python. How do I know when a method modifies
> the original object, when it does not. I have to exmaples:
> Example 1:
>> L = [3, 6, 1,4]
>> L.reverse()
>> L
> [4, 1, 6, 3]
> This changes the original list.
>
> Example 2:
>> name = "John Smith"
>> name.replace("J", j")
>> name
> 'John Smith'
> This does not change the original string.
>
> Why the two examples produce different results? As a beginner, I find this
> confusing. How do you do it?

A very fair question.

Firstly, strings are immutable. Once you have a string, nothing can ever change
 it. Lists, on the other hand, can change (you can append to them, remove
elements, etc, etc). So reversing a string in-place is impossible, but it's an
option for the list.

Secondly, you get a clue from the return values.

>>> L = [3, 6, 1,4]
>>> L.reverse()
>>> L
[4, 1, 6, 3]
>>> name = "John Smith"
>>> name.replace("J", "j")
'john Smith'
>>> name
'John Smith'

Notice how name.replace() returns the new string, but L.reverse() doesn't
return anything? (Technically it returns None, but that's used as a signal
meaning "I got nuffin, govna!".) That's a strong clue; if something sounds like
 it ought to make a change, but it returns None, it's almost certainly changed
the object in-place.

If you like, you can iterate backwards over the list, rather than actually
reversing it:

for number in reversed(L): ...

And you can use a very convenient, if a little obscure, syntax to create a
reversed copy of the list:

>>> L
[4, 1, 6, 3]
>>> L[::-1]
[3, 6, 1, 4]

(So you can assign that to another name, or whatever.) This is called "slicing"
 the list, if you want to look it up in the docs.

Ultimately, your question comes down to the difference between mutable and
immutable types. Definitely something worth learning more about, and definitely
 worth asking these sorts of questions about.

Thanks for asking! :)

ChrisA

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


PyDev 6.5.0 released

2018-09-05 Thread Fabio Zadrozny
 PyDev 6.5.0 Release Highlights

   -

   *Debugger*
   - Debugger is *much* more responsive (fixed bug in reader/writer on the
  PyDev side).
  - *breakpoint()* builtin is now supported to add a programmatic
  breakpoint (on any Python version).
  - Watch expression no longer giving error if evaluation is empty
  (patch by glhez).
   -

   *Editor*
   - Code folding of *#region/#endregion* regions (patch by ghbcode).
  - There's a new action which allows creating local imports from a
  global import (use *Ctrl+1* on top of global import name).
   -

   It's now possible to change the default interpreter through an action
   (default binding: *Ctrl+Shift+Alt+I*).
   - The interactive console now has scroll lock (patch by bongibong).

About PyDev

PyDev is an open-source Python IDE on top of Eclipse for Python, Jython and
IronPython development, now also available for Python on Visual Studio Code.

It comes with goodies such as code completion, syntax highlighting, syntax
analysis, code analysis, refactor, debug, interactive console, etc.

It is also available as a standalone through LiClipse with goodies such as
multiple cursors, theming and support for many other languages, such as Django
Templates, Jinja2, Html, JavaScript, etc.

Links:

PyDev: http://pydev.org
PyDev Blog: http://pydev.blogspot.com PyDev on VSCode: http://pydev.org/vscode
LiClipse: http://www.liclipse.com
PyVmMonitor - Python Profiler: http://www.pyvmmonitor.com/

Cheers,

Fabio Zadrozny

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


Re: Anaconda with Python 3.7

2018-09-05 Thread Alex Kaye
Sorry bad typing.  AK


On Mon, Sep 3, 2018 at 7:07 AM Alex Kaye  wrote:

> When one downloads Anaconda, doesn't it
> bring Pyhon with it ?
>
> AK
>
> On Mon, Sep 3, 2018 at 6:13 AM Thomas Jollans  wrote:
>
>> On 2018-09-03 11:38, gvim wrote:
>> > Anyone have any idea when Anaconda might ship a version compatible with
>> > Python 3.7. I sent them 2 emails but no reply.
>> >
>> > gvim
>>
>> You can install Python 3.7 in a conda environment right now. Most
>> packages (certainly all the ones I use) appear to be available for
>> Python 3.7 at least on Windows and Linux already.
>>
>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>

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


Re: Why list.reverse() modifies the list, but name.replace() does not

2018-09-05 Thread Mike C
Yes, I forgot that strings are immutable. I can't change anything in the
string. Silly me!

Thank you very much, I appreciate it. I guess sometimes it just take an
outsider to take you outside the box. And all is answered. :)


From: Python-list  on behalf
of Mark Lawrence  Sent: Monday, September 3, 2018
2:21:36 PM To: [email protected]
Subject: Re: Why list.reverse() modifies the list, but name.replace() does not
modify the string?

On 03/09/18 18:49, C W wrote:
> Hello all,
>
> I am learning the basics of Python. How do I know when a method modifies
> the original object, when it does not. I have to exmaples:
> Example 1:
>> L = [3, 6, 1,4]
>> L.reverse()
>> L
> [4, 1, 6, 3]
> This changes the original list.

Lists are mutable, i.e. can be changed, so it makes sense to do this change in
place.

>
> Example 2:
>> name = "John Smith"
>> name.replace("J", j")
>> name
> 'John Smith'
> This does not change the original string.

Strings are immutable, i.e. cannot be changed, so you have to create a new
string.  Your call to `replace` will do just that, but as it's not saved `name`
 remains the same.  You could use

name = name.replace("J", j") or

newname = name.replace("J", j") as you see fit.

>
> Why the two examples produce different results? As a beginner, I find this
> confusing. How do you do it?
>
> Thank you!
>


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

Mark Lawrence

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

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


Re: Cross platform mutex to prevent script running more than instance?

2018-09-05 Thread CFK
What about using flock()? I don't know if it works on Windows, but it works
really well for Unix/Linux systems.  I typically create a log file in a known
location using any atomic method that doesn't replace/overwrite a file, and
flock() it for the duration of the script.

Thanks,
Cem Karan

On Mon, Sep 3, 2018, 11:39 PM Cameron Simpson  wrote:

> On 03Sep2018 07:45, Malcolm Greene  wrote:
> >Use case: Want to prevent 2+ instances of a script from running ...
> >ideally in a cross platform manner. I've been researching this topic and
> >am surprised how complicated this capability appears to be and how the
> >diverse the solution set is. I've seen solutions ranging from using
> >directories, named temporary files,  named sockets/pipes, etc. Is there
> >any consensus on best practice here?
>
> I like os.mkdir of a known directory name. This tends to be atomic and
> forbidden when the name already exists, on all UNIX platforms, over remote
> filesystems. And, I expect, likewise on Windows.
>
> All the other modes like opening files O_EXCL etc tend to be platform
> specific
> and not reliable over network filesystems.
>
> And pid based approaches don't work cross machine, if that is an issue.
>
> Cheers,
> Cameron Simpson 
> --
> https://mail.python.org/mailman/listinfo/python-list
>

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


Re: Cross platform mutex to prevent script running more than instance?

2018-09-05 Thread Thomas Jollans
On 09/04/2018 05:35 AM, Cameron Simpson wrote:
> On 03Sep2018 07:45, Malcolm Greene  wrote:
>> Use case: Want to prevent 2+ instances of a script from running ...
>> ideally in a cross platform manner. I've been researching this topic and
>> am surprised how complicated this capability appears to be and how the
>> diverse the solution set is. I've seen solutions ranging from using
>> directories, named temporary files,â  named sockets/pipes, etc. Is there
>> any consensus on best practice here?
>
> I like os.mkdir of a known directory name. This tends to be atomic and
> forbidden when the name already exists, on all UNIX platforms, over
> remote filesystems. And, I expect, likewise on Windows.

The trouble with a simple lock file (or directory) is of course that it can't
recover from the program being killed or from program or system crashes without
 manual intervention. For some use cases that's fine, for others it's a
problem.

>
> All the other modes like opening files O_EXCL etc tend to be platform
> specific and not reliable over network filesystems.
>
> And pid based approaches don't work cross machine, if that is an issue.

I think a PID file is the traditional approach for *nix daemons, but as you
say, it does have its own drawbacks.

-- Thomas

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


Re: Any SML coders able to translate this to Python?

2018-09-05 Thread Paul Moore
On Tue, 4 Sep 2018 at 13:31, Steven D'Aprano
 wrote:
>
> I have this snippet of SML code which I'm trying to translate to Python:
>
> fun isqrt n = if n=0 then 0
>  else let val r = isqrt (n/4)
>   in
> if n < (2*r+1)^2 then 2*r
> else 2*r+1
>   end
>
>
> I've tried reading up on SML and can't make heads or tails of the
> "let...in...end" construct.
>
>
> The best I've come up with is this:
>
> def isqrt(n):
> if n == 0:
> return 0
> else:
> r = isqrt(n/4)
> if n < (2*r+1)**2:
> return 2*r
> else:
> return 2*r+1
>
> but I don't understand the let ... in part so I'm not sure if I'm doing
> it right.

I've not used SML much, but what you have looks right. let ... in is basically
a local binding "let x = 12 in x+2" is saying "the value of x+2 with x set to
12".

As I'm sure you realise (but I'll add it here for the sake of any newcomers who
 read this), the recursive approach is not natural (or efficient) in Python,
whereas it's the natural approach in functional languages like SML. In Python
an iterative solution would be better.

Paul

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


Re: Anaconda with Python 3.7

2018-09-05 Thread gvim
On 03/09/2018 10:49, Thomas Jollans wrote:
> On 2018-09-03 11:38, gvim wrote:
>> Anyone have any idea when Anaconda might ship a version compatible with
>> Python 3.7. I sent them 2 emails but no reply.
>>
>> gvim
>
> You can install Python 3.7 in a conda environment right now. Most
> packages (certainly all the ones I use) appear to be available for
> Python 3.7 at least on Windows and Linux already.
>

That's not the same as a specific Python 3.7 distribution. Why are they so
tight-lipped about it? I mean it's been a couple of months now. Do they usually
 take so long?

gvim

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


problem with json.dumps / complexjson.loads in python 3.4 virtualenv

2018-09-05 Thread M. Fioretti
Greetings,

I have an error in a python application that I installed. I already opened an
issue about it on the application page at github, but I would also greatly
appreciate any help to (at least) better debug the problem, because I urgently
need to use that program.

Details:

I need to run the python client for the shaarli bookmarks manager, whose home
page is https://github.com/shaarli/python-shaarli-client, on a Centos release
7.5 x86_64 server. Since that client requires python >= 3.4, and I do not want
to move the whole server to that version, I created a virtualenv following the
instructions at
https://github.com/shaarli/python-shaarli-client/blob/master/docs/user/installa
tion.rst

When I try to run it, I get the error messages that I already reported in full
at

https://github.com/shaarli/python-shaarli-client/issues/33

as far as I can understand after some searching, it **may** be the problem
described at
https://mcgrattan.org/2017/01/24/ordered-json-in-python-with-requests/

but I honestly don't know enough python, to go further without some
help/pointers.

TIA,
Marco


--
http://mfioretti.com

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


Re: Any SML coders able to translate this to Python?

2018-09-05 Thread Marko Rauhamaa
Steven D'Aprano :

> I have this snippet of SML code which I'm trying to translate to Python:
>
> fun isqrt n = if n=0 then 0
>  else let val r = isqrt (n/4)
>   in
> if n < (2*r+1)^2 then 2*r
> else 2*r+1
>   end
>
>
> I've tried reading up on SML and can't make heads or tails of the
> "let...in...end" construct.
>
>
> The best I've come up with is this:
>
> def isqrt(n):
> if n == 0:
> return 0
> else:
> r = isqrt(n/4)
> if n < (2*r+1)**2:
> return 2*r
> else:
> return 2*r+1
>
> but I don't understand the let ... in part so I'm not sure if I'm doing
> it right.

You must make sure "r" doesn't leak outside its syntactic context so:

def isqrt(n):
if n == 0:
return 0
else:
def f2398478957():
r = isqrt(n//4)
if n < (2*r+1)**2:
return 2*r
else:
return 2*r+1
return f2398478957()

(Also use // instead of /: isqrt = integer square root.)


Marko

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


Hi I'm trying to get live data from stock using python , is it possible

2018-09-05 Thread alon najman
Hi ,
for example:
I want to know if AAPL is more than value 300 and if it does I want it to send
to me mail with gmail :) . thanks for the help..

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


Any SML coders able to translate this to Python?

2018-09-05 Thread Steven D'Aprano
I have this snippet of SML code which I'm trying to translate to Python:

fun isqrt n = if n=0 then 0
 else let val r = isqrt (n/4)
  in
if n < (2*r+1)^2 then 2*r
else 2*r+1
  end


I've tried reading up on SML and can't make heads or tails of the
"let...in...end" construct.


The best I've come up with is this:

def isqrt(n):
if n == 0:
return 0
else:
r = isqrt(n/4)
if n < (2*r+1)**2:
return 2*r
else:
return 2*r+1

but I don't understand the let ... in part so I'm not sure if I'm doing it
right.


--
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing it everywhere."
 -- Jon Ronson

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


Re: Hi I'm trying to get live data from stock using python , is it poss

2018-09-05 Thread alon najman
On Tuesday, September 4, 2018 at 7:21:31 PM UTC+3, [email protected] wrote:
> Hi ,
> for example:
> I want to know if AAPL is more than value 300 and if it does I want it to
send to me mail with gmail :) . thanks for the help..

im using python 2.7

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


Re: Anaconda with Python 3.7

2018-09-05 Thread Alex Kaye
When one downloads Anaconda, doesn't it bring Pyhon with it ?

AK

On Mon, Sep 3, 2018 at 6:13 AM Thomas Jollans  wrote:

> On 2018-09-03 11:38, gvim wrote:
> > Anyone have any idea when Anaconda might ship a version compatible with
> > Python 3.7. I sent them 2 emails but no reply.
> >
> > gvim
>
> You can install Python 3.7 in a conda environment right now. Most
> packages (certainly all the ones I use) appear to be available for
> Python 3.7 at least on Windows and Linux already.
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

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


Re: Hi I'm trying to get live data from stock using python , is it

2018-09-05 Thread Thomas Jollans
On 2018-09-04 18:22, [email protected] wrote:
> On Tuesday, September 4, 2018 at 7:21:31 PM UTC+3, [email protected] wrote:
>> Hi ,
>> for example:
>> I want to know if AAPL is more than value 300 and if it does I want it to
send to me mail with gmail :) . thanks for the help..

Of course it's possible. The standard library includes facilities modules for
interacting with web services, modules for writing emails, and everything else
you'll need.

>
> im using python 2.7
>

Please use Python 3, especially if you're new to Python. Python 2.7 is woefully
 out of date.

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


Re: Pass a list of values as options to 3 dropdown menus

2018-09-05 Thread Peter Pearson
On Sun, 2 Sep 2018 13:40:18 -0700 (PDT), Nick Berg wrote:
> how can i be able to store a list of values to drop-down menu and then
> grab the value that the user selects?
>
> **
> name = month = year = ''
>
> # populate names, months, years
> names.add( '' )
> months = ( '==', 'îÖî±î½î¿ïàî¬ïüî1î¿ ...
> years  = ( '=', 2010, 2011, 2012, 2 ...
>
>
> pdata = pdata + '''
> îòï î1î»îµîºïäî1îºîR
îæî½î±î¶îRïäî·ïâî·: 
>
> 
>  %s 
> 
>
> 
>  %s 
> 
>
> 
>  %s 
> 
> 
> 
> ''' % ( url_for( 'seek', name=name, month=month, year=year ), name, name,
month, month, year, year )
> **

I can't tell whether this is an HTML question or a Python question. If you can
reduce it to a Python question, perhaps I can help.

--
To email me, substitute nowhere->runbox, invalid->com.

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


Re: Why list.reverse() modifies the list, but name.replace() does not

2018-09-05 Thread Mark Lawrence
On 03/09/18 18:49, C W wrote:
> Hello all,
>
> I am learning the basics of Python. How do I know when a method modifies
> the original object, when it does not. I have to exmaples:
> Example 1:
>> L = [3, 6, 1,4]
>> L.reverse()
>> L
> [4, 1, 6, 3]
> This changes the original list.

Lists are mutable, i.e. can be changed, so it makes sense to do this change in
place.

>
> Example 2:
>> name = "John Smith"
>> name.replace("J", j")
>> name
> 'John Smith'
> This does not change the original string.

Strings are immutable, i.e. cannot be changed, so you have to create a new
string.  Your call to `replace` will do just that, but as it's not saved `name`
 remains the same.  You could use

name = name.replace("J", j") or

newname = name.replace("J", j") as you see fit.

>
> Why the two examples produce different results? As a beginner, I find this
> confusing. How do you do it?
>
> Thank you!
>


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

Mark Lawrence

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


Re: Hi I'm trying to get live data from stock using python ,

2018-09-05 Thread Skip Montanaro
> I want to know if AAPL is more than value 300 and if it does I want it to
send to me mail with gmail :) . thanks for the help..

Try searching pypi.org for "finance", then scroll through the many returned
packages. A few show how to get stock data from Yahoo! or Google.

Skip

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


Re: Hi I'm trying to get live data from stock using python , is it

2018-09-05 Thread Michael Torrie
On 09/04/2018 10:21 AM, [email protected] wrote:
> Hi ,
> for example:
> I want to know if AAPL is more than value 300 and if it does I want it to
send to me mail with gmail :) . thanks for the help..
>

Yes it's definitely possible!  Hop on Google and do some searches; you're bound
 to find some articles on the subject, possibly some demo code, and probably
some Python libraries to automate the process. Google search terms you'll want
to try include things like "python stock price email."

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


Re: Verifying the integrity/lineage of a file

2018-09-05 Thread Grant Edwards
On 2018-09-01, Peter Pearson  wrote:

> Writing your own crypto software is fraught with peril, and that
> includes using existing libraries.

Writing your own crypto software isn't a problem, and it can be very
educational.

Just don't _use_ your own crypto software.

Howerver, the set of people who write software without intending to use it is
pretty small...

--
Grant Edwards   grant.b.edwardsYow! ... the MYSTERIANS are
  at   in here with my CORDUROY
  gmail.comSOAP DISH!!

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


Re: Cross platform mutex to prevent script running more than instance?

2018-09-05 Thread Cameron Simpson
On 03Sep2018 07:45, Malcolm Greene  wrote:
>Use case: Want to prevent 2+ instances of a script from running ...
>ideally in a cross platform manner. I've been researching this topic and
>am surprised how complicated this capability appears to be and how the
>diverse the solution set is. I've seen solutions ranging from using
>directories, named temporary files,  named sockets/pipes, etc. Is there
>any consensus on best practice here?

I like os.mkdir of a known directory name. This tends to be atomic and
forbidden when the name already exists, on all UNIX platforms, over remote
filesystems. And, I expect, likewise on Windows.

All the other modes like opening files O_EXCL etc tend to be platform specific
and not reliable over network filesystems.

And pid based approaches don't work cross machine, if that is an issue.

Cheers,
Cameron Simpson 

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


PEP 8001 -- Python Governance Voting Process

2018-09-05 Thread Mark Lawrence
I believe that this https://www.python.org/dev/peps/pep-8001/ may be of
interest.

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

Mark Lawrence

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


Re: Hi I'm trying to get live data from stock using python , is it poss

2018-09-05 Thread Calvin Spealman
Please don't keep spamming this list with the same question, while you have
not responded to any of the advice you've already been given.

If you have specific trouble with any of that advice and need further help,
please give details and ask new questions!

Good luck.

On Wed, Sep 5, 2018 at 4:02 PM alon najman  wrote:

> On Tuesday, September 4, 2018 at 7:21:31 PM UTC+3, [email protected]
> wrote:
> > Hi ,
> > for example:
> > I want to know if AAPL is more than value 300 and if it does I want it to
> send to me mail with gmail :) . thanks for the help..
>
> im using python 2.7
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hi I'm trying to get live data from stock using python , is it poss

2018-09-05 Thread Chris Angelico
On Thu, Sep 6, 2018 at 6:06 AM, Calvin Spealman  wrote:
> Please don't keep spamming this list with the same question, while you have
> not responded to any of the advice you've already been given.
>
> If you have specific trouble with any of that advice and need further help,
> please give details and ask new questions!
>

I don't think this was spamming the list with the same question; a
glitch somewhere in a netnews server appears to be re-posting some old
posts.

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


Re: Re: CURSES WINDOWS

2018-09-05 Thread Peter via Python-list

I get this:


C:\Users\Me> py
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 
bit (Inte

l)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import curses
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Program Files (x86)\Python36-32\lib\curses\__init__.py", 
line 13, in


    from _curses import *
ModuleNotFoundError: No module named '_curses'
>>>


I get the same on py 2.7



On 5/09/2018 4:59 PM, Anssi Saari wrote:

[email protected] (shinobi) writes:


Hello All,

can anyone please let me know what's the path to port linux python curses
program to Windows?

Is there really anything that needs to be done? At least a simple hello
world python curses program runs on Windows and Linux with no changes.





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


Re: Calling an unbound method in C using the Public API

2018-09-05 Thread Matthieu Dartiailh
Thanks Serhiy. This does come with a performance penalty (in particular for 
function taking keyword arguments) but this is to be expected. Also the 
PyList_Insert solution does not sadly work for all the methods that I need to 
wrap.

Best

Matthieu

> On Aug 30, 2018, at 11:09 AM, Serhiy Storchaka  wrote:
> 
> 29.08.18 17:33, Matthieu Dartiailh пише:
>> I tried to look at the public C API for a way to call an unbound method with 
>> a minimal cost (in term of speed and memory). It seems to me, but please 
>> correct me if I am wrong, that one cannot call a MethodDef using only the 
>> public API. To use the public C API, one has to use PyCFunction_Call (or a 
>> variant) that expect a PyCFunctionObject which binds a the MethodDef to an 
>> instance. In my case, to avoid creating a temporary PyCFunctionObject each 
>> time I call list.insert on my custom subclass instance, I have to store that 
>> PyCFunctionObject for each instance. But this means storing  7 
>> PyCFunctionObject per instance (one for each method of list I need to wrap). 
>> So I can either use the public API and increase the memory footprint or slow 
>> down the code by creating PyCFunctionObject for each call
>>  , or use large amount of the private API.
>> Am I missing something ?
> 
> In general, you need to cache the unbound method object, and call it with 
> self as the first argument.
> 
> list_insert = PyObject_GetAttrString((PyObject *)&PyList_Type, "insert");
> ...
> res = PyObject_CallFunctionObjArgs(list_insert, self, index, value, NULL);
> 
> But in the particular case of the insert method it will be easier and more 
> efficient to use PyList_Insert().
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

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


Re: Any SML coders able to translate this to Python?

2018-09-05 Thread Marko Rauhamaa
Marko Rauhamaa  (Marko Rauhamaa):
> Steven D'Aprano :
>> I have this snippet of SML code which I'm trying to translate to Python:
>>
>> fun isqrt n = if n=0 then 0
>>  else let val r = isqrt (n/4)
>>   in
>> if n < (2*r+1)^2 then 2*r
>> else 2*r+1
>>   end
> [...]
> You must make sure "r" doesn't leak outside its syntactic context so:
>
> def isqrt(n):
> if n == 0:
> return 0
> else:
> def f2398478957():
> r = isqrt(n//4)
> if n < (2*r+1)**2:
> return 2*r
> else:
> return 2*r+1
> return f2398478957()

Actually, this is a more direct translation:

   def isqrt(n):
   if n == 0:
   return 0
   else:
   def f2398478957(r):
   if n < (2*r+1)**2:
   return 2*r
   else:
   return 2*r+1
   return f2398478957(isqrt(n//4))


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


[SOLVED]: problem with json.dumps / complexjson.loads in python 3.4 virtualenv

2018-09-05 Thread M. Fioretti

On 2018-09-05 08:21, dieter wrote:

"M. Fioretti"  writes:

I have an error in a python application that I installed...
... https://github.com/shaarli/python-shaarli-client/issues/33

...
Looks like the problem is immediately at the start of the response
(--> "ValueError: Expecting value: line 1 column 1 (char 0)"),
i.e. the server response is not recognizable as a JSON encoded value.


indeed, it turned out that the problem was a misconfiguration of the 
server
that prevented it from sending correct answers when contacted by that 
python application. Thanks for helping me to look in the right 
direction.


Marco
--
http://mfioretti.com
--
https://mail.python.org/mailman/listinfo/python-list