Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use errno?
#11
With respect to rotating files you may find useful RotatingFileHandler from logging module. Sort of easy to implement solution.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#12
(Oct-04-2018, 01:38 AM)bkpsusmitaa Wrote: Your very sentence says that Smile we could use if-else.
if/elif is much different than try/except. If a condition in the if clause breaks, the program crashes, whereas a program breaking condition in the try clause, just moves control to the except block.

It seems nilamo answered your question. I am not sure what else you are asking either? Your responses are way too wordy that drowns everything else out. You have no explicit questions in your responses. Questions require question marks. Punctuation matters. The only one i see is the OP
Quote:Is there no other way than using try:?
It also sounds like English is not your native language which doesnt help either. Sometimes a shorter response gives more detail than a long one.

Please read this
https://python-forum.io/misc.php?action=help&hid=19

Also please dont use Google drive. Just post the code here on the forums...especially since they are only 20 or so lines each. That leads me to another issue. You should be able to represent your problem in 20 lines or less.

Quote:Just direct me enough to look at the Python References and Manuals and some example codes. i would pick up the rest. If i can't, i shall ask for your suggestions. You shall provide me with only bare minimum guidance / links as i require. But never, complete lines.
Im not sure what you are trying to accomplish here. This sounds more rude leading to people not wanting to help you.

im going to lay out your code here so people can easily read it
useChklIfPrime.py
#! /usr/bin/python

import primey

inputFile = open ('testNum.txt', 'r')
numChk = inputFile.read(100)
numChk = int(numChk)
answer = primey.checkIfPrime(numChk)
inputFile.close()
testNum.txt
23457311
primey.py
#!/usr/bin/python
import os
import errno

