Re: on the prng behind random.random()

2018-11-20 Thread Christian Gollwitzer

Am 19.11.18 um 22:05 schrieb Robert Girault:

Chris Angelico  writes:


On Tue, Nov 20, 2018 at 7:31 AM Robert Girault  wrote:

Nice.  So Python's random.random() does indeed use mt19937.  Since it's
been broken for years, why isn't it replaced by something newer like
ChaCha20?  Is it due to backward compatibility?  That would make sense.


What exactly do you mean by "broken"?


I mean the fact that with 624 samples from the generator, you can
determine the rest of the sequence completely.


As far as I understand it, this is true only if you see the full 32bit 
output number from the Mersenne Twister for those 624 outputs. If 
however you create a list:


[random.randrange(10) for i in range(624)]

I don't think you can predict what follows.

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


question on the 'calendar' function

2018-11-20 Thread o1bigtenor
Greetings

I am in the process of learning my first computer programming language
(unless g-code counts and then it is my second - - - grin). It
definitely is a big world out there.

The calendar function has a lot of versatility and shows care in its
development.

There is one area where I don't understand if I even could use this
function or if I need to look to something(s) else to achieve what I
need.

For planning I need to be able to easily look backward 6 months and
forward at least 12 and better 18 months and would prefer perhaps even
a total of 36 (and even 60 might be useful) months of calendar
available. It could be useful to see the longer time spans as weeks
rather than as days but seeing the larger time frames only as months
would enable the planning that I need to do.

Do I need to (somehow and I have no idea how) extend the calendar function?
Is there some other way of displaying dates/calendars that would allow
me to achieve my needed span?

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


Basic pynomo instructions not working

2018-11-20 Thread Adam Funk
Hi,

I'm trying to use the basic stuff in pynomo



which I've installed with pip3, but I run into this problem trying to
the basic stuff in the documentation:

#v+
$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pynomo.nomographer import *
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/adam/.local/lib/python3.6/site-packages/pynomo/nomographer.py", 
line 16, in 
from nomo_wrapper import *
ModuleNotFoundError: No module named 'nomo_wrapper'
>>> import pynomo
>>> import pynomo.nomographer
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/adam/.local/lib/python3.6/site-packages/pynomo/nomographer.py", 
line 16, in 
from nomo_wrapper import *
ModuleNotFoundError: No module named 'nomo_wrapper'
>>>
#v-

Any ideas?

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


Re: Suggestions for plotting slide rule & sector scales?

2018-11-20 Thread Adam Funk
On 2018-11-08, Stefan Ram wrote:

> Adam Funk  writes:
>>and get a line 100 mm long with a log scale on the top and a linear
>>scale on the bottom.
>
>   From what I have heard,
>
> pyqt.sourceforge.net/Docs/PyQt4/qx11info.html#appDpiX
>
>   will give you the dots per inch (link not validated).
>
>   matplotlib.axis.Axis handles drawing of t tick lines,
>   grid lines, tick and axis label (information not verified).

I hadn't thought of using matplotlib to do axes only, without the rest
of the graph --- interesting idea.

I've also found pynomo, which looks more appropriate, but I'm having
problems with that (see other post).


-- 
Physics is like sex. Sure, it may give some practical results, but 
that's not why we do it.---Richard Feynman
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: bottledaemon stop/start doesn't work if killed elsewhere

2018-11-20 Thread Adam Funk
On 2018-11-18, Dan Sommers wrote:

