Re: [Tutor] print in py3

2013-12-22 Thread Mark Lawrence

On 22/12/2013 17:42, Keith Winston wrote:


On Sun, Dec 22, 2013 at 6:00 AM, mailto:tutor-requ...@python.org>> wrote:

But in Python 2, the parentheses aren't part of the function call,
because print isn't a function. So what do the brackets do? They are
used for *grouping* terms together.

In the first line, the brackets group variable a, comma, myExample[a]
together. What does the comma do? It creates a tuple.



Sorry my question was rambling and imprecise. Thanks, I never would have
guessed the tuple issue, though it makes perfect sense the second you
say it.

The other part of my question was: how did you find that PEP? I started
looking, and it seemed like I could have taken hours, even though I sort
of knew what I was looking for. You must have had a reasonably efficient
search strategy/tool.



I'm there so often I've got the PEP index book marked :)

--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] The Charms of Gmail

2013-12-22 Thread Steven D'Aprano
On Sun, Dec 22, 2013 at 07:06:24PM -0500, Keith Winston wrote:
> The way I was doing this before, I had to retype the subject line, and I
> think that broke threading. Hopefully it will be fixed now that I ditched
> digests.

Nah, threading is already broken in a digest. Every "normal" post is 
either a reply to a previous post, in which case it continues the thread 
from that previous post, or the start of a brand new thread. But digests 
are special: they include many different posts. So the digest itself 
cannot be part of all of those independent threads. It has to be treated 
as a new post, and hence the start of a new thread. But not everyone 
gets digests, and they aren't archived. So when you reply to the digest, 
your reply shows up as a reply to a thread which doesn't exist anywhere.

Editing the subject line will not break threading. Or at least it 
shouldn't -- there may be some feeble email programs which don't know 
how to thread correctly when you change the subject line.


> I don't know what you mean, nik, about (including layer 8!)? [research]
> Never mind, I get it. But I can't get layer 8 buy-in, too many disparate
> interests & inattentive participants (me, myself, AND I, after all).

I have no idea what "layer 8" means either. Googling finds this:

http://en.wikipedia.org/wiki/Layer_8


-- 
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Chutes & Ladders

2013-12-22 Thread Keith Winston
On Sun, Dec 22, 2013 at 3:04 PM,  wrote:

> To sum it up: I like what you have, my hints are all about very minor
> points
> :)
>


Peter, that's a bunch of great suggestions, I knew there were a lot of
places to streamline, make more readable, and probably make faster. Thank
you.

I find that if I run it [1] [10] times, it takes about 20s on my
machine, so I'm eventually going to take a little time seeing how fast I
can get it, I think... maybe I'll learn decorators so I can time it/parts
of it?

I'm really grateful for yours and everyone's help.

-- 
Keith
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] The Charms of Gmail

2013-12-22 Thread Keith Winston
The way I was doing this before, I had to retype the subject line, and I
think that broke threading. Hopefully it will be fixed now that I ditched
digests.

I don't know what you mean, nik, about (including layer 8!)? [research]
Never mind, I get it. But I can't get layer 8 buy-in, too many disparate
interests & inattentive participants (me, myself, AND I, after all).
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] certain packages won't install

2013-12-22 Thread Matthew Ngaha
oh i think it might be the 2nd case of having the wrong version of
pip. I do have pip for Python 2 also but both are not on my path so
cmd doesn't recognise 'pip' unless used in their python folders. I'll
try reinstalling pip. i got it via easy_install so i may have the
wrong one there also:(

On Sun, Dec 22, 2013 at 11:21 PM, Steven D'Aprano  wrote:
> On Sun, Dec 22, 2013 at 11:10:13PM +, Matthew Ngaha wrote:
>> hey i've tried installing a few packages with pip that failed. i'm on
>> windows and python3.3.
>
> You're trying to use Python 3.3, but somehow your version of pip is
> written for Python 2, which is why you're getting syntax errors.
>
> This could happen if you have two versions of pip installed, and Windows
> is getting confused about which version goes with which version of
> Python. Or possibly you only have one version of pip, but the wrong one.
> I don't know.
>
> You might try reinstalling pip, making sure you get a Python 3
> compatible version.
>
>
>
> --
> Steven
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Stuck on Error

2013-12-22 Thread Steven D'Aprano
On Sun, Dec 22, 2013 at 04:39:24AM -0500, Keith Winston wrote:

[...]
> You could do this entire piece with a list comprehension in one line, but
> I'm only mentioning it b/c I just learned them. My crude first effort would
> look like this:
> 
> RN = []  # create the array RN
> [RN.append(random.randint(1, 75)) for i in range(5)]  # populate the array

Definitely a crude first effort :-)

I'm afraid you've missed the point of list comprehensions if you write 
them like that. Here is how you should write the above: just call the 
function you want to append with directly, no need for an extra append.

RN = [random.randint(1, 75)) for i in range(5)]

The list comprehension itself creates a new list and populates it. No 
need to pre-create an empty list and then populate it.

What your code ends up doing is:

- create an empty list, RN
- run a list comprehension which builds a temporary 
  list [None, None, None, None, None]
- as a side-effect of building that temp list, populate
  the RN list
- throw away the temp list


The end result probably does twice as much work as needed.

In your list comp, you call RN.append(something) five times. Each call 
to RN.append returns None. That's not obvious from the interactive 
interpreter, because it suppresses printing of None as a convenience, 
but it is true:

py> result = [].append(23)
py> print(result)
None


So your list comp builds a list made up of nothing but None, only to 
throw it away immediately it is done.


-- 
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] print in py3

2013-12-22 Thread Steven D'Aprano
On Sun, Dec 22, 2013 at 12:42:30PM -0500, Keith Winston wrote:

