Modulok wrote:
> if number <= 10 and number >= 1:
I like that you can spell that
if 1 <= number <= 10:
in Python.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
Hi,
I have a question regarding the TypeError.
I have this script as follows in Python. I have run a program in Fortran:
# coding: utf-8
from pylab import *
import numpy
import matplotlib.pyplot as pyplot
import matplotlib.mlab as mlab
t=3600
N = 100
dz = 1.0
with open("act_out.list", "r") as
stm atoc wrote:
> Hi,
>
> I have a question regarding the TypeError.
>
> I have this script as follows in Python. I have run a program in Fortran:
>
> # coding: utf-8
> from pylab import *
> import numpy
> import matplotlib.pyplot as pyplot
> import matplotlib.mlab as mlab
>
> t=3600
> N = 100
Hi,
I am trying to create a chat program.(Programs are attached)
Please find the code below, where I am having the problem.
def run( self ):
while 1:
print "Hello There "
print self.descriptors
# Await an event on a readable socket descriptor
(srea
Hi all,
I want to build a small download accelerator program. I want to know how to
split the file to be downloaded into small pieces and assign the each small
piece to a thread for downloading.
--
Thanks & Regards,
Arun Kumar
http://clicknscroll.blogspot.com
Hello,
My code is -
l = len(m)
item = str(m[1])
for i in range(2,l):
item = item + "-" + str(m[i])
This code is part of a bigger function. It works fine. But I am not happy
with the way I have written it. I think there is a better (Pythonic) way to
rewrite it.
If anyone knows how to improve
spa...@gmail.com wrote:
Hello,
My code is -
l = len(m)
item = str(m[1])
for i in range(2,l):
item = item + "-" + str(m[i])
This code is part of a bigger function. It works fine. But I am not happy
with the way I have written it. I think there is a better (Pythonic) way to
rewrite it.
If an
Hi Arun,
On 26 January 2012 21:27, Arun Kumar wrote:
> I want to build a small download accelerator program. I want to know how to
> split the file to be downloaded into small pieces and assign the each small
> piece to a thread for downloading.
OK, so what else have you tried and what are you h
Exercise 17, extra credit 6 Learn python the hard way: Find out why
you had to do output.close() in the code.
Code:
from sys import argv
from os.path import exists
script, from_file, to_file = argv
print "Copying from %s to %s" % (from_file, to_file)
input = open(from_file)
indata = input.rea
On 1/26/12 3:20 PM, amt wrote:
Exercise 17, extra credit 6 Learn python the hard way: Find out why
you had to do output.close() in the code.
Code:
output.close()
input.close()
I don't get it. If you don't close input and output it works exactly
the same as if you would close them, so why do
>> Exercise 17, extra credit 6 Learn python the hard way: Find out why
>> you had to do output.close() in the code.
>>
>>
>> Code:
>>
>> output.close()
>> input.close()
>>
>>
>> I don't get it. If you don't close input and output it works exactly
>> the same as if you would close them, so why
On 01/26/2012 06:20 PM, amt wrote:
Exercise 17, extra credit 6 Learn python the hard way: Find out why
you had to do output.close() in the code.
Code:
from sys import argv
from os.path import exists
script, from_file, to_file = argv
print "Copying from %s to %s" % (from_file, to_file)
input
amt wrote:
I don't get it. If you don't close input and output it works exactly
the same as if you would close them, so why do you have to do
output.close() and input.close()?
(1) It is a matter of good programming practice. If you don't close them
yourself, Python will eventually close them
Hi All,
I had a question regarding installing packages that I posted a couple
of days ago. But I'm re-sending the question again.. this time with
output so that it is clearer.
I am unable to install libraries using 'python setup.py install'
Say that I'm installing a package "kando". I extr
On 26/01/12 23:20, amt wrote:
input = open(from_file)
indata = input.read()
...
output = open(to_file, 'w')
output.write(indata)
print "Alright, all done."
output.close()
input.close()
I don't get it. If you don't close input and output it works exactly
the same as if you would close them,
Hello Steven,
Thanks a lot for the detailed answer. I will implement your suggestions.
Really appreciate it.
Thanks and Regards,
Sumod
On Fri, Jan 27, 2012 at 4:34 AM, Steven D'Aprano wrote:
> spa...@gmail.com wrote:
>
>> Hello,
>>
>> My code is -
>>
>> l = len(m)
>> item = str(m[1])
>> for i i
Hi Steven,
> (5) When assembling strings from substrings, never use repeated concatenation
> using + as that can be EXTREMELY slow. Use str.join to build the string in
> one assignment, instead of multiple assignments.
>
> Your code shown above is *very* inefficient and will be PAINFULLY slow i
Alan Gauld, 27.01.2012 02:16:
> with open(myfile) as aFile:
> # use aFile
I should add that this is the shortest, safest (as in "hard to get wrong")
and most readable way to open and close a file. It's worth getting used to.
Stefan
___
Tutor maill
18 matches
Mail list logo