Re: Getting the dependencies of a function from a library

2020-04-20 Thread Juergen Brendel


Hello!

Not sure what's vague about the question, I think it was pretty clear.

Imagine this:

>>> import requests
>>>
>>> magic_function(requests.get)
. prints big output of all other functions and libraries used by 
. requests.get, plus all the functions used by those functions, 
. etc. Maybe in some kind of tree representation...


But realistically, I think in Python that's quite difficult to do
reliably in a static manner, considering how you can dynamically change
all sorts of things at run time.

It might be more realistic to do this at run-time, using a dynamically
created call-graph. If you Google for "python call graph" you'll get
numerous hits. This is one of the top ones, to give you an idea of what
kind of output you can expect:

https://pycallgraph.readthedocs.io/en/master/

This call graph will only show the code that was actually called,
though, not all the code (and attributes for that matter) that COULD
conceivably be used under some other circumstances.

Nevertheless, it's a good start to see what your code relies on when
under use.


Juergen



On Mon, 2020-04-20 at 23:50 -0400, Bob Gailer wrote:
> For me the question is a little vague.
> 
> What do you mean by Library?
> 
> Could you give us a simple example of the input and the output?
> 
> It's possible to interpret your question as an assessment of your
> skill
> level. We know nothing about your skill level.
> 
> It's possible to interpret your question as to whether or not this is
> a
> turing complete problem.
> 
> If you succeed in coming up with a sample input and output then how
> about
> trying to write a program to process that input to get that output.
> Post
> those results to this list and we'll see what we can do to help you.
> 
> Bob gailer
> 
> On Apr 20, 2020 6:18 PM, "elisha hollander"  >
> wrote:
> 
> > I have a python library with a function.
> > This function call some other functions, classes and variable from
> > the
> > library (and those functions and classes call other ones, etc)...
> > Can I automatically create a file with all of the dependencies (and
> > nothing
> > else)?
> > (Already posted on stack overflow with no answer)
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> > 

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


Re: Getting the dependencies of a function from a library

2020-04-20 Thread DL Neil via Python-list

On 21/04/20 9:40 AM, elisha hollander wrote:

I have a python library with a function.
This function call some other functions, classes and variable from the
library (and those functions and classes call other ones, etc)...
Can I automatically create a file with all of the dependencies (and nothing
else)?
(Already posted on stack overflow with no answer)


This is a good question (because it is one I often ask myself), but it 
is difficult to understand exactly what you seek.


- did you write this library
- is it part of the Python Standard Library, from Pypi, from ...
- are you intending to use the library from your own code
- do you want to "package" this library
???



The short answer is, that it should not be necessary to ask! Each Python 
module, function, etc, should have docstrings 'everywhere' anticipating 
exactly this sort of question!


If it is code you have 'acquired' from elsewhere, then that's already a 
suggestion that it might not be suitable for your use!



In the ?good, old days - and with other languages, we used to have tools 
for 'cross referencing'. Against every identifier, the utility would 
list each line (NR) of code where it was used.


These days, a decent editor/IDE will do much of that.


You may like to review: https://wiki.python.org/moin/DocumentationTools 
which mentions the likes of PyDoc which will go through a module and 
display all of its docstrings. https://docs.python.org/3/library/pydoc.html


The inspect module provides several useful functions to help get 
information about live objects such as modules, classes, methods, 
functions, tracebacks, frame objects, and code objects. For example, it 
can help you examine the contents of a class, retrieve the source code 
of a method, extract and format the argument list for a function, or get 
all the information you need to display a detailed traceback. 
https://docs.python.org/3/library/inspect.html



Let us know if there's an answer here. Alternately, please refine the 
question giving more, and specific detail...

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


Re: Getting the dependencies of a function from a library

2020-04-20 Thread Bob Gailer
For me the question is a little vague.

What do you mean by Library?

Could you give us a simple example of the input and the output?

It's possible to interpret your question as an assessment of your skill
level. We know nothing about your skill level.

It's possible to interpret your question as to whether or not this is a
turing complete problem.

If you succeed in coming up with a sample input and output then how about
trying to write a program to process that input to get that output. Post
those results to this list and we'll see what we can do to help you.

Bob gailer

On Apr 20, 2020 6:18 PM, "elisha hollander" 
wrote:

> I have a python library with a function.
> This function call some other functions, classes and variable from the
> library (and those functions and classes call other ones, etc)...
> Can I automatically create a file with all of the dependencies (and nothing
> else)?
> (Already posted on stack overflow with no answer)
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "pip" error message

2020-04-20 Thread Souvik Dutta
Have you tried updating pip? There was a bug in pip version
10

Souvik flutter dev

On Mon, Apr 20, 2020, 10:10 PM Simone Bravin 
wrote:

