Sunday, January 19, 2014

comp.lang.python - 25 new messages in 9 topics - digest

comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en

comp.lang.python@googlegroups.com

Today's topics:

* Python Scalability TCP Server + Background Game - 5 messages, 4 authors
http://groups.google.com/group/comp.lang.python/t/8234bf03949a8164?hl=en
* How to write this as a list comprehension? - 7 messages, 6 authors
http://groups.google.com/group/comp.lang.python/t/0b63055a0d321622?hl=en
* doctests compatibility for python 2 & python 3 - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/e83b94c8f7e04717?hl=en
* numpy.where() and multiple comparisons - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/252e25bda74254c2?hl=en
* Guessing the encoding from a BOM - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/1b4501ed3e9e2af1?hl=en
* python to enable javascript , tried selinium, ghost, pyQt4 already - 3
messages, 3 authors
http://groups.google.com/group/comp.lang.python/t/a453f34131ad9343?hl=en
* Python 3.x adoption - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/3d5defc6634ef3b4?hl=en
* advice and comment wanted on first tkinter program - 4 messages, 4 authors
http://groups.google.com/group/comp.lang.python/t/f800a6855b860c2f?hl=en
* Python Simple program - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/737ceee2724b315a?hl=en

==============================================================================
TOPIC: Python Scalability TCP Server + Background Game
http://groups.google.com/group/comp.lang.python/t/8234bf03949a8164?hl=en
==============================================================================

== 1 of 5 ==
Date: Sat, Jan 18 2014 12:01 am
From: Chris Angelico


On Sat, Jan 18, 2014 at 6:44 PM, <phiwer@gmail.com> wrote:
>> Quick smoke test. How big are your requests/responses? You mention
>>
>> REST, which implies they're going to be based on HTTP. I would expect
>>
>> you would have some idea of the rough size. Multiply that by 50,000,
>>
>> and see whether your connection can handle it. For instance, if you
>>
>> have a 100Mbit/s uplink, supporting 50K requests/sec means your
>>
>> requests and responses have to fit within about 256 bytes each,
>>
>> including all overhead. You'll need a gigabit uplink to be able to
>>
>> handle a 2KB request or response, and that's assuming perfect
>>
>> throughput. And is 2KB enough for you?
>>
>>
>>
>> ChrisA
>
> My assumption is that there will be mostly reads and some writes; maybe in the order of 80-20%. There is a time element in the game, which forces player's entity to update on-demand. This is part of the reason why I wanted the server to be able to handle so many reques, so that it could handle the read part without having any caching layer.
>

(You're using Google Groups, which means your replies are
double-spaced and your new text is extremely long lines. Please fix
this, either by the fairly manual job of fixing every post you make,
or the simple method of switching to a better client. Thanks.)

My point was just about the REST API, nothing else. You have to handle
a request and a response for every API call. Whether they're reads or
writes, you need to receive an HTTP request and send an HTTP response
for each one. In order to support the 50k requests per second you hope
for, you would have to handle 50k requests coming in and 50k responses
going out. To do that, you would need - at a very VERY rough estimate
- a maximum request size of 2KB and a gigabit internet connection
(which is expensive). No further calculations are worth pursuing if
you can't handle those requests and responses.

(And small requests tend to be more expensive than large ones. Since
you'll need a minimum of >SYN, <SYN/ACK, >ACK, >DATA, <DATA, >FIN,
<FIN/ACK, >ACK in order to transmit and receive one single packet's
worth of data each way, you're looking at roughly 8 packets minimum
for a one-byte message and one-byte response. But at a very very rough
estimate, 2KB each direction is the most you can sustain.)

ChrisA




== 2 of 5 ==
Date: Sat, Jan 18 2014 3:54 am
From: phiwer@gmail.com


