Why does the compiler choke on this? It seems to me that the enhanced
subtraction resolves to a legitimate integer in the exponent, but I get a
syntax error:
B = '11011101'
sum = 0
start = len(B)
for char in B:
sum += int(char) * 2**(start -= 1) ## syntax error
print(sum)
--
Jim
___
Is there any difference between these two since they give the same result,
and when is the second preferred?
>>> x = 'ABE'
>>> x.lower()
'abe'
>>> str.lower(x)
'abe'
--
Jim
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription o
>>>start_time = "2014-7-1"
>>> revlines = commands.getoutput("git log --pretty=format:'%ad:%an'
--date=short --since='%s' --no-merges" %start_time).strip().split('\n')
Traceback (most recent call last):
File "", line 1, in
ValueError: unsupported format character 'a' (0x61) at index 26
>>>
if
On Apr 21, 2015 12:24 AM, "Jim Mooney" wrote:
>
> Why does the compiler choke on this? It seems to me that the enhanced
> subtraction resolves to a legitimate integer in the exponent, but I get a
> syntax error:
>
> B = '11011101'
> sum = 0
> start = len(B)
> for char in B:
> sum += int(char)
On Apr 21, 2015 12:27 AM, "lei yang" wrote:
>
> >>>start_time = "2014-7-1"
> >>> revlines = commands.getoutput("git log --pretty=format:'%ad:%an'
> --date=short --since='%s' --no-merges" %start_time).strip().split('\n')
> Traceback (most recent call last):
> File "", line 1, in
> ValueError: un
On 21/04/15 05:19, Jim Mooney wrote:
Is there any difference between these two since they give the same result,
and when is the second preferred?
x = 'ABE'
x.lower()
'abe'
str.lower(x)
'abe'
They are essentially the same method being accessed in two
different ways. The first via the insta
On 21/04/15 06:22, lei yang wrote:
start_time = "2014-7-1"
revlines = commands.getoutput("git log --pretty=format:'%ad:%an'
--date=short --since='%s' --no-merges" %start_time).strip().split('\n')
Traceback (most recent call last):
File "", line 1, in
ValueError: unsupported format character
On 21/04/15 01:44, Jim Mooney wrote:
Why does the compiler choke on this? It seems to me that the enhanced
subtraction resolves to a legitimate integer
That's your mistake. Assignment is a statement not an expression. It
does not return anything. In fact its just illegal to try:
>>> print x=
Jim Mooney wrote:
> Is there any difference between these two since they give the same result,
> and when is the second preferred?
>
x = 'ABE'
x.lower()
> 'abe'
str.lower(x)
> 'abe'
You may call str.lower() explicitly for subclasses of str. If the subclass
overrides the lower() me
Peter Otten wrote:
class Cow:
> ... def lower(self): return "moo"
If you can't make sense of that: at the time of writing I thought that
"lowering" was a synonym for "mooing". After a look into the dictionary it
turns out to be "lowing", not "lowering". Sorry!
On 21/04/15 09:45, Peter Otten wrote:
Peter Otten wrote:
class Cow:
... def lower(self): return "moo"
If you can't make sense of that: at the time of writing I thought that
"lowering" was a synonym for "mooing". After a look into the dictionary it
turns out to be "lowing", not "lowering"
On 04/21/2015 01:21 AM, Danny Yoo wrote:
What's supposed to happen in this situation?
##
class Person(object):
def __init__(self): pass
j = Person()
john = j
jack = j
##
What single name should we get back fr
On 04/20/2015 08:44 PM, Jim Mooney wrote:
Why does the compiler choke on this? It seems to me that the enhanced
subtraction resolves to a legitimate integer in the exponent, but I get a
syntax error:
B = '11011101'
sum = 0
start = len(B)
for char in B:
sum += int(char) * 2**(start -= 1) ##
On 20/04/2015 21:05, Albert-Jan Roskam wrote:
Hi,
My Raspberry Pi 2 comes with Python 3.2 (and 2.7). I run some code that uses
the datetime module but I get an error:
"AttributeError: 'datetime.datetime' object has no attribute 'timestamp'". On
https://docs.python.org/3/whatsnew/3.3.html I se
On 20/04/2015 21:47, Ben Finney wrote:
Jim Mooney writes:
I can't seem to get my head around this 'simple' book example of
binary-to-decimal conversion, which goes from left to right:
B = '11011101'
I = 0
while B:
I = I * 2 + int(B[0])
B = B[1:]
print(I)
221
That is, IMO, a need
- Original Message -
> From: Mark Lawrence
> To: tutor@python.org
> Cc:
> Sent: Tuesday, April 21, 2015 1:31 PM
> Subject: Re: [Tutor] Is it possible to "backport" the datetime module of
> Python 3.3 to Python 3.2?
>
> On 20/04/2015 21:05, Albert-Jan Roskam wrote:
>
>> Hi,
>>
>>
On Tue, Apr 21, 2015 at 12:31:53PM +0100, Mark Lawrence wrote:
> Python is very strong in guaranteeing backward compatibility, so why not
> copy the 3.3 pure Python code to your 3.2 setup and see what happens?
Normally backwards compatibility refers to the other way: 3.3 will run
3.2 code. To h
Good morning underscore underscore Peter underscore underscore,
class Cow:
... def lower(self): return "moo"
If you can't make sense of that: at the time of writing I thought
that "lowering" was a synonym for "mooing". After a look into the
dictionary it turns out to be "lowing", not
On Tue, Apr 21, 2015 at 7:09 AM, Martin A. Brown
wrote:
> And, I dairy not chase this pun any further
>
No - keep milking it. It gets butter all the time.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https
On 2015-04-20 22:21, Danny Yoo wrote:
What's supposed to happen in this situation?
##
class Person(object):
def __init__(self): pass
j = Person()
john = j
jack = j
##
What single name should we get back from t
> But I see what I think you and others have been trying to explain to me:
> that the expression some_object.__name__, if it existed, would indeed be
> schizophrenic since it would be an attribute of the object, not the name(s)
> to which it is bound.
The hypothetical feature might also, if desi
Hi, I am developing an automated testing script in python which will, among
other things, send an email when it is done. For this I would like to send
an email when an exception is raised as well - since it already has a
cleanup function registered with atexit, this is the logical place to do
it. H
Hi,
Didn't really understand the instructions on the website but is this the right
email address for help?
Thanks, cory :)
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription op
On 04/21/2015 04:17 AM, Ryan Scholes wrote:
Hi,
Didn't really understand the instructions on the website but is this the right
email address for help?
It can be...
Some very smart, experienced and helpful folks here - some are even all
three! ;)
Generally speaking... they aren't going
On 21/04/15 12:17, Ryan Scholes wrote:
Didn't really understand the instructions on the website but is this the right
email address for help?
If its help about:
a) learning to program
b) learning the Python programming language
c) learning the Python standard library
Then yes, this is the ri
"Martin A. Brown" writes:
> Good morning underscore underscore Peter underscore underscore,
The Pythonic way to pronounce that would be “dunder Pete dunder”
https://wiki.python.org/moin/DunderAlias>.
--
\ “Geeks like to think that they can ignore politics. You can |
`\leave
Alex Kleider writes:
> I was hoping that it would be possible to create a function
> that would do the following:
>
> def my_name(some_object):
> return some_object.__name__
That hope is understandable.
It is also easy to be confused about why such a feature doesn't exist;
after all, it works
On 21Apr2015 09:59, Alex Kleider wrote:
On 2015-04-20 22:21, Danny Yoo wrote:
What's supposed to happen in this situation?
##
class Person(object):
def __init__(self): pass
j = Person()
john = j
jack = j
##
Wha
On 21Apr2015 09:03, alan.ga...@btinternet.com wrote:
On 21/04/15 05:19, Jim Mooney wrote:
Is there any difference between these two since they give the same result,
and when is the second preferred?
x = 'ABE'
x.lower()
'abe'
str.lower(x)
'abe'
They are essentially the same method being a
On 21Apr2015 22:50, Steven D'Aprano wrote:
On Tue, Apr 21, 2015 at 12:31:53PM +0100, Mark Lawrence wrote:
Python is very strong in guaranteeing backward compatibility, so why not
copy the 3.3 pure Python code to your 3.2 setup and see what happens?
Normally backwards compatibility refers to
On 2015-04-21 16:48, Cameron Simpson wrote:
But it would not be schizophrenic to write a function that returned a
name arbitrarily, by inspecting locals(). It depends whether you only
need a name, or if you need "the" name.
In my use case there'd probably be only one name for the given object
On 2015-04-21 16:38, Ben Finney wrote:
That hope is understandable.
Your "understanding" is appreciated.
It is also easy to be confused
So true, but with the help of "Python Tutors" things are being
rectified!
about why such a feature doesn't exist;
So why not arbitrary objects?
Ben Finney wrote:
> "Martin A. Brown" writes:
>
>> Good morning underscore underscore Peter underscore underscore,
>
> The Pythonic way to pronounce that would be “dunder Pete dunder”
> https://wiki.python.org/moin/DunderAlias>.
>
Hm, should I campaign for a peter() builtin?
33 matches
Mail list logo