python-docx

2019-11-25 Thread Ethan Woo
Hi everyone,

I am currently using Python 3.7.4, and have used pip to install python
docx. I have looked up on many tutorials on how to use it, but they are all
mostly the same.
doc.add_heading("Test")
when i type that line, i get this:
KeyError: "no style with name 'Heading 1'"
can help?
-- 
https://mail.python.org/mailman/listinfo/python-list


Library Generate a diff between two text files

2019-11-25 Thread Noah
Hi Folks,

>From experience, could someone point me to a library that can do a diff
between two separate text files...

*difflib* doesn't seem to cut it to this end

*./noah*
neo - network engineering and operations
-- 
https://mail.python.org/mailman/listinfo/python-list


Fit to function values with numpy/scipy

2019-11-25 Thread Machiel Kolstein

If I have an array with values, which are distributed according to a Gaussian 
function, then I can fit with: 
   (fit_mu, fit_sigma) = stats.norm.fit(x_array)

However, now, I have one array with values for the xbins (e.g., 0.0, 0.1, 0.2, 
0.3, ..., up till 1.0) and one value for the corresponding y-value (e.g. 0.0, 
0.3, 0.6, 1.2, 5.0, 10.0, 5.0, 1.2, 0.6, 0.3, 0.0).
(These values are just an example). 
Now I want to fit this, with a Gauss. So, obviously I don't want to fit over 
neither the values in xbins, nor the y_array (neither of which is normal 
distributed) but over the y values for each x bin. 
The only thing I can think of is looping over all bins, and then filling an 
artificial array: 

for i in range(0, Nbins): 
   x = xbinvalue(i)
   weight = y_value_for_this_x(x)
   for w in range(0, weight)
   numpy.vstack((tmp_array, x)
(fit_mu, fit_sigma) = scipy.stats.norm.fit(tmp_array)

But this seems a rather silly way of doing this. Is there an other way?

Cheers, 

Machiel   

-- 
Avís -
Aviso - Legal Notice - (LOPD) - http://legal.ifae.es 

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


Re: Fit to function values with numpy/scipy

2019-11-25 Thread Machiel Kolstein

Okay, I found some answer myself: use scipy.optimize.curve_fit
However, I still find it strange that I have to define a gauss function myself 
instead of it being readily available. I did this: 

# Define model function to be used to fit to the data
def gauss(x, *p):
A, mu, sigma = p
return A*np.exp(-(x-mu)**2/(2.*sigma**2))
p0 = [1., 0., 1.]

# Fit the histogram -
coeff, var_matrix = curve_fit(gauss, x_array, y_array, p0=p0)
amplitude, mu, sigma = coeff
print "amplitude, mu, sigma = ", amplitude, mu, sigma

# Get the fitted curve
hist_fit = gauss(x_array, *coeff)
plt.plot(x_array, hist_fit, color='red', linewidth=5, label='Fitted data')

plt.show()

-- 
Avís -
Aviso - Legal Notice - (LOPD) - http://legal.ifae.es 

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


Re: Python Resources related with web security

2019-11-25 Thread Pycode
On Sun, 24 Nov 2019 10:41:29 +1300, DL Neil wrote:

> Curiosity: why have recent similar enquiries also come from
> non-resolving domain names?
> 
> 
> Recently we've seen security-related enquiries (on more than one Python
> Discussion List) which don't explicitly claim to come from 'white hat
> hackers' but which do have the potential to have less-than productive
> aims or interests.
> 
> Are such email addresses 'open' and honest?
> Do they create extra and unnecessary scut-work for ListAdmins?
> Does such meet PSF 'standards' for honest and respectful interchange?
> 
> WebRef:
> https://www.python.org/psf/conduct/
> 
> 
> 
> On 24/11/19 8:18 AM, Pycode wrote:
>> Hello,
>> 
>> can anyone post links for python resources that contain tools and
>> scripts related with security and pentesting?
>> not looking for the obvious such as OWASP,etc
>> 
>> can anyone post a list of interesting links? you can also include blogs
>> and forums..
>> 
>> Thanks
>>

you are not being helpful or answer the question..
can someone answer? maybe should i ask on the mailing list?

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


Why isn't "-std=c99" (and others) not part of python3-config's output?

2019-11-25 Thread Musbur
I've successfully built and installed a copy of Python3.6.8 (replacing a 
probably buggy installation on my RHEL system, different story). Also I 
set up a virtualenv by doing "$ /usr/local/bin/python3.6dm -m venv 
/usr/local/pyenv36"


In my activated virtualenv, I try "$ pip install numpy" but it fails 
with lots of errors about something that is valid only in C99. Obviously 
numpy relies on -std=c99


(pyenv36)$ /usr/local/bin/python3.6dm-config  --cflags
-I/usr/local/include/python3.6dm -I/usr/local/include/python3.6dm  
-Wno-unused-result -Wsign-compare  -g -Og -Wall

(pyenv36)$

This surprises me, because "my" /usr/local/bin/python3.6m itself was 
built -std=c99, as seen in these sysconfig entries:


'CONFIGURE_CFLAGS_NODIST': '-std=c99 -Wextra -Wno-unused-result '
'PY_CFLAGS_NODIST': '-std=c99 -Wextra -Wno-unused-result '
'PY_CORE_CFLAGS': '-Wno-unused-result -Wsign-compare -g -Og -Wall 
-std=c99 '


I can install numpy on the system Python3, and not surprisingly, there 
is -std=c99 among tons of other CFLAGS:


$ /usr/bin/python3.6m-config --cflags
-I/usr/include/python3.6m -I/usr/include/python3.6m  -Wno-unused-result 
-Wsign-compare -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions 
-fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches 
  -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv   
-DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall 
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong 
--param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic 
-D_GNU_SOURCE -fPIC -fwrapv

$

My questions are:

1) Why does the output of /usr/local/bin/python3.6m-config --cflags 
differ from the CFLAGS in sysconfig.get_config_vars() ? I've confirmed 
that the /usr/local/bin/python3.6m binary and 
/usr/local/bin/python3.6m-config are really from the same build.


2) How does one activate the necessary CFLAGs for extension building?

3) Where do all the extra flags in the system /usr/bin/python3.6m-config 
--cflags come from?


4) Why isn't the config script installed into the /bin of a virtualenv? 
This is super annoying when building extensions on a multi-version 
system because it may lead to version mix-ups


A bit of background on this: I've written a C extension that leaks 
memory like a sieve on my production RHEL7's system python3 but neither 
on my Debian development system nor on my "self-built" Python on the 
production server. So I'd like to install the self-built Python on the 
production server, but for that I need a bunch of other packages to work 
as well, including numpy.


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


Re: Python Resources related with web security

2019-11-25 Thread Tim Chase
On 2019-11-25 21:25, Pycode wrote:
> On Sun, 24 Nov 2019 10:41:29 +1300, DL Neil wrote:
>> Are such email addresses 'open' and honest?
> 
> you are not being helpful or answer the question..

What DL Neil seems to be getting at is that there's been an uptick in
questions

1) where we don't know who you (and several other recent posters) are:

  - The pyc.ode domain-name of your email address isn't a
real/registered domain

  - there doesn't seem to be much evidence of you being part of the
Python community with a history of other messages

  Neither factor inspires much confidence.

2) you (and others) are asking to be spoonfed example code that could
cause problems on the internet.

>>> can anyone post links for python resources that contain tools and
>>> scripts related with security and pentesting?

They're the sorts of tools that, if the community deems you a
non-threatening-actor, they might point you in the right direction.
But not knowing who you are (see point #1 above), I imagine folks here
are hesitant.  And almost certainly not going to spoon-feed example
code that could then end up attacking sites on the web.

So I suspect DL Neil was raising awareness to make sure that anybody
who *did* answer your questions might take the time to think about
the potential consequences of the actions.  So DL *is* being helpful,
but rather to the community, even if not necessarily to you in
particular.

> can someone answer? maybe should i ask on the mailing list?

You did.  The usenet & mailing lists are mirrored.  Though perhaps if
you post from a legit mail identity/address (whether to the mailing
list or usenet), it might help folks evaluate whether you're a "white
hat" or a "black hat" (or somewhere in between).


As to your questions, all the basics are available:  materials on
security & pentesting are a web-search away, and Python provides
libraries for both socket-level interfaces & application-specific
protocols.  How you choose to combine them is up to you.  How the
community chooses to assist you in combining them largely depends on
how much they trust you.

-tkc






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


Re: Python Resources related with web security

2019-11-25 Thread DL Neil via Python-list

On 26/11/19 11:48 AM, Tim Chase wrote:

On 2019-11-25 21:25, Pycode wrote:

On Sun, 24 Nov 2019 10:41:29 +1300, DL Neil wrote:

Are such email addresses 'open' and honest?


you are not being helpful or answer the question..


What DL Neil seems to be getting at is that there's been an uptick in
questions

1) where we don't know who you (and several other recent posters) are:

   - The pyc.ode domain-name of your email address isn't a
 real/registered domain

   - there doesn't seem to be much evidence of you being part of the
 Python community with a history of other messages


+other consideration regarding the best use of mail-lists and respecting 
people's time.


For reference: an attempt to contact the OP directly, in a bid to refine 
his questions/assist the production of answers (perhaps), failed - due 
to the problem mentioned, ie one of his/her own making!




   Neither factor inspires much confidence.

2) you (and others) are asking to be spoonfed example code that could
cause problems on the internet.

...



So I suspect DL Neil was raising awareness to make sure that anybody
who *did* answer your questions might take the time to think about
the potential consequences of the actions.  So DL *is* being helpful,
but rather to the community, even if not necessarily to you in
particular


Thanks @tkc. Yes!

Given that the OP may have legitimate (and legal) reasons for the 
question, I was reluctant to express direct criticism (which, 
ironically-enough) is contrary to 'open' etc behavior.