> (You're using Google Groups, which means your replies are
>
> double-spaced and your new text is extremely long lines. Please fix
>
> this, either by the fairly manual job of fixing every post you make,
>
> or the simple method of switching to a better client. Thanks.)
>
>
>
> My point was just about the REST API, nothing else. You have to handle
>
> a request and a response for every API call. Whether they're reads or
>
> writes, you need to receive an HTTP request and send an HTTP response
>
> for each one. In order to support the 50k requests per second you hope
>
> for, you would have to handle 50k requests coming in and 50k responses
>
> going out. To do that, you would need - at a very VERY rough estimate
>
> - a maximum request size of 2KB and a gigabit internet connection
>
> (which is expensive). No further calculations are worth pursuing if
>
> you can't handle those requests and responses.
>
>
>
> (And small requests tend to be more expensive than large ones. Since
>
> you'll need a minimum of >SYN, <SYN/ACK, >ACK, >DATA, <DATA, >FIN,
>
> <FIN/ACK, >ACK in order to transmit and receive one single packet's
>
> worth of data each way, you're looking at roughly 8 packets minimum
>
> for a one-byte message and one-byte response. But at a very very rough
>
> estimate, 2KB each direction is the most you can sustain.)
>
>
>
> ChrisA


Aha, thanks for the info.

But the assumptions you are making does not answer the question.

And the question you raise, although important, is more a financial one,
not really relevant to the questions I posed.

Regards,
Phil




== 3 of 5 ==
Date: Sat, Jan 18 2014 4:13 am
From: Asaf Las


On Wednesday, January 15, 2014 8:37:25 PM UTC+2, phi...@gmail.com wrote:
> My problem is as follows:
> ....
> 2) The network layer of the game server runs a separate process as well,
> and my intention was to use gevent or tornado (http://nichol.as/asynchronous-
>servers-in-python).
> 3) The game server has a player limit of 50000. My requirement/desire is to
> be able to serve 50k requests per second
> 4) The game is not a real-time based game, but is catered towards the web.
> Due to this information, I have developed the initial server using netty in
> java. I would, however, rather develop the server using python,... and then
> use python for the frontend. ...

do you have references to implementations where python was used as frontend for such traffic load?

you can have a look to this group for numbers
https://groups.google.com/forum/#!forum/framework-benchmarks

Asaf




== 4 of 5 ==
Date: Sat, Jan 18 2014 4:40 am
From: phiwer@gmail.com


Den lördagen den 18:e januari 2014 kl. 13:13:47 UTC+1 skrev Asaf Las:
> On Wednesday, January 15, 2014 8:37:25 PM UTC+2, phi...@gmail.com wrote:
>
> > My problem is as follows:
>
> > ....
>
> > 2) The network layer of the game server runs a separate process as well,
>
> > and my intention was to use gevent or tornado (http://nichol.as/asynchronous-
>
> >servers-in-python).
>
> > 3) The game server has a player limit of 50000. My requirement/desire is to
>
> > be able to serve 50k requests per second
>
> > 4) The game is not a real-time based game, but is catered towards the web.
>
> > Due to this information, I have developed the initial server using netty in
>
> > java. I would, however, rather develop the server using python,... and then
>
> > use python for the frontend. ...
>
>
>
> do you have references to implementations where python was used as frontend for such traffic load?
>
>
>
> you can have a look to this group for numbers
>
> https://groups.google.com/forum/#!forum/framework-benchmarks
>
>
>
> Asaf

