On 11/21/2016 07:10 PM, rmjbr...@gmail.com wrote:
Hi! This is my first post! I'm having trouble understanding my code. I get
"SyntaxError:invalid syntax" on line 49. I'm trying to code a simple text-based
rpg on repl.it. Thank you for reading.
print("Welcome to Gladiator Game! Choose your ch
On 11/22/2016 08:51 AM, Michiel Overtoom wrote:
Hi Ganesh,
Any better suggestion to improve this piece of code and make it look more
pythonic?
import random
# A list of tuples. Note that the L behind a number means that the number is a
'long'.
data = [(1, 1, 373891072L, 8192), (1, 3, 390
Hi all
Sometimes I write something that I think is quite clever, but later on I
look at it and ask 'What was I thinking?'.
I have just come up with a 'clever' solution to a problem. Would this cause
raised eyebrows if you were reviewing this?
I have a class that represents a single database
"Frank Millman" :
> 3. When instantiating an object, check if it would need computation -
>if computation_required:
>self.getval = self._getval_with_comp
>else:
>self.getval = self._getval
>
> 4. In _getval_with_comp, perform the computation, then add the following -
>
"Marko Rauhamaa" wrote in message news:87inrer0dl@elektro.pacujo.net...
"Frank Millman" :
> What is the verdict? -1, 0, or +1?
Perfectly cromulent, run-of-the-mill Python code.
A new word to add to my vocabulary - thanks :-)
Frank
--
https://mail.python.org/mailman/listinfo/pytho
type= title = Wizo - Anderster Full Album - YouTube
type= title = Wizo - Bleib Tapfer / für'n Arsch Full
Album - YouTube
Traceback (most recent call last):
File "./music-fetcher.py", line 39, in
title = HTMLParser.HTMLParser().unescape(title)
File "/usr/lib/python2.7/HTMLParser.py",
On Wednesday, November 23, 2016 at 3:43:05 AM UTC-5, Larry Hudson wrote:
> On 11/22/2016 08:51 AM, Michiel Overtoom wrote:
> > Hi Ganesh,
> >
> >> Any better suggestion to improve this piece of code and make it look more
> >> pythonic?
> >
> >
> > import random
> >
> > # A list of tuples. Note tha
"Marko Rauhamaa" wrote in message news:87inrer0dl@elektro.pacujo.net...
"Frank Millman" :
> 3. When instantiating an object, check if it would need computation -
>if computation_required:
>self.getval = self._getval_with_comp
>else:
>self.getval = self._getval
>
> 4
On Wed, 23 Nov 2016 08:10 pm, Frank Millman wrote:
[...]
> The class has a getval() method to return the current value.
>
> Usually the value is stored in the instance, and can be returned
> immediately, but sometimes it has to be computed, incurring further
> database lookups.
This is called me
On Wed, Nov 23, 2016 at 10:11 PM, Frank Millman wrote:
> Gah! The law of unintended consequences strikes again!
>
> As I mentioned, the class in question represents a database column. A
> separate class represents a database row. I have a __str__() method on the
> 'row' class that prints a nicely
Frank Millman wrote:
> Hi all
>
> Sometimes I write something that I think is quite clever, but later on I
> look at it and ask 'What was I thinking?'.
>
> I have just come up with a 'clever' solution to a problem. Would this
> cause raised eyebrows if you were reviewing this?
>
> I have a clas
"Frank Millman" wrote in message news:o13meh$p2g$1...@blaine.gmane.org...
3. When instantiating an object, check if it would need computation -
if computation_required:
self.getval = self._getval_with_comp
else:
self.getval = self._getval
4. In _getval_with_comp, perfor
On Wed, Nov 23, 2016 at 11:27 PM, Frank Millman wrote:
>
> @Chris
>>
>> This strongly suggests that str(x) is the wrong way to get the
>> information. You shouldn't be doing database requests inside __str__
>> or __repr__.
>
>
> I guess you are right, but still it is a pity. __str__ has been worki
"Chris Angelico" wrote in message
news:CAPTjJmqGEwHPVyrR+Ti9bV=S5MsLt3nquF4TvE=xpees188...@mail.gmail.com...
On Wed, Nov 23, 2016 at 11:27 PM, Frank Millman
wrote:
>
> @Chris
>>
>> This strongly suggests that str(x) is the wrong way to get the
>> information. You shouldn't be doing database
I'm just learning, so please excuse my ignorance for what I know is a simple
issue...
I'm writing a "Hello, World" type of script to see how things work in python3.
I'm asking for input to get a person's birthday, then I want to compare that to
"today" and see how many days have past.
--code-
On 11/23/2016 09:18 AM, jones.day...@gmail.com wrote:
but how do I replace the "2008, 8, 18" and "2008, 9, 26" with *my* values?
I've tried several things (which I can't remember all of) but usually end up with an error like
this:
Does this not work for you?
d = date(byear, bmonth,
ah...yes, but then how could I strip the rest (h:m:s) from it?
Enter the numerical month you were born: 3
Enter the numerical day of the month you were born: 30
Enter the year you were born: 1989
10100 days, 0:00:00
--
https://mail.python.org/mailman/listinfo/python-list
jones.day...@gmail.com writes:
> but how do I replace the "2008, 8, 18" and "2008, 9, 26" with *my* values?
> I've tried several things (which I can't remember all of) but usually end up
> with an error like this:
Something like this?
today = date.today()
birthday = date(byear, bmonth, bday)
On 2016-11-23 22:15, Steve D'Aprano wrote:
> On Wed, 23 Nov 2016 08:10 pm, Frank Millman wrote:
> > The class has a getval() method to return the current value.
> >
> > Usually the value is stored in the instance, and can be returned
> > immediately, but sometimes it has to be computed, incurring
Ah, perfect - thanks. I was overly complicating things.
--
https://mail.python.org/mailman/listinfo/python-list
On Wed, Nov 23, 2016 at 7:13 AM, Dayton Jones
wrote:
> ah...yes, but then how could I strip the rest (h:m:s) from it?
>
> Enter the numerical month you were born: 3
> Enter the numerical day of the month you were born: 30
> Enter the year you were born: 1989
> 10100 days, 0:00:00
> --
> https://m
Hi, I am wondering how to concatenate corresponding strings in two lists,
assuming that the lists are of same length, e.g.
val_1 = ['a', 'b', 'c']
val_2 = ['A', 'B', 'C']
# concatenate corresponding strings in 'val_1' and 'val_2'
# and put results in another list 'val' so that
# val = ['aA', 'bB'
On 23 November 2016 at 19:40, Daiyue Weng wrote:
> Hi, I am wondering how to concatenate corresponding strings in two lists,
> assuming that the lists are of same length, e.g.
>
> val_1 = ['a', 'b', 'c']
> val_2 = ['A', 'B', 'C']
>
> # concatenate corresponding strings in 'val_1' and 'val_2'
> # a
On 11/23/2016 12:40 PM, Daiyue Weng wrote:
Hi, I am wondering how to concatenate corresponding strings in two lists,
assuming that the lists are of same length, e.g.
val_1 = ['a', 'b', 'c']
val_2 = ['A', 'B', 'C']
# concatenate corresponding strings in 'val_1' and 'val_2'
# and put results in a
I'd like to be able to display 2 calendars side by side, instead of stacked...
is this possible?
for instance:
print(calendar.month(year_a,month))
print()
print(calendar.month(year_b,month))
prints:
June 1971
Mo Tu We Th Fr Sa Su
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15
Can please anyone explaine me what do each of these code lines and how k-means
algorithm works?
from scipy.cluster.vq import *
from scipy.misc import imresize
from pylab import *
from PIL import Image
steps = 500
im = array(Image.open("empire.jpg"))
dx = im.shape[0] / steps
dy = im.shape[1] / s
On 2016-11-23 10:02, Dayton Jones wrote:
> I'd like to be able to display 2 calendars side by side, instead of
> stacked... is this possible?
>
> for instance:
>
> print(calendar.month(year_a,month))
> print()
> print(calendar.month(year_b,month))
>
> prints:
> June 1971
> Mo Tu
Dayton Jones wrote:
> I'd like to be able to display 2 calendars side by side, instead of
> stacked... is this possible?
I'm too lazy to look around for a ready-to-use solution, so here's my own:
$ cat side_by_side.py
from itertools import zip_longest
def zip_lines(*columns, sep=" "):
colu
On 2016-11-23 18:02, Dayton Jones wrote:
I'd like to be able to display 2 calendars side by side, instead of stacked...
is this possible?
for instance:
print(calendar.month(year_a,month))
print()
print(calendar.month(year_b,month))
prints:
June 1971
Mo Tu We Th Fr Sa Su
1
Perfect! Thank you.
--
https://mail.python.org/mailman/listinfo/python-list
I need a way of generating a random number but there is a catch:
I don't want to include certain numbers, is this possible?
random.randint(1,100) works as it will randomly pick numbers between 1 and 100
but say i don't want 48 to come out is there a way of doing this. It needs to
be an integer
Thomas Grops :
> random.randint(1,100) works as it will randomly pick numbers between 1
> and 100 but say i don't want 48 to come out is there a way of doing
> this. It needs to be an integer too so not a list unless there is a way
> to convert list to int
r = 48
while r == 48:
r = r
On 11/23/2016 02:17 PM, Thomas Grops via Python-list wrote:
I need a way of generating a random number but there is a catch:
I don't want to include certain numbers, is this possible?
random.randint(1,100) works as it will randomly pick numbers between 1 and 100
but say i don't want 48 to come
On Wed, Nov 23, 2016 at 11:17 AM, Thomas Grops via Python-list
wrote:
> I need a way of generating a random number but there is a catch:
>
> I don't want to include certain numbers, is this possible?
>
> random.randint(1,100) works as it will randomly pick numbers between 1 and
> 100 but say i do
You can use a while statement until you get a number out of your
excluded numbers
excludedNumbers = [1,2,3,4]
randomNumber = random.randomint(1,100)
while randomNumber in excludedNumbers:
randomNumber = random.randomint(1,100)
After the while you have a number outside the excluded nu
On Wednesday, 23 November 2016 19:30:04 UTC, Thomas Nyberg wrote:
> On 11/23/2016 02:17 PM, Thomas Grops via Python-list wrote:
> > I need a way of generating a random number but there is a catch:
> >
> > I don't want to include certain numbers, is this possible?
> >
> > random.randint(1,100) work
On Wednesday, 23 November 2016 19:30:21 UTC, Chris Kaynor wrote:
> On Wed, Nov 23, 2016 at 11:17 AM, Thomas Grops via Python-list
> wrote:
> > I need a way of generating a random number but there is a catch:
> >
> > I don't want to include certain numbers, is this possible?
> >
> > random.randint
On 2016-11-23 19:29, Chris Kaynor wrote:
On Wed, Nov 23, 2016 at 11:17 AM, Thomas Grops via Python-list
wrote:
I need a way of generating a random number but there is a catch:
I don't want to include certain numbers, is this possible?
random.randint(1,100) works as it will randomly pick numbe
Thankyou for all your help I have managed to pick a way that works from your
suggestions :D
--
https://mail.python.org/mailman/listinfo/python-list
Frank Millman wrote:
For the time being I will use 'print(await obj.__str__())', as this is a
good compromise.
It seems more like a very *bad* compromise to me.
I can't see how this gains you anything over just doing
print(await obj.getvalue()), and you lose the ability to
do anything that cal
On Wed, 23 Nov 2016 11:27 pm, Frank Millman wrote:
> It is a bit like quantum theory. I have no way of telling whether the
> computation has been carried out without looking at it, but the act of
> looking at it triggers the computation. I can tell, of course, by looking
> at the underlying attrib
On Wed, 23 Nov 2016 06:18:38 -0800, jones.dayton wrote:
> I'm just learning, so please excuse my ignorance for
> what I know is a simple issue...
>
> I'm writing a "Hello, World" type of script to see how
> things work in python3. I'm asking for input to get a
> person's birthday, then I want to
On 23/11/2016 23:28, Lawrence D’Oliveiro wrote:
To the controllers of Python-List:
I never asked to be on your list. I never consented to having my postings
appear on your list. And I certainly didn’t agree to any conditions you might
impose on members on your list.
Therefore, to see you take
On Thu, Nov 24, 2016 at 10:02 AM, Wildman via Python-list
wrote:
> Try the code that is below:
>
> import datetime
> from datetime import date
>
> today = date.today()
> person = input("Enter your name: ")
> byear = raw_input("Enter the four-digit year you were born: ")
Please take care of Python
On 11/23/2016 04:31 PM, mm0fmf wrote:
> On 23/11/2016 23:28, Lawrence D’Oliveiro wrote:
>> Therefore, to see you take offence at something I said, and use
>> that as an excuse to “ban” me from your list, is an act of
>> breathtaking hypocrisy. As far as I am concerned, it is you lot who
>> should b
On Thu, 24 Nov 2016 10:28 am, Lawrence D’Oliveiro wrote:
> To the controllers of Python-List:
>
> I never asked to be on your list. I never consented to having my postings
> appear on your list. And I certainly didn’t agree to any conditions you
> might impose on members on your list.
comp.lang.
On Wed, 23 Nov 2016 10:11 pm, Frank Millman wrote:
> Gah! The law of unintended consequences strikes again!
>
> As I mentioned, the class in question represents a database column.
Yes, you mentioned that.
> A
> separate class represents a database row. I have a __str__() method on the
> 'row'
>>> pygame.draw.rect(screen, BROWN, [60, 400, 30, 45])
Traceback (most recent call last):
File "", line 1, in
pygame.draw.rect(screen, BROWN, [60, 400, 30, 45])
NameError: name 'pygame' is not defined
How to solve this error ?
--
https://mail.python.org/mailman/listinfo/python-list
On Wed, Nov 23, 2016 at 9:44 PM, Cai Gengyang wrote:
pygame.draw.rect(screen, BROWN, [60, 400, 30, 45])
> Traceback (most recent call last):
> File "", line 1, in
> pygame.draw.rect(screen, BROWN, [60, 400, 30, 45])
> NameError: name 'pygame' is not defined
>
> How to solve this error ?
> --
I tried to import pygame by using these commands
https://www.google.com.sg/#q=how+to+import+pygame
but this is the error I got :
CaiGengYangs-MacBook-Pro:~ CaiGengYang$ sudo apt-get install python-pygame
sudo: apt-get: command not found
On Thurs
On Thu, 24 Nov 2016 11:59:17 +1100, Chris Angelico wrote:
> On Thu, Nov 24, 2016 at 10:02 AM, Wildman via Python-list
> wrote:
>> Try the code that is below:
>>
>> import datetime
>> from datetime import date
>>
>> today = date.today()
>> person = input("Enter your name: ")
>> byear = raw_input("
On Thu, Nov 24, 2016 at 2:41 PM, Wildman via Python-list
wrote:
> Point taken. I did miss the python3 part.
>
> I switched to raw_input because it handles an empty
> input. An empty input would trigger the ValueError.
> No doubt with the correct code the same or similar
> could be done with inpu
Hello,
Given a list of files:
In [81]: ec_files[0:10]
Out[81]:
[u'EC_20160604002000.csv',
u'EC_2016060401.csv',
u'EC_20160604012000.csv',
u'EC_20160604014000.csv',
u'EC_2016060402.csv']
where the numbers are are a timestamp with format %Y%m%d%H%M%S, I'd like
to generate a list of m
On 11/23/2016 10:02 PM, Cai Gengyang wrote:
I tried to import pygame by using these commands
https://www.google.com.sg/#q=how+to+import+pygame
but this is the error I got :
CaiGengYangs-MacBook-Pro:~ CaiGengYang$ sudo apt-get install python-pygam
On 11/23/2016 03:09 AM, Ned Batchelder wrote:
[snip...]
Or using the new string formatting syntax:
msg = '{},{},{}:{}'.format(*item)
The *item in the format() unpacks the tuple.
"new" == "Introduced in 2.6, available since 2008" :)
--Ned.
Of course. I probably should have said "newer" o
Yea, using Mac
Following the instructions here for Mac
---https://bitbucket.org/pygame/pygame/issues/82/homebrew-on-leopard-fails-to-install#comment-627494
GengYang Cai CaiGengYangs-MacBook-Pro:~ CaiGengYang$ brew install python
==> Installing dependencies for python: xz, pkg-config, readline,
"Steve D'Aprano" wrote in message
news:583653bb$0$1603$c3e8da3$54964...@news.astraweb.com...
Even if the computation of the memoised value is done asynchronously, you
can easily split the computation off to a separate method (as you already
talked about doing!) and make getval() block until it
I don't see anything in that output resembling an error, just a few
warnings that some features may no be available.
Have you tried importing pygame after you did that? That's what'll prove
one way or another that it worked.
Regards,
Nate
On Wed, Nov 23, 2016 at 10:48 PM, Cai Gengyang
wrote:
>
On Thu, 24 Nov 2016 14:49:27 +1100, Chris Angelico wrote:
> On Thu, Nov 24, 2016 at 2:41 PM, Wildman via Python-list
> wrote:
>> Point taken. I did miss the python3 part.
>>
>> I switched to raw_input because it handles an empty
>> input. An empty input would trigger the ValueError.
>> No doubt
On 11/23/2016 11:17 AM, Thomas Grops wrote:
I need a way of generating a random number but there is a catch:
I don't want to include certain numbers, is this possible?
random.randint(1,100) works as it will randomly pick numbers between 1 and 100
but say i don't want 48 to come out is there a
On Thursday 24 November 2016 15:55, Frank Millman wrote:
> "Steve D'Aprano" wrote in message
> news:583653bb$0$1603$c3e8da3$54964...@news.astraweb.com...
>
>> Even if the computation of the memoised value is done asynchronously, you
>> can easily split the computation off to a separate method (a
"Steven D'Aprano" wrote in message
news:58368358$0$1513$c3e8da3$54964...@news.astraweb.com...
On Thursday 24 November 2016 15:55, Frank Millman wrote:
> "Steve D'Aprano" wrote in message
> news:583653bb$0$1603$c3e8da3$54964...@news.astraweb.com...
>
>> Even if the computation of the memoised
Steven Truppe writes:
> type= title = Wizo - Anderster Full Album - YouTube
> type= title = Wizo - Bleib Tapfer / für'n Arsch Full
> Album - YouTube
> Traceback (most recent call last):
> File "./music-fetcher.py", line 39, in
> title = HTMLParser.HTMLParser().unescape(title)
> File
Alex writes:
> Can please anyone explaine me what do each of these code lines and how
> k-means algorithm works?
How about searching "wikipedia"?
(--> "https://en.wikipedia.org/wiki/K-means_clustering";).
--
https://mail.python.org/mailman/listinfo/python-list
64 matches
Mail list logo