On 06/16/2013 01:40 AM, Dotan Cohen wrote:
On Sat, Jun 15, 2013 at 2:32 PM, Dave Angel wrote:
Thank you. So would it be clear if I were to say "I prefer
printf-style formatting over the format method."?
I'd be careful there, since method is an English word as well as a Python
one. So I'd ma
On 06/16/2013 01:58 AM, Steven D'Aprano wrote:
On 16/06/13 11:53, Dave Angel wrote:
On 06/15/2013 08:36 PM, Steven D'Aprano wrote:
for key in sorted(mydict.keys()):
...
works fine.
[...]
The sort() method doesn't work, but sorted does.
[...]
for key in sorted(mydict.keys()):
Not o
On 16/06/13 11:53, Dave Angel wrote:
On 06/15/2013 08:36 PM, Steven D'Aprano wrote:
for key in sorted(mydict.keys()):
...
works fine.
[...]
The sort() method doesn't work, but sorted does.
[...]
for key in sorted(mydict.keys()):
Not only that, but sorted works too:
for key in sort
On 15 June 2013 22:32, Steven D'Aprano wrote:
> http://mail.python.org/pipermail/python-list/2013-June/649710.html
A succinct list - worth putting in my Keep file ;')
-
Jim
After indictment the bacon smuggler was put on the no-fry list
___
Tutor mailli
On 16/06/13 12:31, Joel Goldstick wrote:
On Sat, Jun 15, 2013 at 10:21 PM, Jim Mooney wrote:
On 15 June 2013 19:03, Dave Angel wrote:
Why such a convoluted way of expressing yourself?
I was demonstrating the parallelism, but let's just take one so I can
unbefuddle meself ;')
*** Python 3.3
On Sat, Jun 15, 2013 at 2:41 PM, Steven D'Aprano wrote:
> On 15/06/13 20:18, Dotan Cohen wrote:
>>
> "I prefer % formatting over str.format method."
>
> "I prefer percent-formatting over brace-formatting."
>
> "I prefer C-style string formatting over the newer string format method."
>
Thank you S
On Sat, Jun 15, 2013 at 2:32 PM, Dave Angel wrote:
>> Thank you. So would it be clear if I were to say "I prefer
>> printf-style formatting over the format method."?
>>
>
> I'd be careful there, since method is an English word as well as a Python
> one. So I'd make it clear i was referrring to a
On 16/06/13 13:15, Jim Mooney wrote:
## Comparing different types for equality always fails:
if '5' != 5:
print('oops')
Not always. Counter-examples are most obvious when it comes to numbers:
py> from decimal import Decimal
py> from fractions import Fraction
py> Fraction(1, 2) == Decima
On 16/06/13 11:30, Jim Mooney wrote:
##This is puzzling me. If I check the equality of 0, None, empty
string, and empty list with False,
##only zero satisfies the equality. But if I use them in a not
statement, they all turn out False.
##What gives?
That's because the tests do different things
On 15 June 2013 21:41, Dave Angel wrote:
class NobodyHome:
> ... def __bool__(self):
> ... return False #normally, you'd be testing some attribute to
> decide this
>
> ...
x = NobodyHome()
not x
> True
>
That's a breath of fresh air - talk about freedom ;') Makes me
On 06/15/2013 11:53 PM, Jim Mooney wrote:
On 15 June 2013 20:48, Joel Goldstick wrote:
One and zero for True and False may seem not quite right today,
I still think they should be taken out and shot ;')
But my simplification plan failed. Equality always fails for different
types, and 'not i
On 15 June 2013 20:48, Joel Goldstick wrote:
>
> One and zero for True and False may seem not quite right today, but digital
> computers are based on the fact that circuits can be built that have two
> states -- on/off or true/false, or 1/0.
But then, if we're going down to the gate level, why no
On 15 June 2013 20:48, Joel Goldstick wrote:
> One and zero for True and False may seem not quite right today,
I still think they should be taken out and shot ;')
But my simplification plan failed. Equality always fails for different
types, and 'not in front of None or any empty object such as
On Sat, Jun 15, 2013 at 11:15 PM, Jim Mooney wrote:
> On 15 June 2013 19:45, eryksun wrote:
> > On Sat, Jun 15, 2013 at 10:23 PM, eryksun wrote:
> >> This function is hard coded for the singletons True,
> >> False, and None -- and otherwise uses either __bool__
> >> (tp_as_number->nb_bool) or __
On 15 June 2013 19:45, eryksun wrote:
> On Sat, Jun 15, 2013 at 10:23 PM, eryksun wrote:
>> This function is hard coded for the singletons True,
>> False, and None -- and otherwise uses either __bool__
>> (tp_as_number->nb_bool) or __len__ (tp_as_mapping->mp_length or
>> tp_as_sequence->sq_length
On Sat, Jun 15, 2013 at 10:23 PM, eryksun wrote:
> This function is hard coded for the singletons True,
> False, and None -- and otherwise uses either __bool__
> (tp_as_number->nb_bool) or __len__ (tp_as_mapping->mp_length or
> tp_as_sequence->sq_length). A length of 0 is falsey.
I forgot to add
On 15 June 2013 19:28, Dave Angel wrote:
> If you want to compare a non-boolean to False or True, expect it'll always
> be false. They are different types. (except for the int historical
> nonsense I mentioned earlier).
Ah, that clarifies it - type differences - something I can look out
for -
On Sat, Jun 15, 2013 at 10:21 PM, Jim Mooney wrote:
> On 15 June 2013 19:03, Dave Angel wrote:
> > Why such a convoluted way of expressing yourself?
>
> I was demonstrating the parallelism, but let's just take one so I can
> unbefuddle meself ;')
>
> *** Python 3.3.2 32 bit (Intel)] on win32. ***
On 06/15/2013 10:21 PM, Jim Mooney wrote:
On 15 June 2013 19:03, Dave Angel wrote:
Why such a convoluted way of expressing yourself?
I was demonstrating the parallelism, but let's just take one so I can
unbefuddle meself ;')
*** Python 3.3.2 32 bit (Intel)] on win32. ***
'' == False
False
On Sat, Jun 15, 2013 at 9:30 PM, Jim Mooney wrote:
> This is puzzling me. If I check the equality of 0, None, empty
> string, and empty list with False, only zero satisfies the equality.
> But if I use them in a not statement, they all turn out False.
> What gives?
>
> #Using C:\Python33\python.ex
On 15 June 2013 19:03, Dave Angel wrote:
> Why such a convoluted way of expressing yourself?
I was demonstrating the parallelism, but let's just take one so I can
unbefuddle meself ;')
*** Python 3.3.2 32 bit (Intel)] on win32. ***
>>> '' == False
False
>>> not ''
True
>>>
Why the difference he
On 06/15/2013 09:30 PM, Jim Mooney wrote:
##This is puzzling me. If I check the equality of 0, None, empty
string, and empty list with False,
##only zero satisfies the equality. But if I use them in a not
statement, they all turn out False.
##What gives?
#Using C:\Python33\python.exe on Win 7 in
On 06/15/2013 08:36 PM, Steven D'Aprano wrote:
On 16/06/13 07:55, Alan Gauld wrote:
On 15/06/13 20:54, Jim Mooney wrote:
I just like to avoid typing all those odd little-finger characters.
The dictionaries are the worst.
I think your making it harder than it is.
Just use the result as you wo
##This is puzzling me. If I check the equality of 0, None, empty
string, and empty list with False,
##only zero satisfies the equality. But if I use them in a not
statement, they all turn out False.
##What gives?
#Using C:\Python33\python.exe on Win 7 in c:\python33\jimprogs
print('Zero is equal
On 16/06/13 07:55, Alan Gauld wrote:
On 15/06/13 20:54, Jim Mooney wrote:
I just like to avoid typing all those odd little-finger characters.
The dictionaries are the worst.
I think your making it harder than it is.
Just use the result as you would expect and it will work.
Don't get hung up
On 15 June 2013 14:55, Alan Gauld wrote:
> I think your making it harder than it is.
> Just use the result as you would expect and it will work.
I just meant that since I'm learning I'll create a dictionary on the
fly to try something out. All goes well except my IDE will type two
quotes if I ty
On 15/06/13 20:54, Jim Mooney wrote:
I just like to avoid typing all those odd little-finger characters.
The dictionaries are the worst.
I think your making it harder than it is.
Just use the result as you would expect and it will work.
Don't get hung up over a list versus an iterable.
Just u
On 15 June 2013 12:34, Andreas Perstinger wrote:
d = {'a': 1, 'b': 2, 'c': 3, 'd': 4}
list(d.keys())
> ['a', 'c', 'b', 'd']
Ah, that simplifies it. I probably read that and forgot it - so little
time so much to learn ;') Without you guys the memory-fog would do me
in .
I just like to
On 15 June 2013 11:51, Chris “Kwpolska” Warrick wrote:
> The standard use is:
>
> for k, v in d.items():
>do_stuff_with_dict_items_here()
>
Yes, they're easy to get keys = [x for x in d], or vals = [d[x] for x in d]
It's just that Python usually does what I expect and presents me w
On 16/06/13 04:41, Jim Mooney wrote:
When I try to get the keys of a dictionary, such as d.keys(), I get
the below instead of a plain list, and it's not very usable. How can I
use the keys from this like it was a list, or is this basically
useless other than to see the keys or values?
*** Python
Jim Mooney wrote:
>When I try to get the keys of a dictionary, such as d.keys(), I get
>the below instead of a plain list, and it's not very usable. How can I
>use the keys from this like it was a list, or is this basically
>useless other than to see the keys or values?
If you really need a list
On Sat, Jun 15, 2013 at 2:41 PM, Jim Mooney wrote:
> When I try to get the keys of a dictionary, such as d.keys(), I get
> the below instead of a plain list, and it's not very usable. How can I
> use the keys from this like it was a list, or is this basically
> useless other than to see the keys o
On Sat, Jun 15, 2013 at 8:41 PM, Jim Mooney wrote:
> When I try to get the keys of a dictionary, such as d.keys(), I get
> the below instead of a plain list, and it's not very usable. How can I
> use the keys from this like it was a list, or is this basically
> useless other than to see the keys o
When I try to get the keys of a dictionary, such as d.keys(), I get
the below instead of a plain list, and it's not very usable. How can I
use the keys from this like it was a list, or is this basically
useless other than to see the keys or values?
*** Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 201
On 15 June 2013 03:23, Dotan Cohen wrote:
Oh? Which book is that? I've so far been learning by writing small
> applications here and there. I have been meaning to go through Learn
> Python The Hard Way for the longest time.
>
=
>
> Learning Python, fifth edition, by Mark Lutz
On 15/06/13 20:18, Dotan Cohen wrote:
On Fri, Jun 14, 2013 at 6:46 PM, Steven D'Aprano wrote:
On 15/06/13 01:23, Dotan Cohen wrote:
What are these two string-formatting styles called?
'%.3f' % x
'{0:.3f}'.format(x)
"String formatting", and "string formatting" *wink*
Sometimes the first is
On 06/15/2013 06:23 AM, Dotan Cohen wrote:
On Fri, Jun 14, 2013 at 7:01 PM, Jim Mooney wrote:
On 14 June 2013 08:23, Dotan Cohen wrote:
What are these two string-formatting styles called?
'%.3f' % x
'{0:.3f}'.format(x)
The first one is a string Expression, using % as the overloaded operat
On Fri, Jun 14, 2013 at 7:01 PM, Jim Mooney wrote:
> On 14 June 2013 08:23, Dotan Cohen wrote:
>>
>> What are these two string-formatting styles called?
>> '%.3f' % x
>> '{0:.3f}'.format(x)
>
>
> The first one is a string Expression, using % as the overloaded operator
> The second one is a string
On Fri, Jun 14, 2013 at 6:46 PM, Steven D'Aprano wrote:
> On 15/06/13 01:23, Dotan Cohen wrote:
>>
>> What are these two string-formatting styles called?
>> '%.3f' % x
>> '{0:.3f}'.format(x)
>
>
> "String formatting", and "string formatting" *wink*
>
> Sometimes the first is called "string interpo
On Fri, Jun 14, 2013 at 12:05 PM, Jim Mooney wrote:
> On 14 June 2013 08:49, eryksun wrote:
>>
>> C:\>doskey calc=c:\python33\python -c "from cmath import *;print($*)"
>>
>> C:\>calc e**(1j*pi/3)
>> (0.5001+0.8660254037844386j)
>>
>> Cool. I totally forgot about doskey mac
On Fri, Jun 14, 2013 at 6:35 PM, Jim Mooney wrote:
> On 14 June 2013 08:49, eryksun wrote:
>>
>> C:\>python -i -c "import os; os.chdir('C:/Python33')"
>
> Well, that didn't work anyway. Got me the right directory and the
> interpeter, but I couldn't run a py file from command. Batch file didn
Hello Tutors,
Would any of you have any teaching (or substantial self learning)
experience with a library for Symbolic math?
I am currently exploring sympy (http://sympy.org) as part of writing a
book chapter and would like to know if there any better/easier option
out there which can successfull
42 matches
Mail list logo