Yes I've looked at those charts, and that was one of the reasons why I decided
to go with netty for the back-end (although I'm probing to see if python
possibly could match in some way, which I haven't thought of yet...).

With regards to front-end, I haven't fully decided upon which framework to use.
It's easier to scale the front-end, however, given that the problem of
locking game state is not present in this logical part of the architecture.




== 5 of 5 ==
Date: Sat, Jan 18 2014 5:19 am
From: Mark Lawrence



On 18/01/2014 12:40, phiwer@gmail.com wrote:

[snip the stuff I can't help with]

Here's the link you need to sort the problem with double spacing from
google groups https://wiki.python.org/moin/GoogleGroupsPython

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

Mark Lawrence






==============================================================================
TOPIC: How to write this as a list comprehension?
http://groups.google.com/group/comp.lang.python/t/0b63055a0d321622?hl=en
==============================================================================

== 1 of 7 ==
Date: Sat, Jan 18 2014 12:36 am
From: Peter Otten <__peter__@web.de>


Piet van Oostrum wrote:

> Hi,
>
> I am looking for an elegant way to write the following code as a list
> comprehension:
>
> labels = []
> for then, name in mylist:
> _, mn, dy, _, _, _, wd, _, _ = localtime(then)
> labels.append(somefunc(mn, day, wd, name))
>
> So mylist is a list of tuples, the first member of the tuple is a time
> (as epoch offset) and I neeed to apply a function on some fields of the
> localtime of it.
>
> I could define a auxiliary function like:
>
> def auxfunc(then, name):
> _, mn, dy, _, _, _, wd, _, _ = localtime(then)
> return somefunc(mn, day, wd, name)
>
> and then use
> [auxfunc(then, name) for then, name in mylist]
>
> or even
> [auxfunc(*tup) for tup in mylist]
>
> But defining the auxfunc takes away the elegance of a list comprehension.
> I would like to integrate the unpacking of localtime() and calling
> somefunc within the list comprehension, but I don't see a simple way to do
> that.
>
> somefunc(mn, day, wd, name) for _, mn, dy, _, _, _, wd, _, _ in
> [localtime(then)] (i.e. using a list comprehension on a one element list
> to do the variable shuffling) works but I don't find that very elegant.
>
> labels = [somefunc(mn, day, wd, name)
> for then, name in mylist
> for _, mn, dy, _, _, _, wd, _, _ in [localtime(then)]]
>
> Python misses a 'where' or 'let'-like construction as in Haskell.
>
> Anybody has a more elegant solution?

Options I can think of:

You could do it in two steps...

time_name_pairs = ((localtime(then), name) for then, name in mylist)
labels = [somefunc(t.tm_mon, t.tm_mday, t.tm_wday, name)
for t, name in time_name_pairs]

...or you could inline the helper function...

mon_mday_wday = operator.attrgetter("tm_mon", "tm_day", "tm_wday")
labels = [somefunc(*mon_mday_wday(localtime(then)), name=name)
for then, name in mylist]

-- but both seem less readable than the classical for-loop.

What would a list-comp with `let` or `where` look like? Would it win the
beauty contest against the loop?





== 2 of 7 ==
Date: Sat, Jan 18 2014 2:00 am
From: Piet van Oostrum


Rustom Mody <rustompmody@gmail.com> writes:

> On Saturday, January 18, 2014 4:49:55 AM UTC+5:30, Piet van Oostrum wrote:
[...]
>
>> Python misses a 'where' or 'let'-like construction as in Haskell.
>
> +1
> Yes Ive often been bitten by the lack of a 'comprehension-let'

If it used only in a comprehension as in my example you can write instead of 'where vars = expr':
for vars in [expr], unnecessarily construction a one element list.
If there would be a syntax like:
for vars = expr
this could be avoided.
>
> Something like this is possible??
>
>
> [somefunc(mn,day,wd,name) for (_, mn,dy,_,_,_,wd,_,_), name) in
> [localtime(then), name for then, name in mylist]]
It works modulo some corrections in the parentheses:

[somefunc(mn,day,wd,name) for (_, mn,dy,_,_,_,wd,_,_), name in
[(localtime(then), name) for then, name in mylist]]
but I find that hardly more elegant.
--
Piet van Oostrum <piet@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]




== 3 of 7 ==
Date: Sat, Jan 18 2014 2:57 am
From: matej@ceplovi.cz (Matěj Cepl)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2014-01-17, 23:19 GMT, you wrote:
> But defining the auxfunc takes away the elegance of a list
> comprehension.

