Srinivas Iyyer wrote:
Thank you Bob for your email.
Sorry for the confusion.
here is what I ment:
test = ['10\t15', '16\t20', '25\t35', '45\t50',
'55\t60', '61\t65', '75\t80']
I would get:
10 20
25 35
45 50
55 65
75 80
Here is my take on it:
test =
Dear group:
I have a data like this:
10 15
16 20
25 35
45 50
55 60
61 65
75 80
Since 15 precedes 16, I want to consider 10:20 as one
unit. If I repeat completely for data
I would get:
10 20
25 35
45 50
55 65
75 80
test = ['10\t15',
Srinivas Iyyer wrote:
Dear group:
I have a data like this:
10 15
16 20
25 35
45 50
55 60
61 65
75 80
Since 15 precedes 16, I want to consider 10:20 as one
unit. If I repeat completely for data
I would get:
10 20
25 35
45 50
55
Thank you Bob for your email.
Sorry for the confusion.
here is what I ment:
test = ['10\t15', '16\t20', '25\t35', '45\t50',
'55\t60', '61\t65', '75\t80']
x = []
y = []
for m in test:
... cols = m.split('\t')
... x.append(cols[0])
... y.append(cols[1])
...
x
['10', '16', '25',
try this:
test = ['10\t15', '16\t20', '25\t35', '45\t50','55\t60', '61\t65',
'75\t80']
t='\t'.join(test).split('\t')
t
['10', '15', '16', '20', '25', '35', '45', '50', '55', '60', '61', '65',
'75', '80']
t2=[int(i) for i in t]
t2
[10, 15, 16, 20, 25, 35, 45, 50, 55, 60, 61, 65, 75,
I am using Tk and
have a series of Radio buttons that I want to bind to it's own listboxfor
further selection.
I just don't get
the point how to click the button and select the proper listbox I want it tied
too.
Joe Cox513-293-4830
mobile[EMAIL PROTECTED]
Joe Cox wrote:
I am using Tk and have a series of Radio buttons that I want to bind
to it's own listbox for further selection.
I just don't get the point how to click the button and select the
proper listbox I want it tied too.
Do you mean you want clicking on the radio button to enable a
I just thumped my head against the wall for a few hours on something,
and I was wondering if it's just my green-ness in Python, or if I'm
doing something unsavory.
I had several list comprehensions that I was mucking with; these lists
are working on a simple subclass of the built-in list object.
On 3 Apr 2006, [EMAIL PROTECTED] wrote:
I had several list comprehensions that I was mucking with; these lists
are working on a simple subclass of the built-in list object. They
looked liked this:
filelist = getFilesToAdd()
filelist2 = getFilesToDel()
adds = MyList('foo')
dels =
stv wrote:
# return all changes, deletes first
return dels.extend(adds)
Since extend returns None, I ran into a lot of not-iterable errors
when calling this code. So I fixed this with
dels.extend(adds)
return dels
And all is good, although it took way more head scratching than
So don't write:
[adds.add_changes('foo', path) for path in filelist]
but:
for path in filelist: adds.add_changes('foo', path)
Excellent point; new toy, got carrid away :) I feel silly on that one.
And now that I've made the
return list.extend(foo)
mistake, I'll surely neve- ... er, wait
kevin parks wrote:
John,
Thanks... i am liking this variation a tad more since it means i only
have to type the path in one place but it is akin to your second
one... i was (still am really) having a hard time understanding
how to apply path.join _and_ listdir sometimes list
howdy,
I am using the os module to do some of my heavy lifting for me. I am
tried of building lists
by hand so i decided that i would get python to look in a bunch of
directories and stuff all the things it
find there into a list depending on it's extension.
Works great ... one problem
On 27/02/06, kevin parks [EMAIL PROTECTED] wrote:
snd = [f for f in os.listdir('/Users/kevin/snd/') if f.endswith('.aif')]
If this is all you need, then you could do something like:
snd = ['/Users/kevin/snd/%s' % f for f in
os.listdir('/Users/kevin/snd/') if f.endswith('.aif')]
Or, slightly
John Fouhy wrote:
On 27/02/06, kevin parks [EMAIL PROTECTED] wrote:
snd = [f for f in os.listdir('/Users/kevin/snd/') if f.endswith('.aif')]
If this is all you need, then you could do something like:
snd = ['/Users/kevin/snd/%s' % f for f in
os.listdir('/Users/kevin/snd/') if
On 2/3/06, Chris or Leslie Smith [EMAIL PROTECTED] wrote:
Rinzwind wrote:
| Well Chris or Leslie Smith.
|
| This bit l[:]=l[-1:]+l[0:-1] I think is VERY elegant. When I saw this
| in your post I tought: DUH.
| I did the same with 1 line more but I am still new to python ;)
|
You're seeing
On 2/3/06, Chris or Leslie Smith [EMAIL PROTECTED] wrote:
Others could give you a really good answer. I am a BASIC/FORTRAN writer
myself, and getting used to the *object* orientation of python took a little
while, but after you get the hang of it, it's not bad. In BASIC you think of
variables
On 2/3/06, Kent Johnson [EMAIL PROTECTED] wrote:
On 2/3/06, Chris or Leslie Smith [EMAIL PROTECTED] wrote:Others could give you a really good answer. I am a BASIC/FORTRAN writer
myself, and getting used to the *object* orientation of python took a little
while, but after you get the hang of it,
Rinzwind wrote:
On 2/3/06, *Kent Johnson* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
wrote:
You definitely have to stop thinking of variables as containers. They
are pointers or references to values. Another way to think of this is
that variables are names for things. You may
But this assignment sort of puzzles me to why it's done like this
(maybe cuz I am not used to it and can not see beyond my own
experience in coding (having a blind spot or something like that)).
If we have a snippet of code like:
###
def test():
x = []
f(x)
print x
Hello,
was just trying to do something and tried the following code:
list = [1, test, 1.5]
for x in list:
print list.pop(x)
I get the following error:
print list.pop(x)
TypeError: an integer is required
Does this mean i can't use a for loop to pop things from a list? or is
On Thu, 2 Feb 2006, Michael Haft wrote:
was just trying to do something and tried the following code:
list = [1, test, 1.5]
for x in list:
print list.pop(x)
I get the following error:
print list.pop(x)
TypeError: an integer is required
Hi Michael,
The error message
| Hello,
| was just trying to do something and tried the following code:
|
| list = [1, test, 1.5]
|
| for x in list:
| print list.pop(x)
|
| I get the following error:
|
| print list.pop(x)
| TypeError: an integer is required
|
| Does this mean i can't use a for loop to pop
What purpose does list.__init__() play in the piece of
code below?
class Mylist(list):
def __init__(self, value = []):
list.__init__([])
self.concat(value)
def concat(self, value):
for x in value:
if not x in
Christopher Spears wrote:
What purpose does list.__init__() play in the piece of
code below?
It's an incorrect call to the base class __init__() function. This does
base class initialization on the current list. The correct call is
list.__init__(self)
By the way this list seems to be doing
On 19/12/05, Øyvind [EMAIL PROTECTED] wrote:
I have one function that finds some values. Then I want that function to
find new values based on the values it found first. However, by just
looping, it starts on an eternal job.
As illustrated in:
list = [1,2,3]
list2 = list
list2
[1, 2,
Hi,
I'd like to form a list of class instances. The following does not work
(TextfieldLong, Textarea, TextfieldShort etc being class names):
fields = [
TextfieldLong(name='title', label='Seitentitel', value=''),
Textarea(name='content', label='Inhalt', value=''),
Hi,
Jan Eden wrote on 20.09.2005:
Hi,
I'd like to form a list of class instances. The following does not work
(TextfieldLong, Textarea, TextfieldShort etc being class names):
fields = [
TextfieldLong(name='title', label='Seitentitel', value=''),
Textarea(name='content',
Jan Eden wrote:
I'd like to form a list of class instances. The following does not work
(TextfieldLong, Textarea, TextfieldShort etc being class names):
fields = [
TextfieldLong(name='title', label='Seitentitel', value=''),
Textarea(name='content', label='Inhalt', value=''),
Hi,
Orri Ganel wrote on 20.09.2005:
As a side-note, unless you're okay with only being able to access
those instance variables through the fields list (ie fields[0],
fields[1], fields[2]), you may want to actually name them first.
Yes, I am fine with that - I actually prefer to have a sorted
I'm using Python 2.3 in Win32/WinXP context.
I'm new at all to newsgroups and discussion lists; the
first help I need, is how to learn good-manner use
of such very effective, but time-consuming tools. My
approach will be a try-and-error one; I encourage
all of you to send me any
Hi Shidan!
on Wed, 22 Jun 2005 00:28:44 -0400 Shidan [EMAIL PROTECTED] wrote :
-
Shidan Hi I have a list of regular expression patterns like such:
Shidan
Shidan thelist =
for pattern in thelist:
regex=re.compile(pattern)
if regex.match('24110'):
the_pattern = pattern
.
.
sys.exit(0)
but in this case it will pick thelist[2] and not the list[3] as I
wanted to,
how can I have it pick the pattern that describes it better from
On Wed, 22 Jun 2005, Shidan wrote:
Hi I have a list of regular expression patterns like such:
thelist = ['^594694.*','^689.*','^241.*',
'^241(0[3-9]|1[0145]|2[0-9]|3[0-9]|41|5[1-37]|6[138]|75|8[014579]).*']
Now I want to iterate thru each of these like:
for pattern in thelist:
Hi I have a list of regular expression patterns like such:
thelist =
['^594694.*','^689.*','^241.*','^241(0[3-9]|1[0145]|2[0-9]|3[0-9]|41|5[1-37]|6[138]|75|8[014579]).*']
Now I want to iterate thru each of these like:
for pattern in thelist:
regex=re.compile(pattern)
if
Hi,
I have a load of files I need to process. Each line of a file looks
something like this:
eYAL001C1 Spar81 3419451845192 1
So basically its a table, separated with tabs. What I need to do is make a
new file where all the entries in the table are
On 1 Jun 2005 [EMAIL PROTECTED] wrote:
I have a load of files I need to process.
[text cut]
So basically its a table, separated with tabs. What I need to do is make
a new file where all the entries in the table are those where the values
in columns 1 and 5 were present as a pair more than
On 1 Jun 2005 [EMAIL PROTECTED] wrote:
eYAL001C1 Spar81 3419451845192 1
So basically its a table, separated with tabs. What I need to do is make
a new file where all the entries in the table are those where the values
in columns 1 and 5 were present as
[EMAIL PROTECTED] wrote:
Hi,
I have a load of files I need to process. Each line of a file looks
something like this:
eYAL001C1 Spar81 3419451845192 1
So basically its a table, separated with tabs. What I need to do is make a
new file where all
I have a load of files I need to process. Each line of a file looks
something like this:
eYAL001C1 Spar 81 3419 4518 4519 2 1
So basically its a table, separated with tabs. What I need to do is
make a
new file where all the entries in the table are those where the
values in
columns 1 and 5
Hi,
Is there a way to apply multiple actions within one list comprehension?
i.e. instead of
a = []
for i in x:
i.pop(3)
g = [ int(item) for item in i]
a.append(g)
Is there any guides to this (possibly obtuse) tool?
Regards,
Liam Clarke
PS I can see how nested list
Clarke
Sent: Wednesday, March 23, 2005 5:44 AM
To: Tutor Tutor
Subject: [Tutor] List comprehensions
Hi,
Is there a way to apply multiple actions within one list comprehension?
i.e. instead of
a = []
for i in x:
i.pop(3)
g = [ int(item) for item in i]
a.append(g)
Is there any guides
Liam Clarke wrote:
Is there any guides to this (possibly obtuse) tool?
Think of it this way. A list comprehension generates a new list. So, you
should think about list comps whenever you have old_list - new_list
style behavior.
There are two advantages to list comps over map:
1) a list comp can
Liam Clarke wrote:
Is there any guides to this (possibly obtuse) tool?
http://docs.python.org/tut/node7.html#SECTION00714
http://www.amk.ca/python/2.0/index.html#SECTION00060
Kent
___
Tutor maillist - Tutor@python.org
Ryan Davis wrote:
I think map is a little cleaner is some cases. Not sure if its more Pythonic,
I'm still trying to figure out exactly what that
means.
map is (probably) going to be removed in Python3000 :-( So it's
probably better to not get into the habit of using it.
--
John.
Kent Johnson kent37 at tds.net writes:
[snip]
You still aren't doing anything with newdic. The absence of 'newdic' in the
code
after 'read.close()' should be a clue
I think you want to overwrite the saved dict, but with the new dict instead
of
with a filename string...
Hi Kent,
Jacob S. wrote:
Hi everyone, sent this on to the list as told to.
cc to eri to verify my sending to list...
;-) Jacob
dear jacob,
sorry to send this to you but if you may, kindly send to tutor list as im
no longer subscribed. my problem is in the update dict portion: it just
doesnt update
Kent Johnson kent37 at tds.net writes:
Jacob S. wrote:
sorry to send this to you but if you may, kindly send to tutor list as im
no longer subscribed. my problem is in the update dict portion: it just
doesnt update regardless how many contacts i add. kindly advise where
my mistake
Hi everyone, sent this on to the list as told to.
cc to eri to verify my sending to list...
;-) Jacob
dear jacob,
sorry to send this to you but if you may, kindly send to tutor list as im
no longer subscribed. my problem is in the update dict portion: it just
doesnt update regardless how many
Jacob S. wrote:
sorry to send this to you but if you may, kindly send to tutor list as im
no longer subscribed. my problem is in the update dict portion: it just
doesnt update regardless how many contacts i add. kindly advise where
my mistake is or code gone wrong. the rest of the options i
On Jan 13, 2005, at 04:13, Bob Gailer wrote:
I like Kent's response.
foobar(item)/0 is a valid expression. It fits the grammar of
expressions. The fact that it raises an exception does not make it an
invalid expression.
Consider foobar(item)/xyz. It is valid. If xyz == 0 then it will also
Blake Winton wrote:
Kent Johnson wrote:
If you mean for j to be a list of foobar(item) then use
j=[foobar(item) for item in x]
The first part of the list comp can be any valid expression.
Does that mean that there are invalid expressions? I'd enjoy seeing
an example.
I suppose if it's an
Quoting Liam Clarke [EMAIL PROTECTED]:
As a comprehension, if you get what I mean... Can I build a for loop
with a function in for x in x part?
Ack. Having difficulty summing it up properly.
I'm not sure exactly what you mean, so my answer is probably.
from math import sin
arr =
If you mean for j to be a list of foobar(item) then use
j=[foobar(item) for item in x]
The first part of the list comp can be any valid expression.
Kent
Liam Clarke wrote:
Hi,
Am I able to achieve something like this -
def foobar();
# stuff
return
x=[1,1000]
for j=foobar(item) for item in
Aah, thank you both - I knew there was a way to do it.
Regards,
Liam Clarke
PS John - another Kiwi, seems to be a lot of NZers involved in Python
Python projects. Is it the No. 8 wire freedom of Python? ; )
On Wed, 12 Jan 2005 18:48:39 -0500, Kent Johnson [EMAIL PROTECTED] wrote:
If you
At 04:48 PM 1/12/2005, Kent Johnson wrote:
If you mean for j to be a list of foobar(item) then use
j=[foobar(item) for item in x]
The first part of the list comp can be any valid expression.
Does that mean that there are invalid expressions? I'd enjoy seeing an
example.
Bob Gailer
mailto:[EMAIL
I suppose if it's an expression, it must be valid, eh? Otherwise it's something
else.
Bob Gailer wrote:
At 04:48 PM 1/12/2005, Kent Johnson wrote:
If you mean for j to be a list of foobar(item) then use
j=[foobar(item) for item in x]
The first part of the list comp can be any valid expression.
601 - 657 of 657 matches
Mail list logo