On 24/12/17 08:12, anish singh wrote:
> However, I am stuck. I have below code which is not working.
Define "not working"
Do you get an error message? (show us)
If the output different to what you expect (show us)
Have you tried printing the intermediate results?
For example the dictionary befor
On 06/02/17 12:13, boB Stepp wrote:
py> 'pi = \N{GREEK SMALL LETTER PI}'
'pi = π'
>>>
>>>
>>> You have surprised me here by using single quotes to enclose the
>>> entire assignment statements. I thought this would throw a syntax
>>> error, but it works just like you show. What is going
On Sun, Feb 5, 2017 at 10:49 PM, Cameron Simpson wrote:
> On 05Feb2017 22:27, boB Stepp wrote:
>>
>> On Sun, Feb 5, 2017 at 7:23 PM, Steven D'Aprano
>> wrote:
>>>
>>> Alternatively, you can embed it right in the string. For code points
>>> between U+ and U+, use the \u escape, and for th
On 05Feb2017 22:27, boB Stepp wrote:
On Sun, Feb 5, 2017 at 7:23 PM, Steven D'Aprano wrote:
Alternatively, you can embed it right in the string. For code points
between U+ and U+, use the \u escape, and for the rest, use \U
escapes:
py> 'pi = \u03C0' # requires exactly four hex digit
On Sun, Feb 5, 2017 at 7:23 PM, Steven D'Aprano wrote:
> On Sun, Feb 05, 2017 at 04:31:43PM -0600, boB Stepp wrote:
>> On Sat, Feb 4, 2017 at 10:50 PM, Random832 wrote:
>> > On Sat, Feb 4, 2017, at 22:52, boB Stepp wrote:
> Alternatively, you can embed it right in the string. For code points
>
On Sun, Feb 5, 2017 at 5:25 PM, Cameron Simpson wrote:
> You might want to drop this term "hexadecimal"; they're just ordinals (plain
> old numbers). Though Unicode ordinals are often _written_ in hexadecimal for
> compactness and because various character grouping are aligned on ranges
> based o
On Sun, Feb 05, 2017 at 04:31:43PM -0600, boB Stepp wrote:
> On Sat, Feb 4, 2017 at 10:50 PM, Random832 wrote:
> > On Sat, Feb 4, 2017, at 22:52, boB Stepp wrote:
> >> Does the list sort() method (and other sort methods in Python) just go
> >> by the hex value assigned to each symbol to determine
On Sun, Feb 5, 2017 at 10:30 PM, boB Stepp wrote:
> I was looking at http://unicode.org/charts/ Because they called them
> charts, so did I. I'm assuming that despite this organization into
> charts, each and every character in each chart has its own unique
> hexadecimal code to designate each c
On 05Feb2017 16:31, boB Stepp wrote:
On Sat, Feb 4, 2017 at 10:50 PM, Random832 wrote:
On Sat, Feb 4, 2017, at 22:52, boB Stepp wrote:
Does the list sort() method (and other sort methods in Python) just go
by the hex value assigned to each symbol to determine sort order in
whichever Unicode e
On Sat, Feb 4, 2017 at 10:50 PM, Random832 wrote:
> On Sat, Feb 4, 2017, at 22:52, boB Stepp wrote:
>> Does the list sort() method (and other sort methods in Python) just go
>> by the hex value assigned to each symbol to determine sort order in
>> whichever Unicode encoding chart is being implemen
On Sun, Feb 5, 2017 at 2:32 AM, Steven D'Aprano wrote:
> On Sat, Feb 04, 2017 at 09:52:47PM -0600, boB Stepp wrote:
>> Does the list sort() method (and other sort methods in Python) just go
>> by the hex value assigned to each symbol to determine sort order in
>> whichever Unicode encoding chart i
On Sat, Feb 4, 2017, at 22:52, boB Stepp wrote:
> Does the list sort() method (and other sort methods in Python) just go
> by the hex value assigned to each symbol to determine sort order in
> whichever Unicode encoding chart is being implemented?
By default. You need key=locale.strxfrm to make it
On Sat, Feb 04, 2017 at 09:52:47PM -0600, boB Stepp wrote:
> Does the list sort() method (and other sort methods in Python) just go
> by the hex value assigned to each symbol to determine sort order in
> whichever Unicode encoding chart is being implemented?
Correct, except that there is only one
On Sun, Feb 5, 2017 at 3:52 AM, boB Stepp wrote:
> Does the list sort() method (and other sort methods in Python) just go
> by the hex value assigned to each symbol to determine sort order in
> whichever Unicode encoding chart is being implemented?
list.sort uses a less-than comparison. What you
George Nyoro wrote:
Hey all, again:
Thanks for the delete thing. Helped with that problem a lot. Especially the
getattr thing came in handy.
Question 1:
How do you guys indent and put in the triple greater than signs and all
that when sending mail? Manually? Coz the last mail I sent was using th
Date: Wed, 8 Sep 2010 20:10:28 +0200
From: f...@libero.it
To: tutor@python.org
Subject: Re: [Tutor] sort problem
On 08/09/2010 19.12, Francesco Loffredo wrote:
> ...
> a little example:
>
> separator = "Roelof"
> list = ["Wobben", "Python", "L
On 08/09/2010 19.12, Francesco Loffredo wrote:
...
a little example:
separator = "Roelof"
list = ["Wobben", "Python", "Learner"]
print separator.join(list)
... what you will get? Guess before you try.
There's more, I forgot to add:
print separator
This is important, this method *returns* a
On 08/09/2010 19.12, Roelof Wobben wrote:
...
Oke,
If I understand it right with join I can put two strings into 1 string.
Roelof
Not quite. With join you can put together in one string all the elements
of a list of strings. While you do so, you can also put another string
as a "wall" between e
"Roelof Wobben" wrote
> Carefully read the documentation for str.join:
> http://docs.python.org/library/stdtypes.html#str.join
>
>How does it work, what does it return, etc. Then fix the
>corresponding line in your code.
str.join(iterable)¶
It puts all the elements of iterable into one s
On 9/8/2010 1:12 PM, Roelof Wobben wrote:
If I understand it right
You don't.
What does "put two strings into 1 string" mean. Provide an example.
What does the documentation say about join? What part of that do you not
understand?
--
Bob Gailer
919-636-4239
Chapel Hill NC
__
Date: Wed, 8 Sep 2010 12:38:03 -0400
From: gregb...@gmail.com
To: tutor@python.org
Subject: Re: [Tutor] sort problem
On Wed, Sep 8, 2010 at 11:50 AM, Roelof Wobben wrote:
> Subject: Re: [Tutor] sort problem
> From: evert@gmail.com
> Date: Wed, 8 Sep 2010 17:26:58 +
On Wed, Sep 8, 2010 at 11:50 AM, Roelof Wobben wrote:
>
>
> > Subject: Re: [Tutor] sort problem
> > From: evert@gmail.com
> > Date: Wed, 8 Sep 2010 17:26:58 +0200
> > CC: tutor@python.org
> > To: rwob...@hotmail.com
>
> >
> >
On 08/09/2010 17.50, Roelof Wobben wrote:
> Subject: Re: [Tutor] sort problem
> From: evert@gmail.com
> Date: Wed, 8 Sep 2010 17:26:58 +0200
> CC: tutor@python.org
> To: rwob...@hotmail.com
...
> > seq2 = list(seq)
> > seq2.sort()
> > print seq2
&
> Subject: Re: [Tutor] sort problem
> From: evert@gmail.com
> Date: Wed, 8 Sep 2010 17:26:58 +0200
> CC: tutor@python.org
> To: rwob...@hotmail.com
>
> > I have this :
> >
> > def sort_sequence(seq):
> > """
> &
> I have this :
>
> def sort_sequence(seq):
> """
> >>> sort_sequence([3, 4, 6, 7, 8, 2])
> [2, 3, 4, 6, 7, 8]
> >>> sort_sequence((3, 4, 6, 7, 8, 2))
> (2, 3, 4, 6, 7, 8)
> >>> sort_sequence("nothappy")
> 'ahnoppty'
> """
>if type(seq) == type([]):
Le Wed, 4 Feb 2009 22:33:45 -,
"Alan Gauld" a écrit :
>
> "Timo" wrote
>
> class Person:
> def __init__(self, parser):
> self.first = parser.get(person, 'firstName')
> >
> > Hey Alan, thanks for that explanation!
> >
> > But the class you gave, does almost the
"Timo" wrote
class Person:
def __init__(self, parser):
self.first = parser.get(person, 'firstName')
Hey Alan, thanks for that explanation!
But the class you gave, does almost the same thing as my function.
That was my point. Its just a prettier way of handling it and slight
Alan Gauld schreef:
"spir" wrote
> The current way of reading the data is this:
> > def get_info(person)
>infoDic = {}
>infoDic['first'] = parser.get(person, 'firstName')
>infoDic['last'] = parser.get(person, 'lastName')
>infoDic['father'] = parser.get(person, 'fat
"spir" wrote
> The current way of reading the data is this:
>
> def get_info(person)
>infoDic = {}
>infoDic['first'] = parser.get(person, 'firstName')
>infoDic['last'] = parser.get(person, 'lastName')
>infoDic['father'] = parser.get(person, 'father')
>infoDic[
Le Wed, 4 Feb 2009 01:16:17 + (GMT),
ALAN GAULD a écrit :
> > > And I assume you are reading these into a Person class and
> > > storing these classes in a persons dictionary?
>
>
> > Can you explain this a little more for me please?
>
>
> Sure.
> (I didn't notice this on gmane so apolo
> > And I assume you are reading these into a Person class and
> > storing these classes in a persons dictionary?
> Can you explain this a little more for me please?
Sure.
(I didn't notice this on gmane so apologies if others already answered)
> The current way of reading the data is this:
>
Alan Gauld schreef:
Timo wrote
So my entry's look like this (more or less ;)):
[person1]
firstName = foo
lastName = bar
father = person2
mother = person3
And I assume you are reading these into a Person class and
storing these classes in a persons dictionary? Then to access
a father becomes:
"Timo" wrote
I'm writing an application that stores people with some info. I'm
doing this with ConfigParser and it works, but currently (for
testing), there are only 10 persons in it. What if I add, let's say,
about 500-600 or even more? Is this still a good choice?
I'd be happy with this f
Le Mon, 26 Jan 2009 14:58:43 +0100,
Timo a écrit :
> Hello,
>
> I'm writing an application that stores people with some info. I'm doing
> this with ConfigParser and it works, but currently (for testing), there
> are only 10 persons in it. What if I add, let's say, about 500-600 or
> even more
Timo wrote:
Hello,
I'm writing an application that stores people with some info. I'm doing
this with ConfigParser and it works, but currently (for testing), there
are only 10 persons in it. What if I add, let's say, about 500-600 or
even more? Is this still a good choice?
Last week, I creat
"Wayne Watson" <[EMAIL PROTECTED]> wrote
I was surprised to find the result below.
Well done, you just found one of the standard beginners gotchas!
a =[4,2,5,8]
b = a
This makes b refer to the *same list* as a.
a.sort()
This sorts the list contents in-place
a
[2, 4, 5, 8]
As sh
Solution 1:
>>> a=[2,3,1,4]
>>> b=a[:]
>>> a
[2, 3, 1, 4]
>>> b
[2, 3, 1, 4]
>>> a.sort()
>>> a
[1, 2, 3, 4]
>>> b
[2, 3, 1, 4]
>>>
Solution 2:
>>> from copy import deepcopy
>>> a=[2,1,3,4]
>>> b=deepcopy(a)
>>> a
[2, 1, 3, 4]
>>> b
[2, 1, 3, 4]
>>> a.sort()
>>> a
[1, 2, 3, 4]
>>> b
[2, 1, 3, 4]
On Wed, Sep 17, 2008 at 3:30 PM, Wayne Watson
<[EMAIL PROTECTED]>wrote:
> I'm using Python 2.4 in Win XP. I was surprised to find the result below.
>
> >>> a =[4,2,5,8]
> >>> b = a
> >>> a.sort()
> >>> a
> [2, 4, 5, 8]
> >>> b
> [2, 4, 5, 8]
>
> b no longer has the same value as it began. Apparen
On Wed, Sep 17, 2008 at 3:30 PM, Wayne Watson
<[EMAIL PROTECTED]> wrote:
> I'm using Python 2.4 in Win XP. I was surprised to find the result below.
>
a =[4,2,5,8]
b = a
This binds the name "b" to the same object that "a" is bound to.
a.sort()
a
> [2, 4, 5, 8]
b
> [2, 4,
On Wed, Sep 17, 2008 at 3:30 PM, Wayne Watson
<[EMAIL PROTECTED]> wrote:
> I'm using Python 2.4 in Win XP. I was surprised to find the result below.
>
a =[4,2,5,8]
b = a
a.sort()
a
> [2, 4, 5, 8]
b
> [2, 4, 5, 8]
>
> b no longer has the same value as it began. Apparently to
If you use sort(a), it will be ok.
>>>a =[4,2,5,8]
>>>b=a
>>> sort(a)
: array([2, 4, 5, 8])
>>> b
[4, 2, 5, 8]
>>> a
[4, 2, 5, 8]
On Wed, Sep 17, 2008 at 12:30 PM, Wayne Watson <[EMAIL PROTECTED]
> wrote:
> I'm using Python 2.4 in Win XP. I was surprised to find the result below.
>
> >>> a
Incidentally, I was wondering what the value of using
operator.itemgetter is. So I ran some tests.
Morpork:~/offlode repton$ python -m timeit -s 'import math' -s 'a =
[(i, math.sin(i)) for i in range(1)]' -s 'f = lambda e: e[1]'
'sorted(a, key=f)'
10 loops, best of 3: 22.4 msec per loop
Morp
"Dave S" <[EMAIL PROTECTED]> wrote
> I have a bunch of lists within lists that I need to sort ref item
> [4], I can't
> access my code at the moment but I basically ...
>
> a = [[...], [...], ]
> a.sort(item4)
>
> def item4(a,b):
> return a[4], b[4]
>
>
> Having googled I think there is a be
On Thursday 16 November 2006 22:35, John Fouhy wrote:
> On 17/11/06, Dave S <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I have a bunch of lists within lists that I need to sort ref item [4], I
> > can't access my code at the moment but I basically ...
>
> [...]
>
> > Having googled I think there is
On 17/11/06, Dave S <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a bunch of lists within lists that I need to sort ref item [4], I can't
> access my code at the moment but I basically ...
>
[...]
>
> Having googled I think there is a better way of doing this with the key
> attribute
>
> a.sort(key=
Ok. That's the point. I think i meant case-sensitive. There are
some ways described here that will me help out.
Yes, the list is sorted when i print it out.
It was my fault, sorry guys.
Thank you a lot.
mac
___
Tutor maillist - Tutor@python.org
http:/
> In python2.4, you can also use the key= keyword argument:
>
> ###
> def toUpper(s):
> return s.upper()
> files.sort(key=toUpper)
> ###
>
> This is more efficient, I believe, because the key function is only
> called once for each element, whereas cmp is called more than once.
>
> (we could use
On 24/11/05, Danny Yoo <[EMAIL PROTECTED]> wrote:
> The files that start with uppercase come first because of the way those
> strings compare to lowercase strings. If we want a case-insensitive sort,
> we can do something like this:
>
> ##
> >>> def case_insensitive_cmp(a, b):
> ... return
At 09:55 AM 11/23/2005, lmac wrote:
>i have a list with the dirs/files from the current path. When i use
>sort() to sort the list alphabetically the list is still unsorted.
When you say "unsorted" - are the list members in the same order as
before the sort?
>dirs_files = os.listdir(os.getcwd())
On Wed, 23 Nov 2005, lmac wrote:
> i have a list with the dirs/files from the current path. When i use
> sort() to sort the list alphabetically the list is still unsorted. How
> to use ?
>
> dirs_files = os.listdir(os.getcwd())
> print dirs_files
> dirs_files.sort()
> print dirs_files
Hi lmac,
How about this? Not only does it count each element, but you can also get a
sorted set without using set!
a = [24,24,24,16,16,15,15]
b = {}
for i in a:
try: b[i] += 1
except KeyError: b[i] = 1
print b
li = b.keys()
print li
li.sort()
print li
li.reverse()
print li
has output
{24: 3, 16
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
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
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
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
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
Quoting Jonas Melian <[EMAIL PROTECTED]>:
> Thank you very much!.
>
> I didn't want to make it using the old-style programming because it's
> more large and I'm supposed that slower that using a list comprehension
> solution.
Well, we can investigate, to find out the truth :-)
Hopefully you ca
Jonas Melian wrote:
> best = [ [1024, 768], [800, 600], [640, 480] ] (it's larger)
>
> modes = [
> (24, [1280, 1024]),
> (24, [1024, 768]),
> (24, [640, 480]),
> (16, [1600, 1200]),
> (16, [1280, 1024]),
> (15, [320, 200]),
> ]
>
> I want to create a list with ALL elements of 'modes', but follow
Quoting Jonas Melian <[EMAIL PROTECTED]>:
> best = [ [1024, 768], [800, 600], [640, 480] ] (it's larger)
>
> modes = [
> (24, [1280, 1024]),
> (24, [1024, 768]),
> (24, [640, 480]),
> (16, [1600, 1200]),
> (16, [1280, 1024]),
> (15, [320, 200]),
> ]
>
> I want to create a list with ALL elements
Klas Marteleur wrote:
Thanks Kent
Your program does what i wanted to accomplish. But i dont really know why, and
that disturbs me.
I guess its the class that confuses me. Could you or sombody else on this list
help me out by putting some words on what is happening in this program, and
in which
Thanks Kent
Your program does what i wanted to accomplish. But i dont really know why, and
that disturbs me.
I guess its the class that confuses me. Could you or sombody else on this list
help me out by putting some words on what is happening in this program, and
in which order things are done
Klas Marteleur wrote:
Hi
I have wrestled with a problem since last weeks knapsack discussion.
This is what i want, but i cant get it into a program.
I have a sorted list (for example):
aList = [10,9,8,7,6,5,4,3,2,1]
I have a max value (for example):
maxValue
63 matches
Mail list logo