Au contraire! Remember, that brevity is the sister of talent.

I would definitively vote for

labels = [make_label(then, name) for then, name in mylist]

(always use descriptive names of functions and variables;
auxfunc is a short way to the hell)

Beauty of the list comprehensions is that they show nicely what
list is being processed, how it is filtered (if at all), and
what we do with each element of the generated list. Anything you
add to this simplicity is wrong. Whenever you start to feel you
are missing some methods how to stuff more commands into
a comprehension (or for example multiple embedded ones), you
should start new function.

The same rule applies here as with any other lambda function
(because these are in fact lambda functions): the best way how
to write lambda is to write algorithm somewhere on the side,
describe what this function does in one word, then add `def` in
front of that name, and use so created named function instead.

Best,

Matěj

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iD8DBQFS2l4X4J/vJdlkhKwRAjEgAJ4n1OuANYlVFzlgBZ0f1uMhO/t36gCfdFjE
VmYDJ+F7aN0khzvlY50i0iA=
=Trcc
-----END PGP SIGNATURE-----




== 4 of 7 ==
Date: Sat, Jan 18 2014 3:53 am
From: Alain Ketterlin


Piet van Oostrum <piet@vanoostrum.org> writes:

[...]
> I could define a auxiliary function like:
>
> def auxfunc(then, name):
> _, mn, dy, _, _, _, wd, _, _ = localtime(then)
> return somefunc(mn, day, wd, name)
>
> and then use
> [auxfunc(then, name) for then, name in mylist]

[...]

> labels = [somefunc(mn, day, wd, name)
> for then, name in mylist
> for _, mn, dy, _, _, _, wd, _, _ in [localtime(then)]]
>
> Python misses a 'where' or 'let'-like construction as in Haskell.

"let x = v in e" really is (lambda x:e)(v)

In your case:

[ (lambda na,ti : somefunc(ti[1],ti[2],ti[6],na))(name,localtime(then))
for then,name in mylist ]

Warning: absolutely untested (not even syntax-checked).

You may also use *localtime(...) and keep underscores.

-- Alain.




== 5 of 7 ==
Date: Sat, Jan 18 2014 7:20 am
From: Rustom Mody


On Saturday, January 18, 2014 2:06:29 PM UTC+5:30, Peter Otten wrote:

> Options I can think of:

> You could do it in two steps...

> time_name_pairs = ((localtime(then), name) for then, name in mylist)
> labels = [somefunc(t.tm_mon, t.tm_mday, t.tm_wday, name)
> for t, name in time_name_pairs]

> ...or you could inline the helper function...

> mon_mday_wday = operator.attrgetter("tm_mon", "tm_day", "tm_wday")
> labels = [somefunc(*mon_mday_wday(localtime(then)), name=name)
> for then, name in mylist]

> -- but both seem less readable than the classical for-loop.

> What would a list-comp with `let` or `where` look like? Would it win the
> beauty contest against the loop?

For me this is neat

[somefunc(mn,day,wd,name) for (then, name) in mylist let (_,mn,dy,_,_,_,wd,_,_) = localtime(then)]

Others may not find it so!

See it across > 1 line (as I guess it will come after being posted!) and its not so neat.




== 6 of 7 ==
Date: Sat, Jan 18 2014 8:00 am
From: Jussi Piitulainen


Rustom Mody writes:

> On Saturday, January 18, 2014 2:06:29 PM UTC+5:30, Peter Otten wrote:
>
> > What would a list-comp with `let` or `where` look like? Would it
> > win the beauty contest against the loop?
>
> For me this is neat
>
> [somefunc(mn,day,wd,name) for (then, name) in mylist let (_,mn,dy,_,_,_,wd,_,_) = localtime(then)]
>
> Others may not find it so!
>
> See it across > 1 line (as I guess it will come after being posted!)
> and its not so neat.