> On 11/18/18 1:21 PM, MRAB wrote:> On 2018-11-18 17:50, Adam Funk wrote:
> >> Hi,
> >>
> >> I'm using bottledaemon to run a little REST service on a Pi that takes
> >> input from other machines on the LAN and stores stuff in a database.
> >> I have a cron job to call 'stop' and 'start' on it daily, just in case
> >> of problems.
> >>
> >> Occasionally the oom-killer runs overnight and kills the process using
> >> bottledaemon; when this happens (unlike properly stopping the daemon),
> >> the pidfile and its lockfile are left on the filesystem, so the 'stop'
> >> does nothing and the 'start' gets refusedq because the old pidfile and
> >> lockfile are present.  At the moment, I eventually notice something
> >> wrong with the output data, ssh into the Pi, and rm the two files then
> >> call 'start' on the daemon again.
> >>
> >> Is there a recommended or good way to handle this situation
> >> automatically?
> >>
> > Could you write a watchdog daemon that checks whether bottledaemon is
> > running, and deletes those files if it isn't (or hasn't been for a 
> while)?
>
> What if the oom-killer kills the watchdog?
>
> Whatever runs in response to the start command has to be smarter:  if
> the pid and lock files exist, then check whether they refer to a
> currently running bottledaemon.  If so, then all is well, and refuse to
> start a redundant daemon.  If not, then remove the pid and lock files
> and start the daemon.

I've reported this as an issue on github.  It seems to me that the
'stop' subcommand should delete the pidfile and lockfile if the pid is
no longer running.


-- 
It's like a pair of eyes. You're looking at the umlaut, and it's
looking at you. ---David St. Hubbins
-- 
https://mail.python.org/mailman/listinfo/python-list


Have I Been Banned?

2018-11-20 Thread Wildman via Python-list
In the past I have participated in the group without any
problems.  I access the forum through the usenet mirror
and I am still using the same newsreader and account.
Recently I made some followup posts to the group and they
never showed up.  Have I been banned?  If so, I would
appreciate it to know why?

Of course I am not sure if this post will make it to the
server.

-- 
 GNU/Linux user #557453
Restricted area!  Authorized trespassers only.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Have I Been Banned?

2018-11-20 Thread Jon Ribbens
On 2018-11-20, Wildman  wrote:
> In the past I have participated in the group without any
> problems.  I access the forum through the usenet mirror
> and I am still using the same newsreader and account.
> Recently I made some followup posts to the group and they
> never showed up.  Have I been banned?  If so, I would
> appreciate it to know why?

If you mean you made posts to the comp.lang.python group and they did
not show up on your news server then the problem is either at your
end or with your news server - unlike the mailing list, the group is
unmoderated and therefore nobody can be banned from it.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Have I Been Banned?

2018-11-20 Thread Wildman via Python-list
On Tue, 20 Nov 2018 16:39:39 +, Jon Ribbens wrote:

> On 2018-11-20, Wildman  wrote:
>> In the past I have participated in the group without any
>> problems.  I access the forum through the usenet mirror
>> and I am still using the same newsreader and account.
>> Recently I made some followup posts to the group and they
>> never showed up.  Have I been banned?  If so, I would
>> appreciate it to know why?
> 
> If you mean you made posts to the comp.lang.python group and they did
> not show up on your news server then the problem is either at your
> end or with your news server - unlike the mailing list, the group is
> unmoderated and therefore nobody can be banned from it.

Yes, I make posts to comp.lang.python.  My newsreader's log says the
posts are accepted by the server.  I will contact Giganews to see if
they can shed some light on the subject.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: question on the 'calendar' function

2018-11-20 Thread Schachner, Joseph
It's possible I don't understand the question.  The calendar functions are NOT 
limited to this year or any limited range.

Example:
import calendar
print( calendar.monthcalendar(2022, 12) )

Prints lists of dates in each week of December 2022.  It prints:
[[0, 0, 0, 1, 2, 3, 4], [5, 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17, 18], 
[19, 20, 21, 22, 23, 24, 25], [26, 27, 28, 29, 30, 31, 0]]

So, Dec 1 is a Wednesday; Dec 31 is a Saturday.  

That's 49 months ahead of this month.   Change the year and month to any 
(valid) number, and it will do what it does.  
The only caveat is that if the moon's orbit slows down as it gets farther away 
from the earth and the earth's rotation speed changes, then the calculations 
done by calendar for leap years may not be correct about the distant future.

--- Joseph S.


-Original Message-
From: o1bigtenor  
Sent: Tuesday, November 20, 2018 8:37 AM
To: python-list@python.org
Subject: question on the 'calendar' function

