Re: Server side Blazor-like framework in Python?

2019-12-15 Thread Test Bot
+1

Though the implementation might be good from an exercise perspective. But
there is a general philosophy in Software Engineering namely

Separation of Concern.

Python as a language is not concerned about the "Front-End" side of things
since it is not meant for that. Though i am a very devote Python
programmer, i would still prefer to limit Python to backend tasks and have
the Front End implemented in React.

On Sun, Dec 15, 2019 at 5:47 PM Chris Angelico  wrote:

> On Sun, Dec 15, 2019 at 11:11 PM  wrote:
> >
> > I've been doing a lot of development with server side Blazor on .NET
> recently, and I think it's a very interesting UI model (
> https://docs.microsoft.com/en-us/aspnet/core/blazor/hosting-models?view=aspnetcore-3.1).
> What would it take to make something similar in Python? I guess a lot of
> relevant Python packages already exist.
> >
> > SSB works by having a component/DOM model running on the server. The
> client web page sends events and receives DOM diffs over a
> SignalR/websocket comnection.
> >
>
> I *much* prefer to have the front end in charge of the UI, and the
> back end work as an API. Just send and receive JSON with useful
> information in it, and let the front end figure out how it wants to
> display that.
>
> But hey, if you want to ship a DOM diff down the wire, go ahead. Just
> don't ask me to use your tool. :)
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Unable to install Flask-Mongoengine

2019-12-15 Thread Test Bot
No help with using pip3

On Sun, Dec 15, 2019 at 2:49 PM tommy yama  wrote:

> how about pip3?
>
> On Sun, Dec 15, 2019 at 5:16 PM Test Bot  wrote:
>
>> Hi Guys,
>>
>> I am unable to install *Flask-Mongoengine* using pip. Here are my
>> specifications
>>
>> 1. *OS* => OSX 10.14.6
>> 2. *Python* => Python 3.8.0 (Working in a virtualenv)
>> 3. *Dependency Manager* => pip(19.3.1), setuptools(42.0.2)
>> 3. *Flask-Mongoengine* => flask-mongoengine==0.9.5
>>
>> I am inside my virtualenv and trying to install flask-mongoengine using
>>
>> > (env) $ pip install flask-mongoengine==0.9.5
>>
>>
>> Here is my error
>>
>> >  distutils.errors.DistutilsError: Command
>> > '['/Users/onlinejudge95/Workspace/GitHub/alma-serv/env/bin/python',
>> '-m',
>> > 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w',
>> > '/var/folders/r7/pgqw605n55x5f9018rp72hsmgn/T/tmpgrvp80jd',
>> '--quiet',
>> > 'rednose']' returned non-zero exit status 1.
>>
>>
>> Please Find attached my full error log.
>>
>> I am on a new system in which i installed python through the mac installer
>> from python.org, i had run the *Install Certificates.command* for SSL
>> related issues, if it might be of help.
>>
>> In case there is a more specific mailing list to redirect to, please let
>> me
>> know.
>>
>> Thanks,
>> onlinejudge95
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Unable to install Flask-Mongoengine

2019-12-15 Thread Test Bot
Hi Guys,

I am unable to install *Flask-Mongoengine* using pip. Here are my
specifications

1. *OS* => OSX 10.14.6
2. *Python* => Python 3.8.0 (Working in a virtualenv)
3. *Dependency Manager* => pip(19.3.1), setuptools(42.0.2)
3. *Flask-Mongoengine* => flask-mongoengine==0.9.5

I am inside my virtualenv and trying to install flask-mongoengine using

> (env) $ pip install flask-mongoengine==0.9.5


Here is my error

>  distutils.errors.DistutilsError: Command
> '['/Users/onlinejudge95/Workspace/GitHub/alma-serv/env/bin/python', '-m',
> 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w',
> '/var/folders/r7/pgqw605n55x5f9018rp72hsmgn/T/tmpgrvp80jd', '--quiet',
> 'rednose']' returned non-zero exit status 1.


Please Find attached my full error log.