I would write that on three lines anyway, properly indented:

[ somefunc(mn,day,wd,name)
for (then, name) in mylist
let (_,mn,dy,_,_,_,wd,_,_) = localtime(then) ]

It could be made to use existing keywords:

[ somefunc(mn,day,wd,name)
for (then, name) in mylist
with localtime(then) as (_,mn,dy,_,_,_,wd,_,_) ]




== 7 of 7 ==
Date: Sat, Jan 18 2014 9:40 am
From: Piet van Oostrum


Alain Ketterlin <alain@dpt-info.u-strasbg.fr> writes:

> Piet van Oostrum <piet@vanoostrum.org> writes:
> [...]
>> Python misses a 'where' or 'let'-like construction as in Haskell.
>
> "let x = v in e" really is (lambda x:e)(v)
>
You are right, but it is a lot less readable IMHO.
--
Piet van Oostrum <piet@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]





==============================================================================
TOPIC: doctests compatibility for python 2 & python 3
http://groups.google.com/group/comp.lang.python/t/e83b94c8f7e04717?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Jan 18 2014 12:39 am
From: Albert-Jan Roskam


--------------------------------------------
On Fri, 1/17/14, Terry Reedy <tjreedy@udel.edu> wrote:

Subject: Re: doctests compatibility for python 2 & python 3
To: python-list@python.org
Date: Friday, January 17, 2014, 10:10 PM

On 1/17/2014 7:14 AM, Robin Becker
wrote:

> I tried this approach with a few more complicated
outcomes and they fail
> in python2 or 3 depending on how I try to render the
result in the doctest.

I never got how you are using doctests. There were certainly
not meant for heavy-duty unit testing, but for testing
combined with explanation. Section 26.2.3.7. (in 3.3)
Warnings warns that they are fragile to even single char
changes and suggests == as a workaround, as 'True' and
'False' will not change. So I would not reject that option.


=====> I used doctests in .txt files and I converted ALL of them when I wanted to make my code work for both Python 2 and 3. I tried to fix something like a dozen of them so they'd work in Python 2.7 and 3,3. but I found it just too cumbersome and time consuming. The idea of doctest is super elegant, but it is really only meant for testable documentation (maybe with sphinx). If you'd put all the (often boring, e.g. edge cases) test cases in docstrings, the .py file will look very cluttered. One thing that I missed in unittest was Ellipsis, but: https://pypi.python.org/pypi/gocept.testing/1.6.0 offers assertEllipsis and other useful stuff.

Albert-Jan







==============================================================================
TOPIC: numpy.where() and multiple comparisons
http://groups.google.com/group/comp.lang.python/t/252e25bda74254c2?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Jan 18 2014 12:50 am
From: Peter Otten <__peter__@web.de>


John Ladasky wrote:

> On Friday, January 17, 2014 6:16:28 PM UTC-8, duncan smith wrote:
>
>> >>> a = np.arange(10)
>> >>> c = np.where((2 < a) & (a < 7))
>> >>> c
>> (array([3, 4, 5, 6]),)
>
> Nice! Thanks!
>
> Now, why does the multiple comparison fail, if you happen to know?

2 < a < 7

is equivalent to

2 < a and a < 7

Unlike `&` `and` cannot be overridden (*), so the above implies that the
boolean value bool(2 < a) is evaluated. That triggers the error because the
numpy authors refused to guess -- and rightly so, as both implementable
options would be wrong in a common case like yours.

(*) I assume overriding would collide with short-cutting of boolean
expressions.






==============================================================================
TOPIC: Guessing the encoding from a BOM
http://groups.google.com/group/comp.lang.python/t/1b4501ed3e9e2af1?hl=en
==============================================================================

== 1 of 2 ==
Date: Sat, Jan 18 2014 1:41 am
From: Gregory Ewing


