data sequencing

2020-01-31 Thread khishorks
I have a data sequence of around 30 sets. I need to batch the sequence into 
an input-output format. for example 

data= [1,2,3,4,5,6,7,8,9,10,..,100]

X1= [1,2,3,4,5,6,7,8,9,10]   y1 = [11,12]
X2= [3,4,5,6,7,8,9,11,12] y2 = [13,14]
and it continues till 100.

here X is input and y is output. How to sequence the data in steps of 2?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Please answer fast.....

2020-01-31 Thread DL Neil via Python-list

On 1/02/20 1:05 AM, Souvik Dutta wrote:

Hi,
This is problem from pyqt5. Actually I want to have about 40 labels added
into a window when a button is clicked. The text are not the same so the
label is not the same. I cannot just add 40 labels before hand and then
change its text to something from a qlineedit. Please say me something that
is more efficient and less idiot like. Thank you.



Hi, you have certainly become part of the Python community. It's 
probably too late to say "welcome".


Perhaps you are unfamiliar with this sort of discussion list, so please 
allow me try helping you to fit-in...


Are you aware that the people who might ask your question are paid as 
much for that, as you were when asking it? ie ZERO! Is the message title 
respectfully asking for someone to give-up his/her free time to help 
you? The key word is "community" (as distinct from HelpDesk or 
(salaried) Support Department).


Has this question been asked before? Such could only be ascertained by 
reviewing the list's archives (which we should all do before posting). 
Let's assume (with some confidence) that you are 'the first' to ask 
about Qt5 labels and buttons, how might someone else with a similar 
question, sometime in the future, be able to find 'the answer'? Would 
the message title "Please answer fast..." do it for you/for them? So, 
thoughtful selection of question subject-lines, just as for Python 
object names, is how you would be helping us all!

(at the same time as asking ('everyone') for help)

Sometimes people come to the list asking for 'work' to be done for them 
- either to avoid $paying a professional, or perhaps to avoid doing 
their homework - which rather defeats their learning objectives, but...! 
(that's a question/reference you will have seen on-list during the last 
few days) If you show (code) what you have done (and err.msgs showing 
where it went-wrong), might other people be more motivated to help you?


Similarly, (see this sort of response in other posts) if you are 
challenged coping with something 'new', would it help a respondent if 
you mentioned your (level of) existing knowledge, eg even "it worked in 
Qt4" informs. If "forms" is a new topic to you, or you are a beginner at 
learning Python, mentioning the tutorial/book/course you are following 
would also help 'set the scene' and assist/motivate us to help you with 
something "more efficient and less idiot like". (More/less than what?)


Lastly, (and with apologies because I don't know the answer to either 
your posted-question, or this one) is this the best place for Qt 
questions, or are there alternative venues? Which is not to say that 
there won't be someone, who is also using Qt5 from Python, who will be 
able to help...


Apologies if it feels as if I am rebuking you. The intent is actually to 
help you, and to hope that as you ask questions and learn for yourself, 
we might also learn (from you)!
(the bulk of the membership read far more posts than they ever 
post/contribute answers)


Here's hoping someone smarter than I (and five times cuter - hah, 
"Qt5"!) will be able to help...

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


Re: Suggestions on mechanism or existing code - maintain persistence of file download history

2020-01-31 Thread DL Neil via Python-list

On 31/01/20 9:53 PM, R.Wieser wrote:

Using ctrl+c is a VERY BAD idea.


To have it just exit the program ?  Yes, indeed.

Though you /could/ keep track of what needs to be finished and have the
ctrl-c handler do that for you (barf).

Another posibility is to capture the ctrl-c and set a flag, which than
instructs the program to terminate loops wherever possible - and thus have
the program finish as if there was no more to do.


(see also 'sledgehammer to crack a nut')


While I agree with you there, I've been searching for other ways to detect a
keypress (in a console-based script) and have found none.   IOW, you do not
(seem to) have another option.


Color me disappointed! I was hoping to be enlightened as to how one 
might code exactly that. (so I went looking...)


My first thought was a try...except looking for a keyboard error, but 
wouldn't that only work if there was an input() loop? The idea of 
putting, effectively the entire code-base, into a try...except block 
seemed crude and likely to cause side-effects.


https://stackoverflow.com/questions/1112343/how-do-i-capture-sigint-in-python 
put me on a good path. So, I opened a door in my memory, shut my ears to 
the intense screeching noise, and used a yard-broom to sweep away all 
the rust that flaked off the hinges...


