Re: How to install your personal module/package on site.

2020-08-21 Thread Antoon Pardon




Op 21/08/20 om 01:49 schreef Cameron Simpson:

On 16Aug2020 08:32, Marco Sulla  wrote:

Sorry, didn't read well, Apart the other suggestion, you (or your
sysop) can create a private Pypi:
https://pypi.org/project/private-pypi/


Even simpler, you can put a code repo path into your requirements.txt
(or directly with pip via its "-e" option). Example from a project
requirements.txt file:

 -e 
git+https://github.com/SpectraLogic/ds3_python3_sdk.git@v5.0.3#egg=ds3-sdk

So if you've an work internal service for your revision control you can
pull directly from that with pip. Note that the above example pulls a
particular tagged release via the "@5.0.3" suffix.


That is a nice feature. I will have a closer look at this.

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


Python Pandas

2020-08-21 Thread J Conrado


HI,


I'm using Pandas to read my .xls file and I used the command to read it:

df = pd.read_excel(filexcel, parse_dates=[0], dayfirst=True)


and I had the day, month, year and hour correctly


But, if I  run the same script inside a virtual environment, I had this 
error message:


  File "xlsteste.py", line 16, in 
    df = pd.read_excel(filexcel, parse_dates=[0], dayfirst=True)
  File 
"/home/conrado/PENDRIVE_ASIEL/EXCEL/IMAGENS_ESTAÇÕES/env/lib/python3.8/site-packages/pandas/util/_decorators.py", 
line 296, in wrapper

    return func(*args, **kwargs)
TypeError: read_excel() got an unexpected keyword argument 'dayfirst'


Please,could someone explain why my script doesn't run when I'm in the 
virtual environment.


Thanks,

Conrado


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


Temporary text for multiple entries

2020-08-21 Thread Prashant Aggarwal
I am working to make a form where I have added multiple entries. I wish to add 
temporary text on all of them, as the text to be deleted when clicked and to 
inserted again when focused out. I have done with the single entry but not able 
to find a solution for multiple entries.Kindly suggest me a better way to do.
-- 
https://mail.python.org/mailman/listinfo/python-list


Matrix of size 100*100- Meghna

2020-08-21 Thread Meghna Karkera
Dear Respected Sir

I am Meghna, a PhD student. I have installed python in my ubuntu OS from
your website recently and tried using spyder and jupyter.

May I request you to help me with importing few matrices, each of size
100*100 in python from XLSX and perform operations on the matrices like
addition, multiplication, finding matrix inverse, creating diagonal
matrices each of size 100*100 from column vectors each of size 100*1,
creating identity matrix of size 100*100. I have surfed in the internet,
but unable to get answer for it.

I would be grateful to you if you could help me in this regard.

Thanking you

Sincerely
Meghna Raviraj Karkera
PhD Student
Department of Data Science
Prasanna School of Public Health
Manipal Academy of Higher Education
Manipal 576104
Karnataka
India
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Temporary text for multiple entries

2020-08-21 Thread dn via Python-list

On 22/08/2020 00:01, Ashanti Aggarwal wrote:

I am working to make a form where I have added multiple entries. I wish to add 
temporary text on all of them, as the text to be deleted when clicked and to 
inserted again when focused out. I have done with the single entry but not able 
to find a solution for multiple entries.Kindly suggest me a better way to do.



In programming, the usual way to repeat a given set of steps is to write 
a function. In this case, a series of functions to handle the 'before' 
and 'after' behaviors might suit a "context manager".



If you need further information, please help us to help you:
- operating system and version
- name and version of the GUI-library
- more information about the full-location of this "text"
- exactly what you typed/did
- exactly what happened as a result
- use a descriptive message title that will help other beginners with 
similar problems to benefit from answers-given

--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: Matrix of size 100*100- Meghna

2020-08-21 Thread dn via Python-list

On 22/08/2020 02:17, Meghna Karkera wrote:

Dear Respected Sir

I am Meghna, a PhD student. I have installed python in my ubuntu OS from
your website recently and tried using spyder and jupyter.