Chris Angelico wrote:
> On Fri, Jan 17, 2014 at 8:10 PM, Mark Lawrence <breamoreboy@yahoo.co.uk> wrote:
>
>Every time I see it I picture Inspector
>>Clouseau, "A BOM!!!" :)
>
> Special delivery, a berm! Were you expecting one?

A berm? Is that anything like a shrubbery?

--
Greg




== 2 of 2 ==
Date: Sat, Jan 18 2014 2:10 am
From: Chris Angelico


On Sat, Jan 18, 2014 at 8:41 PM, Gregory Ewing
<greg.ewing@canterbury.ac.nz> wrote:
> Chris Angelico wrote:
>>
>> On Fri, Jan 17, 2014 at 8:10 PM, Mark Lawrence <breamoreboy@yahoo.co.uk>
>> wrote:
>>
>> Every time I see it I picture Inspector
>>>
>>> Clouseau, "A BOM!!!" :)
>>
>>
>> Special delivery, a berm! Were you expecting one?
>
>
> A berm? Is that anything like a shrubbery?

http://www.youtube.com/watch?v=GLDvtpSC_98

ChrisA





==============================================================================
TOPIC: python to enable javascript , tried selinium, ghost, pyQt4 already
http://groups.google.com/group/comp.lang.python/t/a453f34131ad9343?hl=en
==============================================================================

== 1 of 3 ==
Date: Sat, Jan 18 2014 3:54 am
From: Jaiprakash Singh


hi,

can you please suggest me some method for study so that i can scrap a site having JavaScript behind it


i have tried selenium, ghost, pyQt4, but it is slow and as a am working with thread it sinks my ram memory very fast.




== 2 of 3 ==
Date: Sat, Jan 18 2014 10:05 am
From: Denis McMahon


On Sat, 18 Jan 2014 03:54:17 -0800, Jaiprakash Singh wrote:

> can you please suggest me some method for study so that i can
> scrap a site having JavaScript behind it

Please expand upon the requirement, are you trying to:

a) replace server side javascript with server side python, or
b) replace client side javascript with server side python, or
c) replace client side javascript with client side python, or
d) something else?

(c) is not possible (you can't guarantee that all clients will have
python, or that there will be a mechanism for calling it from your
webpages), (b) doesn't make a lot of sense (you'll be trading cpu in the
client for cpu in the server + network bandwidth and latency).

--
Denis McMahon, denismfmcmahon@gmail.com




== 3 of 3 ==
Date: Sat, Jan 18 2014 10:13 am
From: Chris Angelico


On Sat, Jan 18, 2014 at 10:54 PM, Jaiprakash Singh
<jaiprakash@wisepromo.com> wrote:
> hi,
>
> can you please suggest me some method for study so that i can scrap a site having JavaScript behind it
>
>
> i have tried selenium, ghost, pyQt4, but it is slow and as a am working with thread it sinks my ram memory very fast.

Do you mean "scrape"? You're trying to retrieve the displayed contents
of a web page that uses JavaScript? If so, that's basically impossible
without actually executing the JS code, which means largely
replicating the web browser.

ChrisA





==============================================================================
TOPIC: Python 3.x adoption
http://groups.google.com/group/comp.lang.python/t/3d5defc6634ef3b4?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Jan 18 2014 5:27 am
From: beliavsky@aol.com


On Friday, January 17, 2014 6:03:45 PM UTC-5, Terry Reedy wrote:
> On 1/17/2014 5:16 PM, beliavsky@aol.com wrote:

> > Python 2 and 3 are incompatible in ways that do not apply to Fortran
>
> > standards pre- and post- F77.
>
>
>
> As stated above, I disagree with respect to pre-F77 and F77. Did you
>
> actually program in both, as I did?
>
>
>
> --
>
> Terry Jan Reedy

I should have written "F77 and post F77". I have programmed in Fortran 77, 90, and 95.





==============================================================================
TOPIC: advice and comment wanted on first tkinter program
http://groups.google.com/group/comp.lang.python/t/f800a6855b860c2f?hl=en
==============================================================================