> The other part of my question was: how did you find that PEP? I started
> looking, and it seemed like I could have taken hours, even though I sort of
> knew what I was looking for. You must have had a reasonably efficient
> search strategy/tool.

I googled for "Python PEP", went to the index page, and then used my 
browser's local Find Text command to search for any PEPs that mentioned 
"print" in the title.

https://duckduckgo.com/html/?q=python+pep

The first link found gives PEP 0, the index of all other PEPs:

http://www.python.org/dev/peps/

and then I just hit Ctrl-F, typed "print", and Jane's yer auntie :-)


On the other hand, if I had added one extra word, and googled for 
"python pep print", the first link found would have been the right link:

https://duckduckgo.com/html/?q=python+pep+print




-- 
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] certain packages won't install

2013-12-22 Thread Steven D'Aprano
On Sun, Dec 22, 2013 at 11:10:13PM +, Matthew Ngaha wrote:
> hey i've tried installing a few packages with pip that failed. i'm on
> windows and python3.3.

You're trying to use Python 3.3, but somehow your version of pip is 
written for Python 2, which is why you're getting syntax errors.

This could happen if you have two versions of pip installed, and Windows 
is getting confused about which version goes with which version of 
Python. Or possibly you only have one version of pip, but the wrong one. 
I don't know.

You might try reinstalling pip, making sure you get a Python 3 
compatible version.



-- 
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] certain packages won't install

2013-12-22 Thread Matthew Ngaha
hey i've tried installing a few packages with pip that failed. i'm on
windows and python3.3. I have tried 'pip install pycurl' and 'pip
install flup' which is something i need for django. I tried flup today
and what bothers me is even though it failed, it's making some temp
folders in places i never look at.

here's the error:

  File "appdata\local\temp\pip-build-happylions\flup\setup.py"
, line 2, in 

from ez_setup import use_setuptools

  File ".\ez_setup.py", line 98

except pkg_resources.VersionConflict, e:

^

SyntaxError: invalid syntax

pycurl is in the same location if you replace \flup\ with \pycurl\ in
that path above. It has a full directory with even a Makefile in it,
yet the pip install failed. I'm a bit confused that these directories
have been in these hard to find places and i haven't known. But it
also makes me question if i did something wrong? directories usually
won't be created if the install fails. Is there another way to install
these packages? especially flup?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] The Charms of Gmail

2013-12-22 Thread Dominik George
> >OMG, so obvious. I actually had to reply to several messages in recent
> >digests, and I utterly resented my clunky technique the second I saw
> >you'd mentioned this. Thanks.
> >
> >--
> >Keith
> >
> 
> This might also prevent you from completely losing all threading.
> This has happened on at least the last six messages I've seen from
> you.

And it is what I hate *most*, especially on mailing lists. It makes me
want to call for a complete GMail ban, because it appears GMail users
*always* manage to do such things ...

Please, don't get me wrong, but by all means get a *complete* sane mail
setup (including layer 8!).

-nik

-- 
 Ein Jabber-Account, sie alle zu finden; ins Dunkel zu treiben
und ewig zu binden; im NaturalNet, wo die Schatten droh'n ;)!

PGP-Fingerprint: 3C9D 54A4 7575 C026 FB17  FD26 B79A 3C16 A0C4 F296


signature.asc
Description: Digital signature
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Stats packages in Mint 16

2013-12-22 Thread eryksun
On Sun, Dec 22, 2013 at 12:37 PM, Keith Winston  wrote:
>
> Well how about that. I looked all over the web, all over scipy, and somehow
> this was never suggested. I'm still learning about repositories and such.
> Anyway, looks like it worked, don't have time to test it right now. Thanks!

Use apt-cache: `apt-cache search numpy`.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] The Charms of Gmail

2013-12-22 Thread Mark Lawrence

On 22/12/2013 17:52, Keith Winston wrote:


On Sun, Dec 22, 2013 at 6:00 AM, mailto:tutor-requ...@python.org>> wrote:

The problem is that you're responding to the digest. Change your
subscription to receive individual messages. Create a filter that
automatically puts the tutor list emails under a particular label

OMG, so obvious. I actually had to reply to several messages in recent
digests, and I utterly resented my clunky technique the second I saw
you'd mentioned this. Thanks.

--
Keith



This might also prevent you from completely losing all threading.  This 
has happened on at least the last six messages I've seen from you.


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] print in py3

2013-12-22 Thread eryksun
On Sun, Dec 22, 2013 at 12:42 PM, Keith Winston  wrote:
> The other part of my question was: how did you find that PEP? I started
> looking, and it seemed like I could have taken hours, even though I sort of
> knew what I was looking for. You must have had a reasonably efficient search
> strategy/tool.

I'd either search the PEP index for "print" or use Google:

print site:www.python.org/dev/peps
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] The Charms of Gmail

2013-12-22 Thread Keith Winston
On Sun, Dec 22, 2013 at 6:00 AM,  wrote:

> The problem is that you're responding to the digest. Change your
> subscription to receive individual messages. Create a filter that
> automatically puts the tutor list emails under a particular label
>

OMG, so obvious. I actually had to reply to several messages in recent
digests, and I utterly resented my clunky technique the second I saw you'd
mentioned this. Thanks.


-- 
Keith
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Global namespace/dictionary

2013-12-22 Thread Keith Winston
On Sun, Dec 22, 2013 at 6:00 AM,  wrote:

> They have to live somewhere.


Don't we all. Thanks, this helped clarify, I'll experiment more...


-- 
Keith
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Stats packages in Mint 16

2013-12-22 Thread Keith Winston
On Sun, Dec 22, 2013 at 6:00 AM,  wrote:

> As an alternative to numpy, or possibly as well as numpy, you might like
> to try the statistics library which will appear in Python 3.4. As the
> author of that library, I would be very, very grateful for bug reports
> or other feedback.
>