May I request you to help me with importing few matrices, each of size
100*100 in python from XLSX and perform operations on the matrices like
addition, multiplication, finding matrix inverse, creating diagonal
matrices each of size 100*100 from column vectors each of size 100*1,
creating identity matrix of size 100*100. I have surfed in the internet,
but unable to get answer for it.

I would be grateful to you if you could help me in this regard.



Dropping two of the key-words (above) into a search-engine produced an 
ideal suggestion (https://duckduckgo.com/?q=python+xlsx&t=brave&ia=web).


There are code-libraries which can be added to Python for data analysis, 
eg numpy and pandas. Such should offer training and tutorial assistance 
to newcomers (in varying degrees) and be part of your choice-criteria.

--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Having trouble with Mock and exception side effects

2020-08-21 Thread Joshua J. Kugler
Hello!  I am using Mock to raise an exception in an function as a side effect. 
However, Mock is completely redefining the exception itself turning it in to a 
MagickMock object, which generates the Python exception

TypeError: catching classes that do not inherit from BaseException is not 
allowed

This is my minimal reproducible test case.

# test_case.py
#!/usr/bin/python3

from unittest.mock import patch

import package.module

print('Before patcher start:', package.module.MyException)

patcher = patch('package.module')
mock_hvac = patcher.start()

print('After patcher start:', package.module.MyException)

try:
print('Right before raise:', package.module.MyException)
raise package.module.MyException

except package.module.MyException:
print('Got the exception')

package/__init__.py
# Empty

package/module.py
class MyException(BaseException):
pass

Output:
$ python3.6 --version
Python 3.6.9
$ python3.6 test_case.py
Before patcher start: 
After patcher start: 
Right before raise: 
Traceback (most recent call last):
  File "test_case.py", line 21, in 
raise package.module.MyException
TypeError: exceptions must derive from BaseException

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test_case.py", line 23, in 
except package.module.MyException:
TypeError: catching classes that do not inherit from BaseException is not 
allowed

This is also causing problems for Mock side effects. In this line of code in 
mock.py (line 997 for me):

if effect is not None:
if _is_exception(effect):
raise effect

The _is_exception() function checks for an exception via:

return (
isinstance(obj, BaseExceptions) or
isinstance(obj, type) and issubclass(obj, BaseExceptions)
)

Which of course is false, because it's been replaced by a MagicMock object, so 
exception side effects aren't properly raised.

According to https://docs.python.org/3.6/library/unittest.mock.html#calling 
calling a function after setting the side_effect should raise the Exception, 
not a MagicMock object.

https://docs.python.org/3.6/library/unittest.mock.html#unittest.mock.Mock also 
says "Alternatively side_effect can be an exception class or instance. In this 
case the exception will be raised when the mock is called."

So, this seems to be not behaving as design, or at least not as documented. 
This is creating some really serious problems for testing our code, as we want 
a function to have a side effect of an Exception, and catch that exception, but 
we can do neither when it has been replaced by a MagicMock object.

Thanks for any tips, pointers, or "You're doing it wrong!" education. :)

j


-- 
Joshua J. Kugler - Fairbanks, Alaska - jos...@azariah.com
Azariah Enterprises - Programming and Website Design
PGP Key: http://pgp.mit.edu/  ID 0x68108cbb73b13b6a


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


[RELEASED] Python 3.5.10rc1 is released

2020-08-21 Thread Larry Hastings


On behalf of the Python development community, I'm pleased to finally 
announce the availability of Python 3.5.10rc1.


Python 3.5 is in "security fixes only" mode.  This new version only 
contains security fixes, not conventional bug fixes, and it is a 
source-only release.


Important Notice: The latest releases of Linux (Ubuntu 20.04, Fedora 32) 
ship with a new version of OpenSSL.  New versions of OpenSSL often 
include upgraded configuration requirements to maintain network 
security; this new version no longer finds Python 3.5's OpenSSL 
configuration acceptable.  As a result, most or all secure-transport 
networking libraries are broken in this release on systems where this 
new version of OpenSSL is deployed.  This means, for example, that seven 
(7) of the regression tests in the test suite now regularly fail.  Older 
versions of Linux, with older versions of OpenSSL installed, are 
unaffected.  We're aware of the problem.  Unfortunately, as 3.5 is 
nearly completely out of support, it has become very low priority, and 
we've been unable to find the resources to get the problem fixed.  It's 
possible that these problems simply won't be fixed in 3.5 before it 
reaches its end-of-life.  As always we recommend upgrading to the latest 
Python release wherever possible.



