Re: [Tutor] Fwd: glob and file names

2014-06-06 Thread Peter Otten
Gabriele Brambilla wrote:

 2014-06-05 22:10 GMT-04:00 Peter Romfeld peter.romfeld...@gmail.com:
 
 On Friday, June 06, 2014 10:04 AM, Gabriele Brambilla wrote:

 fiLUMOname = 'Lsum_' + period + '_' + parts[2] + '_' + parts[3] + '_'
 + parts[4] + '_*.dat'

 aaa = glob.glob(fiLUMOname)
 print(aaa)
 fiLUMO = open(aaa[0], 'r')

 i would do:

 aaa = glob.glob('Lsum_%s_%s_%s_%s_*.dat' % (period, parts[2], parts[3],
 parts[4]))
 
 thanks, it works.

While Peter's way may be easier to read both approaches should give you the 
same result, assuming 'period' and the items in the 'parts' list are all 
strings. There must be an accidental change elsewhere -- maybe you changed 
the current working directory before invoking the script?

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fwd: glob and file names

2014-06-06 Thread Gabriele Brambilla
oh yes! I had a problem inside the file name! (I had a lot of file to open
and I changed the one I was looking at!the one I was trying to open has a
wrong filename...)

Sorry for the misunderstanding.

Gabriele


2014-06-06 3:05 GMT-04:00 Peter Otten __pete...@web.de:

 Gabriele Brambilla wrote:

  2014-06-05 22:10 GMT-04:00 Peter Romfeld peter.romfeld...@gmail.com:
 
  On Friday, June 06, 2014 10:04 AM, Gabriele Brambilla wrote:
 
  fiLUMOname = 'Lsum_' + period + '_' + parts[2] + '_' + parts[3] + '_'
  + parts[4] + '_*.dat'
 
  aaa = glob.glob(fiLUMOname)
  print(aaa)
  fiLUMO = open(aaa[0], 'r')
 
  i would do:
 
  aaa = glob.glob('Lsum_%s_%s_%s_%s_*.dat' % (period, parts[2], parts[3],
  parts[4]))
 
  thanks, it works.

 While Peter's way may be easier to read both approaches should give you the
 same result, assuming 'period' and the items in the 'parts' list are all
 strings. There must be an accidental change elsewhere -- maybe you changed
 the current working directory before invoking the script?

 ___
 Tutor maillist  -  Tutor@python.org
 To unsubscribe or change subscription options:
 https://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] idlex

2014-06-06 Thread Mark Lawrence
I'd never heard of this until today so thought I'd flag it up for the 
benefit of anybody who might be interested.  It's at 
http://idlex.sourceforge.net/


Quoting from the site IdleX is a collection of over twenty extensions 
and plugins that provide additional functionality to IDLE, a Python IDE 
provided in the standard library. It transforms IDLE into a more useful 
tool for academic research and development as well as exploratory 
programming..


It's available from pypi via easy_install or pip.

--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] idlex

2014-06-06 Thread Alan Gauld

On 06/06/14 23:13, Mark Lawrence wrote:

I'd never heard of this until today so thought I'd flag it up for the
benefit of anybody who might be interested.  It's at
http://idlex.sourceforge.net/



IdleX is cool. They've been trying to get many of the
features incorporated into core Idle for years. I don't
follow the discussion closely enough to understand why
there is so much reluctance to do so. So far as I can
tell all the changes are good!

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Pease help

2014-06-06 Thread Glen Chan
Hello I am a student trying to figure out this program. Here is my objective 
and program below. What am I doing wrong? I can't get this to work.
 



Calculate the average pints of
blood donated during a blood drive.  The
program should take in the number of pints donated during the drive, based on a
seven hour drive period.  The average
pints donated during that period should be calculated and written to a
file.  Write a loop around the program to
run multiple times.  The data should be
appended to the file to keep track of multiple days.  If the user wants to 
print data from the
file, read it in and then display it. 
Store the pints per hour and the average pints donated in a file called
blood.txt.  





 #the
main function

def
main():


  endProgram = 'no'


  print


  while endProgram == 'no':


option = 0


print


print 'Enter 1 to enter in new data and
store to file'


print 'Enter 2 to display data from the
file'


option = input('Enter now -')


print


 
# declare variables

pints = [0] * 7


totalPints = 0


averagePints = 0


if option == 1:



  # function calls

  pints = getPints(pints)


  totalPints = getTotal(pints, totalPints)


  averagePints = getAverage(totalPints,
averagePints)


  
else:


endProgram = raw_input('Do you want to end
program? (Enter no or yes): ')


while not (endProgram == 'yes' or
endProgram == 'no'):

  print 'Please enter a yes or no'


  endProgram = raw_input('Do you want to
end program? (Enter no or yes): ')



 #the
getPints function

def
getPints(pints):


  counter = 0


  while counter  7:


  pints[counter] = input('Enter pints
collected: ')


  counter = counter + 1


  return pints


 
#the
getTotal function

def
getTotal(pints, totalPints):


  counter = 0


  while counter  7:


totalPints = totalPints + pints[counter]


counter = counter + 1


  return totalPints



 #the
getAverage function

def
getAverage(totalPints, averagePints):


  averagePints = float(totalPints) / 7


  return averagePints






#the
writeToFile function

def
writeToFile(averagePints, pints):





#the
readFromFile function


 def readFromFile(averagePints, pints):



#
calls main


main()


  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor