Since the question is less than 200, I used
b limit.
However, to have limit = 2, perhaps I should do
while b = limit.
Thanks Alan for pointing it out.
- Original Message -
From: Alan Gauld [EMAIL PROTECTED]
To: tutor@python.org
Date: Thu, 31 Jul 2008 06:39:32 +0100
Steve Poe wrote:
Hi tutor list,
In dictionaries, I know that the keys are immutable, and the values
can change What about the place/order of the key/order? I thought
that they were sequential and they do not change.
You were wrong :)
A lot of electronic ink has been spilt on this subject
Python dictionaries are not ordered the order you will get when you print
a dictionary is the order that the python virtual machines thinks optimal
for that dictionary for its own internal procedures.
___
Tutor maillist - Tutor@python.org
Hello,
I am using the following function to mixin in classes into specific object
instances (this is adapted from python-list written py J.Jacob
new-style-classes-mixin, Fri Aug 9 14:05:41 CEST 2002):
***
def
I'm looking for some thoughts on how two separate threads can
communicate in Python
You will probably get out of your doubts by reading about the
SocketServer module
and SocketServer.ThreadingTCPServer class.
Once your get a server up running you can run parallel threads, from
there you can
This is a great suggestion. I too learned how to do threading in
python from reading code. For me I read the btdownloadheadless.py
code. Which comes as part of the standard bittorrent client in linux.
On Thu, Jul 31, 2008 at 7:11 AM, Monika Jisswel
[EMAIL PROTECTED] wrote:
I'm looking for
Hi Everyone,
I am trying to read a comma-delimitted list (aaa,bbb,ccc) from a text
file and assign those values to a list, x, such that:
x = [aaa, bbb, ccc]
The code that I have come up with looks like this:
x = []
f = open(r'c:\test.txt', 'r')
x.extend(f.readlines())
x
['aaa,bbb,ccc']
If
On Thu, Jul 31, 2008 at 8:07 AM, S Python [EMAIL PROTECTED] wrote:
Hi Everyone,
I am trying to read a comma-delimitted list (aaa,bbb,ccc) from a text
file and assign those values to a list, x, such that:
x = [aaa, bbb, ccc]
The code that I have come up with looks like this:
x = []
f
If your list is in the format:
aaa,bbb,ccc
You can use
foo = in_file.readline.split(',')
--
Amin Rainmaker---BeginMessage---
Hi Everyone,
I am trying to read a comma-delimitted list (aaa,bbb,ccc) from a text
file and assign those values to a list, x, such that:
x = [aaa, bbb, ccc]
The code
This is what I'd use...
But it'd also be rather easy with regex...
Oh well.
Here:
f = open('intext', 'r')
foo = f.readline().strip().replace('','').split(',')
foo
['aaa', 'bbb', 'ccc']
Cheers
On 1/08/2008, at 1:49 AM, [EMAIL PROTECTED] wrote:
If your list is in the format:
aaa,bbb,ccc
Hello,
I am new to python this is the code I have written to download a file from
the internet and then send en email if any error occurs during download. I
just want know how to specify which folder to download my files. It
automatically downloads file to the directory where TEST1.txt sits...
S Python wrote:
Hi Everyone,
I am trying to read a comma-delimitted list (aaa,bbb,ccc)
In this case, the standard library provides csv for parsing comma
separated files. It's not the same as rolling your own, but it is made
specifically for this use case...
Emile
= csv.reader(open(some.csv, rb))
for row in reader:
print row
I yanked this straight out of the Python Reference Library :)
Thanks in advance.
Samir
-- next part --
An HTML attachment was scrubbed...
URL:
http://mail.python.org/pipermail/tutor/attachments/20080731
Emile is right, in python you can do most of the stuff yourself by hand
coding it, or you can use pre-made bullet proof and ready to go modules,
here you can go for the csv module that comes part of the standard library.
import csv
myfile = open('file', 'r') # open file for reading
data =
Monika Jisswel wrote:
Emile is right, in python you can do most of the stuff yourself by hand
coding it, or you can use pre-made bullet proof and ready to go modules,
here you can go for the csv module that comes part of the standard library.
Yes -- and you'll avoid the pitfalls of dealing
urllib.urlretrieve(url.strip(),save_to)
could be changed into this :
folder = '/home/html-data/'
urllib.urlretrieve(url.strip(),folder+save_to)
2008/7/31 swati jarial [EMAIL PROTECTED]
Hello,
I am new to python this is the code I have written to download a file from
the internet and
Hi Everyone,
Thanks for the variety of responses in such a short amount of time.
This distribution list is incredible.
Sorry for the delayed reply as I wanted to test what everyone
suggested, so here goes:
---
@Amin: I tried your suggestion, but perhaps I don't
oops it is reader not Reader (all lower case), so this line : data =
csv.Reader(myfile, delimeter = ',')
should be data = csv.reader(myfile, delimeter = ',')
2008/7/31 S Python [EMAIL PROTECTED]
Hi Everyone,
Thanks for the variety of responses in such a short amount of time.
This
Monika,
Thanks for your help. I got it to work using the following (also had
to spell delimiter):
import csv
myfile = open(r'c:\test.txt', 'r')
data = csv.reader(myfile, delimiter=',')
print data
_csv.reader object at 0x00D41870
for item in data:
print item
['aaa',
S Python wrote:
f = open(r'C:\test.txt', 'r')
foo = f.readline.split(',')
readline is the function/method name
readline() executes that function/method and returns a value
try typing in 'type(f.readline)' vs 'type(f.readline())'
you can't .split() a function but you may split its return
Emile is rigth, there should be a () there.
I'm sorry, im writing this from my cellphone and there's not a pc around XD.
I didn,t know about the csv module either and had to do over complicated things
to deal with embedded commas, thx for that too :).
--
Amin Rainmaker---BeginMessage---
S
Emile, Amin: Thank you both for your replies. I was able to get it
working using:
f = open(r'c:\test.txt', 'r')
foo = f.readline().split(',')
Samir
On Thu, Jul 31, 2008 at 3:00 PM, [EMAIL PROTECTED] wrote:
Emile is rigth, there should be a () there.
I'm sorry, im writing this from my
Kepala Pening wrote:
def sumEvenFibonacci( limit ):
a, b = 1, 1 # don't waste with a = 0
sum = 0
while b limit:
if b%2 == 0: sum += b
a, b = b, a + b
return sum
print sumEvenFibonacci( 200 )
Every 3rd element in the
Tomaz Bevec [EMAIL PROTECTED] wrote
I am using the following function to mixin in classes
into specific object instances ...
Is there an analogous way to Mixout classes from an instance at
runtime?
I'm sure it is possible but...
Are you just asking out of interest?
Or do you have a real
Kepala Pening [EMAIL PROTECTED] wrote
However, to have limit = 2, perhaps I should do
while b = limit.
Thanks Alan for pointing it out.
No probs, forgetting to test both ends of the range is a common
mistake.
In fact good testing practice says that for any range of values
you should test
Alan Gauld wrote:
W W [EMAIL PROTECTED] wrote
output = At an average weekly savings of $%.02f, your monthly
savings will
be $%.02f. \n Your annual savings will be $%.02f. % (diff,
monthly_savings,
annual_savings)
print output.
As you can see, it's very much longer than the 72 characters
Thanks for your reply Alan,
I am partially asking out of interest, but I also have a potential application.
I'm working on a simulation of cellular growth patterns (basically cell
instances interacting stochastically on a lattice). Anyway, there are many
different cell behaviors that I have
On Thu, Jul 31, 2008 at 8:09 PM, Tomaz Bevec [EMAIL PROTECTED] wrote:
Thanks for your reply Alan,
I am partially asking out of interest, but I also have a potential
application.
I'm working on a simulation of cellular growth patterns (basically cell
instances interacting stochastically on
On Thursday 31 July 2008 05:33, Monika Jisswel wrote:
Python dictionaries are not ordered the order you will get when you print
a dictionary is the order that the python virtual machines thinks optimal
for that dictionary for its own internal procedures.
If you need an ordered dictionary,
29 matches
Mail list logo