I now remember reading this before, I will try it, thanks.


-- 
Keith
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Global namespace/dictionary

2013-12-22 Thread Keith Winston
On Sun, Dec 22, 2013 at 6:00 AM,  wrote:

> They have to live somewhere.





-- 
Keith
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] print in py3

2013-12-22 Thread Keith Winston
On Sun, Dec 22, 2013 at 6:00 AM,  wrote:

> But in Python 2, the parentheses aren't part of the function call,
> because print isn't a function. So what do the brackets do? They are
> used for *grouping* terms together.
>
> In the first line, the brackets group variable a, comma, myExample[a]
> together. What does the comma do? It creates a tuple.
>


Sorry my question was rambling and imprecise. Thanks, I never would have
guessed the tuple issue, though it makes perfect sense the second you say
it.

The other part of my question was: how did you find that PEP? I started
looking, and it seemed like I could have taken hours, even though I sort of
knew what I was looking for. You must have had a reasonably efficient
search strategy/tool.

-- 
Keith
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Stats packages in Mint 16

2013-12-22 Thread Keith Winston
On Sun, Dec 22, 2013 at 10:09 AM,  wrote:

> What did you try? I don't have Mint 16, but I'd expect that
>
> $ sudo apt-get install python3-numpy
>
> will work.
>

Well how about that. I looked all over the web, all over scipy, and somehow
this was never suggested. I'm still learning about repositories and such.
Anyway, looks like it worked, don't have time to test it right now. Thanks!


-- 
Keith
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] The Charms of Gmail

2013-12-22 Thread eryksun
On Sun, Dec 22, 2013 at 8:14 AM, David Abbott  wrote:
> Then what I do is reply to all and remove the individual email address
> and move tutor@ to the To: and make sure to reply at the bottom by
> clicking on the 3 dots that open up the message.

I prefer to set reply-all as the default in Gmail. Also, it doesn't
top post if you select the text to quote before replying.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Chutes & Ladders

2013-12-22 Thread Peter Otten
Keith Winston wrote:

> I've put together my first small program. It's a simulation of the game
> Chutes & Ladders. It plays the game and amasses an array of  ([multicount]
> [gamecount]) size, and then crunches simple stats on the average moves,
> chutes, and ladders for all games in each high-level (multi) pass.
> Hopefully the code is clear.
> 
> I don't think I really thought out the OOP element properly... I was
> thinking of accomodating a multiplayer version in the future, but that
> would require a significant rewrite. Perhaps Games should be a separate
> class, I still don't really have OOP down (I'm learning Python, OOP, and
> Linux simultaneously). There's no interaction between players in the game,
> so there's not really any reason to do a multiplayer version: I was just
> using this to familiarize myself with basic Python and maybe some stats.

You could add a rule that a second player arriving on a field can kick out 
the current occupant -- like in 

http://en.wikipedia.org/wiki/Mensch_ärgere_dich_nicht

> I'd be interested in ALL feedback: aesthetic, functional, design,
> whatever. I would have used numpy but I couldn't get it installed... I
> noticed,
> belatedly,  that the math module has arrays, I didn't look to see if they
> would have made sense to use, I think I remember hearing something about
> them being inefficient or something. Anyway, thanks.

My random remarks:
 
> #Chutes & Ladders Simulation 1.0
> import random
> 
> # Landing on a chute (key) causes one to slide down to the corresponding
> value.
> chutes = {16: 6, 47: 26, 49: 11, 56: 53, 62: 19, 64: 60, 87: 24, 93: 73,
> 95: 75, 98:78}
> 
> # Landing on a ladder (key) causes one to slide up to the corresponding
> value.
> ladders = {1: 38, 4: 14, 9: 31, 21: 42, 28: 84, 36: 44, 51: 67, 71: 91,
> 80:100}
> 
> class Player:
> """Player class for Chutes & Ladders."""
> 
> def __init__(self):

Consider providing chutes and ladders as arguments to avoid the implicit 
dependency from global variables.

> self.reset()
> 
> def reset(self):
> self.position = 0
> self.movecount = 0
> self.numchutes = 0
> self.numladders = 0
> 
> def move(self):
> """Single move, with chutes, ladders, & out of bounds"""
> roll = random.randint(1,6)
> self.movecount += 1
> self.position += roll
> if self.position in chutes.keys():
> self.position = chutes.get(self.position)
> self.numchutes += 1

.keys() is redundant in Python 3 (and does a lot of extra work in Python 2).
When you already know that key is in somedict `somedict[key]` is more 
efficient than `somedict.get(key)` and has the same result.

I would write the above two lines as

  if self.position in chutes: 
  self.position = chutes[self.position]

> elif self.position in ladders.keys():
> self.position = ladders.get(self.position)
> self.numladders += 1

When you look at the code you see that chutes and ladders are handled the 
same way. You might consider using a single dictionary for both.

> elif self.position > 100:  # move doesn't count, have to land
> exactly
> self.position -= roll
> 
> def game(self):
> """Single game"""
> self.reset()
> while self.position < 100:
> self.move()
> 
> def gameset(self, reps):
> """A set of games, returning associated stats array"""
> setstats = []
> for i in range(reps):
> self.game()
> stat = [i, self.movecount, self.numchutes, self.numladders]

As you are not planning to append items to `stat` a tuple is more idiomatic 
here than a list. For extra readability try collections.namedtuple which 
allows accessing the data in the tuple as (for example) `stat.numchutes` 
instead of the hard to remember stat[3].

> setstats.append(stat)
> return setstats
> 
> def multisets(self, multi, reps):
> """A set of game sets, adding another dim to the stats array"""
> multistats = []
> for i in range(multi):
> set1 = p1.gameset(reps)

That should be
  set1 = self.gameset(reps)

> multistats.append(set1)
> return multistats

