On Fri, Jan 03, 2014 at 02:11:21PM -0800, Devin Jeanpierre wrote:
On Fri, Jan 3, 2014 at 1:53 PM, Keith Winston keithw...@gmail.com wrote:
I am gearing up for the next project (yeah, an eventual end to Chutes
Ladders!). It is a typing tutor, I am inclined to use it to learn Dvorak but
I
On 04/01/14 04:47, Keith Winston wrote:
Here is what I think will be about the final version of C and L.
Much better. Only one suggestion...
def run_CandL(gamecount):
tarray = CandL_Array()
tarray.populate(gamecount)
tarray.print_stuff()
Remove the middle line by making the
On 01/04/2014 05:47 AM, Keith Winston wrote:
Here is what I think will be about the final version of C and L. I
rearranged it quite a bit (into 2 classes), fixed a bug or two, and
generally cleaned it up a bit. I haven't really polished it, but hopefully
it will be less difficult to read...
On 01/04/2014 05:45 AM, Steven D'Aprano wrote:
On Fri, Jan 03, 2014 at 09:56:25PM -0500, Keith Winston wrote:
gmail is driving me crazy. Anyway, every time I run it with:
if __name__ == __main__:
tarray = CandL_Array
tarray.populate(100)
I get an error
Traceback (most recent call
Ok. Will try and explain the problem.
I wrote a script in python and found I could use it on my android
phone with SL4a.
It was really useful.
Haven't used it for a few months.
A few days ago I decided to improve it and found it no longer works.
the problem seems to be that when it reaches
On 01/04/2014 06:32 AM, Keith Winston wrote:
On Fri, Jan 3, 2014 at 11:59 PM, Steven D'Aprano st...@pearwood.infowrote:
thelist = vars()[name]
I see: vars() certainly looks less dangerous than eval(), but I'm guessing
that's still smelly code? I hadn't known about vars() or I probably
Thanks to both of you. In this particular case, the main use of eval() was
only for 2 calls, which were essentially hard-coded (you could see the
calls to summarize_game in my code). I was looking for a more general
solution to what I was trying to do, but I don't need it for this project.
Still,
Perhaps you could include the script?
On Sat, Jan 4, 2014 at 5:47 AM, blech...@fireflyuk.net wrote:
Ok. Will try and explain the problem.
I wrote a script in python and found I could use it on my android phone
with SL4a.
It was really useful.
Haven't used it for a few months.
A few days
On 01/04/2014 06:36 AM, Steven D'Aprano wrote:
Now, it's true that when *debugging code*, being able to see the name of
the variable and the contents of the variable is useful. But in ordinary
code, why would you care to print the name of the variable and its
contents. Who cares what the
On 01/04/2014 07:24 AM, Keith Winston wrote:
I had heard about deep/shallow copies, though in
this particular example (all int dicts), I don't think there's a
difference...?
There's none, you're right. It's only whenever inner items (fields, etc...)
themselves are complex elements and
I havent included the script as it seems to be the use ' input' on my
phone that now wont work.
At the command line (on my computer) I can type
h = input( enter character )
and when i type a response and enter it, then type h and return, i am
given back the response i put in.
I type j
On 01/04/2014 10:14 AM, Steven D'Aprano wrote:
While I agree with Devin, it is possible to write absurdly slow code in
*any* language. This is why is is better to write straightforward,
simple code in preference to complicated, intricate code -- it is easier
to understand simple code, which
On 01/04/2014 02:38 AM, Keith Winston wrote:
The thing that put me on edge was noticing that my simple
Chutes Ladders game doesn't go ANY faster on a machine that benchmarks
perhaps 1000 times faster than another...
You could say this about most programs in most langs. Actually, some even
Thanks Alan Denis: Alan, the improvement you suggested had already been
made, and adopted. Good catch.
Denis: alas, there are chutes and ladders dicts, but I guess your chutes
ladders lists are local to the results class... Your suggestion is quite
shocking to me, I wouldn't have thought of
Well, I probably can't help you, I haven't installed SL4 (yet), and am a
Python beginner myself anyway. I imagine others might be more prepared to
help you with a copy of the script.
However: something about the way you are responding to this thread keeps
breaking it, so you end up starting a new
On 01/04/2014 12:33 PM, Keith Winston wrote:
Thanks Alan Denis: Alan, the improvement you suggested had already been
made, and adopted. Good catch.
Denis: alas, there are chutes and ladders dicts, but I guess your chutes
ladders lists are local to the results class... Your suggestion is quite
On Sat, Jan 4, 2014 at 11:24 AM, blech...@fireflyuk.net wrote:
I havent included the script as it seems to be the use ' input' on my phone
that now wont work.
Even if the error is with 'input', it is still an odd error and no one
will be able to debug your program or have a clue what's
Thank you. I see, it was running python 3.x
when that didn't work I uninstalled it
and used SL4a to reinstall
it installed Python 2.x
(Thanks, sorry for being slow to catch on and for multiple threads)
So raw_input should work instead of input
On Fri, Jan 03, 2014 at 08:38:47PM -0500, Keith Winston wrote:
The thing that put me on edge was noticing that my simple
Chutes Ladders game doesn't go ANY faster on a machine that benchmarks
perhaps 1000 times faster than another...
Damn! You've discovered our secret! Hidden deep insight the
Thanks again Denis, I might just have to ruminate on this, but I am
definitely having an allergic reaction.
I understand that Python doesn't have composite objects, but neither does
it dislallow my list of lists of ints and lists... which is, I imagine,
very space efficient. I think what you are
On 04/01/2014 10:47, blech...@fireflyuk.net wrote:
Ok. Will try and explain the problem.
I wrote a script in python and found I could use it on my android phone
with SL4a.
It was really useful.
Haven't used it for a few months.
A few days ago I decided to improve it and found it no longer works.
On Sat, Jan 04, 2014 at 07:19:43AM -0500, Keith Winston wrote:
I understand that Python doesn't have composite objects, but neither does
it dislallow my list of lists of ints and lists... which is, I imagine,
very space efficient.
I'm afraid I have no idea what you mean by Python not having
On 01/04/2014 02:03 PM, Steven D'Aprano wrote:
I understand that Python doesn't have composite objects, but neither does
it dislallow my list of lists of ints and lists... which is, I imagine,
very space efficient.
I'm afraid I have no idea what you mean by Python not having composite
objects.
On 01/04/2014 02:03 PM, Steven D'Aprano wrote:
I'm also a bit confused here: obviously tuples are immutable, but one can
use lists in them... I think that makes those lists' contents immutable?
Nope. It makes the tuple immutable in the sense that it's *direct*
contents cannot be changed, but
On 04/01/14 11:24, blech...@fireflyuk.net wrote:
At the command line (on my computer) I can type
h = input( enter character )
and when i type a response and enter it, then type h and return, i am
given back the response i put in.
I type j , get 'j' back
Now on my phone i can do the same.
On Sat, 04 Jan 2014 12:16:29 +, blech...@fireflyuk.net wrote:
Thank you. I see, it was running python 3.x
when that didn't work I uninstalled it
and used SL4a to reinstall
it installed Python 2.x
So raw_input should work instead of input
If you're stuck with 2.x then you could
Hello fellow tutors,
I am curious to know why the split() method does not output the arbitrary
delimiter that is passed as an argument? For example:
string1 = this,is,just,another,string
print(string1.split(,))
I understand the the above code simply states, break at every ' , ' .
But why is
On 04/01/14 14:10, Christian Alexander wrote:
I am curious to know why the split() method does not output the
arbitrary delimiter that is passed as an argument? For example:
Because in most cases you don't want it and would have to strip
it off each element manually after the event.
I
On 2014-01-03 20:45, Steven D'Aprano wrote:
On Fri, Jan 03, 2014 at 09:56:25PM -0500, Keith Winston wrote:
...
Eryksun has already solved your immediate problem, but I'd like to
point
out that the above has a couple of code smells.
Are you familiar with the concept of a code smell? Code
On 04/01/14 17:21, Alex Kleider wrote:
In the reference you site, under Oddball Solution mention is made of
adaptor model.
Is this the same as what is described here,
http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93adapter, under
the name of Model-View-Adaptor?
I haven't read it but
On 2014-01-04 10:56, Alan Gauld wrote:
On 04/01/14 17:21, Alex Kleider wrote:
In the reference you site, under Oddball Solution mention is made of
adaptor model.
Is this the same as what is described here,
http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93adapter, under
the name of
Any suggestions as to a better way to handle the problem of encoding in
the following context would be appreciated. The problem arose because
'Bogota' is spelt with an acute accent on the 'a'.
$ cat IP_info.py3
#!/usr/bin/env python3
# -*- coding : utf -8 -*-
# file: 'IP_info.py3' a module.
On Sat, Jan 4, 2014 at 2:26 PM, Alex Kleider aklei...@sonic.net wrote:
The output I get on an Ubuntu 12.4LTS system is as follows:
alex@x301:~/Python/Parse$ ./IP_info.py3
Exception raised.
IP address is 201.234.178.62:
Country: COLOMBIA (CO); City: b'Bogot\xe1'.
Continuing to look into the subject of code smells, I ran across this:
The situation where switch statements or type codes are needed should
be handled by creating subclasses.
@ http://www.soberit.hut.fi/mmantyla/BadCodeSmellsTaxonomy.htm
Assuming I am correct that in Python, switch statements
On 04/01/14 20:11, Alex Kleider wrote:
Assuming I am correct that in Python, switch statements must be
implemented as a series of if; elif; .. statements, how is it that this
can be avoided by creating subclasses?
Its called polymorphism and is one of the most powerful advantages of
OOP
I meant to add...
On 04/01/14 20:47, Alan Gauld wrote:
Its called polymorphism and is one of the most powerful advantages of
OOP since case or switch statements are one of the most fault prone
structures in procedural programming.
...
Without OOP you would need to do something like
for shape
On 2014-01-04 12:01, eryksun wrote:
On Sat, Jan 4, 2014 at 2:26 PM, Alex Kleider aklei...@sonic.net
wrote:
.
b'\xe1' is Latin-1. Look in the response headers:
url =
'http://api.hostip.info/get_html.php?ip=201.234.178.62position=true'
response = urllib.request.urlopen(url)
On Sat, Jan 04, 2014 at 11:26:35AM -0800, Alex Kleider wrote:
Any suggestions as to a better way to handle the problem of encoding in
the following context would be appreciated.
Python gives you lots of useful information when errors occur, but
unfortunately your code throws that information
On 2014-01-04 15:52, Steven D'Aprano wrote:
Oh great. An exception was raised. What sort of exception? What error
message did it have? Why did it happen? Nobody knows, because you throw
it away.
Never, never, never do this. If you don't understand an exception, you
have no business covering it
On Sat, Jan 4, 2014 at 7:15 PM, Alex Kleider aklei...@sonic.net wrote:
py 'Bogotá'.encode('utf-8')
I'm interested in knowing how you were able to enter the above line
(assuming you have a key board similar to mine.)
I use an international keyboard layout:
Following my previous email...
On Sat, Jan 04, 2014 at 11:26:35AM -0800, Alex Kleider wrote:
Any suggestions as to a better way to handle the problem of encoding in
the following context would be appreciated. The problem arose because
'Bogota' is spelt with an acute accent on the 'a'.
Thank you for clarifying my inquiry. I was just unable to find the reason
as to why the built-in excludes the delimiter from the outpu.
On Sat, Jan 4, 2014 at 9:25 AM, Alan Gauld alan.ga...@btinternet.comwrote:
On 04/01/14 14:10, Christian Alexander wrote:
I am curious to know why the
On Sat, Jan 04, 2014 at 04:15:30PM -0800, Alex Kleider wrote:
py 'Bogotá'.encode('utf-8')
I'm interested in knowing how you were able to enter the above line
(assuming you have a key board similar to mine.)
I'm running Linux, and I use the KDE or Gnome character selector,
depending on
A heartfelt thank you to those of you that have given me much to ponder
with your helpful responses.
In the mean time I've rewritten my procedure using a different approach
all together. I'd be interested in knowing if you think it's worth
keeping or do you suggest I use your revisions to my
Hi Alex,
According to:
http://www.hostip.info/use.html
there is a JSON-based interface. I'd recommend using that one! JSON
is a format that's easy for machines to decode. The format you're
parsing is primarily for humans, and who knows if that will change in
the future to make it easier
You were asking earlier about the line:
# -*- coding : utf -8 -*-
See PEP 263:
http://www.python.org/dev/peps/pep-0263/
http://docs.python.org/release/2.3/whatsnew/section-encodings.html
It's a line that tells Python how to interpret the bytes of your
source program. It allows us
One of the common cases for split() is to break a line into a list of
words, for example.
#
'hello this is a test'.split()
['hello', 'this', 'is', 'a', 'test']
#
The Standard Library can not do everything that we can
On Sat, 04 Jan 2014 18:31:13 -0800, Alex Kleider aklei...@sonic.net
wrote:
exactly what the line
# -*- coding : utf -8 -*-
really indicates or more importantly, is it true, since I am using
vim
and I assume things are encoded as ascii?
I don't know vim specifically, but I'm 99% sure it
Compare:
###
class Dog(object): pass
class Cat(object): pass
class Cow(object): pass
def sayHi(animal):
if isinstance(animal, Dog):
print(Woof)
elif isinstance(animal, Cat):
print(Meow)
elif isinstance(animal, Cow):
There's an assumption in the question here that all programs are CPU bound.
I actually do not think so. From prior discussion about what the
program is doing, I got the impression that it was trying to hold
gigabytes of data in RAM. Isn't that still true? If so, then I would
be very surprised
On 2014-01-04 18:44, Danny Yoo wrote:
Hi Alex,
According to:
http://www.hostip.info/use.html
there is a JSON-based interface. I'd recommend using that one! JSON
is a format that's easy for machines to decode. The format you're
parsing is primarily for humans, and who knows if that
On Sat, Jan 4, 2014 at 11:16 PM, Alex Kleider aklei...@sonic.net wrote:
{u'city': None, u'ip': u'201.234.178.62', u'lat': u'10.4', u'country_code':
u'CO', u'country_name': u'COLOMBIA', u'lng': u'-75.2833'}
If I use my own IP the city comes in fine so there must still be some
problem with the
Oh! That's unfortunate! That looks like a bug on the hostip.info
side. Check with them about it.
I can't get the source code to whatever is implementing the JSON
response, so I can not say why the city is not being properly included
there.
[... XML rant about to start. I am not
Hi Danny, no, I don't think there's any disk access, and the memory of the
two machines is rather different: one is 4 Gb or so, the other 9 changing
to 12 any day... but I think I haven't been rigorous enough to justify a
great deal more attention here. I am convinced that I should just keep
then? I'm convinced that all the extraneous structure and complexity
in XML causes the people who work with it to stop caring, the result
being something that isn't for the benefit of either humans nor
computer programs.
... I'm sorry. Sometimes I get grumpy when I haven't had a Snickers.
On 2014-01-04 21:20, Danny Yoo wrote:
Oh! That's unfortunate! That looks like a bug on the hostip.info
side. Check with them about it.
I can't get the source code to whatever is implementing the JSON
response, so I can not say why the city is not being properly included
there.
[... XML
Thanks all, interesting. I'll play more with tuples, I haven't knowingly
used them at all...
Keith
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
On 05/01/2014 07:09, Keith Winston wrote:
Thanks all, interesting. I'll play more with tuples, I haven't knowingly
used them at all...
Keith
Homework for you :) Write a line of code that creates a list of say 3
or 4 integers, then write a line that creates a tuple with the same
integers.
On 2014-01-04 21:20, Danny Yoo wrote:
Oh! That's unfortunate! That looks like a bug on the hostip.info
side. Check with them about it.
I can't get the source code to whatever is implementing the JSON
response, so I can not say why the city is not being properly included
there.
[... XML
59 matches
Mail list logo