comp.lang.python - 25 new messages in 8 topics - digest
comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en
comp.lang.python@googlegroups.com
Today's topics:
* How to write this as a list comprehension? - 8 messages, 6 authors
http://groups.google.com/group/comp.lang.python/t/0b63055a0d321622?hl=en
* numpy.where() and multiple comparisons - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/252e25bda74254c2?hl=en
* Python Scalability TCP Server + Background Game - 6 messages, 4 authors
http://groups.google.com/group/comp.lang.python/t/8234bf03949a8164?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
* 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 - 1
messages, 1 author
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
==============================================================================
TOPIC: How to write this as a list comprehension?
http://groups.google.com/group/comp.lang.python/t/0b63055a0d321622?hl=en
==============================================================================
== 1 of 8 ==
Date: Fri, Jan 17 2014 7:25 pm
From: Rustom Mody
On Saturday, January 18, 2014 4:49:55 AM UTC+5:30, 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.
+1
Yes Ive often been bitten by the lack of a 'comprehension-let'
Something like this is possible??
[somefunc(mn,day,wd,name) for (_, mn,dy,_,_,_,wd,_,_), name) in [localtime(then), name for then, name in mylist]]
Some debugging of the structure will be necessary (if at all possible)
I dont have your functions so cant do it
== 2 of 8 ==
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?
== 3 of 8 ==
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]
== 4 of 8 ==
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-----
== 5 of 8 ==
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.
== 6 of 8 ==
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.
== 7 of 8 ==
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,_,_) ]
== 8 of 8 ==
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: numpy.where() and multiple comparisons
http://groups.google.com/group/comp.lang.python/t/252e25bda74254c2?hl=en
==============================================================================
== 1 of 2 ==
Date: Fri, Jan 17 2014 8:00 pm
From: John Ladasky
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 of 2 ==
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: Python Scalability TCP Server + Background Game
http://groups.google.com/group/comp.lang.python/t/8234bf03949a8164?hl=en
==============================================================================
== 1 of 6 ==
Date: Fri, Jan 17 2014 11:44 pm
From: phiwer@gmail.com
> 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.
Let me explain a bit more about the architecture, and possible remedies, to give you an idea:
* On top are the web servers exposing a REST api.
* At the bottom is the game.
* Communication betweeen these layers is handled by a simple text protocol using TCP.
The game has a tick function every now and then, which forwards the game's time. If a player enters the game, a message is sent to the game server (querying for player details), and if the game's tick is greater than the cached version of the player details, then the game updates the player details (and caches it).
This design obviously has its flaws. One being that both reads/writes has to pass through the game server. One way to remedy this is by using a new layer, on top of the game, which would hold the cache. But then another problem arises, that of invalidating the cache when a new tick has been made. I'm leaning towards letting the cache layer check the current tick every now and then, and if new tick is available, update a local variable in the cache (which each new connection would check against). Any thoughts regarding this?
There are some periods in the game, where many people will be online during the same tick, which could potentially cause the game to become slow at times, but maybe this should be accepted for the pleasure of making the game in python... :D
A follow-up question (which is more to the point really): How does other python game development frameworks solve this issue? Do they not use greenlets for the network layer, to be able to use the shared Queue from multiprocess? Do they only use one process for both network and game operations?
On a side note, I'm considering using 0MQ for the message layering between services (web-server <-> cache <-> game) on the back-end. Besides being a great message protocol, it also has built in queues which might be able to remedy the situation when many clients are requesting data. Anyone with experience with regards to this?
(This problem can be boggled down multiple producer, single consumer, and then back to producer again).
Thanks for all the replies.
/Phil
== 2 of 6 ==
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
== 3 of 6 ==
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
== 4 of 6 ==
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
== 5 of 6 ==
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.
== 6 of 6 ==
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: 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: 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 1 ==
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.
==============================================================================
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/
==============================================================================
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