In <8c0a3ea9-2560-47eb-a9c7-3770e41fe...@googlegroups.com>
subhabangal...@gmail.com writes:
> Dear Group,
> I have a list of the following pattern,
> [("''", "''"), ('Eastern', 'NNP'), ('Army', 'NNP'), ('Commander', 'NNP'), (=
> 'Lt', 'NNP'), ('Gen', 'NNP'), ('Dalbir', 'NNP'), ('Singh', 'NNP'),
On 2012-12-02, Thomas Bach wrote:
> On Sun, Dec 02, 2012 at 04:16:01PM +0100, Lutz Horn wrote:
>>
>> len([x for x in l if x[1] == 'VBD'])
>>
>
> Another way is
>
> sum(1 for x in l if x[1] == 'VBD')
>
> which saves the list creation.
To also index them:
vbdix = [i for i, a in emumerate(l) if a
On Sunday, December 2, 2012 9:29:22 PM UTC+5:30, Thomas Bach wrote:
> On Sun, Dec 02, 2012 at 04:16:01PM +0100, Lutz Horn wrote:
>
> >
>
> > len([x for x in l if x[1] == 'VBD'])
>
> >
>
>
>
> Another way is
>
>
>
> sum(1 for x in l if x[1] == 'VBD')
>
>
>
> which saves the list creati
On Sun, Dec 02, 2012 at 04:16:01PM +0100, Lutz Horn wrote:
>
> len([x for x in l if x[1] == 'VBD'])
>
Another way is
sum(1 for x in l if x[1] == 'VBD')
which saves the list creation.
Regards,
Thomas.
--
http://mail.python.org/mailman/listinfo/python-list
Him
Am 02.12.2012 um 16:03 schrieb subhabangal...@gmail.com:
> I have a list of the following pattern,
>
> [("''", "''"), ('Eastern', 'NNP'), ('Army', 'NNP'), ('Commander', 'NNP'),
> ('Lt', 'NNP'), ('Gen', 'NNP'), ('Dalbir', 'NNP'), ('Singh', 'NNP'), ('Suhag',
> 'NNP'), ('briefed', 'VBD'), ('th
Dear Group,
I have a list of the following pattern,
[("''", "''"), ('Eastern', 'NNP'), ('Army', 'NNP'), ('Commander', 'NNP'),
('Lt', 'NNP'), ('Gen', 'NNP'), ('Dalbir', 'NNP'), ('Singh', 'NNP'), ('Suhag',
'NNP'), ('briefed', 'VBD'), ('the', 'DT'), ('Army', 'NNP'), ('chief', 'NN'),
('on', 'IN'),
On Mon, Sep 24, 2012 at 10:56 AM, Littlefield, Tyler
wrote:
> I've not been following this thread fully, but why not just use x=list(y) to
> copy the list?
> The issue is that when you assign i=[1,2,3] and then j = i, j is just a
> reference to i, which is why you change either and the other chang
On 9/23/2012 3:44 PM, jimbo1qaz wrote:
On Sunday, September 23, 2012 2:31:48 PM UTC-7, jimbo1qaz wrote:
I have a nested list. Whenever I make a copy of the list, changes in one affect
the other, even when I use list(orig) or even copy the sublists one by one. I
have to manually copy each cell
On Sunday, September 23, 2012 2:31:48 PM UTC-7, jimbo1qaz wrote:
> I have a nested list. Whenever I make a copy of the list, changes in one
> affect the other, even when I use list(orig) or even copy the sublists one by
> one. I have to manually copy each cell over for it to work.
>
> Link to br
On Sun, 23 Sep 2012 14:31:48 -0700, jimbo1qaz wrote:
> I have a nested list. Whenever I make a copy of the list, changes in one
> affect the other,
Then you aren't making a copy.
py> first_list = [1, 2, 3]
py> second_list = first_list # THIS IS NOT A COPY
py> second_list.append()
py> print
On 09/23/2012 05:44 PM, jimbo1qaz wrote:
> On Sunday, September 23, 2012 2:31:48 PM UTC-7, jimbo1qaz wrote:
>> I have a nested list. Whenever I make a copy of the list, changes in one
>> affect the other, even when I use list(orig) or even copy the sublists one
>> by one. I have to manually copy
On Mon, Sep 24, 2012 at 7:44 AM, jimbo1qaz wrote:
> On Sunday, September 23, 2012 2:31:48 PM UTC-7, jimbo1qaz wrote:
>> I have a nested list. Whenever I make a copy of the list, changes in one
>> affect the other, even when I use list(orig) or even copy the sublists one
>> by one. I have to manu
On 23 September 2012 22:31, jimbo1qaz wrote:
> I have a nested list. Whenever I make a copy of the list, changes in one
> affect the other, even when I use list(orig) or even copy the sublists one
> by one. I have to manually copy each cell over for it to work.
> Link to broken code: http://jimbo
On Sunday, September 23, 2012 2:31:48 PM UTC-7, jimbo1qaz wrote:
> I have a nested list. Whenever I make a copy of the list, changes in one
> affect the other, even when I use list(orig) or even copy the sublists one by
> one. I have to manually copy each cell over for it to work.
>
> Link to br
I have a nested list. Whenever I make a copy of the list, changes in one affect
the other, even when I use list(orig) or even copy the sublists one by one. I
have to manually copy each cell over for it to work.
Link to broken code: http://jimbopy.pastebay.net/1090401
--
http://mail.python.org/ma
28 Sep 2010 11:59:08 -0700, geremy condra wrote:
> >>
> >> >> On Tue, Sep 28, 2010 at 11:44 AM, Rog wrote:
> >> >>> Hi all,
> >> >>> Have been grappling with a list problem for hours... a = [2, 3, 4,
> >> >>> 5,.]
> >&g
28, 2010 at 11:44 AM, Rog wrote:
>> >>> Hi all,
>> >>> Have been grappling with a list problem for hours... a = [2, 3, 4,
>> >>> 5,.]
>> >>> b = [4, 8, 2, 6,.]
>> >>> Basicly I am trying to place a[0], b[0] in a s
On 29 sep, 14:17, Steven D'Aprano wrote:
> On Tue, 28 Sep 2010 20:11:51 +0100, Rog wrote:
> > On Tue, 28 Sep 2010 11:59:08 -0700, geremy condra wrote:
>
> >> On Tue, Sep 28, 2010 at 11:44 AM, Rog wrote:
> >>> Hi all,
> >>> Have been grapp
On Tue, 28 Sep 2010 20:11:51 +0100, Rog wrote:
> On Tue, 28 Sep 2010 11:59:08 -0700, geremy condra wrote:
>
>> On Tue, Sep 28, 2010 at 11:44 AM, Rog wrote:
>>> Hi all,
>>> Have been grappling with a list problem for hours... a = [2, 3, 4,
>>> 5,.]
>
On Wed, Sep 29, 2010 at 1:15 AM, rog wrote:
> Shashwat Anand wrote:
>
>
>>
>> On Wed, Sep 29, 2010 at 12:14 AM, Rog > r...@pynguins.com>> wrote:
>>
>> Hi all,
>>Have been grappling with a list problem for hours...
>>a = [2, 3, 4,
On Tue, 28 Sep 2010 11:59:08 -0700, geremy condra wrote:
> On Tue, Sep 28, 2010 at 11:44 AM, Rog wrote:
>> Hi all,
>> Have been grappling with a list problem for hours... a = [2, 3, 4,
>> 5,.]
>> b = [4, 8, 2, 6,.]
>> Basicly I am trying to place a[0], b[
On Tue, Sep 28, 2010 at 11:44 AM, Rog wrote:
> Hi all,
> Have been grappling with a list problem for hours...
> a = [2, 3, 4, 5,.]
> b = [4, 8, 2, 6,.]
> Basicly I am trying to place a[0], b[0] in a seperate list
> IF a[2] and b[2] is present.
> I have tried sets, zi
On Wed, Sep 29, 2010 at 12:14 AM, Rog wrote:
> Hi all,
> Have been grappling with a list problem for hours...
> a = [2, 3, 4, 5,.]
> b = [4, 8, 2, 6,.]
> Basicly I am trying to place a[0], b[0] in a seperate list
> IF a[2] and b[2] is present.
>
You are not ex
Hi all,
Have been grappling with a list problem for hours...
a = [2, 3, 4, 5,.]
b = [4, 8, 2, 6,.]
Basicly I am trying to place a[0], b[0] in a seperate list
IF a[2] and b[2] is present.
I have tried sets, zip etc with no success.
I am tackling Euler projects with Python 3.1, with minimal
Neil Webster a écrit :
Thanks for the help so far.
The background to the problem is that the lists come from reading a
dbf file. The code that I am trying to write is to merge lines of the
dbf based on the first column. So in my example there would be three
lines:
a 2 3 4
b 10 11 12
a 2 3 4
T
Mark Lawrence wrote:
>On 22/06/2010 15:06, Neil Webster wrote:
>> I have a list of lists such as [[a,2,3,4],[b,10,11,12], [a,2,3,4]]. I
>> need to combine the two lists that have the same first character in
>> this example 'a'. In reality there are 656 lists within the list.
>> [ ... ]
>My simp
Thanks for the help so far.
The background to the problem is that the lists come from reading a
dbf file. The code that I am trying to write is to merge lines of the
dbf based on the first column. So in my example there would be three
lines:
a 2 3 4
b 10 11 12
a 2 3 4
The expected output from t
Neil Webster a écrit :
Hi all,
I've got a simple problem but it's defeated me and I was wondering if
somebody could point out where I'm going wrong
1/ not posting working code (got a NameError)
2/ not posting the expected output
3/ not posting the actual output
or offer an alternative
soluti
On 22/06/2010 15:06, Neil Webster wrote:
Hi all,
I've got a simple problem but it's defeated me and I was wondering if
somebody could point out where I'm going wrong or offer an alternative
solution to the problem?
I have a list of lists such as [[a,2,3,4],[b,10,11,12], [a,2,3,4]]. I
need to c
On Wed, Jun 23, 2010 at 12:06 AM, Neil Webster wrote:
> I've got a simple problem but it's defeated me and I was wondering if
> somebody could point out where I'm going wrong or offer an alternative
> solution to the problem?
Is this a hypothetical/mathematical problem of sorts ?
If so, do you ha
On 23 June 2010 00:06, Neil Webster wrote:
> Hi all,
>
> I've got a simple problem but it's defeated me and I was wondering if
> somebody could point out where I'm going wrong or offer an alternative
> solution to the problem?
>
> I have a list of lists such as [[a,2,3,4],[b,10,11,12], [a,2,3,4]]
Hi all,
I've got a simple problem but it's defeated me and I was wondering if
somebody could point out where I'm going wrong or offer an alternative
solution to the problem?
I have a list of lists such as [[a,2,3,4],[b,10,11,12], [a,2,3,4]]. I
need to combine the two lists that have the same fir
On Sat, 17 Apr 2010 13:31:54 -0700 Chris Rebert
wrote:
> On Sat, Apr 17, 2010 at 12:40 PM, Martin Hvidberg
> wrote:
> > I have this code, it builds up a data structure of nested lists,
> > and filling data in them. My problem is that it seems that one of
> > the lists SA[1] is not a list of uniq
On Sat, Apr 17, 2010 at 12:40 PM, Martin Hvidberg wrote:
> I have this code, it builds up a data structure of nested lists, and filling
> data in them.
> My problem is that it seems that one of the lists SA[1] is not a list of
> unique instances but rather individual links to the same variable.
Dear list
I have this code, it builds up a data structure of nested lists, and filling
data in them.
My problem is that it seems that one of the lists SA[1] is not a list of unique
instances but rather individual links to the same variable.
In the example below I assign 'X' to what I intended to
On Tue, 09 Dec 2008 21:40:08 -0800, dongzhi wrote:
> I have one problem for List. Like that:
>
> format='just "a" ""little"" test'
> part = format.split('"')
> print part
>
> the result is : ['just ', 'a', ' ', '', 'little', '', ' test']
>
> the list part have 7 element.
>
> If I execute part[
On Dec 10, 2:00 pm, "James Mills" <[EMAIL PROTECTED]>
wrote:
> On Wed, Dec 10, 2008 at 3:40 PM, dongzhi <[EMAIL PROTECTED]> wrote:
> > If I execute part[1], I have got 'a'. If I execute part[2], I have
> > got ' '. But, if I execute part[1::2], I have got ['a', '', '']. I
> > don't know why. Pleas
On Wed, Dec 10, 2008 at 3:40 PM, dongzhi <[EMAIL PROTECTED]> wrote:
> If I execute part[1], I have got 'a'. If I execute part[2], I have
> got ' '. But, if I execute part[1::2], I have got ['a', '', '']. I
> don't know why. Please tell me why.
Perhaps you meant:
part[1:2]
pydoc list
This will
Hi All,
I have one problem for List. Like that:
format='just "a" ""little"" test'
part = format.split('"')
print part
the result is : ['just ', 'a', ' ', '', 'little', '', ' test']
the list part have 7 element.
If I execute part[1], I have got 'a'. If I execute part[2], I have
got ' '. But, i
Alan Bromborsky wrote:
> I wish to create a list of empty lists and then put something in one of
> the empty lists. Below is what I tried, but instead of appending 1 to
> a[2] it was appended to all the sub-lists in a. What am I doing wrong?
>
> a = 6*[[]]
> >>> a
> [[], [], [], [], [], []]
>
I wish to create a list of empty lists and then put something in one of
the empty lists. Below is what I tried, but instead of appending 1 to
a[2] it was appended to all the sub-lists in a. What am I doing wrong?
a = 6*[[]]
>>> a
[[], [], [], [], [], []]
>>> a[2].append(1)
>>> a
[[1], [1],
I'm creating one aplicattion and I use SQLObject, but I have a little
problem, when I try to create one table my aplicattion crash! :(
Let me show you:
[EMAIL PROTECTED]:~/Proyectos/ghhp/lib$ python
Python 2.4.4 (#2, Apr 5 2007, 20:11:18)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on lin
[EMAIL PROTECTED] wrote:
> For example i write the following code in the Python command line;
>
list = ['One,Two,Three,Four']
>
> Then enter this command, which will then return the following;
>
> ['One,Two,Three,Four']
This is already wrong. Assignments do not return anything.
Georg
--
h
[EMAIL PROTECTED] wrote:
> For example i write the following code in the Python command line;
>
list = ['One,Two,Three,Four']
>
> Then enter this command, which will then return the following;
>
> ['One,Two,Three,Four']
>
>
> Now the problem, reading through the Python tutorial's, it desc
[EMAIL PROTECTED] wrote:
> For example i write the following code in the Python command line;
>
list = ['One,Two,Three,Four']
>
> Then enter this command, which will then return the following;
>
> ['One,Two,Three,Four']
>
>
> Now the problem, reading through the Python tutorial's, it des
For example i write the following code in the Python command line;
>>>list = ['One,Two,Three,Four']
Then enter this command, which will then return the following;
['One,Two,Three,Four']
Now the problem, reading through the Python tutorial's, it describe's
that list's can sliced, concatenated a
[EMAIL PROTECTED] wrote:
> It looks like the PyTensor object *should* have .xx, .xy, etc
> properties, but they may be accessible through a matrix, i.e. .t(i,j)
Thanks to all of you for your help!
The solution is easy: The tensor components have labels t11, t12,...
Good guess ruibalp!
--
http:
Thank you all for the replies, i now have a better solution.
Cheers
--
http://mail.python.org/mailman/listinfo/python-list
"placid" <[EMAIL PROTECTED]> writes:
> >>> list1 = [ ' XXX1', 'XXX2', 'XXX3', 'XXX5']
>
> the second list contains strings that are identical to the first list,
> so lets say the second list contains the following
>
> >>> list1 = [ ' XXX1', 'XXX2', 'XXX3', 'XXX6']
I think you meant list2 for the
Gerard Flanagan wrote:
> placid wrote:
> > Hi all,
> >
> > I have two lists that contain strings in the form string + number for
> > example
> >
> > >>> list1 = [ ' XXX1', 'XXX2', 'XXX3', 'XXX5']
> >
> > the second list contains strings that are identical to the first list,
> > so lets say the sec
placid wrote:
> Hi all,
>
> I have two lists that contain strings in the form string + number for
> example
>
> >>> list1 = [ ' XXX1', 'XXX2', 'XXX3', 'XXX5']
>
> the second list contains strings that are identical to the first list,
> so lets say the second list contains the following
>
> >>> lis
placid wrote:
>
> But there may be other characters before XXX (which XXX is constant). A
> better example would be, that string s is like a file name and the
> characters before it are the absolute path, where the strings in the
> first list can have a different absolute path then the second list
placid wrote:
> Hi all,
>
> I have two lists that contain strings in the form string + number for
> example
>
> >>> list1 = [ ' XXX1', 'XXX2', 'XXX3', 'XXX5']
>
> the second list contains strings that are identical to the first list,
> so lets say the second list contains the following
>
> >>> lis
placid:
This may be a solution:
l1 = ['acXXX1', 'XXX2', 'wXXX3', 'kXXX5']
l2 = [ 'bXXX1', 'xXXX2', 'efXXX3', 'yXXX6', 'zZZZ9']
import re
findnum = re.compile(r"[0-9]+$")
s1 = set(int(findnum.search(el).group()) for el in l1)
s2 = set(int(findnum.search(el).group()) for el in l2)
nmax = max(max(s
placid wrote:
> Simon Forman wrote:
> > placid wrote:
> > > Hi all,
> > >
> > > I have two lists that contain strings in the form string + number for
> > > example
> > >
> > > >>> list1 = [ ' XXX1', 'XXX2', 'XXX3', 'XXX5']
> > >
> > > the second list contains strings that are identical to the first
Simon Forman wrote:
> placid wrote:
> > Hi all,
> >
> > I have two lists that contain strings in the form string + number for
> > example
> >
> > >>> list1 = [ ' XXX1', 'XXX2', 'XXX3', 'XXX5']
> >
> > the second list contains strings that are identical to the first list,
> > so lets say the second
Simon Forman wrote:
> Finally, you can say:
>
> for i in xrange(1,10):
> s = "XXX1%04i" % i
> if s not in list1 and s not in list2:
> print s
>
> HTH,
> ~Simon
D'oh! Forgot to break.
for i in xrange(1,10):
s = "XXX1%04i" % i
if s not in list1 and s not in list2:
p
placid wrote:
> Hi all,
>
> I have two lists that contain strings in the form string + number for
> example
>
> >>> list1 = [ ' XXX1', 'XXX2', 'XXX3', 'XXX5']
>
> the second list contains strings that are identical to the first list,
> so lets say the second list contains the following
>
> >>> list
Hi all,
I have two lists that contain strings in the form string + number for
example
>>> list1 = [ ' XXX1', 'XXX2', 'XXX3', 'XXX5']
the second list contains strings that are identical to the first list,
so lets say the second list contains the following
>>> list1 = [ ' XXX1', 'XXX2', 'XXX3', '
Thanks very much. Deepcopy works fine, as does reversed(b). I thought I
needed the index number but I didn't.
Duncan Booth wrote:
> manstey wrote:
>
> > for index in reversed(range(0,len(a)-1)):
> >if '75' in b[index][1]:
> > b[index][1].remove('75')
> > b[index][1].append('99')
manstey wrote:
> for index in reversed(range(0,len(a)-1)):
>if '75' in b[index][1]:
> b[index][1].remove('75')
> b[index][1].append('99')
>
What on earth is all that messing around in the for loop intended to do? If
you want a range from len(a)-2 to 0 inclusive then just do it i
Hi,
if u check the id's of a and b lists and also its elements, you will
obeserve that the id's of a and b have changed but id's of their
elements have not changed.
If you make a deep copy of the list a and then make your changes in
that list, it shud work. this can be done using the copy module
I can't figure out why my code is not working. I thought I had the list
copied correctly:
Here is my code:
a=[[u'HF', []], [u')F', [u'75']], [u'RE', []], [u'C', []]]
b=a[:]
for index in reversed(range(0,len(a)-1)):
if '75' in b[index][1]:
b[index][1].remove('75')
b[i
Fredrik Lundh wrote:
> Jon Bowlas wrote:
(snip)
>>But I get the following error- Line 5: Yield statements are not allowed.
>
>
> umm. I might be missing something, but I cannot find any trace of that
> error message in the Python interpreter source code. it doesn't even look
> like a Python tr
Many thanks for your help, worked a treat
Jon
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Peter
Otten
Sent: 16 August 2005 17:25
To: python-list@python.org
Subject: RE: looping list problem
Jon Bowlas wrote:
> Incidentally I'm doing this
Jon Bowlas wrote:
> Incidentally I'm doing this in zope.
Many posters (including me) in this newsgroup don't do zope, so your best
option is to ask on a zope-related mailing list.
> I was hoping that this would loop through the elements in the list
> returned by the hiddens function comparing th
uld ignore it and move onto the
next one, but it doesn't seem to do anything.
Any help would be appreciated.
Incidentally I'm doing this in zope.
Jon
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Peter
Otten
Sent: 16 August 2005 14:41
To
Jon Bowlas wrote:
> Ok so I changed it to this:
>
> attobject = context.get_attobject()
> navstring = context.get_uclattribute(attobject, 'ucl_navhide')
> hiddennavelements = navstring.split(' ')
> for hiddennavelement in hiddennavelements:
> yield hiddennavelements
>
> But I get the followi
Jon Bowlas wrote:
> Ok so I changed it to this:
>
> attobject = context.get_attobject()
> navstring = context.get_uclattribute(attobject, 'ucl_navhide')
> hiddennavelements = navstring.split(' ')
> for hiddennavelement in hiddennavelements:
> yield hiddennavelements
>
> But I get the followi
Jon Bowlas wrote:
> Ok so I changed it to this:
>
> attobject = context.get_attobject()
> navstring = context.get_uclattribute(attobject, 'ucl_navhide')
> hiddennavelements = navstring.split(' ')
> for hiddennavelement in hiddennavelements:
>yield hiddennavelements
>
> But I get the following
Well, you are returning prematurely from a for loop, so that is why you
are only getting the first value. Its just like:
for i in range(100):
return i
It doesn't matter how big the range is you are iterating over, you'll
return on the first element and that's it.
If what you want is the
5: Yield statements are not allowed.
Any ideas
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Fredrik Lundh
Sent: 16 August 2005 13:44
To: python-list@python.org
Subject: Re: looping list problem
Jon Bowlas wrote:
> attobject = context.get_
Jon Bowlas wrote:
> attobject = context.get_attobject()
> navstring = context.get_uclattribute(attobject, 'ucl_navhide')
> hiddennavelements = navstring.split(' ')
> for hiddennavelement in hiddennavelements:
>return hiddennavelement
>
> So the script 'get_attobject' basically looks for an ins
HI all,
I'm fairly new to python and programming in general so I was hoping someone
here may be able to help me. Let me explain what the problem I'm having is:
I am trying to parse the XML of an attributes object I created, this object
has the structure outlined below. Everything is ok on the par
74 matches
Mail list logo