Greetings

I am in the process of learning my first computer programming language (unless 
g-code counts and then it is my second - - - grin). It definitely is a big 
world out there.

The calendar function has a lot of versatility and shows care in its 
development.

There is one area where I don't understand if I even could use this function or 
if I need to look to something(s) else to achieve what I need.

For planning I need to be able to easily look backward 6 months and forward at 
least 12 and better 18 months and would prefer perhaps even a total of 36 (and 
even 60 might be useful) months of calendar available. It could be useful to 
see the longer time spans as weeks rather than as days but seeing the larger 
time frames only as months would enable the planning that I need to do.

Do I need to (somehow and I have no idea how) extend the calendar function?
Is there some other way of displaying dates/calendars that would allow me to 
achieve my needed span?

TIA

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


Re: question on the 'calendar' function

2018-11-20 Thread Ben Finney
o1bigtenor  writes:

> I am in the process of learning my first computer programming language
> (unless g-code counts and then it is my second - - - grin). It
> definitely is a big world out there.

Welcome, and congratulations on starting with Python!

> The calendar function has a lot of versatility and shows care in its
> development.

I assume we are here talking about the standard library ‘calendar’
module https://docs.python.org/3/library/calendar.html>, and the
function is ‘calendar.calendar’ to generate a whole year calendar
https://docs.python.org/3/library/calendar.html#calendar.calendar>.

> For planning I need to be able to easily look backward 6 months and
> forward at least 12 and better 18 months and would prefer perhaps even
> a total of 36 (and even 60 might be useful) months of calendar
> available. It could be useful to see the longer time spans as weeks
> rather than as days but seeing the larger time frames only as months
> would enable the planning that I need to do.

Have you looked through the rest of the documentation of that module?
Does ‘calendar.monthcalendar’ come close to what you need
https://docs.python.org/3/library/calendar.html#calendar.monthcalendar>?

> Do I need to (somehow and I have no idea how) extend the calendar
> function?

It's quite feasible you may get to that point, at which time you will
want to learn about composing functions by calling other functions;
eventually you will learn a different technique, of creating a class by
inheriting from an existing class.

But all that may be in the future! Try just using the existing functions
from that library module and see how far that gets you.

Good hunting.