You can find Python 3.5.10rc1 here:

   https://www.python.org/downloads/release/python-3510rc1/



Cheers,


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


How do I use the data entered in a form?

2020-08-21 Thread Steve
I have a simple form that I copied/modified from a python web site.  A lot
of it makes sense but I do not see how the form in activated.  

Is there some call in there that I am just not seeing?


How do I use the information entered into the  form.  Everything works here
except for line 30 where I get a "fetch not defined" error.  I can send the
entered information to the screen but I do not see how I can use the
information outside the functions defined. 

 Do I need a "return SR, TSR"? 

def Data_Entry(entries):
   SR = (entries['Sensor_Reading'].get())
   print("SR:   ", SR) #This line prints
   TSR = (entries['Test_Strip_Reading'].get())
   print("TSR:  ", TSR)  #This line prints

def SubmitForm(entries):
   print("Form Submitted")
   SR = entries['Sensor_Reading'].get()
   print("SR inside = " + SR)  #This line prints
   
def makeform(root, fields):
   entries = {}
   for field in fields:
  row = Frame(root)
  lab = Label(row, width=22, text=field+": ", anchor='w')
  ent = Entry(row)
  ent.insert(0,"0")
  row.pack(side = TOP, fill = X, padx = 5 , pady = 5)
  lab.pack(side = LEFT)
  ent.pack(side = RIGHT, expand = YES, fill = X)
  entries[field] = ent
   return entries

if __name__ == '__main__':
   root = Tk()
   ents = makeform(root, fields)
  # root.bind('', (lambda event, e = ents: fetch(e)))
   #"fetch not defined" reported here
   b1 = Button(root, text = 'Submit',
  command=(lambda e = ents: SubmitForm(e)))
   b1.pack(side = LEFT, padx = 5, pady = 5)

   b2 = Button(root, text = 'Quit', command = root.quit)
   b2.pack(side = LEFT, padx = 5, pady = 5)
   root.mainloop()

SR = (entries['Sensor_Reading'].get())   
print ("SR Outside = " + SR)

==
The last two lines were guesses but they still failed.

Steve


==

Footnote:
English speakers on a roller coaster: "W"
Spanish speakers on a rollercoaster:  " Nosostros"

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


Re: Having trouble with Mock and exception side effects

2020-08-21 Thread Kushal Kumaran
You could attempt something like what is mentioned in
https://docs.python.org/3/library/unittest.mock-examples.html#partial-mocking

See below.

"Joshua J. Kugler"  writes:

> Hello!  I am using Mock to raise an exception in an function as a side 
> effect. 
> However, Mock is completely redefining the exception itself turning it in to 
> a 
> MagickMock object, which generates the Python exception
>
> TypeError: catching classes that do not inherit from BaseException is not 
> allowed
>
> This is my minimal reproducible test case.
>
> # test_case.py
> #!/usr/bin/python3
>
> from unittest.mock import patch
>
> import package.module
>
> print('Before patcher start:', package.module.MyException)
>

orig_exception = package.module.MyException

> patcher = patch('package.module')
> mock_hvac = patcher.start()
>
> print('After patcher start:', package.module.MyException)

package.module.MyException = orig_exception
print('After exception restore:', package.module.MyException)