PSL's signal — Set handlers for asynchronous events 
(https://docs.python.org/3/library/signal.html) appears to handle 
keyboard interrupts, *at least in MS-Windows*.


Rusty? I think, years ago, I used signal(s) to establish time-limits on 
systems that had a possibility of 'run-away' or over-refining a solution 
which would only ever be asymptotic. I've not used the library in this 
manner.


That said, I'm using one of Python's asynchronous features, and Internet 
activity is riddled with delay-periods which make such retrievals ripe 
for async (code) solutions...




Why do you need to abandon the process mid-way?


Take your pick.Mostly because of "I need to leave *now*".   Or perhaps
because of an "you have X seconds before the device shuts down because of
the battery being low" situation.


I (personally) cannot make use of the above. However, even if my 
portable's battery threatens complete disaster, the system "hibernates", 
and thus averts major disaster, eg file system (or RDBMS) corruption. 
This seems enough for 99% of 'average uses'. Of course it is regarded as 
trivially-unacceptable in the non-stop world, eg banking. Would our OP 
classify this project as anything other than the first of those 
categories? Thus:



What is the OP's definition of "unlikely" or "acceptable risk"?


Good question, but one I had no wish for to try to ascertain.   I just gave
some "worst case" secenario based replies (aka, the "did you think of 
situation" kind).


Understood. However, your understanding of RDBMS interrupt 'security' 
appears either aged, or biased to a particular implementation (which (in 
my imagination) wouldn't match the high-standards I expect you hold).


Have already admitted that I (personally) may 'over use' RDBMS because 
it is 'easy' for me. When we do feel the justification to examine the 
details of "worst case scenarios"/"did you think of this?" RDBMS 
stand-out as a 'solution' simply because of the incredible amounts of 
time and depths of thought, highly-specialised minds (far superior to 
any input I could offer) have invested in providing highly refined 
services/servers. (which I dare-say informed @Chris' comments)


Neither MSFT nor the relevant GNU/Linux projects assure common file 
systems to such a degree (and particularly not in the mentioned 
circumstances). That's why there are FS 'rescue' procedures (Linux runs 
fsck automatically when 'trouble' is noted during system-start and every 
so-many reboots, regardless).


I'm sufficiently intrigued to wonder if anyone will dispute/correct such 
- but not sufficiently motivated to research any position other than the 
one currently held - so call me "Curious", but not "George" then...




There are so many reasons why such won't work first-time, when they should
every time; that it may be quite difficult to detect 'corruption'


:-) That was not even considered.  Just the "what do I still need to
download" datafile.


Yes, we left the OP's (actual) spec, way-back somewhere!



Accordingly, there is no non-atomic transaction in the proposal


The problem there is that you are second-guessing to what the OP will be
writing, and that it will be good.   I didn't and I don't assume that.  I've
seen too much "it works, so its good" noobie code. :-)


Absolutely! One of the 'joys' of working text-only is that even when one 
knows (much) more about the background to a posted-question, it is still 
so easy to 'answer-wrong'.


Even in my courses, where the Discussion Lists (are supposedly) related 
to each week/chapter of a course, you'd think we'd have adequate 'hints' 
as to the level of the trainee and where his/her question is 
'coming-from'. Not 

Re: Suggestions on mechanism or existing code - maintain persistence of file download history

2020-01-31 Thread DL Neil via Python-list

On 31/01/20 9:30 AM, jkn wrote:

Err, well, thanks for that discussion gents...

As it happens I do know how to use a database, but I regard it as overkill for
what I am trying to do here. I think a combination of hashing the URL,
and using a suffix to indicate the result of previous downloaded attempts, will
work adequately for my needs.

 Thanks again
 Jon N



Don't let the, um, robust discussion concern you. Certainly you bear no 
responsibility.


As elsewhere, your understanding of 'the problem' is more complete than 
any of us can claim. Accordingly, your 'answer' is the correct one! 
Should you 'fail fast, and fail often', then you have other courses that 
may be worth considering...



Speaking personally, I find a lot to be learned from reading what 
different folk have to say, and taking benefit from their experiences 
and different ways of looking at the same thing. It's worth remembering 
that not everyone comes across in email as a mild-mannered, 
absent-minded, over-stereotyped, British boffin.



There is/was a London PUG Discussion List, just as there likely are for 
other British groups/localities. I don't recall a recent posting - or 
maybe they've ex-communicated me for requiring them to shout very (very) 
loudly to reach me...



Thanks for the challenge!
--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: QTableWidget help!!

2020-01-31 Thread Barry


> On 31 Jan 2020, at 03:38, Souvik Dutta  wrote:
> 
> Hi,
> I want to add a QTableWidget to an existing window with other labels and
> button. How can I add the QTableWidget without having to set it as
> centralwidget and be able to move it and set geometry. Because I am not
> being able to move the central widget by using
> self.centralwidget.setGeometry . The error is cannot find reference. Please
> advise.

Sounds like you have discover layouts yet.

Have read about them: https://doc.qt.io/qt-5/examples-layouts.html

Barry

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


Re: QTableWidget help!!

2020-01-31 Thread Abdur-Rahmaan Janhangeer
QTableView is recommended, what pyqt version are you using?

On Fri, 31 Jan 2020, 07:35 Souvik Dutta,  wrote:

> Hi,
> I want to add a QTableWidget to an existing window with other labels and
> button. How can I add the QTableWidget without having to set it as
> centralwidget and be able to move it and set geometry. Because I am not
> being able to move the central widget by using
> self.centralwidget.setGeometry . The error is cannot find reference. Please
> advise.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Please answer fast.....

2020-01-31 Thread Souvik Dutta
Hi,
This is problem from pyqt5. Actually I want to have about 40 labels added
into a window when a button is clicked. The text are not the same so the
label is not the same. I cannot just add 40 labels before hand and then
change its text to something from a qlineedit. Please say me something that
is more efficient and less idiot like. Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Suggestions on mechanism or existing code - maintain persistence of file download history

2020-01-31 Thread R.Wieser
jkn,

> I'm happy to consider the risk and choose (eg.) the hash function 
> accordingly, thanks.

No problem, just wanted you to be aware and (thus) able to choose.

Regards,
Rudy Wieser


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


Re: Suggestions on mechanism or existing code - maintain persistence of file download history

2020-01-31 Thread jkn
On Friday, January 31, 2020 at 9:41:32 AM UTC, R.Wieser wrote:
> jkn,
> 
> > I think a combination of hashing the URL,
> 
> I hope you're not thinking of saving the hash (into the "done" list) instead 
> if the URL itself.   While hash collisions do not happen often (especially 
> not in a small list), you cannot rule them out.  And when that happens that 
> would mean you would be skipping downloads ...
> 
> Regards,
> Rudy Wieser

I'm happy to consider the risk and choose (eg.) the hash function accordingly, 
thanks.

Jon N

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


Re: Suggestions on mechanism or existing code - maintain persistence of file download history

2020-01-31 Thread jkn
On Friday, January 31, 2020 at 9:41:32 AM UTC, R.Wieser wrote:
> jkn,
> 
> > I think a combination of hashing the URL,
> 
> I hope you're not thinking of saving the hash (into the "done" list) instead 
> if the URL itself.   While hash collisions do not happen often (especially 
> not in a small list), you cannot rule them out.  And when that happens that 
> would mean you would be skipping downloads ...
> 
> Regards,
> Rudy Wieser

Hi Rudy

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


Python3.8.1 basemap

2020-01-31 Thread J Conrado

Hi,

I installed the Python3.8.1 and I run the example of basemap gallery: 
https://matplotlib.org/basemap/users/examples.html 



plotgreatcircle.py

for Python3.8 plotgreatcircle.py

I had:


Traceback (most recent call last):
  File "plotgreatcircle.py", line 1, in 
    from mpl_toolkits.basemap import Basemap
ModuleNotFoundError: No module named 'mpl_toolkits'


for Python3.7 plotgreatcircle.py

It is ok. Please, what what can I do to solve this error for Python3.8.

Thanks,


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


Re: Suggestions on mechanism or existing code - maintain persistence of file download history

2020-01-31 Thread R.Wieser
jkn,

> I think a combination of hashing the URL,

I hope you're not thinking of saving the hash (into the "done" list) instead 
if the URL itself.   While hash collisions do not happen often (especially 
not in a small list), you cannot rule them out.  And when that happens that 
would mean you would be skipping downloads ...

Regards,
Rudy Wieser


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


Re: Suggestions on mechanism or existing code - maintain persistence of file download history

2020-01-31 Thread Chris Angelico
On Fri, Jan 31, 2020 at 7:56 PM R.Wieser  wrote:
>
> Dennis,
>
> > A full client/server RDBM should never be affected by an abort
> > of a client program.
>
> What you describe is on the single query level.   What I was thinking of was
> having several queries that /should/ work as a single unit, but could get
> interrupted (because of the OPs ctrl-c).
>
> Yes, Chris was probably right about using a transaction to fix that, but
> that has to be learned - knowledge I do not take for granted with a
> hobbyist.
>

Do you also permit people to drive cars without knowing about the
handbrake? When you start using a database, you have to learn how to
speak its language (usually SQL). Transactions are part of that. What
is so hard about this? They're not some esoteric thing that only a few
people use. EVERY request to a PostgreSQL database (and many other
DBMSes) is part of a transaction, whether implicit or explicit.

I Googled "postgres python tutorial". The first hit was
https://www.postgresqltutorial.com/postgresql-python/ and it mentions
transactions in the very first section, on connecting to the database.

Second hit: https://pynative.com/python-postgresql-tutorial/ - the
word "transaction" comes up on the landing page, albeit part way down;
but the first example that does any mutation does use an explicit
commit.

I didn't check for SQLAlchemy but it's likely the same.

Use transactions. Learn them.

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


Re: Suggestions on mechanism or existing code - maintain persistence of file download history

2020-01-31 Thread R.Wieser
DL,

>> Nothing that can't be countered by keeping copies of the last X number of
>> to-be-dowloaded-URLs files.
>
> That's a good idea, but how would the automated system 'know' to give-up
> on the current file and utilise generation n-1? Unable to open the file or
> ???

Well, that would be one reason for it.   But there was also talk about
integrity checking, both on the file and URL-entry level.   Failing any of
that could trigger it.

But to be honest, I would not even automate it.   Such a situation should
not occur often, if at all.  So having it is cause for concern, and should
be investigated.   Instead I would give the user an error message, and offer
him the list of older files to choose one from to continue with (or have him
specify the file on the commandline).

> Using ctrl+c is a VERY BAD idea.

To have it just exit the program ?  Yes, indeed.

Though you /could/ keep track of what needs to be finished and have the
ctrl-c handler do that for you (barf).

Another posibility is to capture the ctrl-c and set a flag, which than
instructs the program to terminate loops wherever possible - and thus have
the program finish as if there was no more to do.

> (see also 'sledgehammer to crack a nut')

While I agree with you there, I've been searching for other ways to detect a
keypress (in a console-based script) and have found none.   IOW, you do not
(seem to) have another option.

> Why do you need to abandon the process mid-way?

Take your pick.Mostly because of "I need to leave *now*".   Or perhaps
because of an "you have X seconds before the device shuts down because of
the battery being low" situation.

> What is the OP's definition of "unlikely" or "acceptable risk"?

Good question, but one I had no wish for to try to ascertain.   I just gave
some "worst case" secenario based replies (aka, the "did you think of 
situation" kind).

> There are so many reasons why such won't work first-time, when they should
> every time; that it may be quite difficult to detect 'corruption'

:-) That was not even considered.  Just the "what do I still need to
download" datafile.

> Accordingly, there is no non-atomic transaction in the proposal

The problem there is that you are second-guessing to what the OP will be
writing, and that it will be good.   I didn't and I don't assume that.  I've
seen too much "it works, so its good" noobie code. :-)