-- 
 \ “I have the simplest tastes. I am always satisfied with the |
  `\best.” —Oscar Wilde, quoted in _Chicago Brothers of the Book_, |
_o__) 1917 |
Ben Finney

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


Re: question on the 'calendar' function

2018-11-20 Thread o1bigtenor
On Tue, Nov 20, 2018 at 11:50 AM Schachner, Joseph
 wrote:
>
> It's possible I don't understand the question.  The calendar functions are 
> NOT limited to this year or any limited range.
>
> Example:
> import calendar
> print( calendar.monthcalendar(2022, 12) )
>
> Prints lists of dates in each week of December 2022.  It prints:
> [[0, 0, 0, 1, 2, 3, 4], [5, 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17, 
> 18], [19, 20, 21, 22, 23, 24, 25], [26, 27, 28, 29, 30, 31, 0]]
>
> So, Dec 1 is a Wednesday; Dec 31 is a Saturday.
>
> That's 49 months ahead of this month.   Change the year and month to any 
> (valid) number, and it will do what it does.
> The only caveat is that if the moon's orbit slows down as it gets farther 
> away from the earth and the earth's rotation speed changes, then the 
> calculations done by calendar for leap years may not be correct about the 
> distant future.
>

Greetings

If my syntax or commands are wrong - - - - I've just started so
something is likely to NOT be correct - - - grin - - - I'sa noob!

# calendar 2019

that is to show the year 2019

How could I show June 2018 to Dec 2019, inclusive?
Or June 2018 to Dec 2021, inclusive?
Or June 2018 to Dec 2023 by week (June wk 1,2,3,4 2018; July wk
1,2,3,4,5 2018; . . .   Dec wk 1,2,3,4,5 2023 or maybe even by dates),
inclusive?

Note that the time frame is ALWAYS more than 1 year.
AIUI there isn't a way to do that, at least not that I can see, and I
would like to be able to do that.
A friend suggested using a script wrapped around the command. I
thought maybe there might we a way of doing what I need to do without
using 2 levels of programming.

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


Re: question on the 'calendar' function

2018-11-20 Thread o1bigtenor
On Tue, Nov 20, 2018 at 12:09 PM Ben Finney  wrote:
>
> o1bigtenor  writes:
>
> > I am in the process of learning my first computer programming language
> > (unless g-code counts and then it is my second - - - grin). It
> > definitely is a big world out there.
>
> Welcome, and congratulations on starting with Python!
>
> > The calendar function has a lot of versatility and shows care in its
> > development.
>
> I assume we are here talking about the standard library ‘calendar’
> module https://docs.python.org/3/library/calendar.html>, and the
> function is ‘calendar.calendar’ to generate a whole year calendar
> https://docs.python.org/3/library/calendar.html#calendar.calendar>.

These are the documents that I was examining before I asked my question.
>
> > For planning I need to be able to easily look backward 6 months and
> > forward at least 12 and better 18 months and would prefer perhaps even
> > a total of 36 (and even 60 might be useful) months of calendar
> > available. It could be useful to see the longer time spans as weeks
> > rather than as days but seeing the larger time frames only as months
> > would enable the planning that I need to do.
>
> Have you looked through the rest of the documentation of that module?
> Does ‘calendar.monthcalendar’ come close to what you need
> https://docs.python.org/3/library/calendar.html#calendar.monthcalendar>?

No - - - the limit is still one year (of 12 months) and my minimum would be
18 months and preferably quite a bit more.
>
> > Do I need to (somehow and I have no idea how) extend the calendar
> > function?
>
> It's quite feasible you may get to that point, at which time you will
> want to learn about composing functions by calling other functions;
> eventually you will learn a different technique, of creating a class by
> inheriting from an existing class.

Hmm - - - this sounds like what I'm going to have to do.
let's see if I can find docs on this.
>
> But all that may be in the future! Try just using the existing functions
> from that library module and see how far that gets you.

The calendar function as it exists just quite spread its wings far enough
for my needs but this extension by inheritance is intriguing!

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


Re: Reading 'scientific' csv using Pandas?

2018-11-20 Thread Martin Schöön
Den 2018-11-19 skrev Martin Schöön :
> I spoke too early. Upon closer inspection I get the first column with
> decimal '.' and the rest with decimal ','. I have tried the converter
> thing to no avail :-(
>
Problem solved!

This morning I woke up with the idea of testing if all this fuss may
be caused by the fact that the 'objectional' files missed some data
in their first few rows. I tested by replacing the blank spaces in one
file with zeros. Bingo! For real this time!

Missing data threw read_csv off course.

Fortunately, only a few files needed a handful of zeros to work so
I could do it manually without breaking too much sweat.

Thanks for the keen interest shown.

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


Re: question on the 'calendar' function

2018-11-20 Thread Ben Finney
o1bigtenor  writes:

> On Tue, Nov 20, 2018 at 12:09 PM Ben Finney  
> wrote:
> > o1bigtenor  writes:
> > > It could be useful to see the longer time spans as weeks rather
> > > than as days but seeing the larger time frames only as months
> > > would enable the planning that I need to do.
> >
> > Does ‘calendar.monthcalendar’ come close to what you need
> > https://docs.python.org/3/library/calendar.html#calendar.monthcalendar>?
>
> No - - - the limit is still one year (of 12 months) and my minimum
> would be 18 months and preferably quite a bit more.

That doesn't match what I understand from the module documentation.

Can you show a (small, self-contained) example that demonstrates the
“limit is still one year” when you try to use ‘calendar.monthcalendar’
for the purpose you described above?

-- 
 \ “I have yet to see any problem, however complicated, which, |
  `\  when you looked at it in the right way, did not become still |
_o__)more complicated.” —Paul Anderson |
Ben Finney

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