> Hello everyone,
>
> > I just started using Python to learn a bit of coding, so I'm pretty a
> > newbie to this, I tried to install few extra packages using pip but it
> > doesn't work.
> >
> > When I check for pip version using command line> pip --version I get
> > the following error message:
> >
> > Traceback (most recent call last):
> >   File
> > "c:\users\simon\appdata\local\programs\python\python38-32\lib\runpy.py",
> > line 193, in _run_module_as_main
> > return _run_code(code, main_globals, None,
> >   File
> > "c:\users\simon\appdata\local\programs\python\python38-32\lib\runpy.py",
> > line 86, in _run_code
> > exec(code, run_globals)
> >   File
> >
> "C:\Users\simon\AppData\Local\Programs\Python\Python38-32\Scripts\pip.exe\__main__.py",
>
> > line 5, in 
> >   File
> >
> "c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\__init__.py",
>
> > line 40, in 
> > from pip._internal.cli.autocompletion import autocomplete
> >   File
> >
> "c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\cli\autocompletion.py",
>
> > line 8, in 
> > from pip._internal.cli.main_parser import create_main_parser
> >   File
> >
> "c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\cli\main_parser.py",
>
> > line 7, in 
> > from pip._internal.cli import cmdoptions
> >   File
> >
> "c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\cli\cmdoptions.py",
>
> > line 24, in 
> > from pip._internal.models.search_scope import SearchScope
> >   File
> >
> "c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\models\search_scope.py",
>
> > line 11, in 
> > from pip._internal.utils.misc import normalize_path,
> > redact_password_from_url
> >   File
> >
> "c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\utils\misc.py",
>
> > line 31, in 
> > *from pip import __version__ *
> > *ImportError: cannot import name '__version__' from 'pip'
> >
> (c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\__init__.py)*
> >
> > I tried to run Repair in Modify Setup and reinstalled python as well
> > but nothing changed.
> >
> > I was wondering if you can help to fix this.
> >
> > Thank you
> >
> > Simone
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Regarding problem faced to run pandas

2020-04-20 Thread Souvik Dutta
Are you that youtuber Amit Jain? And for your kind information you cannot
attach any screenshot in python-list. It gets dropped.

Souvik flutter dev

On Tue, Apr 21, 2020, 4:39 AM Amit Jain  wrote:

> Dear Sir/Madam,
>  After successful installation of PIP for PANDAS when I try to run any
> program, It gives error (Screenshot attached)
>
> The screenshot of the problem is attached herewith for your kind
> information .
>
> Kindly help me to resolve such problem.
>
> --
> *Thanks & Regards
>*
> *Amit Kumar Jain*
> *Jaipur, Rajasthan*
> *India*
>
>
> --
> *Thanks & Regards
>*
> *Amit Kumar Jain*
> *PGT(CS)*
> *KVS, (Under **Ministry of HRD)*
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting a 401 from requests.get, but not when logging in via the browser.

2020-04-20 Thread Eli the Bearded
In comp.lang.python,   wrote:
> On Monday, April 20, 2020 at 5:02:23 PM UTC-4, Eli the Bearded wrote:
> > For an example, back to telnet again.
> > 
> > $ telnet example.com 80
> > Trying 255.11.22.123...
> > Connected to example.com
> > Escape character is '^]'.
> > GET /digest/ HTTP/1.1
> > Host: example.com

FYI, I type in the lines "GET /digest/ HTTP/1.1" and "Host: example.com"
(which should match the name of the site you wish to connect to), then
a blank line. After that the server first begins to "speak".

> > If you don't understand what the site is asking for, it may be very
> > difficult for you to satisfy it.
> Been years since I used Telnet.  I didn't even think that Windows had it
> anymore.

I use it frequently in Linux. But nc or the like works as well for the
way I use it: not for actual "telnet" protocol stuff.

> I tried telneting the landing page, i.e. without the specific node that
> requires the login.  So e.g.
> 
> Telnet thissite.oh.gov 80
> 
> , but it returns a 400 Bad Request.  Before that, the Telnet screen is
> completely blank ; I have to press a key before it returns the Bad
> Request.

It sounds like you are entering a blank line without the GET request
and Host: header.

> Roger on knowing what the site is asking for.  But I don't know how to
> determine that.

Developer tools in your browser may be helpful. As I mentioned, I'm much
better at this at low levels. I haven't kept up with the changes in the
tools over the past decade or so.

If you have an HTTPS site you want to check, the openssl tool can
create an interactive tunnel for you. Command line is more complicated
and output is more verbose, but the gist is similar:

$ openssl s_client -connect example.com:443
[outs of output]
GET /digest/ HTTP/1.1
Host: example.com

[lots of output]

Elijah
--
likes knowing how the pieces fit together
-- 
https://mail.python.org/mailman/listinfo/python-list


Regarding problem faced to run pandas

2020-04-20 Thread Amit Jain
Dear Sir/Madam,
 After successful installation of PIP for PANDAS when I try to run any
program, It gives error (Screenshot attached)

The screenshot of the problem is attached herewith for your kind
information .

Kindly help me to resolve such problem.

-- 
*Thanks & Regards
   *
*Amit Kumar Jain*
*Jaipur, Rajasthan*
*India*


-- 
*Thanks & Regards
   *
*Amit Kumar Jain*
*PGT(CS)*
*KVS, (Under **Ministry of HRD)*
-- 
https://mail.python.org/mailman/listinfo/python-list


Getting the dependencies of a function from a library

2020-04-20 Thread elisha hollander
I have a python library with a function.
This function call some other functions, classes and variable from the
library (and those functions and classes call other ones, etc)...
Can I automatically create a file with all of the dependencies (and nothing
else)?
(Already posted on stack overflow with no answer)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting a 401 from requests.get, but not when logging in via the browser.

2020-04-20 Thread dcwhatthe
On Monday, April 20, 2020 at 5:02:23 PM UTC-4, Eli the Bearded wrote:
> In comp.lang.python,  dc wrote, in reply to me:
> > "What do you think it is doing?"
> > I thought the timeout was waiting for a successful connection.
> 
> A successful *connection* and a successful *authentication* are
> different things. 
> 
> $ telnet example.com 80
> Trying 255.11.22.123...
> Connected to example.com
> Escape character is '^]'.
> 
> [...]
> 
> There's a connection. No authentication, however.
> 
> > "Are you sure the site is using HTTPBasicAuth()? Because if it's not,
> > that would explain how the same credentials can fail. (It could also
> > be something else, like a site returning "401 Unauthorized" because
> > it doesn't like your User-Agent.)"
> > 
> > Yes, that's what I'm getting.
> > 
> > No, I don't know if it's using Basic Authentication.  If I log in
> > through the browser, then it pops up for an id and password.
> > 
> > How do I find out what type of Authentication is applicable?  
> 
> Look at the WWW-Authenticate: header.
> 
> For an example, back to telnet again.
> 
> $ telnet example.com 80
> Trying 255.11.22.123...
> Connected to example.com
> Escape character is '^]'.
> GET /digest/ HTTP/1.1
> Host: example.com
> 
> HTTP/1.1 401 Unauthorized
> Date: Mon, 20 Apr 2020 20:42:25 GMT
> Server: Apache/2.4.41 (Unix) OpenSSL/1.0.2k
> WWW-Authenticate: Digest realm="File Resources", 
> nonce="RyTO776jBQA=5fe3887c65536842f2ebb8ad6cf39bb6b5ec9b66", algorithm=MD5, 
> domain="/digest/", qop="auth"
> Content-Length: 381
> Connection: close
> Content-Type: text/html; charset=iso-8859-1
> ...
> 
> 
> 
> $ telnet example.com 80
> Trying 255.11.22.123...
> Connected to example.com
> Escape character is '^]'.
> GET /basic/ HTTP/1.1
> Host: example.com
> 
> HTTP/1.1 401 Unauthorized
> Date: Mon, 20 Apr 2020 20:45:22 GMT
> Server: Apache/2.4.41 (Unix) OpenSSL/1.0.2k
> WWW-Authenticate: Basic realm="Restricted Resources"
> Content-Length: 381
> Connection: close
> Content-Type: text/html; charset=iso-8859-1
> ...
> 
> 
> There are other ways to authenticate besides those two, but those
> are the ones I've used that operate on the HTTP level and in browsers.
> 
> http://www.iana.org/assignments/http-authschemes/http-authschemes.xhtml
> 
> That list is supposedly all of the auth schemes, I don't know how many
> are widely implemented. Certainly some of them, like "Bearer" I've
> seen for APIs, but not using a browser password GUI. Bearer is a very
> common way to authenticate for APIs.
> 
> If you don't understand what the site is asking for, it may be very
> difficult for you to satisfy it.
> 
> Elijah
> --
> understands all of this at a low level and not well at a library level

Been years since I used Telnet.  I didn't even think that Windows had it 
anymore.

I tried telneting the landing page, i.e. without the specific node that 
requires the login.  So e.g.

Telnet thissite.oh.gov 80

, but it returns a 400 Bad Request.  Before that, the Telnet screen is 
completely blank ; I have to press a key before it returns the Bad Request.


Roger on knowing what the site is asking for.  But I don't know how to 
determine that.

Will continue tomorrow, thanks for your assistance.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting a 401 from requests.get, but not when logging in via the browser.

2020-04-20 Thread Eli the Bearded
In comp.lang.python,   wrote, in reply to me:
> "What do you think it is doing?"
> I thought the timeout was waiting for a successful connection.

A successful *connection* and a successful *authentication* are
different things. 

$ telnet example.com 80
Trying 255.11.22.123...
Connected to example.com
Escape character is '^]'.

[...]

There's a connection. No authentication, however.

> "Are you sure the site is using HTTPBasicAuth()? Because if it's not,
> that would explain how the same credentials can fail. (It could also
> be something else, like a site returning "401 Unauthorized" because
> it doesn't like your User-Agent.)"
> 
> Yes, that's what I'm getting.
> 
> No, I don't know if it's using Basic Authentication.  If I log in
> through the browser, then it pops up for an id and password.
> 
> How do I find out what type of Authentication is applicable?  

Look at the WWW-Authenticate: header.

For an example, back to telnet again.

$ telnet example.com 80
Trying 255.11.22.123...
Connected to example.com
Escape character is '^]'.
GET /digest/ HTTP/1.1
Host: example.com

HTTP/1.1 401 Unauthorized
Date: Mon, 20 Apr 2020 20:42:25 GMT
Server: Apache/2.4.41 (Unix) OpenSSL/1.0.2k
WWW-Authenticate: Digest realm="File Resources", 
nonce="RyTO776jBQA=5fe3887c65536842f2ebb8ad6cf39bb6b5ec9b66", algorithm=MD5, 
domain="/digest/", qop="auth"
Content-Length: 381
Connection: close
Content-Type: text/html; charset=iso-8859-1
...



$ telnet example.com 80
Trying 255.11.22.123...
Connected to example.com
Escape character is '^]'.
GET /basic/ HTTP/1.1
Host: example.com

HTTP/1.1 401 Unauthorized
Date: Mon, 20 Apr 2020 20:45:22 GMT
Server: Apache/2.4.41 (Unix) OpenSSL/1.0.2k
WWW-Authenticate: Basic realm="Restricted Resources"
Content-Length: 381
Connection: close
Content-Type: text/html; charset=iso-8859-1
...


There are other ways to authenticate besides those two, but those
are the ones I've used that operate on the HTTP level and in browsers.

http://www.iana.org/assignments/http-authschemes/http-authschemes.xhtml

That list is supposedly all of the auth schemes, I don't know how many
are widely implemented. Certainly some of them, like "Bearer" I've
seen for APIs, but not using a browser password GUI. Bearer is a very
common way to authenticate for APIs.

If you don't understand what the site is asking for, it may be very
difficult for you to satisfy it.

Elijah
--
understands all of this at a low level and not well at a library level
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting a 401 from requests.get, but not when logging in via the browser.

2020-04-20 Thread dcwhatthe
On Monday, April 20, 2020 at 3:56:46 PM UTC-4, dcwh...@gmail.com wrote:
> On Monday, April 20, 2020 at 3:18:59 PM UTC-4, Eli the Bearded wrote:
> > In comp.lang.python,  dc wrote:
> > > However, one of them immediately returns a 401.  I'm using the exact
> > > same credentials to check this site, as when loggin in.
> > > 
> > > Also, interestingly, it returns the 401 right away.  I tried setting the
> > > timeout value for a ridiculously long time, but it passes the 401 return
> > > immediately.
> > 
> > The timeout presumably is how long to wait for a reply. When the
> > site replies 401 immediately, it's never even bumping up to the
> > timeout.
> > 
> > > Am I misunderstanding the meaning of the timeout parameter?
> > 
> > What do you think it is doing?
> > 
> > > The line in question is 
> > > request = requests.get(ip_s,timeout=5000, verify = False, auth
> > > =HTTPBasicAuth( user_id_s, pw_s))
> > 
> > Are you sure the site is using HTTPBasicAuth()? Because if it's not,
> > that would explain how the same credentials can fail. (It could also
> > be something else, like a site returning "401 Unauthorized" because
> > it doesn't like your User-Agent.)
> > 
> > I use "AuthType Digest" on some of my websites. It's not great, but
> > it's TONS better than basic auth, which sends passwords basically
> > in the clear.
> > 
> > https://en.wikipedia.org/wiki/Digest_access_authentication
> > 
> > In my browser, Digest authentication looks the same GUI-wise as Basic
> > authentication. The differences are all under the hood.
> > 
> > Elijah
> > --
> > digest auth is not as well supported by clients or servers
> 
> 
> "What do you think it is doing?"
> 
> I thought the timeout was waiting for a successful connection.
> 
> 
> "Are you sure the site is using HTTPBasicAuth()? Because if it's not,
> that would explain how the same credentials can fail. (It could also
> be something else, like a site returning "401 Unauthorized" because
> it doesn't like your User-Agent.)"
> 
> Yes, that's what I'm getting.
> 
> No, I don't know if it's using Basic Authentication.  If I log in through the 
> browser, then it pops up for an id and password.
> 
> How do I find out what type of Authentication is applicable?  
> 
> I'll go ahead and try the AuthType that you recommended, for now.
> 
> 
> Thanks and regards,

HTTPDigestAuth() was easy enough to use, same syntax.  But also, same result.  
Just a 401 Unauthorized
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Floating point problem

2020-04-20 Thread Richard Damon
On 4/20/20 4:19 PM, Chris Angelico wrote:
> On Tue, Apr 21, 2020 at 6:07 AM Schachner, Joseph
>  wrote:
>> 16 base 10 digits / log base10( 2) = 53.1508495182 bits.   Obviously, 
>> fractional bits don't exist, so 53 bits. If you note that the first non-zero 
>> digit as 4, and the first digit after the 15 zeroes was 2, then you got an 
>> extra bit. 54 bits.  Where did the extra bit come from?  It came from the 
>> IEEE format's assumption that the top bit of the mantissa of a normalized 
>> floating point value must be 1.  Since we know what it must be, there is no 
>> reason to use an actual bit for it.  The 53 bits in the mantissa do not 
>> include the assumed top bit.
>>
>> Isn't floating point fun?
>>
> IEEE 64-bit packed floating point has 53 bits of mantissa, 11 scale
> bits (you've heard of "scale birds" in art? well, these are "scale
> bits"), and 1 sign bit.
>
> 53 + 11 + 1 == 64.
>
> Yep, floating point is fun.
>
> That assumed top 1 bit is always there, except when it isn't. Because
> denormal numbers are a thing. They don't have that implied 1 bit.
>
> Yep, floating point is fun.
>
> ChrisA

Well, the assumed 1 isn't there unless the exponent is all zeros, in
which case you have a denormal or zero value, which have all their bits
explicitly so we can get 53 more powers of two of range with reducing
precision. With Binary floating point, you only have denormals near
underflow.

Now Decimal Floating point doesn't have this implied leading 1, but can
have denormals at almost all of the ranges.

-- 
Richard Damon

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


Re: Floating point problem

2020-04-20 Thread Chris Angelico
On Tue, Apr 21, 2020 at 6:07 AM Schachner, Joseph
 wrote:
>
> 16 base 10 digits / log base10( 2) = 53.1508495182 bits.   Obviously, 
> fractional bits don't exist, so 53 bits. If you note that the first non-zero 
> digit as 4, and the first digit after the 15 zeroes was 2, then you got an 
> extra bit. 54 bits.  Where did the extra bit come from?  It came from the 
> IEEE format's assumption that the top bit of the mantissa of a normalized 
> floating point value must be 1.  Since we know what it must be, there is no 
> reason to use an actual bit for it.  The 53 bits in the mantissa do not 
> include the assumed top bit.
>
> Isn't floating point fun?
>

IEEE 64-bit packed floating point has 53 bits of mantissa, 11 scale
bits (you've heard of "scale birds" in art? well, these are "scale
bits"), and 1 sign bit.

53 + 11 + 1 == 64.

Yep, floating point is fun.

That assumed top 1 bit is always there, except when it isn't. Because
denormal numbers are a thing. They don't have that implied 1 bit.

Yep, floating point is fun.

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


RE: Floating point problem

2020-04-20 Thread Schachner, Joseph
16 base 10 digits / log base10( 2) = 53.1508495182 bits.   Obviously, 
fractional bits don't exist, so 53 bits. If you note that the first non-zero 
digit as 4, and the first digit after the 15 zeroes was 2, then you got an 
extra bit. 54 bits.  Where did the extra bit come from?  It came from the IEEE 
format's assumption that the top bit of the mantissa of a normalized floating 
point value must be 1.  Since we know what it must be, there is no reason to 
use an actual bit for it.  The 53 bits in the mantissa do not include the 
assumed top bit.

Isn't floating point fun?

--- Joseph S.

-Original Message-
From: Pieter van Oostrum  
Sent: Sunday, April 19, 2020 7:49 AM
To: python-list@python.org
Subject: Re: Floating point problem

"R.Wieser"  writes:

> Souvik,
>
>> I have one question here. On using print(f"{c:.32f}") where c= 2/5 
>> instead of getting 32 zeroes I got some random numbers. The exact 
>> thing is 0.40002220446049250313 Why do I get this and not 
>> 32 zeroes?
>
> Simple answer ?   The conversion routine runs outof things to say.
>
> A bit more elaborate answer ? You should not even have gotten that many 
> zeroes after the 0.4.The precision of a 32-bit float is about 7 digits. 
> That means that all you can depend on is the 0.4 followed by 6 more digits. 
> Anything further is, in effect, up for grabs.
>
Most Python implementations use 64-bit doubles (53 bits of precision). See 
https://docs.python.org/3.8/tutorial/floatingpoint.html
--
Pieter van Oostrum
www: http://pieter.vanoostrum.org/
PGP key: [8DAE142BE17999C4]

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


Re: Getting a 401 from requests.get, but not when logging in via the browser.

2020-04-20 Thread dcwhatthe
On Monday, April 20, 2020 at 3:18:59 PM UTC-4, Eli the Bearded wrote:
> In comp.lang.python,  dc wrote:
> > However, one of them immediately returns a 401.  I'm using the exact
> > same credentials to check this site, as when loggin in.
> > 
> > Also, interestingly, it returns the 401 right away.  I tried setting the
> > timeout value for a ridiculously long time, but it passes the 401 return
> > immediately.
> 
> The timeout presumably is how long to wait for a reply. When the
> site replies 401 immediately, it's never even bumping up to the
> timeout.
> 
> > Am I misunderstanding the meaning of the timeout parameter?
> 
> What do you think it is doing?
> 
> > The line in question is 
> > request = requests.get(ip_s,timeout=5000, verify = False, auth
> > =HTTPBasicAuth( user_id_s, pw_s))
> 
> Are you sure the site is using HTTPBasicAuth()? Because if it's not,
> that would explain how the same credentials can fail. (It could also
> be something else, like a site returning "401 Unauthorized" because
> it doesn't like your User-Agent.)
> 
> I use "AuthType Digest" on some of my websites. It's not great, but
> it's TONS better than basic auth, which sends passwords basically
> in the clear.
> 
> https://en.wikipedia.org/wiki/Digest_access_authentication
> 
> In my browser, Digest authentication looks the same GUI-wise as Basic
> authentication. The differences are all under the hood.
> 
> Elijah
> --
> digest auth is not as well supported by clients or servers


"What do you think it is doing?"

I thought the timeout was waiting for a successful connection.


"Are you sure the site is using HTTPBasicAuth()? Because if it's not,
that would explain how the same credentials can fail. (It could also
be something else, like a site returning "401 Unauthorized" because
it doesn't like your User-Agent.)"

Yes, that's what I'm getting.

No, I don't know if it's using Basic Authentication.  If I log in through the 
browser, then it pops up for an id and password.

How do I find out what type of Authentication is applicable?  

I'll go ahead and try the AuthType that you recommended, for now.


Thanks and regards,


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


Re: Getting a 401 from requests.get, but not when logging in via the browser.

2020-04-20 Thread Eli the Bearded
In comp.lang.python,   wrote:
> However, one of them immediately returns a 401.  I'm using the exact
> same credentials to check this site, as when loggin in.
> 
> Also, interestingly, it returns the 401 right away.  I tried setting the
> timeout value for a ridiculously long time, but it passes the 401 return
> immediately.

The timeout presumably is how long to wait for a reply. When the
site replies 401 immediately, it's never even bumping up to the
timeout.

> Am I misunderstanding the meaning of the timeout parameter?

What do you think it is doing?

> The line in question is 
> request = requests.get(ip_s,timeout=5000, verify = False, auth
> =HTTPBasicAuth( user_id_s, pw_s))

Are you sure the site is using HTTPBasicAuth()? Because if it's not,
that would explain how the same credentials can fail. (It could also
be something else, like a site returning "401 Unauthorized" because
it doesn't like your User-Agent.)

I use "AuthType Digest" on some of my websites. It's not great, but
it's TONS better than basic auth, which sends passwords basically
in the clear.

https://en.wikipedia.org/wiki/Digest_access_authentication

In my browser, Digest authentication looks the same GUI-wise as Basic
authentication. The differences are all under the hood.

Elijah
--
digest auth is not as well supported by clients or servers
-- 
https://mail.python.org/mailman/listinfo/python-list


Getting a 401 from requests.get, but not when logging in via the browser.

2020-04-20 Thread dcwhatthe
I'm validating several sites in a row, and most of them connect successfully.  

However, one of them immediately returns a 401.  I'm using the exact same 
credentials to check this site, as when loggin in.

Also, interestingly, it returns the 401 right away.  I tried setting the 
timeout value for a ridiculously long time, but it passes the 401 return 
immediately.

Am I misunderstanding the meaning of the timeout parameter?


The line in question is 


request = requests.get(ip_s,timeout=5000, verify = False, auth =HTTPBasicAuth( 
user_id_s, pw_s))


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


Re: "pip" error message

2020-04-20 Thread Richard Guinn
Hi Simone and all -
I'm not sure how to fix/correct... but just a redundant 'me too'.  I tried
to install pybibframe (https://pypi.org/project/pybibframe/) and also keep
getting errors.  Wasn't sure if it was the module/package or what.

My error is along the lines of:

  ERROR: Command errored out with exit status 1:
 command:
'c:\users\rickrigby\appdata\local\programs\python\python38-32\python.exe'
-u -c 'import sys, setuptools, tokenize; sys.argv[0] =
'"'"'C:\\Users\\RickRigby\\AppData\\Local\\Temp\\pip-install-_x4to3h7\\amara3.xml\\setup.py'"'"';

When I 'Google' the error - I find that there's an apparent bug
https://stackoverflow.com/questions/60937863/error-command-errored-out-with-exit-status-1


Doesn't sound like there's an easy workaround.

Richard

On Mon, Apr 20, 2020 at 12:42 PM Simone Bravin 
wrote:

> Hello everyone,
>
> > I just started using Python to learn a bit of coding, so I'm pretty a
> > newbie to this, I tried to install few extra packages using pip but it
> > doesn't work.
> >
> > When I check for pip version using command line> pip --version I get
> > the following error message:
> >
> > Traceback (most recent call last):
> >   File
> > "c:\users\simon\appdata\local\programs\python\python38-32\lib\runpy.py",
> > line 193, in _run_module_as_main
> > return _run_code(code, main_globals, None,
> >   File
> > "c:\users\simon\appdata\local\programs\python\python38-32\lib\runpy.py",
> > line 86, in _run_code
> > exec(code, run_globals)
> >   File
> >
> "C:\Users\simon\AppData\Local\Programs\Python\Python38-32\Scripts\pip.exe\__main__.py",
>
> > line 5, in 
> >   File
> >
> "c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\__init__.py",
>
> > line 40, in 
> > from pip._internal.cli.autocompletion import autocomplete
> >   File
> >
> "c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\cli\autocompletion.py",
>
> > line 8, in 
> > from pip._internal.cli.main_parser import create_main_parser
> >   File
> >
> "c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\cli\main_parser.py",
>
> > line 7, in 
> > from pip._internal.cli import cmdoptions
> >   File
> >
> "c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\cli\cmdoptions.py",
>
> > line 24, in 
> > from pip._internal.models.search_scope import SearchScope
> >   File
> >
> "c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\models\search_scope.py",
>
> > line 11, in 
> > from pip._internal.utils.misc import normalize_path,
> > redact_password_from_url
> >   File
> >
> "c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\utils\misc.py",
>
> > line 31, in 
> > *from pip import __version__ *
> > *ImportError: cannot import name '__version__' from 'pip'
> >
> (c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\__init__.py)*
> >
> > I tried to run Repair in Modify Setup and reinstalled python as well
> > but nothing changed.
> >
> > I was wondering if you can help to fix this.
> >
> > Thank you
> >
> > Simone
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: RFC: For Loop Invariants

2020-04-20 Thread Vincent Vande Vyvre
Le 20/04/20 à 13:08, Tony Flury via Python-list a écrit :
>
> On 10/04/2020 21:44, Elliott Dehnbostel wrote:
>> *We could do this:*
>>
>> chars = "abcaaabkjzhbjacvb"
>> seek = {'a','b','c'}
>> count = sum([1 for a in chars if a in seek])
>>
>> However, this changes important semantics by creating an entire new
>> list before summing.
>
> Creating the list is pointless in this case - sum will take any
> iterable, including a generator expression:
>
> chars = "abcaaabkjzhbjacvb"
> seek = {'a','b','c'}
> count = sum(1 for a in chars if a in seek)
>
> So you haven't really changed any semantics - and it seems that this
> is far better than fiddling with the for loop syntax.

You can use boolean as integer.

>>> chars = "abcaaabkjzhbjacvb"
>>> seek = {'a', 'b', 'c'}
>>> count = 0
>>> for i in chars:
... count += i in seek
...
>>> count
11


Vincent.

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


multiprocessing

2020-04-20 Thread Edward Montague
 Upon using sympy's rubi_integrate upon my quad core
computer, I find that the first CPU is being used 100%,
whilst the other three are around 1% and 2% .

 I'm wondering if you have some code to overcome this limitation.
-- 
https://mail.python.org/mailman/listinfo/python-list


[RELEASE] Python 2.7.18, the end of an era

2020-04-20 Thread Benjamin Peterson
I'm eudaemonic to announce the immediate availability of Python 2.7.18.

Python 2.7.18 is a special release. I refer, of course, to the fact that 
"2.7.18" is the closest any Python version number will ever approximate e, 
Euler's number. Simply exquisite!

A less transcendent property of Python 2.7.18 is that it is the last Python 2.7 
release and therefore the last Python 2 release. It's time for the CPython 
community to say a fond but firm farewell to Python 2. Users still on Python 2 
can use e to compute the instantaneously compounding interest on their 
technical debt.

Download this unique, commemorative Python release on python.org:

   https://www.python.org/downloads/release/python-2718/

Python 2.7 has been under active development since the release of Python 2.6, 
more than 11 years ago. Over all those years, CPython's core developers and 
contributors sedulously applied bug fixes to the 2.7 branch, no small task as 
the Python 2 and 3 branches diverged. There were large changes midway through 
Python 2.7's life such as PEP 466's feature backports to the ssl module and 
hash randomization. Traditionally, these features would never have been added 
to a branch in maintenance mode, but exceptions were made to keep Python 2 
users secure. Thank you to CPython's community for such dedication.

Python 2.7 was lucky to have the services of two generations of binary builders 
and operating system experts, Martin von Löwis and Steve Dower for Windows, and 
Ronald Oussoren and Ned Deily for macOS. The reason we provided binary Python 
2.7 releases for macOS 10.9, an operating system obsoleted by Apple 4 years 
ago, or why the "Microsoft Visual C++ Compiler for Python 2.7" exists is the 
dedication of these individuals.

I thank the past and present Python release managers, Barry Warsaw, Ned Deily, 
Georg Brandl, Larry Hastings, and Łukasz Langa for their advice and support 
over the years. I've learned a lot from them—like don't be the sucker who 
volunteers to manage the release right before a big compatibility break!

Python 3 would be nowhere without the critical work of the wider community. 
Library maintainers followed CPython by maintaining Python 2 support for many 
years but also threw their weight behind the Python 3 statement 
(https://python3statement.org). Linux distributors chased Python 2 out of their 
archives. Users migrated hundreds of millions of lines of code, developed 
porting guides, and kept Python 2 in their brain while Python 3 gained 10 years 
of improvements.

Finally, thank you to GvR for creating Python 0.9, 1, 2, and 3.

Long live Python 3+!

Signing off,
Benjamin
2.7 release manager
-- 
https://mail.python.org/mailman/listinfo/python-list


"pip" error message

2020-04-20 Thread Simone Bravin

Hello everyone,

I just started using Python to learn a bit of coding, so I'm pretty a 
newbie to this, I tried to install few extra packages using pip but it 
doesn't work.


When I check for pip version using command line> pip --version I get 
the following error message:


Traceback (most recent call last):
  File 
"c:\users\simon\appdata\local\programs\python\python38-32\lib\runpy.py", 
line 193, in _run_module_as_main

    return _run_code(code, main_globals, None,
  File 
"c:\users\simon\appdata\local\programs\python\python38-32\lib\runpy.py", 
line 86, in _run_code

    exec(code, run_globals)
  File 
"C:\Users\simon\AppData\Local\Programs\Python\Python38-32\Scripts\pip.exe\__main__.py", 
line 5, in 
  File 
"c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\__init__.py", 
line 40, in 

    from pip._internal.cli.autocompletion import autocomplete
  File 
"c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\cli\autocompletion.py", 
line 8, in 

    from pip._internal.cli.main_parser import create_main_parser
  File 
"c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\cli\main_parser.py", 
line 7, in 

    from pip._internal.cli import cmdoptions
  File 
"c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\cli\cmdoptions.py", 
line 24, in 

    from pip._internal.models.search_scope import SearchScope
  File 
"c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\models\search_scope.py", 
line 11, in 
    from pip._internal.utils.misc import normalize_path, 
redact_password_from_url
  File 
"c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\_internal\utils\misc.py", 
line 31, in 

*from pip import __version__ *
*ImportError: cannot import name '__version__' from 'pip' 
(c:\users\simon\appdata\local\programs\python\python38-32\lib\site-packages\pip\__init__.py)*


I tried to run Repair in Modify Setup and reinstalled python as well 
but nothing changed.


I was wondering if you can help to fix this.

Thank you

Simone 

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


Re: RFC: For Loop Invariants

2020-04-20 Thread Tony Flury via Python-list



On 10/04/2020 21:44, Elliott Dehnbostel wrote:

*We could do this:*

chars = "abcaaabkjzhbjacvb"
seek = {'a','b','c'}
count = sum([1 for a in chars if a in seek])

However, this changes important semantics by creating an entire new
list before summing.


Creating the list is pointless in this case - sum will take any 
iterable, including a generator expression:


chars = "abcaaabkjzhbjacvb"
seek = {'a','b','c'}
count = sum(1 for a in chars if a in seek)

So you haven't really changed any semantics - and it seems that this is 
far better than fiddling with the for loop syntax.

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


Re: Run code automatically

2020-04-20 Thread hanan lamaazi
Yes I try to do it but it doesn't work for two reasons:

I write my code as blocks in jupyter notebook and for each block I use
different datasets that I loc, iloc or concat according to my need.

for this reasons I export it as .py file to run it externally




Garanti
sans virus. www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

Le lun. 20 avr. 2020 à 12:44, Souvik Dutta  a
écrit :

> No no I did not tell you to do it in that way. I said you could try
> putting the whole the code in the .py file in a for loop. That is:-
> for a in range(10):
>  
>
> On Mon, 20 Apr, 2020, 1:55 pm hanan lamaazi, 
> wrote:
>
>> Yes, so to do it I save my code as filename.ipynb and go to terminal
>> (cmd) I write the following commande:
>>
>> >> run for x in {1..10}; do (ipython filename.ipynb > /tmp/$x.log) & done
>>
>> it gives the following error:
>>
>> ERROR: root:File ''for.py'' not found
>>
>>
>> I use another one:
>>
>> >> for filename in $(find $Foldername  -name *.py)
>> .:do
>>...:   python $filename
>>...:done
>>
>> It gives the following error/
>>
>> File "", line 1
>>  for filename in $(find $foldername  -name *.py)
>>
>> SyntaxError: invalid syntax
>>
>>
>> Could please suggest me any other solution? or what is wrong with those
>> expressions?
>>
>> Thank you
>>
>>
>> Le jeu. 16 avr. 2020 à 16:57, Souvik Dutta  a
>> écrit :
>>
>>> Do you want to run the code many times after just clicking run once? If
>>> so then I think grouping the whole program in one for loop would do the
>>> task.
>>>
>>> Souvik python dev
>>>
>>> On Thu, Apr 16, 2020, 4:57 PM hanan lamaazi 
>>> wrote:
>>>
 Dear All,

 I just start the self learning of python, and I tried to use it in
 jupyter
 notebook. I work on real dataset and I used pandas for that. Now my
 problem
 is I developed two separate code but dependent the first one should run
 to
 give me  samples from my dataset and do the clustering (I use Kmeans)
 and
 the second should select data from each cluster provided by the first
 code.

 My question is:
 how can I run both code for many times without pushing the bottom "run"
 each time? make it automatic


 I tried to use Ipyparallel but seems that I don't know how to use it


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

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


Re: Why is a generator expression called a expression?

2020-04-20 Thread Chris Angelico
On Mon, Apr 20, 2020 at 8:26 PM Veek M  wrote:
>
> but one can do the following
> (x for x in 'apple').next() * 2
>
> def foo():
>(yield 2)
> foo().next() * 3
>
> (lambda x: 2)()*4
>
> generator expr, yield expr, lambda expression
> all require some modification (insertion of a .next or explicit () so
> it's quite confusing..
>

I don't know what you mean by "modification", but the lambda
expression has a value - and that value is a function. When you call
that function, you get another value, which is whatever the function
returned. Same with a generator expression.

Also, I recommend upgrading to Python 3. Python 2 is end-of-life.

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


Re: Why is a generator expression called a expression?

2020-04-20 Thread Veek M
but one can do the following
(x for x in 'apple').next() * 2

def foo():
   (yield 2)
foo().next() * 3

(lambda x: 2)()*4

generator expr, yield expr, lambda expression 
all require some modification (insertion of a .next or explicit () so 
it's quite confusing.. 

expression seems to mean anything that gives a value with a little 
massaging..
with statements you can't combine them at all

assert 1 < 2
cannot be mixed at all with anything else unless you use a ; and even 
that won't work within ( )

is this reasonable?

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


Re: Why is a generator expression called a expression?

2020-04-20 Thread DL Neil via Python-list

On 20/04/20 9:19 PM, Chris Angelico wrote:

On Mon, Apr 20, 2020 at 6:51 PM Veek M  wrote:


The docs state that a expression is some combination of value, operator,
variable and function. Also you cannot add or combine a generator
expression with a value as you would do with 2 + 3 + 4. For example,
someone on IRC suggested this
all(a == 'a' for a in 'apple') but

1. all is a function/method
2. so (whatever) in this case is a call but obviously it works so it must
be a generator object as well.. so.. how does 'all' the function object
work with the generator object that's being produced?

I can't for example do min 1,2,3 but i can do min (1,2,3) and the () are
not integral to a tuple - therefore one could argue that the () are part
of the call - not so with a generator Expression where the () are
integral to its existence as an object.

Could someone clarify further.


Short answer: An expression is anything that you can evaluate - that
is, anything where you can figure out its value. "1 + 1" is an
expression that has the value 2, but a 'for' loop doesn't have a
value, so it's not an expression.

In the case of a genexp, the expression has a value which is a
generator object. When you pass that to all(), it takes it and then
iterates over it, because that's one of the things you can do with a
generator object. :)


and, the () are not integral to a tuple. They form a 'parenthesised 
form". In other words they are delimiters - particularly useful if an 
expression needs to span multiple lines of code!


It is the comma-separated "list of expressions" which defines a tuple, 
ie the parentheses are somewhat optional and certainly not 
in-and-of-themselves, a definition, eg


a, b = 1, 2

Which is why a single element/expression tuple must be expressed with a 
comma. Yet, things become slightly confusing when an empty pair of 
parentheses defines an empty tuple.



You will find these definitions (and so much more) in the Python 
Reference Manual amongst the Python docs.

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


Re: Why is a generator expression called a expression?

2020-04-20 Thread Veek M
Also you will note, one can do:
( 2 if 3 > 2 else 4 ) + 4
so the () is just for precedence but otherwise a Conditional Expression 
works as expected by returning a value to be added to + 4.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why is a generator expression called a expression?

2020-04-20 Thread Veek M
On Mon, 20 Apr 2020 19:19:31 +1000, Chris Angelico wrote:

> In the case of a genexp, the expression has a value which is a generator
> object. When you pass that to all(), it takes it and then iterates over

but an object is NOT THE SAME as it's value! '2' is an object which 
happens to have a value of 2 under certain contexts.. ergo a generator 
object is returned by ( whatever ) and therefore NOT a value-to-be-used!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why is a generator expression called a expression?

2020-04-20 Thread Chris Angelico
On Mon, Apr 20, 2020 at 6:51 PM Veek M  wrote:
>
> The docs state that a expression is some combination of value, operator,
> variable and function. Also you cannot add or combine a generator
> expression with a value as you would do with 2 + 3 + 4. For example,
> someone on IRC suggested this
> all(a == 'a' for a in 'apple') but
>
> 1. all is a function/method
> 2. so (whatever) in this case is a call but obviously it works so it must
> be a generator object as well.. so.. how does 'all' the function object
> work with the generator object that's being produced?
>
> I can't for example do min 1,2,3 but i can do min (1,2,3) and the () are
> not integral to a tuple - therefore one could argue that the () are part
> of the call - not so with a generator Expression where the () are
> integral to its existence as an object.
>
> Could someone clarify further.

Short answer: An expression is anything that you can evaluate - that
is, anything where you can figure out its value. "1 + 1" is an
expression that has the value 2, but a 'for' loop doesn't have a
value, so it's not an expression.

In the case of a genexp, the expression has a value which is a
generator object. When you pass that to all(), it takes it and then
iterates over it, because that's one of the things you can do with a
generator object. :)

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


Why is a generator expression called a expression?

2020-04-20 Thread Veek M
The docs state that a expression is some combination of value, operator, 
variable and function. Also you cannot add or combine a generator 
expression with a value as you would do with 2 + 3 + 4. For example, 
someone on IRC suggested this
all(a == 'a' for a in 'apple') but

1. all is a function/method
2. so (whatever) in this case is a call but obviously it works so it must 
be a generator object as well.. so.. how does 'all' the function object 
work with the generator object that's being produced? 

I can't for example do min 1,2,3 but i can do min (1,2,3) and the () are 
not integral to a tuple - therefore one could argue that the () are part 
of the call - not so with a generator Expression where the () are 
integral to its existence as an object.

Could someone clarify further.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Run code automatically

2020-04-20 Thread Souvik Dutta
No no I did not tell you to do it in that way. I said you could try putting
the whole the code in the .py file in a for loop. That is:-
for a in range(10):
 

On Mon, 20 Apr, 2020, 1:55 pm hanan lamaazi, 
wrote:

> Yes, so to do it I save my code as filename.ipynb and go to terminal (cmd)
> I write the following commande:
>
> >> run for x in {1..10}; do (ipython filename.ipynb > /tmp/$x.log) & done
>
> it gives the following error:
>
> ERROR: root:File ''for.py'' not found
>
>
> I use another one:
>
> >> for filename in $(find $Foldername  -name *.py)
> .:do
>...:   python $filename
>...:done
>
> It gives the following error/
>
> File "", line 1
>  for filename in $(find $foldername  -name *.py)
>
> SyntaxError: invalid syntax
>
>
> Could please suggest me any other solution? or what is wrong with those
> expressions?
>
> Thank you
>
>
> Le jeu. 16 avr. 2020 à 16:57, Souvik Dutta  a
> écrit :
>
>> Do you want to run the code many times after just clicking run once? If
>> so then I think grouping the whole program in one for loop would do the
>> task.
>>
>> Souvik python dev
>>
>> On Thu, Apr 16, 2020, 4:57 PM hanan lamaazi 
>> wrote:
>>
>>> Dear All,
>>>
>>> I just start the self learning of python, and I tried to use it in
>>> jupyter
>>> notebook. I work on real dataset and I used pandas for that. Now my
>>> problem
>>> is I developed two separate code but dependent the first one should run
>>> to
>>> give me  samples from my dataset and do the clustering (I use Kmeans) and
>>> the second should select data from each cluster provided by the first
>>> code.
>>>
>>> My question is:
>>> how can I run both code for many times without pushing the bottom "run"
>>> each time? make it automatic
>>>
>>>
>>> I tried to use Ipyparallel but seems that I don't know how to use it
>>>
>>>
>>> Thank you
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
>>>
>>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Run code automatically

2020-04-20 Thread hanan lamaazi
Yes, so to do it I save my code as filename.ipynb and go to terminal (cmd)
I write the following commande:

>> run for x in {1..10}; do (ipython filename.ipynb > /tmp/$x.log) & done

it gives the following error:

ERROR: root:File ''for.py'' not found


I use another one:

>> for filename in $(find $Foldername  -name *.py)
.:do
   ...:   python $filename
   ...:done

It gives the following error/

File "", line 1
 for filename in $(find $foldername  -name *.py)

SyntaxError: invalid syntax


Could please suggest me any other solution? or what is wrong with those
expressions?

Thank you


Le jeu. 16 avr. 2020 à 16:57, Souvik Dutta  a
écrit :

> Do you want to run the code many times after just clicking run once? If so
> then I think grouping the whole program in one for loop would do the task.
>
> Souvik python dev
>
> On Thu, Apr 16, 2020, 4:57 PM hanan lamaazi 
> wrote:
>
>> Dear All,
>>
>> I just start the self learning of python, and I tried to use it in jupyter
>> notebook. I work on real dataset and I used pandas for that. Now my
>> problem
>> is I developed two separate code but dependent the first one should run to
>> give me  samples from my dataset and do the clustering (I use Kmeans) and
>> the second should select data from each cluster provided by the first
>> code.
>>
>> My question is:
>> how can I run both code for many times without pushing the bottom "run"
>> each time? make it automatic
>>
>>
>> I tried to use Ipyparallel but seems that I don't know how to use it
>>
>>
>> Thank you
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
-- 
https://mail.python.org/mailman/listinfo/python-list