def checkIfPrime (numberToCheck):
      for x in range(2, ((numberToCheck)//2)):
            f = open ('outPrime.txt', 'a')
            #print(x)
            f.write(str(x)+'\n')
            f.close()
            
            if (numberToCheck%x == 0):
                  return False
      return True
numDone.txt
354520
354521
354522
354523
354524
354525
354526
354527
354528
354529
354530
354531
354532
354533
354534
354535
354536
354537
354538
354539
354540
...
dskMgmt.py
#! /usr/bin/python
import os
import errno

inputFile = open ('testNum.txt', 'r')
numChk = inputFile.read(100)
numChk = int(numChk)

num = numChk//2
print(num)
for i in range(num): 
	try:
		fileInfo = os.stat('outPrime.txt')
		dataSize = int((fileInfo.st_size)/10240)
		dataSize = int(dataSize)
		if dataSize > 10:		
			os.rename('outPrime.txt','numDone.txt')
			print(dataSize)

	except Exception as e:
		f = open('outPrime.txt','w')
		f.close
Recommended Tutorials:
Reply
#13
(Oct-04-2018, 04:04 PM)micseydel Wrote: ... I'm not clear on what the question is ...
Yes, sir. I do understand that I failed to make myself clearer. I apologise, Sir.

(Oct-04-2018, 04:04 PM)micseydel Wrote: ... and describe the goal rather than the step (the step here is errno) ...
Yes, Sir. I will remember.

The following post was marked Liked. Larz60+, metulburr, volcano63 like this post
(Oct-04-2018, 04:09 PM)nilamo Wrote: ... All that said, it looks like the original question was answered ...
Yes, Sir. The original question, How to use errno? has truly been answered.

(Oct-04-2018, 04:09 PM)nilamo Wrote: ... please explain what problem you're trying to solve, what you've tried, and what errors you're getting ...
I tried my best, Sir, Mr. Nilamo, given the time constraint I had. I seek your apology for appearing ambiguous. It was not my intent, Sir.

(Oct-04-2018, 04:09 PM)nilamo Wrote: ... Otherwise, it looks like this thread is devolving into troll territory, and it'll be locked if we continue in that direction ...
Yes, sir, I admit it is time to end this thread.

(Oct-04-2018, 05:20 PM)buran Wrote: With respect to rotating files you may find useful ... Sort of easy to implement solution ...
Thank you, Sir, for your kind suggestion.

(Oct-04-2018, 06:02 PM)metulburr Wrote: ... if/elif is much different than try/except. If a condition in the if clause breaks, the program crashes, whereas a program breaking condition in the try clause, just moves control to the except block ...
Yes, Sir. I re-read the portions in the book and understood the point, Sir, Mr. Metulburr. Thank you. I used the for loop before try-except to loop the lines.

(Oct-04-2018, 06:02 PM)metulburr Wrote: ...It seems nilamo answered your question.
Yes, Sir, Mr. Metulburr, he has.

(Oct-04-2018, 06:02 PM)metulburr Wrote: ...I am not sure what else you are asking either? Your responses are way too wordy that drowns everything else out. You have no explicit questions in your responses. Questions require question marks. Punctuation matters. The only one i see is the OP
Yes, sir, Mr. Metulburr, i do admit that at times, I have been a little blurry.

(Oct-04-2018, 06:02 PM)metulburr Wrote: ...It also sounds like (appears that) English is not your native language, which doesnt help either. Sometimes, a shorter response gives more detail (is better) than a long one ...
Okay, Sir. I am trying to think aloud and re-construct your sentences to have a better understanding, Sir. Yes, Sir, I understand my limitations. Please consider overlooking my drawbacks and forgive my incompetence, Sir.

(Oct-04-2018, 06:02 PM)metulburr Wrote: Please read this
https://python-forum.io/misc.php?action=help&hid=19...
Yes, Sir. Read again, Sir, Mr. Metulburr.

(Oct-04-2018, 06:02 PM)metulburr Wrote: ... Also please dont use Google drive. Just post the code here on the forums ...
Okay, Sir. Point noted and will be remembered, Mr. Metulburr. Thank you for pointing out a guideline.

(Oct-04-2018, 06:02 PM)metulburr Wrote: ... That leads me to another issue. You should be able to represent your problem in 20 lines or less ...
Okay, Sir. Point noted, Sir, Mr. Metulburr.

(Oct-04-2018, 06:02 PM)metulburr Wrote: ... Im not sure what you are trying to accomplish here. This sounds more rude leading to people not wanting to help you ...
I truly am sorry, Sir, in this regard. I would like to repeat my concerned passage. I do note that some places lacked a please to appear gentler. I apologise, Sir.

(Oct-04-2018, 04:11 AM)bkpsusmitaa Wrote: Of course, Sir, Mr. buran. i definitely will. But you have to (to be inserted: please) assure me that you and the other experienced and senior members won't give me the lines directly. But you won't be superficial either, advising to "Go read the Manual".
(to be inserted: please) Just direct me enough to look at the Python References and Manuals and some example codes. i would pick up the rest. If i can't, i shall ask for your suggestions. You shall (to be inserted: please)provide me with only bare minimum guidance / links as i require. But (to be inserted: please), never, complete lines.
I truly apologise for the rude lines. It wasn't my intent to appear rude.

(Oct-04-2018, 06:02 PM)metulburr Wrote: ... Im not sure what you are trying to accomplish here. This sounds more rude leading to people not wanting to help you ...
Yes, sir, considering my corrections to my earlier post, it began to dawn on me that I have appeared to be rude to my supportive community. In the meanwhile, I have also observed that my reputation has gone down by one integral value, Sir. I realise that I truly deserve the value reduction, to have tried too hard to achieve quite a bit within one question, Sir.

Thank you very much, all of you, sirs. I learnt a lot about socialising with programmers, by interacting with you all on this forum. Thank you once again for answering my questions without fully understanding what they really meant.
Freedom is impossible to conceive.
Books that help:
Dale Carnegie's How To Win Friends And Influence People and Emilie Post's Etiquette In Society, In Business, In Politics, And At Home
Have a good day :)
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020