Previous to this, had discussed such concerns with a ListAdmin, who is 
taking it further. I hope we'll (soon) see something further from the 
Python-/List-gods...



As a student of irony, I was amused at being told that I wasn't 
answering questions - by someone who didn't even acknowledge, and 
certainly didn't attempt to address, concerns raised. Colors += mast?


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


Re: Fit to function values with numpy/scipy

2019-11-25 Thread Richard Damon
On 11/25/19 12:31 PM, Machiel Kolstein wrote:
> Okay, I found some answer myself: use scipy.optimize.curve_fit
> However, I still find it strange that I have to define a gauss function 
> myself instead of it being readily available. I did this: 
>
> # Define model function to be used to fit to the data
> def gauss(x, *p):
> A, mu, sigma = p
> return A*np.exp(-(x-mu)**2/(2.*sigma**2))
> p0 = [1., 0., 1.]
>
> # Fit the histogram -
> coeff, var_matrix = curve_fit(gauss, x_array, y_array, p0=p0)
> amplitude, mu, sigma = coeff
> print "amplitude, mu, sigma = ", amplitude, mu, sigma
>
> # Get the fitted curve
> hist_fit = gauss(x_array, *coeff)
> plt.plot(x_array, hist_fit, color='red', linewidth=5, label='Fitted data')
>
> plt.show()
>
That actually solves a slightly different problem. norm.fit basically
computes the mean and standard deviation of the data (and if you know
what the mean should be, you can provide that to get a better estimate
of the standard deviation). If you problem really is a weighted data
problem, then it isn't hard to compute a weighted average or weighted
standard deviation, I don't know scipy to know if it has something like
that built in. A quick scan shows that numpy.average allows a weighting
array to be provided, so it shouldn't be hard to look at the code for
sci[y.norm.fit and convert it to use weighted averages.

-- 
Richard Damon

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


Re: Python Resources related with web security

2019-11-25 Thread Pycode
On Mon, 25 Nov 2019 17:32:50 -0500, Dennis Lee Bieber wrote:

> On Mon, 25 Nov 2019 21:25:12 + (UTC), Pycode 
> declaimed the following:
> 
> 
>>you are not being helpful or answer the question..
>>can someone answer? maybe should i ask on the mailing list?
> 
>   Why?
> 
> comp.lang.python gmane.comp.python.general
> 
> and "the mailing list"
> 
> are all cross-gatewayed to each other (we don't speak of what Google
> Groups is doing).

can you recommend some forums and blogs?

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


Re: Python Resources related with web security

2019-11-25 Thread Pycode
On Mon, 25 Nov 2019 16:48:59 -0600, Tim Chase wrote:

> On 2019-11-25 21:25, Pycode wrote:
>> On Sun, 24 Nov 2019 10:41:29 +1300, DL Neil wrote:
>>> Are such email addresses 'open' and honest?
>> 
>> you are not being helpful or answer the question..
> 
> What DL Neil seems to be getting at is that there's been an uptick in
> questions
> 
> 1) where we don't know who you (and several other recent posters) are:
> 
>   - The pyc.ode domain-name of your email address isn't a
> real/registered domain
> 
>   - there doesn't seem to be much evidence of you being part of the
> Python community with a history of other messages
> 
>   Neither factor inspires much confidence.
> 
> 2) you (and others) are asking to be spoonfed example code that could
> cause problems on the internet.
> 
 can anyone post links for python resources that contain tools and
 scripts related with security and pentesting?
> 
> They're the sorts of tools that, if the community deems you a
> non-threatening-actor, they might point you in the right direction. But
> not knowing who you are (see point #1 above), I imagine folks here are
> hesitant.  And almost certainly not going to spoon-feed example code
> that could then end up attacking sites on the web.
> 
> So I suspect DL Neil was raising awareness to make sure that anybody who
> *did* answer your questions might take the time to think about the
> potential consequences of the actions.  So DL *is* being helpful, but
> rather to the community, even if not necessarily to you in particular.
> 
>> can someone answer? maybe should i ask on the mailing list?
> 
> You did.  The usenet & mailing lists are mirrored.  Though perhaps if
> you post from a legit mail identity/address (whether to the mailing list
> or usenet), it might help folks evaluate whether you're a "white hat" or
> a "black hat" (or somewhere in between).
> 
> 
> As to your questions, all the basics are available:  materials on
> security & pentesting are a web-search away, and Python provides
> libraries for both socket-level interfaces & application-specific
> protocols.  How you choose to combine them is up to you.  How the
> community chooses to assist you in combining them largely depends on how
> much they trust you.
> 
> -tkc

which keywords should i use for web-search? do you have a list?
what is the best "manual" for the specific security topic?

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


Re: Python Resources related with web security

2019-11-25 Thread Chris Angelico
On Tue, Nov 26, 2019 at 1:56 PM Pycode  wrote:
>
> which keywords should i use for web-search? do you have a list?
> what is the best "manual" for the specific security topic?

https://lmgtfy.com/?q=How+to+search+the+web

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