I am on a new system in which i installed python through the mac installer
from python.org, i had run the *Install Certificates.command* for SSL
related issues, if it might be of help.

In case there is a more specific mailing list to redirect to, please let me
know.

Thanks,
onlinejudge95
(env) $ pip install flask-mongoengine
Collecting flask-mongoengine
  Using cached 
https://files.pythonhosted.org/packages/20/53/1bb8ad34ad5c2047a11651290325e55086bc18fce7cfdbbe6f5522bd0ae5/flask-mongoengine-0.9.5.tar.gz
ERROR: Command errored out with exit status 1:
 command: /Users/onlinejudge95/Workspace/GitHub/alma-serv/env/bin/python3 
-c 'import sys, setuptools, tokenize; sys.argv[0] = 
'"'"'/private/var/folders/r7/pgqw605n55x5f9018rp72hsmgn/T/pip-install-73496mgp/flask-mongoengine/setup.py'"'"';
 
__file__='"'"'/private/var/folders/r7/pgqw605n55x5f9018rp72hsmgn/T/pip-install-73496mgp/flask-mongoengine/setup.py'"'"';f=getattr(tokenize,
 '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', 
'"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info 
--egg-base 
/private/var/folders/r7/pgqw605n55x5f9018rp72hsmgn/T/pip-install-73496mgp/flask-mongoengine/pip-egg-info
 cwd: 
/private/var/folders/r7/pgqw605n55x5f9018rp72hsmgn/T/pip-install-73496mgp/flask-mongoengine/
Complete output (44 lines):
WARNING: The wheel package is not available.
  ERROR: Command errored out with exit status 1:
   command: /Users/onlinejudge95/Workspace/GitHub/alma-serv/env/bin/python3 
-u -c 'import sys, setuptools, tokenize; sys.argv[0] = 
'"'"'/private/var/folders/r7/pgqw605n55x5f9018rp72hsmgn/T/pip-wheel-z44wznx3/rednose/setup.py'"'"';
 
__file__='"'"'/private/var/folders/r7/pgqw605n55x5f9018rp72hsmgn/T/pip-wheel-z44wznx3/rednose/setup.py'"'"';f=getattr(tokenize,
 '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', 
'"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' 
bdist_wheel -d 
/private/var/folders/r7/pgqw605n55x5f9018rp72hsmgn/T/pip-wheel-qz9lk008
   cwd: 
/private/var/folders/r7/pgqw605n55x5f9018rp72hsmgn/T/pip-wheel-z44wznx3/rednose/
  Complete output (6 lines):
  usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
 or: setup.py --help [cmd1 cmd2 ...]
 or: setup.py --help-commands
 or: setup.py cmd --help

  error: invalid command 'bdist_wheel'
  
  ERROR: Failed building wheel for rednose
ERROR: Failed to build one or more wheels
Traceback (most recent call last):
  File 
"/Users/onlinejudge95/Workspace/GitHub/alma-serv/env/lib/python3.8/site-packages/setuptools/installer.py",
 line 128, in fetch_build_egg
subprocess.check_call(cmd)
  File 
"/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py",
 line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 
'['/Users/onlinejudge95/Workspace/GitHub/alma-serv/env/bin/python3', '-m', 
'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', 
'/var/folders/r7/pgqw605n55x5f9018rp72hsmgn/T/tmpjzg2lnoc', '--quiet', 
'rednose']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 1, in 
  File 
"/private/var/folders/r7/pgqw605n55x5f9018rp72hsmgn/T/pip-install-73496mgp/flask-mongoengine/setup.py",
 line 36, in 
setup(
  File 
"/Users/onlinejudge95/Workspace/GitHub/alma-serv/env/lib/python3.8/site-packages/setuptools/__init__.py",
 line 144, in setup
_install_setup_requires(attrs)
  File 
"/Users/onlinejudge95/Workspace/GitHub/alma-serv/env/lib/python3.8/site-packages/setuptools/__init__.py",
 line 139, in _install_setup_requires
dist.fetch_build_eggs(dist.setup_requires)
  File 
"/Users/onlinejudge95/Workspace/GitHub/alma-serv/env/lib/python3.8/site-packages/setuptools/dist.py",
 line 718, in fetch_build_eggs
resolved_dists = pkg_resources.working_set.resolve(
  File 

Re: numpy results in segmentation fault

2019-09-16 Thread Test Bot
Firstly, in response to this
"
I tried to install numpy with 3.7.3 and it is for some
reason not working and after import when I run import numpy at python
console and press enter I get >>? i,e its not working properly.
"

the >> prompt after import numpy signifies that the numpy module has been
loaded and is available in the session.

Can you please provide the traceback you are getting along with the input.

PS - Also, you have some coins like thing on hackerrank I guess to reveal
the test cases, in case everything else fails.

On Mon, Sep 16, 2019 at 5:32 PM Thomas Jollans  wrote:

> Please reply on-list. (both of you)
>
>
>  Forwarded Message 
> Subject: Re: numpy results in segmentation fault
> Date: Mon, 16 Sep 2019 17:04:57 +0530
> From: Test Bot  
> To: Pradeep Patra  
> CC: Thomas Jollans  
>
> Firstly, in response to this
> "
> I tried to install numpy with 3.7.3 and it is for some
> reason not working and after import when I run import numpy at python
> console and press enter I get >>? i,e its not working properly.
> "
>
> the >> prompt after import numpy signifies that the numpy module has been
> loaded and is available in the session.
>
> Can you please provide the traceback you are getting along with the input.
>
> PS - Also, you have some coins like thing on hackerrank I guess to reveal
> the test cases, in case everything else fails.
>
> On Mon, Sep 16, 2019 at 3:08 PM Pradeep Patra 
> wrote:
>
>> Yes it is crashing in the hackerrank site and the testcases fails with
>> segmentation fault. I tried to install numpy with 3.7.3 and it is for some
>> reason not working and after import when I run import numpy at python
>> console and press enter I get >>? i,e its not working properly.
>>
>> Can you please help letting me know the python and numpy compatibility
>> matrix or I am missing anything?
>>
>> I tried some of the numpy code from the other github and it also fails
>> with
>> the segmentation fault :-(. I am guessing some numpy version compatility
>> issue or some environment issue.
>>
>> On Thu, Sep 12, 2019 at 8:00 PM Thomas Jollans  wrote:
>>
>> > On 12/09/2019 15.53, Pradeep Patra wrote:
>> > > Hi ,
>> > >
>> > > I was trying to solve the hackerrank and was using python 3.7.x.
>> > > https://www.hackerrank.com/challenges/np-concatenate/problem
>> > >
>> > > While running the code sometimes I get success result and sometimes it
>> > > fails with "Segmentation Fault" at Hacker rank UI. I dont have any
>> clue
>> > why
>> > > the code is crashing ? Does anyone have any idea?
>> >
>> >
>> > Are you sure it's your code that's crashing, and not something beyond
>> > your control? (Such as the software that is starting Python for you)
>> > Does it depend on the input? Can you reproduce the issue in a controlled
>> > environment (i.e. on your own PC)?
>> >
>> >
>> > >
>> > > Regards
>> > > Pradeep
>> > >
>> > > import numpy
>> > >
>> > > n,m,p = map(int,input().split())
>> > > tgt_arr1 = []
>> > > for i in range(n):
>> > > row = list(map(int,input().split()))
>> > > tgt_arr1.append(row)
>> > > tgt_arr2 = []
>> > > for j in range(m):
>> > > row = list(map(int,input().split()))
>> > > tgt_arr2.append(row)
>> > >
>> > > num_arr1 = numpy.array(tgt_arr1,int)
>> > > num_arr2 = numpy.array(tgt_arr2,int)
>> > >
>> > > print(numpy.concatenate((num_arr1,num_arr2),axis=0))
>> >
>> >
>> > --
>> > https://mail.python.org/mailman/listinfo/python-list
>> >
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Handy utilities = Friday Filosofical Finking

2019-03-28 Thread Test Bot
+1

On Fri, Mar 29, 2019, 2:04 AM DL Neil 
wrote:

> How do you keep, use, and maintain those handy snippets, functions,
> classes... - units of code, which you employ over-and-over again?
>
>
> Having coded 'stuff' once, most of us will keep units of code,
> "utilities", which we expect will be useful in-future (DRY principle),
> eg functions to rename files, choose unique back-up/new fileNMs,
> accessing a DB, journalling (logging) start/stop msgs, building specs
> from YAML/JSON/XML/.ini config files (tongue~cheek), etc.
>
> Do you 'keep' these, or perhaps next time you need something you've
> 'done before' do you remember when/where a technique was last
> used/burrow into 'history'?
> (else, code it from scratch, all over again)
>
> How do you keep them updated, ie if add some new idea, better
> err-checking, re-factor - how to add these 'back' into previous places
> utility is used?
> (who wants more "technical debt", plus handling classic
> update/versioning issue)
>
> How do you keep these? eg special file/dir, within IDE, leave in app and
> 'remember', on paper, ... If the former, how do you access/import them
> from the various applications/systems?
> (Python's import rules and restrictions, change control/version control)
>
>
> Am interested to hear your tactics; to learn, compare, and contrast...
> --
> Regards,
> =dn
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Search and Replace of string in a yaml file

2019-03-27 Thread Test Bot
Assuming you are asking about the logic at the uber level.

You can try handling yaml file with pyyaml. It is a 3rd party package which
has a good support for I/O related to yaml files.

After you are able to read the data from the file, you need to apply your
business logic to it. And log all the erroneous matches.

For example

import yaml

with open(path/to/yaml/file, "r") as fp:
yaml_data = yaml.safe_load(fp)


On Sat, Mar 23, 2019, 5:33 PM Pradeep Patra 
wrote:

> Hi all,
>
> I have several yaml files in a directory around 100s. I have some values
> and my script should search a string(reading from the JSON file)  from the
> series of yaml files and run some validation like the key of the file that
> is updated  in the yaml file and run some basic validation tests like data
> integrity of the replaced string with the source string read from JSON. Can
> anyone suggest some reliable and efficient method to achieve this and
> appreciate some examples for the same?
>
> Regards
> Pradeep
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Managing pipenv virtualenvs

2019-03-26 Thread Test Bot
If the chapters are not contiguous then I can't find a reason to delete
them (previous venv). Moreover it would be better practice to keep separate
venv and not to use a single venv for multiple codebase. Highly discouraged
should be to use the systemwide interpreter.

Moreover the whole idea of using pipenv/pip is to make the venv easy to
recreate. That being said I would focus more on whether my
pipfile/requirements.txt is maintained properly or not. If it is then
spinning up the same venv is an easy task.

On Wed, Mar 27, 2019, 4:21 AM Tim Johnson  wrote:

> * Test Bot  [190326 14:18]:
> > Nothing much i think. If you are properly managing dependencies for each
> > venv, then each new venv should have the same state as the previous one
>   Good to hear
>
> > along with some extra dependencies for each new chapter (haven't gone
> > through the specific book, but I am assuming that in the book, every
> > chapter builds on the previous one).
>   The author's source code is on github, so I downloaded all of it
>   for my edification.
>
>   It appears that consecutive chapters do not always build on the
>   following, i.e. have the previous chapter files.
>
>   I guess I will find out why ...
>   thank you
> > On a personal note it sounds strange why the author wants to have
> different
> > venv's for each chapter.
> >
> > On Wed, Mar 27, 2019, 3:30 AM Tim Johnson  wrote:
> >
> > > I'm on ubuntu 16.04
> > >
> > > using pipenv for the "Django for Beginners..." tutorial book.
> > >
> > > each chapter instructs me to create a new virtual environment with a
> > > folder under ~/.local/share/virtualenvs
> > >
> > > folders are named with the project name followed by an hyphen and a
> > > brief codified string.
> > > examples
> > >  helloworld-_e28Oloi
> > >  pages-Du4qJjUr
> > >
> > > What would happen if I deleted the first folder, which was created
> > > in a previous chapter?
> > >
> > > ... trying to minimize my SSD real estate.
> > > thanks
> > > --
> > > Tim Johnson
> > > http://www.tj49.com
> > > --
> > > https://mail.python.org/mailman/listinfo/python-list
> > >
> > --
> > https://mail.python.org/mailman/listinfo/python-list
>
> --
> Tim Johnson
> http://www.tj49.com
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Managing pipenv virtualenvs

2019-03-26 Thread Test Bot
Nothing much i think. If you are properly managing dependencies for each
venv, then each new venv should have the same state as the previous one
along with some extra dependencies for each new chapter (haven't gone
through the specific book, but I am assuming that in the book, every
chapter builds on the previous one).

On a personal note it sounds strange why the author wants to have different
venv's for each chapter.

On Wed, Mar 27, 2019, 3:30 AM Tim Johnson  wrote:

> I'm on ubuntu 16.04
>
> using pipenv for the "Django for Beginners..." tutorial book.
>
> each chapter instructs me to create a new virtual environment with a
> folder under ~/.local/share/virtualenvs
>
> folders are named with the project name followed by an hyphen and a
> brief codified string.
> examples
>  helloworld-_e28Oloi
>  pages-Du4qJjUr
>
> What would happen if I deleted the first folder, which was created
> in a previous chapter?
>
> ... trying to minimize my SSD real estate.
> thanks
> --
> Tim Johnson
> http://www.tj49.com
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Lifetime of a local reference

2019-02-27 Thread Test Bot
Just to add on regarding file I/O. It would be more pythonic to use.

with open(path):
do_stuff()

On Wed, Feb 27, 2019, 3:31 AM Marko Rauhamaa  wrote:

>
> Consider this function:
>
> def fun():
> f = open("lock")
> flock.flock(f, fcntl.LOCK_EX)
> do_stuff()
> sys.exit(0)
>
> Question: can a compliant Python implementation close f (and,
> consequently, release the file lock) before/while do_stuff() is
> executed?
>
> I couldn't find an immediate answer in the documentation.
>
>
> Marko
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why float('Nan') == float('Nan') is False

2019-02-13 Thread Test Bot
This definition of NaN is much better in mentally visualizing all the so
called bizarreness of IEEE. This also makes intuitive that no 2 NaN will be
equal just as no 2 infinities would be equal. I believe in a hypothesis(of
my own creation) that any arithmetic on a data type of NaN would be similar
to any set of operations on the set of Infinities.

On Thu, Feb 14, 2019, 12:33 AM Avi Gross  I won't speak for the IEEE but NOT A NUMBER does not tell you what
> something
> IS.
>
> If "Hello, World!" is not a number as in an int or a float and we throw
> away
> the content and simply call it a NaN or something and then we notice that
> an
> object that is a list of fruits is also not a number so we call it a NaN
> too, then should  they be equal?
>
> A NaN is a bit like a black hole. Anything thrown in disappears and that is
> about all we know about it. No two black holes are the same even if they
> seem to have the same mass, spin and charge. All they share is that we
> don't
> know what is in them.
>
> When variable "a" is a Nan then it is sort of a pointer to a concept. The
> pointer IS itself but the concepts may not be.
>
> -Original Message-
> From: Python-list  On
> Behalf Of Grant Edwards
> Sent: Wednesday, February 13, 2019 1:03 PM
> To: python-list@python.org
> Subject: Re: Why float('Nan') == float('Nan') is False
>
> On 2019-02-13, ast  wrote:
> > Hello
> >
> > >>> float('Nan') == float('Nan')
> > False
>
> If you think that's odd, how about this?
>
> >>> n = float('nan')
> >>> n
> nan
> >>> n is n
> True
> >>> n == n
> False
> >>>
>
> > Why ?
>
> IEEE says so.
>
> --
> Grant Edwards   grant.b.edwardsYow! Like I always say
>   at   -- nothing can beat
>   gmail.comthe BRATWURST here in
>DUSSELDORF!!
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list