== 1 of 4 ==
Date: Sat, Jan 18 2014 6:52 am
From: Jean Dupont


Op vrijdag 17 januari 2014 22:40:42 UTC+1 schreef Terry Reedy:
> On 1/17/2014 8:20 AM, Jean Dupont wrote:
>
> > Dear all,
>
> > I made a simple gui with tkinter. I can imagine there are things which I
>
> > did which are "not optimal". So what I ask is to comment on my code
>
> > preferable with snippets of code which show how to do improve my code.
>
> > #!/usr/bin/env python
>
> > import Tkinter
>
>
>
> 1. import Tkinter as tk
>
>
>
> Besides saving a bit of writing and reading time later, this makes any
>
> future conversion to 3.x easier.
>
>
>
> import tkinter as tk
>
>
>
> 2. add a few spaces to demarcate blocks of code.
>
>
>
> > import time
>
> > import RPi.GPIO as GPIO
>
>
>
> 2. add a few spaces to demarcate blocks of code, such as here
>
>
>
> > GPIO.setmode(GPIO.BOARD)
>
> > GPIO.setup(26,GPIO.OUT)
>
> > GPIO.setup(24,GPIO.OUT)
>
> > #hardware : connect 2 leds:
>
> > #board-pin 26 on/off led; control with buttons
>
> > #board-pin 24 led with pwm dimming and frequency; control via sliders
>
>
>
> and here
>
>
>
> > top = Tkinter.Tk()
>
> > top.geometry("600x400+310+290")
>
>
>
> This looks strange somehow, but if it works...
>
>
>
>
>
> > label1 = Label(top,relief=RAISED,bg =
>
> > "#EFF980",font=("Helvetica",14),height = 1, width = 15)
>
>
>
> In calls, put spaces after , but not before and after =.
>
> For other suggestions, see
>
> http://www.python.org/dev/peps/pep-0008/
>
>
>
> I suspect that the above is one line in your code and the bad wrapping a
>
> result of mis-spacing. The following is also one line, but easer to read
>
> as spaces separate argument chunks
>
>
>
> label1 = Label(top, relief=RAISED, bg="#EFF980", font=("Helvetica",14),
>
> height=1, width=15)
>
>
>
> and the wrapping, if any, does not break up an arg chunk.
>
>
>
> Some people advocate defining an App class, but Tk and tkinter, even
>
> though object method based, allow the straightforward imperative style
>
> you have used.
>
>
>
> I agree with Peter: "First and foremost a program has to do what the
>
> author wants it to do. Everything else is secondary." But a bit of
>
> styling will make reading and changing easier.
>
>
>
> --
>
> Terry Jan Reedy

Thanks Peter and Terry Jan for the useful suggestions. One thing which I find a bit weird: when asking for Python-help concerning raspberry pi code or problems, a lot of people don't seem to be interested in helping out, that's of course their choice, but maybe they don't seem to be aware the raspberry pi is often the motivation for starting to learn to program in Python. And as such such a reaction is a bit disappointing.

kind regards,
jean




== 2 of 4 ==
Date: Sat, Jan 18 2014 7:12 am
From: Oscar Benjamin


On 18 January 2014 14:52, Jean Dupont <jeandupont314@gmail.com> wrote:
>
> Thanks Peter and Terry Jan for the useful suggestions. One thing which I find a bit weird: when asking for Python-help concerning raspberry pi code or problems, a lot of people don't seem to be interested in helping out, that's of course their choice, but maybe they don't seem to be aware the raspberry pi is often the motivation for starting to learn to program in Python. And as such such a reaction is a bit disappointing.

Hi Jean,

What makes you say that? Did you previously ask questions about
Rasberry Pi code on this list?

If you did I wouldn't have answered those questions because I've never
used a Raspberry Pi and know nothing about them (except that they
encourage using Python somehow). I think that there's actually a list
that is specifically for Raspberry Pi Python questions that might be
more helpful although I don't know what it is...


Oscar




== 3 of 4 ==
Date: Sat, Jan 18 2014 8:15 am
From: Mark Lawrence



On 18/01/2014 15:12, Oscar Benjamin wrote:
> On 18 January 2014 14:52, Jean Dupont <jeandupont314@gmail.com> wrote:
>>
>> Thanks Peter and Terry Jan for the useful suggestions. One thing which I find a bit weird: when asking for Python-help concerning raspberry pi code or problems, a lot of people don't seem to be interested in helping out, that's of course their choice, but maybe they don't seem to be aware the raspberry pi is often the motivation for starting to learn to program in Python. And as such such a reaction is a bit disappointing.
>
> Hi Jean,
>
> What makes you say that? Did you previously ask questions about
> Rasberry Pi code on this list?
>
> If you did I wouldn't have answered those questions because I've never
> used a Raspberry Pi and know nothing about them (except that they
> encourage using Python somehow). I think that there's actually a list
> that is specifically for Raspberry Pi Python questions that might be
> more helpful although I don't know what it is...
>
>
> Oscar
>

As Python is meant to be cross platform i think it's pretty much
irrelevant that Raspberry Pi is mentioned. It's far more likely that
people don't respond as questions are asked about specific libraries
which they haven't used.

Neither does it help when considering Jean's last post that the final
paragraph shows as one line in Thunderbird on Windows and over 60% is
simply blank lines. No guesses as to how he's posting.

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

Mark Lawrence





== 4 of 4 ==
Date: Sat, Jan 18 2014 9:28 am
From: Dennis Lee Bieber


On Sat, 18 Jan 2014 06:52:24 -0800 (PST), Jean Dupont
<jeandupont314@gmail.com> declaimed the following:


>
>Thanks Peter and Terry Jan for the useful suggestions. One thing which I find a bit weird: when asking for Python-help concerning raspberry pi code or problems, a lot of people don't seem to be interested in helping out, that's of course their choice, but maybe they don't seem to be aware the raspberry pi is often the motivation for starting to learn to program in Python. And as such such a reaction is a bit disappointing.
>

There is a difference between learning Python ON a Raspberry-Pi, and
learning the Raspberry-Pi with Python.

R-Pi specific libraries or code aren't things every Python user would
have experience with; asking in the R-Pi newsgroup -- comp.sys.raspberry-pi
-- would at least focus the matter to people with experience or interest in
the R-Pi.

Granted, that may require one to obtain a proper Usenet news-client and
access to a news server carrying the group; rather than the corrupting
influence of Google Groups (I haven't looked to see if GG has access to it;
but GG makes a trash out of messages that gateway out to the real world).
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/






==============================================================================
TOPIC: Python Simple program
http://groups.google.com/group/comp.lang.python/t/737ceee2724b315a?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Jan 18 2014 10:11 am
From: Chris Angelico


On Sun, Jan 19, 2014 at 5:00 AM, indar kumar <indarkumar59@gmail.com> wrote:
> Hello, I am a newbie. Can somebody help me write the code for following program?
>
>
> Write a program that takes student grades and prints out the GPA. The information is input, one student per line in the format: <student id> <course1 grade> <course2 grade> ...
> The number of students is not known in advance. You should prompt the user for more until they enter an empty line. The number of courses per student varies and is also not known in advance. You should read as many grades as are entered on the line.

No.

This is homework, and you should do it yourself - otherwise you are
cheating yourself, cheating on your course, and ultimately, cheating
an employer by making him/her think you know how to do something when
you don't.

If you write the code yourself and then have questions, then by all
means, bring those questions to us! We're happy to help you learn. But
that's quite different from outright doing your homework for you.

ChrisA




==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.python"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.python?hl=en

To unsubscribe from this group, send email to comp.lang.python+unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.python/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate