铁石 wrote:
>I am writing a resource manager like program !
> the files of directory is display on canvas and taged.
> the tag and file name is keep in a dictionary!
> The tag is a increaseing number from 1,so I build the
> dictionary like (1:file1,2:file2,..).
> While geting into another di
I get a list of repeated numbers [24, 24, 24, 16, 16, 15, 15 ]
Is possible get it without repeated numbers, without using set()?
If I use set, then the list is unsorted and i cann't sorting it.
For get the values i use:
[x[0] for x in cardTmp]
or:
from itertools import imap
for i in imap(lamb
Jonas Melian wrote:
> I get a list of repeated numbers [24, 24, 24, 16, 16, 15, 15 ]
> Is possible get it without repeated numbers, without using set()?
>
> If I use set, then the list is unsorted and i cann't sorting it.
>
> A idea it would be create a generator that will return elements one by
Hello,
The documentation says that the built-in join method now replaces the
string.joinfield function. However how do you achieve the same
operation? The join method accepts only one argument, that is, the
list of strings to join. How do you then specify the separating
character?
Thanks
Bernar
Oh. Thanks a lot for that, now that you told me, the doc about join
makes lot more sense!
Thanks
Bernard
On 8/23/05, Harper, Gina <[EMAIL PROTECTED]> wrote:
> Easy.
> Suppose you want to join a list of words with hyphens.
> >>> a_list = ['this', 'is', 'a', 'list', 'of', 'words']
> >>> sep_char
Bernard Lebel wrote:
> Hello,
>
> The documentation says that the built-in join method now replaces the
> string.joinfield function. However how do you achieve the same
> operation? The join method accepts only one argument, that is, the
> list of strings to join. How do you then specify the sepa
Easy.
Suppose you want to join a list of words with hyphens.
>>> a_list = ['this', 'is', 'a', 'list', 'of', 'words']
>>> sep_char = '-'
>>> print sep_char.join(a_list)
this-is-a-list-of-words
>>>
*g*
-Original Message-
From: Bernard Lebel [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August
Great, this is lots of good info. thanks everyone for your input!
JeffKent Johnson <[EMAIL PROTECTED]> wrote:
Jeff Peery wrote:> hello, can python read excel and access files? If so where do I go to > read about how this would work? thanks.There are some resources here that might be helpful:http:
On Tue, 23 Aug 2005, Terry Carroll wrote to Jonas:
> I don't know if you're in a position to rely on the sortedness of the
> input data, but even if not, this works:
>
> >>> l=[24, 24, 15, 16, 16, 15, 24]
> >>> l=sorted(list(set(l)), reverse=True)
> >>> l
> [24, 16, 15]
Sorry, I missed you were
On Tue, 23 Aug 2005, Jonas Melian wrote:
> I get a list of repeated numbers [24, 24, 24, 16, 16, 15, 15 ]
> Is possible get it without repeated numbers, without using set()?
>
> If I use set, then the list is unsorted and i cann't sorting it.
Converting it to a set will eliminate dupes, and con
I have extracted a list of names, i.e.
"Joe Smith"
"Joe Smith"
"Jack Smith"
"Sam Love"
"Joe Smith"
I need to be able to count the occurances of these names and I really
don't have any idea where to begin.
Any ideas? excuse me this is my first post to this list, I hope I
included enough inform
Terry Carroll wrote:
> Sorry, I missed you were on 2.3.x, and I think sorted() is new with 2.4.
> You'd instead have to do the sort in a separate step:
>
>
l=[24, 24, 15, 16, 16, 15, 24]
l=list(set(l))
l.sort(reverse=True)
l
>
> [24, 16, 15]
Actually the reverse parameter is n
Hi,
Suppose i have a string '347 liverpool street'.
I want to remove all the numbers coming at the starting of the string.
I can think of a few ways but whats the cleanest way to do it?
Shitiz__Do You Yahoo!?Tired of spam? Yahoo! Mail has the best
On 8/23/05, Shitiz Bansal <[EMAIL PROTECTED]> wrote:
> Hi,
> Suppose i have a string '347 liverpool street'.
> I want to remove all the numbers coming at the starting of the string.
> I can think of a few ways but whats the cleanest way to do it?
>
> Shitiz
>
I believe this question to be
Shitiz Bansal wrote:
> Hi,
> Suppose i have a string '347 liverpool street'.
> I want to remove all the numbers coming at the starting of the string.
> I can think of a few ways but whats the cleanest way to do it?
With str.lstrip():
>>> '347 liverpool street'.lstrip('0123456789')
' liverpool st
On 8/23/05, Scott Oertel <[EMAIL PROTECTED]> wrote:
> I have extracted a list of names, i.e.
>
> "Joe Smith"
> "Joe Smith"
> "Jack Smith"
> "Sam Love"
> "Joe Smith"
>
> I need to be able to count the occurances of these names and I really
> don't have any idea where to begin.
>
> Any ideas? exc
Luis N wrote:
>Ideally, you would put your names into a list or dictionary to make
>working with them easier. If all you're trying to do is count them
>(and your list of names is long), you might consider a dictionary
>which you would use like so:
>
>#This is just the first thing I considered.
>
>
Byron wrote:
Luis N wrote:
Ideally, you would put your names into a list or dictionary to make
working with them easier. If all you're trying to do is count them
(and your list of names is long), you might consider a dictionary
which you would use like so:
#This is just the first
Scott Oertel wrote:
Byron wrote:
Luis N wrote:
Ideally, you would put your names into a list or dictionary to make
working with them easier. If all you're trying to do is count them
(and your list of names is long), you might consider a dictionary
which you would us
Scott Oertel wrote:
Byron wrote:
Luis N wrote:
Ideally, you would put your names into a list or dictionary to make
working with them easier. If all you're trying to do is count them
(and your list of names is long), you might consider a dictionary
which you would us
I've done:
undup = []
for i in list:
if i not in undup:
undup.append(i)
Which is simple an not very pythonic, but does the trick.
Hugo
Jonas Melian wrote:
> I get a list of repeated numbers [24, 24, 24, 16, 16, 15, 15 ]
> Is possible get it without repeated numbers, without usi
>I have extracted a list of names, i.e.
>
> "Joe Smith"
> "Joe Smith"
> "Jack Smith"
> "Sam Love"
> "Joe Smith"
>
> I need to be able to count the occurances of these names and I
> really don't have any idea where to begin.
The classic way to do this kind of thing is with a dictionary:
names =
Scott Oertel wrote:
> The next problem I have though is creating the dict,
>
> i have a loop, but i can't figure out how to compile the dict, it is
> returning this: ('Joey Gale', ('Scott Joe', 'This is lame' )))
>
>
> listofnames = []
> while (cnt < number[1][0]):
> if (date[2] == today[2
Luis N wrote:
> Ideally, you would put your names into a list or dictionary to make
> working with them easier. If all you're trying to do is count them
> (and your list of names is long), you might consider a dictionary
> which you would use like so:
>
> #This is just the first thing I considered
Hi Scott,
The site ( http://www.greenteapress.com ) has a wonderful tutorial on it
for Python that quickly teaches one (within a few minutes) how to work
with dictionaries. I would highly recommend that you check it out.
It's well worth it...
Byron
_
Shitiz Bansal wrote:
> Hi,
> Suppose i have a string '347 liverpool street'.
> I want to remove all the numbers coming at the starting of the string.
> I can think of a few ways but whats the cleanest way to do it?
>
> Shitiz
Here's a function that can do what you're wanting to accomplish:
By
I have imported a text file consisting of lines of csv. Each line
consists of six items separated by commas. I have converted this file
into a matrix of string variables, T[i]. Now I want to extract each of
the individual strings, convert five them to floats, and save them in
individual vectors
On Tue, 23 Aug 2005, Kent Johnson wrote:
> Actually the reverse parameter is new in 2.4 too, you have to do that in
> a separate step also:
Doh!
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
On Tue, 23 Aug 2005, Tom Strickland wrote:
> I have imported a text file consisting of lines of csv.
[problem statement cut]
> Python doesn't like the ways I've attempted to make these assignments.
Do you mind if you show us what you've tried so far?
Also, show us the exact syntax error and
> Suppose i have a string '347 liverpool street'.
> I want to remove all the numbers coming at the starting of the
> string.
> I can think of a few ways but whats the cleanest way to do it?
If you know they are always a contiguous string themn a simple split()
call will do it:
s = ' '.join(s.sp
Alan G wrote:
>>Suppose i have a string '347 liverpool street'.
>>I want to remove all the numbers coming at the starting of the
>>string.
>>I can think of a few ways but whats the cleanest way to do it?
>
>
> If you know they are always a contiguous string themn a simple split()
> call will do
listofnames = nameofsender[0], listofnames
does not add a name to a list. Rather it creates a tuple of the new
name and the list and then binds the tuple to the list name. That's why
you wind up with the lisp style list.
To add a name to the head of the list use
listofnames.insert(0, na
[Forwarding to Tutor; next time, please also use Reply-to-All in your
email client. That way, everyone can help.]
-- Forwarded message --
Date: Tue, 23 Aug 2005 17:19:43 -0500
From: Tom Strickland <[EMAIL PROTECTED]>
To: Danny Yoo <[EMAIL PROTECTED]>
Subject: Re: [Tutor] Need He
Hi Tom,
Before we continue: it looks like you're starting to learn Python. Have
you gone through one of the tutorials here?
http://wiki.python.org/moin/BeginnersGuide/NonProgrammers
Alan Gauld's tutorial is especially nice, but all of the tutorials there
should be useful. If you go throug
Danny,
Thanks for your comments and your help. I've added my comments to your
text below. Hopefully it will be in red so you can easily identify them.
Tom
Danny Yoo wrote:
>Hi Tom,
>
>Before we continue: it looks like you're starting to learn Python. Have
>you gone through one of the tutorial
[Danny]
> >Anyway, this doesn't answer the problem: how do we add elements to a
> >list? In Python, we can accumulate elements in a list by append()ing:
[code cut]
[Tom]
> So, for example, would I use the following in my "while" loop:
>
> date.append(T[N][0])
>
> Before th
Danny,
I changed the program in accordance with your advice and it now runs
perfectly!!!
Thanks for the education!
Tom Strickland
Danny Yoo wrote:
>[Danny]
>
>
>>>Anyway, this doesn't answer the problem: how do we add elements to a
>>>list? In Python, we can accumulate elements in a list by
On Tue, 23 Aug 2005, Tom Strickland wrote:
> I changed the program in accordance with your advice and it now runs
> perfectly!!!
Hi Tom,
That's very good to hear; glad it's working now.
If you don't mind, can you post up what you have now? I left out some
other suggestions to the program bec
Danny,
Here's the working program.
Tom
*
#!/usr/bin/python2.4
input = open('/home/tom/Python/Input/SPY3.txt', 'r')
N=0
s = 'boo'
date =[]
T = [0,0,0,0,0,0] #don't know why this is necessary
ope
>You can use the itemcget() method of the canvas to retrieve the text:
>
> >>> root = Tk()
> >>> canvas=Canvas(root)
> >>> t=canvas.create_text(10, 10, text='Hello', tag='1')
> >>> canvas.pack()
> >>> canvas.itemcget('1', 'text')
>'Hello'
>
>There does seem to be something strange with reusing the
> input = open('/home/tom/Python/Input/SPY3.txt', 'r')
> N=0
> s = 'boo'
> date =[]
> T = [0,0,0,0,0,0] #don't know why this is necessary
^
Ok, let's talk about that comment there. Why six zeros?
__
41 matches
Mail list logo