>
> try:
> print('Right before raise:', package.module.MyException)
> raise package.module.MyException
>
> except package.module.MyException:
> print('Got the exception')
>
> package/__init__.py
> # Empty
>
> package/module.py
> class MyException(BaseException):
> pass
>
> Output:
> $ python3.6 --version
> Python 3.6.9
> $ python3.6 test_case.py
> Before patcher start: 
> After patcher start:  id='140188666285696'>
> Right before raise: 
> Traceback (most recent call last):
>   File "test_case.py", line 21, in 
> raise package.module.MyException
> TypeError: exceptions must derive from BaseException
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File "test_case.py", line 23, in 
> except package.module.MyException:
> TypeError: catching classes that do not inherit from BaseException is not 
> allowed
>
> This is also causing problems for Mock side effects. In this line of code in 
> mock.py (line 997 for me):
>
> if effect is not None:
> if _is_exception(effect):
> raise effect
>
> The _is_exception() function checks for an exception via:
>
> return (
> isinstance(obj, BaseExceptions) or
> isinstance(obj, type) and issubclass(obj, BaseExceptions)
> )
>
> Which of course is false, because it's been replaced by a MagicMock object, 
> so 
> exception side effects aren't properly raised.
>
> According to https://docs.python.org/3.6/library/unittest.mock.html#calling 
> calling a function after setting the side_effect should raise the Exception, 
> not a MagicMock object.
>

It will raise what you tell it to raise.  You have to maintain a
reference to the original Exception object, so you can continue to use
it after mocking.

> https://docs.python.org/3.6/library/unittest.mock.html#unittest.mock.Mock 
> also 
> says "Alternatively side_effect can be an exception class or instance. In 
> this 
> case the exception will be raised when the mock is called."
>
> So, this seems to be not behaving as design, or at least not as documented. 
> This is creating some really serious problems for testing our code, as we 
> want 
> a function to have a side effect of an Exception, and catch that exception, 
> but 
> we can do neither when it has been replaced by a MagicMock object.
>
> Thanks for any tips, pointers, or "You're doing it wrong!" education. :)
>

Your problem is entirely described by the fact that you point out: the
package.module.MyException name has been pointed to a MagicMock object.

If you don't want that, you have to restore the name to what you want.

-- 
regards,
kushal
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Matrix of size 100*100- Meghna

2020-08-21 Thread Meghna Karkera
Dear Respected Sir,

I will go through the links you provided and get back to you if there are
doubts.

Thanks

Sincerely
Meghna Raviraj Karkera


On Sat, Aug 22, 2020, 01:45 dn via Python-list 
wrote:

> On 22/08/2020 02:17, Meghna Karkera wrote:
> > Dear Respected Sir
> >
> > I am Meghna, a PhD student. I have installed python in my ubuntu OS from
> > your website recently and tried using spyder and jupyter.
> >
> > May I request you to help me with importing few matrices, each of size
> > 100*100 in python from XLSX and perform operations on the matrices like
> > addition, multiplication, finding matrix inverse, creating diagonal
> > matrices each of size 100*100 from column vectors each of size 100*1,
> > creating identity matrix of size 100*100. I have surfed in the internet,
> > but unable to get answer for it.
> >
> > I would be grateful to you if you could help me in this regard.
>
>
> Dropping two of the key-words (above) into a search-engine produced an
> ideal suggestion (https://duckduckgo.com/?q=python+xlsx&t=brave&ia=web).
>
> There are code-libraries which can be added to Python for data analysis,
> eg numpy and pandas. Such should offer training and tutorial assistance
> to newcomers (in varying degrees) and be part of your choice-criteria.
> --
> Regards =dn
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I use the data entered in a form?

2020-08-21 Thread Peter Otten
Steve wrote:

> def makeform(root, fields):
>entries = {}
>for field in fields:
...
>return entries
> 
> if __name__ == '__main__':
>root = Tk()
>ents = makeform(root, fields)

> 
> SR = (entries['Sensor_Reading'].get())
> print ("SR Outside = " + SR)
> 
> ==
> The last two lines were guesses but they still failed.

[Always tell us how your code fails, please. If there's an exception include 
it and the complete traceback in your post.]

In this case you probably get a NameError because 'entries' is a local 
variable in makeform(). In the global namespace the person you copied the 
code from used 'ents' -- so you have to either use ents, too,

> if __name__ == '__main__':
>root = Tk()
 ents = makeform(root, fields)
 ...
 SR = ents['Sensor_Reading'].get()


or rename it

> if __name__ == '__main__':
>root = Tk()
 entries = makeform(root, fields)
 ...
 SR = entries['Sensor_Reading'].get()

>  # root.bind('', (lambda event, e = ents: fetch(e)))
>   #"fetch not defined" reported here

Again, the author of the original code probably defined a fetch() function;
if you want to use it you have to copy it into your script.


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