| | |
creating batch in python
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2006
Posts: 18
Reputation:
Solved Threads: 0
[code]
result=[]
list = int(raw_input("enter the length of list:"))
size_of_batch=int(raw_input("enter the size of batch:"))
def createBatch(lst):
lenLst = len(lst)
if lenLst > size_of_batch:
no_of_batch=lenLst/size_of_batch
last_entry_batch=lenLst%size_of_batch
first_index=0
last_index=size_of_batch
else:
no_of_batch=0
first_index=0
last_entry_batch=lenLst
newList = lst[0:last_entry_batch]
runChangeState(result,newList)
return
while no_of_batch != 0:
newList = lst[first_index:last_index]
runChangeState(result,newList)
first_index=first_index+size_of_batch
last_index=last_index+size_of_batch
no_of_batch = no_of_batch-1
if no_of_batch==0:
newList = lst[first_index:last_index]
runChangeState(result,newList)
def runChangeState(result,newList):
result.append(newList)
#return newList
createBatch(range(list))
for each in result:
print each
[inlinecode]
result=[]
list = int(raw_input("enter the length of list:"))
size_of_batch=int(raw_input("enter the size of batch:"))
def createBatch(lst):
lenLst = len(lst)
if lenLst > size_of_batch:
no_of_batch=lenLst/size_of_batch
last_entry_batch=lenLst%size_of_batch
first_index=0
last_index=size_of_batch
else:
no_of_batch=0
first_index=0
last_entry_batch=lenLst
newList = lst[0:last_entry_batch]
runChangeState(result,newList)
return
while no_of_batch != 0:
newList = lst[first_index:last_index]
runChangeState(result,newList)
first_index=first_index+size_of_batch
last_index=last_index+size_of_batch
no_of_batch = no_of_batch-1
if no_of_batch==0:
newList = lst[first_index:last_index]
runChangeState(result,newList)
def runChangeState(result,newList):
result.append(newList)
#return newList
createBatch(range(list))
for each in result:
print each
[inlinecode]
Best wishes,
Vivek Sharma
Zope/Python Developer
Vivek Sharma
Zope/Python Developer
Code tags are particularly important with Python code since they preserve the indentations. Without the proper indentations Python code becomes hard to read and understand!
I will show the needed tags in reverse so they don't activate:
at the end of your code add this tag [/code]
at the start of your code add tag [code=Python]
I will show the needed tags in reverse so they don't activate:
at the end of your code add this tag [/code]
at the start of your code add tag [code=Python]
May 'the Google' be with you!
![]() |
Similar Threads
- Creating a batch file to clear out Temp files (Windows NT / 2000 / XP)
- Creating batch files in windows xp (Windows NT / 2000 / XP)
- Creating Batch Files in WIndows XP (Windows NT / 2000 / XP)
- Create EXE to delete files in TEMP Directory (Windows NT / 2000 / XP)
Other Threads in the Python Forum
- Previous Thread: On a thumb drive.
- Next Thread: week from given year
Views: 1876 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Python
apache application argv beginner binary calculator character code command compile cursor cx-freeze development dictionaries dictionary dynamic error event examples excel file float format ftp function google gui homework ideas import input java keyboard launcher line linux list lists loop maze microphone mouse movingimageswithpygame newb number numbers obexftp output parsing path permissions phonebook port prime program programming projects py2exe pygame pygtk pyqt pysimplewizard python random recursion recursive refresh return reverse scrolledtext session shebang signal simple sprite ssh string strings table terminal text thread threading time tkinter tlapse trick tuple tutorial ubuntu unicode unit urllib urllib2 valueerror variable verify voip windows wxpython