I'd probably remove the multisets() method from the class to keep the 
interface small and replicate the functionality in client code with

games = [p1.gameset(gamecount) for _ in range(multicount)]

I might do the same for gameset() (and have game() return the statistics for 
a single game).

> p1 = Player()
> gamecount = 1000
> multicount = 10
> games = p1.multisets(multicount, gamecount)
> print("Avg moves  Avg chutes  Avg ladders")
> for i in range(multicount):
> tmulti = games[i]

In Python you can iterate over a list directly. With that in mind...

> summoves, sumchutes, sumladders = 0, 0, 0
> for j in range(gamecount):
> tgset = tmulti[j]
> s

Re: [Tutor] Using asyncio in event-driven network library

2013-12-22 Thread Tobias M.

On 12/22/2013 04:50 PM, Mark Lawrence wrote:


I'm sorry that I can't help directly, but the asyncio module is so new 
that I don't know if any of the other regulars here can help either :( 
I'd be inclined to wait for 24 hours from time of posting and if you 
don't get any positive responses, then ask again on the main Python 
mailing list/news group.  Note that personally I would not ask on 
stackoverflow, I've seen too many completely wrong answers there top 
voted.


Thanks for your advice. I actually wasn't sure which mailinglist is the 
best one for my question.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Using asyncio in event-driven network library

2013-12-22 Thread Mark Lawrence

On 22/12/2013 14:43, Tobias M. wrote:

Hello,

I am currently writing an event-driven client library for a network
protocol [1] and chose to use the new asyncio module. I have no
experience with asynchronous IO and don't understand all the concepts in
asyncio yet. So I'm not sure if asyncio is actually the right choice .

My goal:
I want to provide an easy to use interface to the network protocol.

What I have so far:
I internally use the asyncio event loop and and the user can register
event handler functions for specific events triggered by the network input.
Reduced to the essentials the architecture of my code looks like this:

class Client(asyncio.Protocol):

 def __init__(self, handler, server, port):
 self._handler = handler
 self._server = server
 self._port = port

 def run(self):
 loop = asyncio.get_event_loop()
 task = asyncio.Task(loop.create_connection(self, server, port))
 loop.run_until_complete(task)
 loop.run_forever()

 def data_received(self, data):
 # read data and call the appropriate handler methods on
self._handler
 (..)

The user initializes a Client object, passing a handler to the
constructor. The handler is an instance of a class that contains event
handler methods implemented by the user. (The expected interface of a
handler is defined in an abstract base class.)
Afterwards the user calls run() on the client to start processing.

Problem:
So far this works, but only for applications that solely react to events
from the network. Now I want to be able to use this library for network
communication in interactive applications (command line or GUI), too. In
this case it needs to be able to respond to user input, which must be
somhow incorporated in the event loop. GUI libraries like PyQt even
provide their own event loop.

Questions:
So how do I integrate those aspects in my library?
Is asyncio the right choice?
Or does my whole approach goes in the wrong direction?

I would greatly appreciate any help and suggestions,

Tobias


[1]
The network protocol is IRC (Internet Relay Chat) but I think that does
not really matter here.



I'm sorry that I can't help directly, but the asyncio module is so new 
that I don't know if any of the other regulars here can help either :( 
I'd be inclined to wait for 24 hours from time of posting and if you 
don't get any positive responses, then ask again on the main Python 
mailing list/news group.  Note that personally I would not ask on 
stackoverflow, I've seen too many completely wrong answers there top voted.


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Stuck on Error

2013-12-22 Thread Keith Winston
On Sun, Dec 22, 2013 at 3:55 AM,  wrote:

> import random
>
> for i in range(1):
> RN1 = random.randint(1,75)
>

As noted before, these "for i in range(1)" statements are pointless:
iteration over a range of 1 is no iteration at all. This is exactly
equivalent to simply saying

RN1 = random.randint(1,75)

One thing you might want to do is carefully document your code: add a bunch
of lines, preceded by the pound sign # (to make them into comments), to
explain what you're trying to do in the next section. This might help you
clarify your thinking, and it will definitely help others understand your
intention. Like this:

# Collect a set of lottery results
RN1 = random.randint(1, 75)
RN2 = random.randint(1, 75)
etc.

You could do this entire piece with a list comprehension in one line, but
I'm only mentioning it b/c I just learned them. My crude first effort would
look like this:

RN = []  # create the array RN
[RN.append(random.randint(1, 75)) for i in range(5)]  # populate the array

Also, the fact that you have an identical set of assignments twice makes
one wonder if it's time for a function...

Mostly though, add comments!
-- 
Keith
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Using asyncio in event-driven network library

2013-12-22 Thread Tobias M.

Hello,

I am currently writing an event-driven client library for a network 
protocol [1] and chose to use the new asyncio module. I have no 
experience with asynchronous IO and don't understand all the concepts in 
asyncio yet. So I'm not sure if asyncio is actually the right choice .


My goal:
I want to provide an easy to use interface to the network protocol.

What I have so far:
I internally use the asyncio event loop and and the user can register 
event handler functions for specific events triggered by the network input.

Reduced to the essentials the architecture of my code looks like this:

class Client(asyncio.Protocol):

def __init__(self, handler, server, port):
self._handler = handler
self._server = server
self._port = port

def run(self):
loop = asyncio.get_event_loop()
task = asyncio.Task(loop.create_connection(self, server, port))
loop.run_until_complete(task)
loop.run_forever()

def data_received(self, data):
# read data and call the appropriate handler methods on 
self._handler

(..)

The user initializes a Client object, passing a handler to the 
constructor. The handler is an instance of a class that contains event 
handler methods implemented by the user. (The expected interface of a 
handler is defined in an abstract base class.)

Afterwards the user calls run() on the client to start processing.

Problem:
So far this works, but only for applications that solely react to events 
from the network. Now I want to be able to use this library for network 
communication in interactive applications (command line or GUI), too. In 
this case it needs to be able to respond to user input, which must be 
somhow incorporated in the event loop. GUI libraries like PyQt even 
provide their own event loop.


Questions:
So how do I integrate those aspects in my library?
Is asyncio the right choice?
Or does my whole approach goes in the wrong direction?

I would greatly appreciate any help and suggestions,

Tobias


[1]
The network protocol is IRC (Internet Relay Chat) but I think that does 
not really matter here.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Stats packages in Mint 16

2013-12-22 Thread Peter Otten
Keith Winston wrote:

> I want to play with some stats, but I am having trouble installing numpy
> on mint 16 Petra/Saucy. Is there some way to do it, or some alternative,
> or do I not know what I'm talking about (largely true in this case)?

What did you try? I don't have Mint 16, but I'd expect that

$ sudo apt-get install python3-numpy

will work.

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] The Charms of Gmail

2013-12-22 Thread David Abbott
On Sun, Dec 22, 2013 at 5:21 AM, Oscar Benjamin
 wrote:
>
> On Dec 22, 2013 1:20 AM, "Keith Winston"  wrote:
>
>
>>
>> On Sat, Dec 21, 2013 at 6:00 AM,  wrote:
>>>
>>> I'm unsure as to what the subject line has in common with class and
>>> instance variables, would you care to explain it please.
>>
>>
>>
>> I'm sorry Mark, I'm stuck with using gmail where I have to remember to
>> delete the (essentially invisible) included text of the entire digest I'm
>> responding to, and change the (entirely invisible) subject line. It
>
> The problem is that you're responding to the digest. Change your
> subscription to receive individual messages. Create a filter that
> automatically puts the tutor list emails under a particular label and skips
> the inbox so that the list doesn't clutter your inbox. Then you'll have a
> folder of correctly threaded emails from the list. When you reply to one
> email the subject line will be automatically set and only the previous
> message will be quoted.
>
> Oscar
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>

Then what I do is reply to all and remove the individual email address
and move tutor@ to the To: and make sure to reply at the bottom by
clicking on the 3 dots that open up the message.

-- 
David
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] more html/css question than python :p:

2013-12-22 Thread Paradox


On 12/21/2013 01:04 PM, Timo wrote:

op 21-12-13 16:07, Matthew Ngaha schreef:
I always use the Twitter Bootstrap boilerplate. Here are the docs:
http://getbootstrap.com/

Everything is set up for you already so you can create good looking
websites in a flash.

I'll second the mention of bootstrap.  As an added bonus you a site that 
properly renders on mobile platforms as well without having to write 
that part from scratch.


thomas
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] print in py3

2013-12-22 Thread Chris “Kwpolska” Warrick
On Sun, Dec 22, 2013 at 11:14 AM, Steven D'Aprano  wrote:
> That's the answer to your question: in Python 2, print is a statement,
> not a function. That has many consequences, but the relevant one is that
> statements don't require brackets (parentheses for Americans reading)
> around the arguments.

If Python 3 compatibility is needed/desired, one can do

from __future__ import print_function

in order to make Python 2 operate like Python 3.

> (It is commas, not parentheses, which create tuples.)

…unless you want an empty tuple, in which case it’s just () — without
any commas whatsoever.

-- 
Chris “Kwpolska” Warrick 
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Stuck on error

2013-12-22 Thread Steven D'Aprano
Please help us to help you. When you have a bug you want help with, post 
the ENTIRE error message, starting from the line 

Traceback (most recent call last)

all the way to the end. Do not re-type it, copy and paste it.

> Game + z = N1 + N2 + N3 + N4 + N5 + MB

This line doesn't make any sense. What are you trying to do with it? You 
can't have an operator like + or - (plus or minus) on the left hand side 
of an assignment. Explain in words what you hope to do in this line of 
code, and we'll see if we can help fix it.


-- 
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Global namespace/dictionary

2013-12-22 Thread Steven D'Aprano
On Sat, Dec 21, 2013 at 02:22:32PM -0500, Keith Winston wrote:
> On Sat, Dec 21, 2013 at 12:56 PM,  wrote:
> 
> > py> x = 23
> > py> d = globals()
> > py> d['x']
> > 23
> > py> d['x'] = 42
> > py> x
> > 42
> >
> 
> 
> Well this is sort of fascinating, but a bit confusing: I was playing with
> this, and it seems like the global dictionary includes not just the name
> but the entire contents of every dictionary within it... 

Not just every dictionary, but every string, every list, every object in 
the global scope. That's the whole point of a namespace -- it is the 
"thing" which holds variable names and values.

So if you have a variable "x" set to the dict {1: "one"} and a variable 
"y" set to the list [1, 2, 4, 8], then your global namespace will be:

globals()
=> {"y": [1, 2, 4, 8], "x": {1: "one"}, ...}


(plus other stuff I'm not showing). Now don't worry about that being 
wasteful of memory. The objects (the dict, the list, etc.) have to be 
*somewhere* in memory, and that place happens to be the global 
namespace. Python is very efficient here, and doesn't duplicate values: 
the dictionary returned by globals() is NOT a copy of the variables, it 
actually is the very same dictionary that Python uses. So although it is 
quite large to print, there is nothing redundant about it.


> that seems
> implausibly redundant, so maybe that's just something about how exploring a
> dictionary functions recursively, or something? Maybe it's correct to say
> that any dictionaries within a namespace are stored in that namespace,
> though that doesn't really sound right.

No, that's exactly right. And the same applies for lists, strings, ints, 
floats and any other object. They have to live somewhere.



> >>> d = globals()
> >>> fubar = {1: 'spam', 'eggs': 2}
> >>> d
> {'__name__': '__main__', '__builtins__': ,
> '__doc__': None, '__loader__': ,
> 'fubar': {1: 'spam', 'eggs': 2}, 'd': {...}, '__package__': None}

Now this is a really good example of Python at work. You have a global 
variable d which is bound to the global namespace dict. That's the same 
dictionary which Python uses for global variables. But d is itself a 
global dictionary! Which means that the global namespace dict, which we 
call "d", has to include a reference back to itself.

Sure enough, if you print d, it shows d as a key. What does the value 
for d show? Well, it obviously cannot show the entire globals, since 
that would recurse infinitely:

print(d) 
=> {'__name__': '__main__', '__doc__': None, 
'd': {'__name__': '__main__', '__doc__': None, 
  'd': {'__name__': '__main__', '__doc__': None, 
'd': {'__name__': '__main__', '__doc__': None, 
  'd': ... # and so on, forever


Instead, Python recognises the recursion, and short-cuts the process by 
only displaying "..." inside the dict:

print(d)
=> {'__name__': '__main__', '__doc__': None,
'd': {...} }

(Obviously I've simplified the contents a bit, for brevity.)


You can experiment with such recursive structures in Python very easily. 
Here's a simple example:

L = []  # Empty list.
L.append(L)
print(L)

L.append(42)
print(L[0] == L)



-- 
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Stats packages in Mint 16

2013-12-22 Thread Steven D'Aprano
On Sun, Dec 22, 2013 at 01:05:27AM -0500, Keith Winston wrote:
> I want to play with some stats, but I am having trouble installing numpy on
> mint 16 Petra/Saucy. Is there some way to do it, or some alternative, or do
> I not know what I'm talking about (largely true in this case)?

I don't know much about Mint 16. It might help if you tell us what 
you've actually tried, and what error you got.

As an alternative to numpy, or possibly as well as numpy, you might like 
to try the statistics library which will appear in Python 3.4. As the 
author of that library, I would be very, very grateful for bug reports 
or other feedback.

The statistics.py library is much, much smaller than numpy. You can find 
the source code and documentation here:

http://hg.python.org/cpython/file/default/Lib/statistics.py
http://docs.python.org/3.4/library/statistics.html


and here's the PEP I wrote:

http://www.python.org/dev/peps/pep-0450/


It should run under Python 3.3, if you just copy the statistics.py file 
somewhere in your PYTHONPATH. Contact me off-list if you have trouble 
downloading the file.



-- 
Steven

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] The Charms of Gmail

2013-12-22 Thread Oscar Benjamin
On Dec 22, 2013 1:20 AM, "Keith Winston"  wrote:
>
> On Sat, Dec 21, 2013 at 6:00 AM,  wrote:
>>
>> I'm unsure as to what the subject line has in common with class and
>> instance variables, would you care to explain it please.
>
>
>
> I'm sorry Mark, I'm stuck with using gmail where I have to remember to
delete the (essentially invisible) included text of the entire digest I'm
responding to, and change the (entirely invisible) subject line. It

The problem is that you're responding to the digest. Change your
subscription to receive individual messages. Create a filter that
automatically puts the tutor list emails under a particular label and skips
the inbox so that the list doesn't clutter your inbox. Then you'll have a
folder of correctly threaded emails from the list. When you reply to one
email the subject line will be automatically set and only the previous
message will be quoted.

Oscar
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] print in py3

2013-12-22 Thread Steven D'Aprano
On Sun, Dec 22, 2013 at 12:43:46AM -0500, Keith Winston wrote:
> I've been playing with afterhoursprogramming python tutorial, and I was
> going to write a question about
> 
> myExample = {'someItem': 2, 'otherItem': 20}
> for a in myExample:
> print (a, myExample[a])
> print (a)
> 
> returning

Not returning, printing. Remember, they are two different things. 
Return can only occur inside a function, and once you return, the 
function is exited immediately.

> ('someItem', 2)
> someItem
> ('otherItem', 20)
> otherItem
> 
> Which is to say, why would the output formatting be completely different
> (parens, quotes) between the two print statements, 

You imply, but don't actually say, that the above is in some version of 
Python other than Python 3.3. I expect that you are using Python 2.7.

That's the answer to your question: in Python 2, print is a statement, 
not a function. That has many consequences, but the relevant one is that 
statements don't require brackets (parentheses for Americans reading) 
around the arguments. For example, in Python 2:

print fee, fi, fo, fum

prints the four variables fee, fi, fo and fum with a space between them. 
In Python 3, the above gives a syntax error, and you have to use 
brackets like any other function:

print(fee, fi, fo, fum)

You can also leave a space between the function and the opening bracket, 
like "print (...", without changing the meaning.

So, in Python 3.3, the two lines:

print (a, myExample[a])
print (a)

prints the variable "a" and the value "myExample[a]" with a space in 
between, then on the next line prints the variable "a" alone.

But in Python 2, the parentheses aren't part of the function call, 
because print isn't a function. So what do the brackets do? They are 
used for *grouping* terms together.

In the first line, the brackets group variable a, comma, myExample[a] 
together. What does the comma do? It creates a tuple. A tuple is a group 
of multiple values lumped together. So the first line doesn't print two 
things, a followed by myExample[a]. Instead it prints a single thing, a 
tuple of two items. How do tuples print? They print with round brackets 
around them, and commas between items.

The second line is less complicated: the brackets group a single value, 
a, which is just a. Since there is no comma, you don't get a tuple.

(It is commas, not parentheses, which create tuples.)


> but then when I run it
> in  Python 3.3, it's the more reasonable
> 
> otherItem 20
> otherItem
> someItem 2
> someItem
> 
> Which I'm much happier with. I assume this just reflects changes in the
> print command default formatting: is there some reasonably efficient way to
> see where/when/how this changed? I guess it would be buried in a PEP
> somewhere?

I don't think it was in a PEP... no, I was wrong, there is a PEP for it:

http://www.python.org/dev/peps/pep-3105/


-- 
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] The Charms of Gmail

2013-12-22 Thread Keith Winston
On Sun, Dec 22, 2013 at 3:55 AM,  wrote:

> I'm no expert, but would a (semi-)decent email client help?
>

I do email on a lot of different computers, but I am going to look into
options. Meanwhile, I'm going to redouble my efforts to be conscientious.


-- 
Keith
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Chutes & Ladders

2013-12-22 Thread Keith Winston
I've put together my first small program. It's a simulation of the game
Chutes & Ladders. It plays the game and amasses an array of  ([multicount]
[gamecount]) size, and then crunches simple stats on the average moves,
chutes, and ladders for all games in each high-level (multi) pass.
Hopefully the code is clear.

I don't think I really thought out the OOP element properly... I was
thinking of accomodating a multiplayer version in the future, but that
would require a significant rewrite. Perhaps Games should be a separate
class, I still don't really have OOP down (I'm learning Python, OOP, and
Linux simultaneously). There's no interaction between players in the game,
so there's not really any reason to do a multiplayer version: I was just
using this to familiarize myself with basic Python and maybe some stats.

I'd be interested in ALL feedback: aesthetic, functional, design, whatever.
I would have used numpy but I couldn't get it installed... I noticed,
belatedly,  that the math module has arrays, I didn't look to see if they
would have made sense to use, I think I remember hearing something about
them being inefficient or something. Anyway, thanks.

#Chutes & Ladders Simulation 1.0
import random

# Landing on a chute (key) causes one to slide down to the corresponding
value.
chutes = {16: 6, 47: 26, 49: 11, 56: 53, 62: 19, 64: 60, 87: 24, 93: 73,
95: 75, 98:78}

# Landing on a ladder (key) causes one to slide up to the corresponding
value.
ladders = {1: 38, 4: 14, 9: 31, 21: 42, 28: 84, 36: 44, 51: 67, 71: 91,
80:100}

class Player:
"""Player class for Chutes & Ladders."""

def __init__(self):
self.reset()

def reset(self):
self.position = 0
self.movecount = 0
self.numchutes = 0
self.numladders = 0

def move(self):
"""Single move, with chutes, ladders, & out of bounds"""
roll = random.randint(1,6)
self.movecount += 1
self.position += roll
if self.position in chutes.keys():
self.position = chutes.get(self.position)
self.numchutes += 1
elif self.position in ladders.keys():
self.position = ladders.get(self.position)
self.numladders += 1
elif self.position > 100:  # move doesn't count, have to land
exactly
self.position -= roll

def game(self):
"""Single game"""
self.reset()
while self.position < 100:
self.move()

def gameset(self, reps):
"""A set of games, returning associated stats array"""
setstats = []
for i in range(reps):
self.game()
stat = [i, self.movecount, self.numchutes, self.numladders]
setstats.append(stat)
return setstats

def multisets(self, multi, reps):
"""A set of game sets, adding another dim to the stats array"""
multistats = []
for i in range(multi):
set1 = p1.gameset(reps)
multistats.append(set1)
return multistats

p1 = Player()
gamecount = 1000
multicount = 10
games = p1.multisets(multicount, gamecount)
print("Avg moves  Avg chutes  Avg ladders")
for i in range(multicount):
tmulti = games[i]
summoves, sumchutes, sumladders = 0, 0, 0
for j in range(gamecount):
tgset = tmulti[j]
summoves += tgset[1]
sumchutes += tgset[2]
sumladders += tgset[3]
print(str(summoves/gamecount).rjust(9), \
  str(sumchutes/gamecount).rjust(12), \
  str(sumladders/gamecount).rjust(13))


Sample output is

Avg moves  Avg chutes  Avg ladders
   38.9074.192 3.368
38.644.173 3.276
   39.5844.259 3.355
   39.2544.243 3.411
40.434.399 3.378
39.634.195 3.305
   38.5044.046 3.301
   39.9174.265 3.281
   39.6784.317 3.335
   39.5854.229 3.326

Thanks for any suggestions or thoughts. I know this is a very simple
program, but I'm very pleased that, once I began to sort out the basics, it
fell together pretty readily: I really like Python, though there's a lot to
learn. FYI, I recently played C & L with a 4 y.o. friend, it is not
otherwise my game of choice ;-)

-- 
Keith
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Stats packages in Mint 16

2013-12-22 Thread Keith Winston
I want to play with some stats, but I am having trouble installing numpy on
mint 16 Petra/Saucy. Is there some way to do it, or some alternative, or do
I not know what I'm talking about (largely true in this case)?

-- 
Keith
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] print in py3