> Do I want to deal with the complexities of managing files and corruptions,
> in that arena?
...
> Do you?

:-)   Its was-and-is not my choice to make.   I gave the OP some stuff to
think about, and left making the choice upto him.All three of the
presented options are viable.

> Be aware that formation rules for URLs are not congruent with OS FS rules!

Yup.   Though I seldom see that happen.  Though I guess I should have
mentioned that ... :-|

Regards,
Rudy Wieser



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


Re: Suggestions on mechanism or existing code - maintain persistence of file download history

2020-01-31 Thread R.Wieser
Dennis,

> A full client/server RDBM should never be affected by an abort
> of a client program.

What you describe is on the single query level.   What I was thinking of was 
having several queries that /should/ work as a single unit, but could get 
interrupted (because of the OPs ctrl-c).

Yes, Chris was probably right about using a transaction to fix that, but 
that has to be learned - knowledge I do not take for granted with a 
hobbyist.

> So... (And I know many despise it, but it IS easy to set up) that
> leaves running ...some ... server process.

I think that would make the matter even worse.  It could be silently doing 
some housekeeping work, and a hard shutdown of the 'puter (for whatever 
reason) could easily trash the whole database.

And yes, I'm playing the advocate of the devil there.   :-)

Regards,
Rudy Wieser


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