2013-12-22 Thread Keith Winston
I've been playing with afterhoursprogramming python tutorial, and I was
going to write a question about

myExample = {'someItem': 2, 'otherItem': 20}
for a in myExample:
print (a, myExample[a])
print (a)

returning

('someItem', 2)
someItem
('otherItem', 20)
otherItem

Which is to say, why would the output formatting be completely different
(parens, quotes) between the two print statements, but then when I run it
in  Python 3.3, it's the more reasonable

otherItem 20
otherItem
someItem 2
someItem

Which I'm much happier with. I assume this just reflects changes in the
print command default formatting: is there some reasonably efficient way to
see where/when/how this changed? I guess it would be buried in a PEP
somewhere?

-- 
Keith
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Stuck on error

2013-12-22 Thread Felix Dietrich
"NZHacker1 ."  writes:

> import random
>
> for i in range(1):
> RN1 = random.randint(1,75)

There is no point of using a for loop if you only intent to do something
once.  But looking at the following lines, it actually seems like you
want something to happen multiple times:

> for i in range(1):
> RN2 = random.randint(1,75)
>
> [...]

What you could have done here is to use a `list'.  Like so:

random_numbers = []
for i in range(5):
random_numbers.append(random.randint(1,75))

You can then index into the list to get the individual elements. Indices
start at 0. e.g.:

random_numbers[0]

returns the first random number (RN1).  The last element (the 5th) in
this example has index 4.

> [...]
> z = 0
> Game = ('Game')
> [...]
> z = z + 1
> [...]
> Game + z = N1 + N2 + N3 + N4 + N5 + MB 
> z = 0

Here is the exception again:

> There's an error in your program:
> ***Cant assign to operator.(Mega Millions, line 47)

It says that you cannot have the `+' operator on the left side of an
assignment (that is the equal sign).

Game = N1 + N2 + N3 + N4 + N5 + MB

should work, though it might not do what you want it to.  Game was
initially a reference to a `tuple' holding a string:

Game = ('Game')

and is now an integer:


Now, I am not sure want your intentions with that line are (try to add
that when you ask a question, like: I have a problem with my program, it
does X (throws an exception, breaks, crashes) and I want it to do Y).  I
am guessing that you want variables `Game0', `Game1', ..., `Gamez' to
exist after it?  In that case a list is, again, what you want:

game = []
game.append(N1 + N2 + N3 + N4 + N5 + MB)

Now game is a list and, as before, you can access the individual
elements by indexing:

game[2]

returns the result of the third game.  If there has not yet been a third
game you will get an `IndexError'.  The number of games already played
is the length of the list and can be obtained with:

len(game)


Here are the links to the tutorial section for lists:
python2: http://docs.python.org/2.7/tutorial/introduction.html#lists
python3: http://docs.python.org/3/tutorial/introduction.html#lists




> while plays != 0:
> Plays = Plays - 1

You are testing lowercase `plays' in the while loop's condition here but
are using uppercase `Plays' in the loop's body.

> z = z + 1
> print(Game + str(z))

With a list it can look like this:
for g in games:
print g


> Line 47 in highlighted in red.
It is nice that you marked the line, but people prefer plain-text
messages on this list/group (html messages screw-up the code's
formatting, and for some their reader doesn't display the message at
all).  You can use comments with some fancy ascii symbols around the
offending line.


A few notes regarding the choice of your variable names:

  - all-uppercase variable names (FOO) should be reserved for
"constants",
  - first letter capitalisation should be reserved for (something called)
classes,
  - give them meaningful names

Here's some reading about the suggested python-code styling conventions
(you don't need to read that now):
http://www.python.org/dev/peps/pep-0008/

> I'm not finished with the program
Happy hacking.

--
Felix Dietrich
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Stuck on error

2013-12-22 Thread Alan Gauld

On 21/12/13 20:36, NZHacker1 . wrote:

I'm trying to make a lottery in python and I keep getting this error.

There's an error in your program:
***Cant assign to operator.(Mega Millions, line 47)


Did you read the replies sent last time?
Did you understand them? It seems unlikely since you
haven't changed anything...


import random

.


x = raw_input('Money in pennys.')
Plays = int(x) * 100
plays = int(x) * 100
z = 0
Game = ('Game')


The () are not doing anything here, you don't need them.



while Plays != 0:
 Plays = Plays - 1
 z = z + 1

...

   Game + z = N1 + N2 + N3 + N4 + N5 + MB


You cannot assign a value to an expression.
If we knew what you expected this line to do we can help you find 
another way to express it that Python can understand. But since we don't 
understand what you are trying to do we can't help you.



z = 0
while plays != 0:
 Plays = Plays - 1
 z = z + 1
 print(Game + str(z))


testing 'plays' but modifying 'Plays' will result in an infinite
loop. Your program will lock up if it ever gets to here.


Line 47 in highlighted in red.


Colours and fonts don't work in a plain text mailing list.
But we can see the faulty line without that. What would help
more is if you posted the real error message in it's entirety.


I'm not finished with the program and I put Plays = int(x) * 100,
plays = int(x) * 100
on purpose.


Having two variables with very similar names is going to make
your code harder to maintain. Its much better to clearly
differentiate the names, perhaps adding a tag to indicate
the purpose of each. But if you insist on keeping the names
similar then its legal Python and you will just need to
remember when you use each.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] The Charms of Gmail

2013-12-22 Thread Dominik George
> I'm no expert, but would a (semi-)decent email client help?

Probably not, as Google's IMAP implementation is hopelessly broken
beyond all repair.

-nik

-- 
* concerning Mozilla code leaking assertion failures to tty without D-BUS *
 That means, D-BUS is a tool that makes software look better
than it actually is.

PGP-Fingerprint: 3C9D 54A4 7575 C026 FB17  FD26 B79A 3C16 A0C4 F296


signature.asc
Description: Digital signature
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] The Charms of Gmail

2013-12-22 Thread Mark Lawrence

On 21/12/2013 18:57, Keith Winston wrote:

On Sat, Dec 21, 2013 at 6:00 AM, mailto:tutor-requ...@python.org>> wrote:

I'm unsure as to what the subject line has in common with class and
instance variables, would you care to explain it please.



I'm sorry Mark, I'm stuck with using gmail where I have to remember to
delete the (essentially invisible) included text of the entire digest
I'm responding to, and change the (entirely invisible) subject line. It

--
Keith



I'm no expert, but would a (semi-)decent email client help?

--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Stuck on error

2013-12-22 Thread Mark Lawrence

On 21/12/2013 20:36, NZHacker1 . wrote:

I'm trying to make a lottery in python and I keep getting this error.

There's an error in your program:
***Cant assign to operator.(Mega Millions, line 47)



Do you expect a different answer if you pose the same question with the 
same code a second time?


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor