Re: help on python regular expression named group
On 17 July 2013 07:15, wrote: > Not sure, I'm correct. I took you precise string to > refresh my memory. I'm glad to see you doing something else, but I don't think you understood his problem. Note that his problem has not solution, which a few seconds of Googling has confirmed to me. -- http://mail.python.org/mailman/listinfo/python-list
Re: help on python regular expression named group
Le mercredi 17 juillet 2013 09:46:46 UTC+2, Joshua Landau a écrit : > On 17 July 2013 07:15, wrote: > > > Not sure, I'm correct. I took you precise string to > > > refresh my memory. > > > > I'm glad to see you doing something else, but I don't think you > > understood his problem. Note that his problem has not solution, which > > a few seconds of Googling has confirmed to me. Right. I did not pay attention to "date", "time" *and* "datetime". jmf -- http://mail.python.org/mailman/listinfo/python-list
Re: Homework help requested (not what you think!)
On 16 July 2013 23:43, John Ladasky wrote: > > Well, a few other parents caught wind of what I was doing with my son, and > they asked me whether I could tutor their kids, too. I accepted the jobs > (for pay, actually). > > The kids all claim to be interested. They all want to write the next great > 3D video game. Thus, I'm a little surprised that the kids don't actually try > to sit down and code without me prompting them. I think that they're > disappointed when I show them how much they have to understand just to write > a program that plays Tic Tac Toe. > > Where programming is concerned, I'm an autodidact. I started programming > when I was twelve, with little more guidance than the Applesoft Basic manual > and the occasional issue of Byte Magazine. I hacked away. Over the years, I > have acquired a working knowledge of BASIC, 6502 assembly language, Pascal, > C, and finally Python (my favorite). If I knew how to impart a love of > experimentation to my students, I would do that. > > One kid looks like he's ready to forge ahead. In the mean time, one parent > has recognized his son's lack of independence, and has asked me to assign > programming homework. I hope it doesn't kill the kid's enthusiasm, but I'm > willing to try it. > > So, what I am seeking are suggestions for programming assignments that I can > give to brand-new students of Python. Please keep in mind that none of them > are even up to the task of a simple algorithm like Bubble Sort -- at least, > not yet. As probably the youngest regular on this list (still not a kid any more though, as much as I would like to be) it's always been my experience that if you see someone young who says "I'm really interested in how to program!" they already either know a little (or a lot) or they're probably somewhat deluded. Programming's so easy to learn solo that if they haven't at least tried, they're just not as interested as they say ;). For homework I actually recommend reading assignments. Something that gets you straight there. When I taught a few people (back not that long ago to A-level [UK], once-a week lunchtime things) the first thing everyone went through were these: https://groups.google.com/forum/#!category-topic/learn-how-to-program---matthew-arnold/help-for-lesson-1/cKy43xj56y4 https://groups.google.com/forum/#!category-topic/learn-how-to-program---matthew-arnold/help-for-lesson-2/iR6pMtsgFjA Note that I rather quickly stopped using the forum above, as with https://sites.google.com/site/learnhowtoprogram/, which I only really used to host code we needed (I got too lazy to update the rest, basically), so there's nothing else woth checking. I give you 100% free permission to steal anything of mine from those links, though. I'm no teaching expert, but these seemed to help people get the idea. The basic concept is that before you learn to write, you learn to read. If you give them well-documented (like, every line is documentation¹) code or something like the duo of links I posted above it will probably be a lot more meaningful than asking them to do something trivial they already know. I hear from a lot of people over teh netz that they learnt how to code from reading OSS. I personally didn't do most of my learning that way, but it doesn't mean that it doesn't work. The person from my lessons who learnt the most was the guy who of his own choice took some of the code we were working on and changed it at home without prompting to do something else. At the beginning there was no way he could write code that was marginally useful, and thus doing so would have been massively boring and discouraging -- giving him a platform he could work on made it much easier to do something useful. I hope I inspired a few thoughts, I'm not giving you the One True Way but these ideas should at least be blocks you can build with. ¹ See https://sites.google.com/site/learnhowtoprogram/Snake.py (which might have a purposeful bug in there, it's been a small while since I last ran it). That was for almost-new coders, with the aim of giving them something they originally could read but not really understand, and by gradually editing the code together they ended up getting it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Homework help requested (not what you think!)
On 17 jul 2013, at 08:35, alex23 wrote: > On 17/07/2013 8:43 AM, John Ladasky wrote: >> The kids all claim to be interested. They all want to write the next great >> 3D video game. Thus, I'm a little surprised that the kids don't actually >> try to sit down and code without me prompting them. I think that they're >> disappointed when I show them how much they have to understand just to write >> a program that plays Tic Tac Toe. > > One possible approach would be to pick existing games developed in PyGame and > assist them to modify or extend them. This can be a lot less overwhelming > than starting a game from scratch, and exposes them to the basic concepts > such as the main event loop, separating out logic from display etc. Code > reading is as valuable a skill as code writing. > > Another possibility is using a more extensive framework like Unity, which > provides a lot of the toolchain to simplify the development process. While > Unity doesn't support Python by default, it does provide Boo, which is > Python-inspired. It's also built on top of the Mono framework, and I believe > people have had some success with using .NET's IronPython with it. another vote for Unity here... We teach that at the filmschool here in Holland and it's a really well supported package. There's a free version and it "exports" to Windows, OSX, Linux, Playstation, XBOX, iPhone etc etc But that comes at the cost already mentioned by Alex above... http://en.wikipedia.org/wiki/Unity_(game_engine) http://unity3d.com/ One step more advanced, but only available on Windows, is the CryEngine: http://en.wikipedia.org/wiki/Cryengine http://mycryengine.com/ They also have a free version but again, no Python scripting by default. Another one to bring into attention may be Panda3D: http://www.panda3d.org/ That has full Python support. Don't forget that all these engines require you to build your assets yourself, outside the engine. This means that you have to go into a 3D program like Blender to create characters, environments and creatures. greets Arno Beekman -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter redraw rates
On 07/16/2013 11:04 PM, [email protected] wrote: Noted on the quoting thing. Regarding the threading, well, first, I'm not so much a programmer as someone who knows a bit of how to program. And it seems that the only way to update a tkinter window is to use the .update() method, which is what I was experimenting with. Start up a new thread that just loops the .update() with a 1ms sleep until the download is done. It seems to work, actually. update() is to be used when it's too awkward to return to mainloop. In my second approach, you would periodically call it inside the processing loop. But unless tkinter is unique among GUI's, it's unsafe to do that in any thread besides the GUI thread. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter redraw rates
On Wednesday, July 17, 2013 6:07:22 PM UTC+8, Dave Angel wrote: > On 07/16/2013 11:04 PM, [email protected] wrote: > > > Noted on the quoting thing. > > > > > > Regarding the threading, well, first, I'm not so much a programmer as > > someone who knows a bit of how to program. > > > > > > And it seems that the only way to update a tkinter window is to use the > > .update() method, which is what I was experimenting with. Start up a new > > thread that just loops the .update() with a 1ms sleep until the download is > > done. It seems to work, actually. > > > > > > > update() is to be used when it's too awkward to return to mainloop. In > > my second approach, you would periodically call it inside the processing > > loop. But unless tkinter is unique among GUI's, it's unsafe to do that > > in any thread besides the GUI thread. > > > > > > > > -- > > DaveA Ok. Well, what I'm currently doing, based on advice from this thread, is to create a new thread that handles the downloading, as well as updating a variable for text display on the GUI, and in the main thread, just after the thread is created, a while loop that updates the GUI while the thread is running. -- http://mail.python.org/mailman/listinfo/python-list
Re: grimace: a fluent regular expression generator in Python
On 16 July 2013 20:48, wrote: > From: "Anders J. Munch" <[email protected]> > Date: Tue, 16 Jul 2013 13:38:35 +0200 > Ben Last wrote: > >> north_american_number_re = (RE().start >> .literal('(').followed_by.**exactly(3).digits.then.**literal(')') >> .then.one.literal("-").then.** >> exactly(3).digits >> .then.one.dash.followed_by.**exactly(4).digits.then.end >> .as_string()) >> > > Very cool. It's a bit verbose for my taste, and I'm not sure how well it > will cope with nested structure. > I guess verbosity is the aim, in that *explicit is better than implicit* :) And I suppose that's one of the attributes of a fluent system; they tend to need more typing. It's not Perl... > The problem with Perl-style regexp notation isn't so much that it's terse > - it's that the syntax is irregular (sic) and doesn't follow modern > principles for lexical structure in computer languages. You can get a long > way just by ignoring whitespace, putting literals in quotes and allowing > embedded comments. > Good points. I wanted to find a syntax that allows comments as well as being fluent: RE() .any_number_of.digits # Recall that any_number_of includes zero .followed_by.an_optional.dot.then.at_least_one.digit # The dot is specifically optional # but we must have one digit as a minimum .as_string() ... and yes, I aso specifically wanted to have literals quoted. Nested groups work, but I haven't tackled lookahead and backreferences : essentially because if you're writing an RE that complex, you should probably be working directly in RE strings. Depending on what you mean by "nested", re-use of RE objects is easy (example from the unit tests): identifier_start_chars = RE().regex("[a-zA-Z_]") identifier_chars = RE().regex("[a-zA-Z0-9_]") self.assertEqual(RE().one_or_more.of(identifier_start_chars) .followed_by.zero_or_more(identifier_chars) .as_string(), r"[a-zA-Z_]+[a-zA-Z0-9_]*") Thanks for the comments! ben -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter redraw rates
On Wednesday, July 17, 2013 6:07:22 PM UTC+8, Dave Angel wrote: > On 07/16/2013 11:04 PM, [email protected] wrote: > > > Noted on the quoting thing. > > Regarding the threading, well, first, I'm not so much a programmer as > > someone who knows a bit of how to program. > > And it seems that the only way to update a tkinter window is to use the > > .update() method, which is what I was experimenting with. Start up a new > > thread that just loops the .update() with a 1ms sleep until the download is > > done. It seems to work, actually. > > update() is to be used when it's too awkward to return to mainloop. In > my second approach, you would periodically call it inside the processing > loop. But unless tkinter is unique among GUI's, it's unsafe to do that > in any thread besides the GUI thread. > > -- > > DaveA Yes, based on advice from this thread, I'm doing that. From my main thread, I create a thread that handles the download while updating a variable that the mainloop displays as a text output, and in that mainloop, I have a while loop that updates the GUI until the downloading is done. -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter redraw rates
On 07/17/2013 07:10 AM, [email protected] wrote: On Wednesday, July 17, 2013 6:07:22 PM UTC+8, Dave Angel wrote: On 07/16/2013 11:04 PM, [email protected] wrote: Noted on the quoting thing. Regarding the threading, well, first, I'm not so much a programmer as someone who knows a bit of how to program. And it seems that the only way to update a tkinter window is to use the .update() method, which is what I was experimenting with. Start up a new thread that just loops the .update() with a 1ms sleep until the download is done. It seems to work, actually. update() is to be used when it's too awkward to return to mainloop. In my second approach, you would periodically call it inside the processing loop. But unless tkinter is unique among GUI's, it's unsafe to do that in any thread besides the GUI thread. -- DaveA Yes, based on advice from this thread, I'm doing that. From my main thread, I create a thread that handles the download while updating a variable that the mainloop displays as a text output, and in that mainloop, I have a while loop that updates the GUI until the downloading is done. I can't figure out what you're really doing, since each message from you says something different. You don't need a separate while loop, since that's exactly what app.mainloop() is. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: grimace: a fluent regular expression generator in Python
Ben Last writes:
> Good points. I wanted to find a syntax that allows comments as well as
> being fluent:
> RE()
> .any_number_of.digits # Recall that any_number_of includes zero
> .followed_by.an_optional.dot.then.at_least_one.digit # The dot is
> specifically optional
> # but we must have one digit as a minimum
> .as_string()
Speaking of syntax, have you looked at pyparsing? I like their
pattern-matching syntax, and I can see it being applied to regexes.
They use an operator-heavy syntax, like:
'(' + digits * 3 + ')-' + digits * 3 + '-' + digits * 4
That seems easier for me to read than the foo.then.follow syntax.
That then makes me think of ometa, which is a fun read, but probably not
completely relevant.
Regards,
Johann
--
http://mail.python.org/mailman/listinfo/python-list
Re: tkinter redraw rates
On Wednesday, July 17, 2013 7:42:45 PM UTC+8, Dave Angel wrote: > On 07/17/2013 07:10 AM, [email protected] wrote: > > On Wednesday, July 17, 2013 6:07:22 PM UTC+8, Dave Angel wrote: > >> On 07/16/2013 11:04 PM, [email protected] wrote: > >>> Noted on the quoting thing. > >>> Regarding the threading, well, first, I'm not so much a programmer as > >>> someone who knows a bit of how to program. > >>> And it seems that the only way to update a tkinter window is to use the > >>> .update() method, which is what I was experimenting with. Start up a new > >>> thread that just loops the .update() with a 1ms sleep until the download > >>> is done. It seems to work, actually. > >> update() is to be used when it's too awkward to return to mainloop. In > >> my second approach, you would periodically call it inside the processing > >> loop. But unless tkinter is unique among GUI's, it's unsafe to do that > >> in any thread besides the GUI thread. > >> DaveA > > Yes, based on advice from this thread, I'm doing that. From my main thread, > > I create a thread that handles the download while updating a variable that > > the mainloop displays as a text output, and in that mainloop, I have a > > while loop that updates the GUI until the downloading is done. > I can't figure out what you're really doing, since each message from you > says something different. You don't need a separate while loop, since > that's exactly what app.mainloop() is. > -- > > DaveA Hm. My apologies for not being very clear. What I'm doing is this: self.loader_thread = Thread(target=self.loadpages, name="loader_thread") self.loader_thread.start() while self.loader_thread.isAlive(): self.root_window.update() sleep(0.05) Where loadpages is a function defined elsewhere. -- http://mail.python.org/mailman/listinfo/python-list
Re: Homework help requested (not what you think!)
On 2013-07-16, John Ladasky wrote: > So, what I am seeking are suggestions for programming > assignments that I can give to brand-new students of Python. > Please keep in mind that none of them are even up to the task > of a simple algorithm like Bubble Sort -- at least, not yet. One of the first satisfying programs I wrote as a child autodidact on my Commodore 64 was a random name generator. There are lots of workable strategies and the output can be fun. Hint: Putting together random syllables turned out to be much more fun than random consonants and vowels. Markov chains are an advanced technique you could introduce, but you'd need a huge list of names broken into syllables from somewhere. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: Homework help requested (not what you think!)
On Wed, Jul 17, 2013 at 11:20 PM, Neil Cerutti wrote: > Markov chains are an advanced technique you could introduce, but > you'd need a huge list of names broken into syllables from > somewhere. You could use names broken into letters... or skip the notion of names and just generate words. Lists of words are easy to come by (eg /usr/share/dict/words on many Linux systems), so you can have some fun without much effort. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Homework help requested (not what you think!)
On 2013-07-17, Chris Angelico wrote: > On Wed, Jul 17, 2013 at 11:20 PM, Neil Cerutti wrote: >> Markov chains are an advanced technique you could introduce, but >> you'd need a huge list of names broken into syllables from >> somewhere. > > You could use names broken into letters... or skip the notion > of names and just generate words. Lists of words are easy to > come by (eg /usr/share/dict/words on many Linux systems), so > you can have some fun without much effort. That's true. Something like syllables should emerge from markov chains of letters pretty well, depending on how long the the chain is. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
Re: Homework help requested (not what you think!)
On Wed, Jul 17, 2013 at 11:55 PM, Neil Cerutti wrote: > On 2013-07-17, Chris Angelico wrote: >> On Wed, Jul 17, 2013 at 11:20 PM, Neil Cerutti wrote: >>> Markov chains are an advanced technique you could introduce, but >>> you'd need a huge list of names broken into syllables from >>> somewhere. >> >> You could use names broken into letters... or skip the notion >> of names and just generate words. Lists of words are easy to >> come by (eg /usr/share/dict/words on many Linux systems), so >> you can have some fun without much effort. > > That's true. Something like syllables should emerge from markov > chains of letters pretty well, depending on how long the the > chain is. I might have to hunt down my old Dissociated Press implementations, they were fun fun fun. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: grimace: a fluent regular expression generator in Python
In article , "Anders J. Munch" <[email protected]> wrote: > The problem with Perl-style regexp notation isn't so much that it's terse - > it's > that the syntax is irregular (sic) and doesn't follow modern principles for > lexical structure in computer languages. There seem to be three basic ways to denote what's literal and what's not. 1) The Python (and C, Java, PHP, Fortran, etc) way, where all text is assumed to be evaluated as a language construct, unless explicitly quoted to make it a literal. 2) The shell way, where all text is assumed to be literal strings, unless explicitly marked with a $ (or other sigil) as a variable. 3) The regex way, where some characters are magic, but only sometimes (depending on context), and you just have to know which ones they are, and when, and can escape them to make them non-magic if you have to. Where things get really messy is when you try to embed one language into another, such as regexes in Python. Perl (and awk, from which it evolved) solves the problem in its own way by making regexes a built-in part of the language syntax. Python goes in the other direction, and says regexes are just strings that you pass around. > You can get a long way just by ignoring whitespace, putting literals > in quotes and allowing embedded comments. Setting the re.VERBOSE > flag achieves two out of three [example elided]. Yup. Here's a more complex example. We use this to parse haproxy log files (probably going to munged a bit as lines get refolded by news software). That would be insane without verbose mode (some might argue it's insane now, but that's another thread). pattern = re.compile(r'haproxy\[(?P\d+)]: ' r'(?P(\d{1,3}\.){3}\d{1,3}):' r'(?P\d{1,5}) ' r'\[(?P\d{2}/\w{3}/\d{4}(:\d{2}){3}\.\d{3})] ' r'(?P\S+) ' r'(?P\S+)/' r'(?P\S+) ' r'(?P(-1|\d+))/' r'(?P(-1|\d+))/' r'(?P(-1|\d+))/' r'(?P(-1|\d+))/' r'(?P\+?\d+) ' r'(?P\d{3}) ' r'(?P\d+) ' r'(?P\S+) ' r'(?P\S+) ' r'(?P[\w-]{4}) ' r'(?P\d+)/' r'(?P\d+)/' r'(?P\d+)/' r'(?P\d+)/' r'(?P\d+) ' r'(?P\d+)/' r'(?P\d+) ' r'(\{(?P.*?)\} )?' # Comment this out for a stock haproxy (see above) r'(\{(?P.*?)\} )?' r'(\{(?P.*?)\} )?' r'"(?P.+)"' ) -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN]:JSONStream
Looks interesting. In YAML we used three dashes as the "stream
separator".
So already a YAML processor could handle a JSON stream ...
>>> for doc in yaml.load_all("""
... --- {"one": "value"}
... --- {"two": "another"}
... ---
... {"three": "a third item in the stream",
... "with": "more data"}
... """):
... print doc
...
{'one': 'value'}
{'two': 'another'}
{'with': 'more data', 'three': 'a third item in the stream'}
--
http://mail.python.org/mailman/listinfo/python-list
Re: tkinter redraw rates
On 07/17/2013 09:18 AM, [email protected] wrote: On Wednesday, July 17, 2013 7:42:45 PM UTC+8, Dave Angel wrote: On 07/17/2013 07:10 AM, [email protected] wrote: On Wednesday, July 17, 2013 6:07:22 PM UTC+8, Dave Angel wrote: On 07/16/2013 11:04 PM, [email protected] wrote: Noted on the quoting thing. Regarding the threading, well, first, I'm not so much a programmer as someone who knows a bit of how to program. And it seems that the only way to update a tkinter window is to use the .update() method, which is what I was experimenting with. Start up a new thread that just loops the .update() with a 1ms sleep until the download is done. It seems to work, actually. update() is to be used when it's too awkward to return to mainloop. In my second approach, you would periodically call it inside the processing loop. But unless tkinter is unique among GUI's, it's unsafe to do that in any thread besides the GUI thread. DaveA Yes, based on advice from this thread, I'm doing that. From my main thread, I create a thread that handles the download while updating a variable that the mainloop displays as a text output, and in that mainloop, I have a while loop that updates the GUI until the downloading is done. I can't figure out what you're really doing, since each message from you says something different. You don't need a separate while loop, since that's exactly what app.mainloop() is. -- DaveA Hm. My apologies for not being very clear. What I'm doing is this: self.loader_thread = Thread(target=self.loadpages, name="loader_thread") self.loader_thread.start() while self.loader_thread.isAlive(): self.root_window.update() sleep(0.05) Where loadpages is a function defined elsewhere. Presumably this fragment is from a method of some class you've written. Is it an event handler, or is this happening before you finish setting up the GUI? Somewhere at top-level, you're supposed to fall into a call to mainloop(), which doesn't return till the user cancels the app. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter redraw rates
[email protected] wrote: > Hm. My apologies for not being very clear. What I'm doing is this: > > self.loader_thread = Thread(target=self.loadpages, > name="loader_thread") > self.loader_thread.start() > while self.loader_thread.isAlive(): > self.root_window.update() > sleep(0.05) > > Where loadpages is a function defined elsewhere. I suppose the while loop runs in the main thread? That's not a good idea with Tkinter (and GUIs in general). I suggest using http://effbot.org/zone/tkinter-threads.htm as a template. The main difference is that instead of your while-loop and sleep() it calls the after() method which keeps tkinter in control so that it can still respond to events. -- http://mail.python.org/mailman/listinfo/python-list
Python HTTP POST
I am going to be creating a python script that will make filling in information at my job easier. I have all of the information I need... I guess I just need to see it in practice to fully grasp it. How would I submit a python HTTP POST request to... for example, go to google.com, enter "Pie" into the search box and submit (Search) -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN]:JSONStream
I didn't look into using YAML processor.
Also that would have required pre-processing the data to add the separators.
With this method you don't need the separators. You can have 0 or more
white space between objects:
for obj in JSONStream(StringIO('''{"one":1}{"two":2}{"three":3} 4
{"five": 5}''')):
print(obj)
{"one":1}
{"two":2}
{"three":3}
4
{"five":5}
It solved my problem, so I thought someone might find it useful.
On Wed, Jul 17, 2013 at 11:51 AM, Clark C. Evans wrote:
> **
> Looks interesting. In YAML we used three dashes as the "stream separator".
> So already a YAML processor could handle a JSON stream ...
>
> >>> for doc in yaml.load_all("""
> ... --- {"one": "value"}
> ... --- {"two": "another"}
> ... ---
> ... {"three": "a third item in the stream",
> ... "with": "more data"}
> ... """):
> ... print doc
> ...
> {'one': 'value'}
> {'two': 'another'}
> {'with': 'more data', 'three': 'a third item in the stream'}
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
--
http://mail.python.org/mailman/listinfo/python-list
Storing a very large number
I came across a problem that requires me to store a very large number (say >10^100). How do I do it efficiently? And also, how do I select a particular number (say 209th) from that very large number? I am relatively new to Python. Thank you in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN]:JSONStream
On 17 Jul 2013 20:40, "Sol Toure" wrote:
>
> I didn't look into using YAML processor.
> Also that would have required pre-processing the data to add the
separators.
> With this method you don't need the separators. You can have 0 or more
white space between objects:
>
> for obj in JSONStream(StringIO('''{"one":1}{"two":2}{"three":3} 4
{"five": 5}''')):
> print(obj)
>
> {"one":1}
> {"two":2}
> {"three":3}
> 4
> {"five":5}
>
> It solved my problem, so I thought someone might find it useful.
>
>
>
> On Wed, Jul 17, 2013 at 11:51 AM, Clark C. Evans
wrote:
>>
>> Looks interesting. In YAML we used three dashes as the "stream
separator".
>> So already a YAML processor could handle a JSON stream ...
>>
>> >>> for doc in yaml.load_all("""
>> ... --- {"one": "value"}
>> ... --- {"two": "another"}
>> ... ---
>> ... {"three": "a third item in the stream",
>> ... "with": "more data"}
>> ... """):
>> ... print doc
>> ...
>> {'one': 'value'}
>> {'two': 'another'}
>> {'with': 'more data', 'three': 'a third item in the stream'}
I think this could be useful for the twitter stream api. It feeds
\n-separated json objects over time.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Storing a very large number
On 2013-07-17, Hasit Mistry wrote: > I came across a problem that requires me to store a very large number > (say >10^100). How do I do it efficiently? First you must define "efficient". If you want to store the least number of bytes, and all you need to do is store the number (you don't need to manipulate it numerically, then storing it as an ascii string in exponential notion might be the smallest and fastest: veryLargeNumber = "10^100" That's only 27 bytes (CPython 2.7 on Linux). If you do need to do math on it, then what's wrong with this? veryLargeNumber = 10**100 That takes 58 bytes, but is much simpler for doing calculations. > And also, how do I select a particular number (say 209th) from that very > large number? I don't know what you mean by "a particular number". Do you mean you want to know the value of a particular digit when it's representing in a partuclar base (e.g. base 10)? Does this do what you want? First, we'll generate a number with a lot of digits: >>> int(math.pi * 10**15) ** 40 76912142205156893736567110721938151873066848551250079691933197504698382687850162519363381241341072061717399276279446152783228293733394674915106506777652714586583257515548935662783041098025828748644732150180263384738920337734332306732579704813309358353325051464419679305008247276777590803598706960718369750920313818346498676991944268444745266147723127330821117640028009756028827267657249563468436491879452209207125425662579803287297238987286648041733328816128585346936668110411776730224052535307657062833269810807032506745274610105341051559960125927107837478566295005327614374967849408928939897747893587527876150286368001L >>> x = int(math.pi * 10**15) ** 40 >>> sys.getsizeof(x) 288 >>> math.log10(x) 619.8859949077654 It has 600+ digits and requires 288 bytes to store. Counting from the left-hand side, starting '7' as digit 0, the 209th digit in the base-10 representation is: >>> str(x)[209] '3' -- Grant Edwards grant.b.edwardsYow! If elected, Zippy at pledges to each and every gmail.comAmerican a 55-year-old houseboy ... -- http://mail.python.org/mailman/listinfo/python-list
Re: Storing a very large number
On 07/17/2013 12:21 PM, Hasit Mistry wrote: I came across a problem that requires me to store a very large number (say >10^100). How do I do it efficiently? And also, how do I select a particular number (say 209th) from that very large number? I am relatively new to Python. Thank you in advance. Python already has long numbers (integers) built in.: >>> 10**100 1L The 'L' on the end notifies you it's a *long* int. I can't speak about its efficiency, but I assume it's OK. By 209th number, do you mean 209th *digit*?I'd say just get a string representation and index the 209th character: >>> str(12**345) '2077446682327378559843444695582704973572786912705232236931705903179519704325276892191015329301807037794598378537132233994613616420526484930777273718077112370160566492728059713895917217042738578562985773221381211423961068296308572143393854703167926779929682604844469621152130457090778409728703018428147734622401526422774317612081074841839507864189781700150115308454681772032' >>> str(12**345)[209] '1' Gary Herron -- Dr. Gary Herron Department of Computer Science DigiPen Institute of Technology (425) 895-4418 -- http://mail.python.org/mailman/listinfo/python-list
Re: Storing a very large number
On Wed, Jul 17, 2013 at 1:21 PM, Hasit Mistry wrote: > I came across a problem that requires me to store a very large number (say >>10^100). How do I do it efficiently? Both the int and Decimal types support arbitrary precision. Floats do not. > And also, how do I select a particular number (say 209th) from that very > large number? You mean a particular digit? The most obvious way is to format it as a string and use indexing. >>> x = 2 ** 1000 >>> str(x)[208] '6' Or using arithmetic: >>> (x // 10 ** 208) % 10 5 Note that the first method counts digits from the left and will be off if the value is negative, while the second method counts digits from the right. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python HTTP POST
In <[email protected]> Matt Graves writes: > How would I submit a python HTTP POST request to... for example, go to > google.com, enter "Pie" into the search box and submit (Search) Something like this: import urllib import urllib2 # the google form search input box is named 'q' data = { 'q': 'Pie' } response = urllib2.urlopen('http://google.com', urllib.urlencode(data)) print response.read() -- John Gordon A is for Amy, who fell down the stairs [email protected] B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- http://mail.python.org/mailman/listinfo/python-list
Re: Python HTTP POST
On Wed, Jul 17, 2013 at 4:15 PM, John Gordon wrote: > In <[email protected]> Matt Graves < > [email protected]> writes: > > > How would I submit a python HTTP POST request to... for example, go to > > google.com, enter "Pie" into the search box and submit (Search) > > Something like this: > > import urllib > import urllib2 > > # the google form search input box is named 'q' > data = { 'q': 'Pie' } > > response = urllib2.urlopen('http://google.com', urllib.urlencode(data)) > print response.read() > > -- > John Gordon A is for Amy, who fell down the stairs > [email protected] B is for Basil, assaulted by bears > -- Edward Gorey, "The Gashlycrumb Tinies" > > -- > http://mail.python.org/mailman/listinfo/python-list > Many people find urllib and urllib2 to be confusing. There is a module called requests which makes this stuff a lot easier. ymmv http://docs.python-requests.org/en/latest/ -- Joel Goldstick http://joelgoldstick.com -- http://mail.python.org/mailman/listinfo/python-list
[ANN] bbfreeze 1.1.2
Hi, I've just released bbfreeze 1.1.2. The code is available from pypi https://pypi.python.org/pypi/bbfreeze/ or from github https://github.com/schmir/bbfreeze bbfreeze creates stand-alone executables from python scripts. It's similar in purpose to the well known py2exe for windows, py2app for OS X, PyInstaller and cx_Freeze (in fact ancient versions were based on cx_Freeze. And it uses the modulegraph package, which is also used by py2app). It has the following features: easy installation bbfreeze can be installed with setuptools' easy_install command. zip/egg file import tracking bbfreeze tracks imports from zip files and includes whole egg files if some module is used from an eggfile. Packages using setuputils' pkg_resources module will now work (new in 0.95.0) binary dependency tracking bbfreeze will track binary dependencies and will include DLLs and shared libraries needed by a frozen program. multiple script freezing bbfreeze can freeze multiple scripts at once. python interpreter included bbfreeze will create an extra executable named 'py', which might be used like the python executable itself. automatic pathname rewriting pathnames in tracebacks are replaced with relative pathnames (i.e. if you import package foo.bar from /home/jdoe/pylib/ tracebacks generated from functions in foo.bar will not show your local path /home/jdoe/pylib/foo/bar.py. They will instead show foo/bar.py) distutils command 'bdist_bbfreeze' A new distutils/setuptools command bdist_bbfreeze integrates bbfreeze into your setup.py. bbfreeze works on windows and UNIX-like operating systems. bbfreeze has been tested with python 2.4, 2.5, 2.6 and 2.7 bbfreeze will not work with python 3 or higher. -- Cheers Ralf -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] bbfreeze 1.1.2
On 17 Jul 2013 21:46, "Ralf Schmitt" wrote: > bbfreeze will not > work with python 3 or higher. > > > -- > Cheers > Ralf Seems like it has awesome features, but py3k is really important to me. Is this on your roadmap? -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter redraw rates
On 07/17/2013 05:08 AM, [email protected] wrote: > Ok. Well, what I'm currently doing, based on advice from this thread, > is to create a new thread that handles the downloading, as well as > updating a variable for text display on the GUI, and in the main > thread, just after the thread is created, a while loop that updates > the GUI while the thread is running. Not sure what you mean by "while loop." In an event-driven paradigm, one technique would be to set a timeout event that fires every so many ms. Then in the event callback, you update the widget according to the new value of the variable. At least this is how i'd do it in Qt or GTK. -- http://mail.python.org/mailman/listinfo/python-list
Re: grimace: a fluent regular expression generator in Python
Ben Last wrote:
north_american_number_re = (RE().start
.literal('(').followed_by.__exactly(3).digits.then.__literal(')')
.then.one.literal("-").then.__exactly(3).digits
.then.one.dash.followed_by.__exactly(4).digits.then.end
.as_string())
Is 'dash' the same as 'literal("-")'?
Is there any difference between 'then' and 'followed_by'?
Why do some things have __ in front of them? Is there a
difference between 'literal' and '__literal'?
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
Creating a Program to Decompose a Number and Run a Function on that Decomposition
I've been puzzling over how to get a certain function working in Python. The function, takes positive integers to other positive integers as follows: Phi_m(n2) = Phi_m(m*n + r) = m*x[n1] + r*(x[n1 + 1] - x[n1]) The above terms are all integer valued and are defined as follows: n2 = the (n2)th slot of the output string m = a fixed positive integer n = some multiple of m such that n*m is less than or equal to n2 r = a remainder term to fill in the amount missing from n*m in decomposing n2 x[n1] = the element in the [n1]th slot of the input string x[n1 + 1] = the element in the [n1 + 1]th slot of the input string In general we start with a string of numbers, say 0, 1, 1, 2, 3, 3 and end up with a string of (k+1)m-1 terms, where k is the number of terms you started with. To use the function we first fix an m, say m = 2. Now we decompose n2 in terms of m, where n2 is representing a 'slot' of our output sequence. Say n2=5. Then we are asking 'what is in the fifth 'slot' of our output string'. In this case our total output string will be of length (5+1)2+1. Notice that we do not count 0 - it is always present and is for our purposes the 0th term, hence we have 5 initial terms. To answer our question of what goes in the slot we take 5=2*2+1 as our decomposition. Now that we have a decomposition we can apply our function: F(x(5)) = F(x(2*2+1)) 2x[2] + 1(x[3] - x[2]). The thing is, for Python to do this it has to know how to decompose each number. So it knows 2 is fixed, and knows 2*3 is too much and so chooses 2*2. Then it has to know this is too little and add remainder 1. Only once it's done this can it actually grab n = 5. That is, it can run the function. It seems clear that once it knows how to do this it can just run through every n in our range, but I'm really not sure how to program the meat of this function. Now to answer some questions: Is x a function? A list? A number? x[n] is essentially a list. What do you mean when you say "values of an input string"? What's the signature of Phi_m? The function acting on this list takes in a single element of the list, gives us a decomposition of the number somehow, and then applies the 'formula' you see above. In this sense it is more of a two step algorithm. To give another example, say we want to apply psi_2 to 0,1,2,2. Then we have an output of length (3+1)2-1=7. F(7)=F(2*3+1) = 2x[3] + 1(x[4] - x[3]). As we can see, we are missing x[4] (remember 0 doesn't count as a term). So we actually need to stop our calculation one shy of the 7 terms we 'should' have. Hence, although we actually want 7 terms the program really only needs to give 6 terms, the other term can be hand calculated, or the user can append one extra term to the input string 0,1,2,2 and run the program again. Please let me know if this is unclear. I will certainly continue revising until it makes sense to those reading. -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter redraw rates
On Thursday, July 18, 2013 1:38:34 AM UTC+8, Dave Angel wrote: > On 07/17/2013 09:18 AM, [email protected] wrote: > > On Wednesday, July 17, 2013 7:42:45 PM UTC+8, Dave Angel wrote: > >> On 07/17/2013 07:10 AM, [email protected] wrote: > >>> On Wednesday, July 17, 2013 6:07:22 PM UTC+8, Dave Angel wrote: > On 07/16/2013 11:04 PM, [email protected] wrote: > > Noted on the quoting thing. > > Regarding the threading, well, first, I'm not so much a programmer as > > someone who knows a bit of how to program. > > And it seems that the only way to update a tkinter window is to use the > > .update() method, which is what I was experimenting with. Start up a > > new thread that just loops the .update() with a 1ms sleep until the > > download is done. It seems to work, actually. > update() is to be used when it's too awkward to return to mainloop. In > my second approach, you would periodically call it inside the processing > loop. But unless tkinter is unique among GUI's, it's unsafe to do that > in any thread besides the GUI thread. > DaveA > > >>> Yes, based on advice from this thread, I'm doing that. From my main > >>> thread, I create a thread that handles the download while updating a > >>> variable that the mainloop displays as a text output, and in that > >>> mainloop, I have a while loop that updates the GUI until the downloading > >>> is done. > >> I can't figure out what you're really doing, since each message from you > >> says something different. You don't need a separate while loop, since > >> that's exactly what app.mainloop() is. > >> -- > >> > >> DaveA > > > > Hm. My apologies for not being very clear. What I'm doing is this: > > self.loader_thread = Thread(target=self.loadpages, > > name="loader_thread") > > self.loader_thread.start() > > while self.loader_thread.isAlive(): > > self.root_window.update() > > sleep(0.05) > > Where loadpages is a function defined elsewhere. > > Presumably this fragment is from a method of some class you've written. > Is it an event handler, or is this happening before you finish setting > up the GUI? Somewhere at top-level, you're supposed to fall into a call > to mainloop(), which doesn't return till the user cancels the app. > -- > > DaveA This is, indeed, an event handler from a class for my GUI. My entire GUI is a bit large, so I'll not copy the entire thing here, but it roughly goes: class GUI(object): def __init__(self): [stuff] def init_button(self): self.execute = ttk.Button(self.input_frame, text='Tally', command=self.execute_now) self.execute.grid(column=1, row=2, sticky=(N, S, E, W), columnspan=4) def execute_now(self): [stuff] self.loader_thread = Thread(target=self.loadpages, name="loader_thread") self.loader_thread.start() while self.loader_thread.isAlive(): self.root_window.update() sleep(0.05) [morestuff] if __name__ == "__main__": APP = GUI() APP.root_window.mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter redraw rates
On 07/17/2013 08:44 PM, [email protected] wrote: On Thursday, July 18, 2013 1:38:34 AM UTC+8, Dave Angel wrote: On 07/17/2013 09:18 AM, [email protected] wrote: On Wednesday, July 17, 2013 7:42:45 PM UTC+8, Dave Angel wrote: On 07/17/2013 07:10 AM, [email protected] wrote: On Wednesday, July 17, 2013 6:07:22 PM UTC+8, Dave Angel wrote: On 07/16/2013 11:04 PM, [email protected] wrote: Noted on the quoting thing. Regarding the threading, well, first, I'm not so much a programmer as someone who knows a bit of how to program. And it seems that the only way to update a tkinter window is to use the .update() method, which is what I was experimenting with. Start up a new thread that just loops the .update() with a 1ms sleep until the download is done. It seems to work, actually. update() is to be used when it's too awkward to return to mainloop. In my second approach, you would periodically call it inside the processing loop. But unless tkinter is unique among GUI's, it's unsafe to do that in any thread besides the GUI thread. DaveA Yes, based on advice from this thread, I'm doing that. From my main thread, I create a thread that handles the download while updating a variable that the mainloop displays as a text output, and in that mainloop, I have a while loop that updates the GUI until the downloading is done. I can't figure out what you're really doing, since each message from you says something different. You don't need a separate while loop, since that's exactly what app.mainloop() is. -- DaveA Hm. My apologies for not being very clear. What I'm doing is this: self.loader_thread = Thread(target=self.loadpages, name="loader_thread") self.loader_thread.start() while self.loader_thread.isAlive(): self.root_window.update() sleep(0.05) Where loadpages is a function defined elsewhere. Presumably this fragment is from a method of some class you've written. Is it an event handler, or is this happening before you finish setting up the GUI? Somewhere at top-level, you're supposed to fall into a call to mainloop(), which doesn't return till the user cancels the app. -- DaveA This is, indeed, an event handler from a class for my GUI. My entire GUI is a bit large, so I'll not copy the entire thing here, but it roughly goes: class GUI(object): def __init__(self): [stuff] def init_button(self): self.execute = ttk.Button(self.input_frame, text='Tally', command=self.execute_now) self.execute.grid(column=1, row=2, sticky=(N, S, E, W), columnspan=4) def execute_now(self): [stuff] self.loader_thread = Thread(target=self.loadpages, name="loader_thread") self.loader_thread.start() self.root_window.after(100, self.test_thread) return while self.loader_thread.isAlive(): self.root_window.update() Nope - don't use that. Instead, post an event on the queue, and return to the mainloop() from whence we came. def test_thread(self): if self.loader_thread.isAlive(): self.root_window.after(100, self.test_thread) return [morestuff] sleep(0.05) [morestuff] if __name__ == "__main__": APP = GUI() APP.root_window.mainloop() I probably don't have it quite right, but hopefully you'll get the idea. self.test_thread() is now a new event that will get repeatedly invoked, to do the check on the thread status. It returns rapidly unless the condition has occurred. There are other things that should be done, like blocking the specific events that would create duplicate threads. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Python-list Digest, Vol 118, Issue 144
> From: Gregory Ewing > To: [email protected] > Is 'dash' the same as 'literal("-")'? > Yes, it's a convenience method, like 'dot' and 'underscore'. The code I pasted is from the unit tests, where I use the different methods to push coverage up. > Is there any difference between 'then' and 'followed_by'? > Nope, they're synonyms. Same as 'zero_or_more' is the same as 'any_number_of', or 'digit' is the same as 'digits'. Why do some things have __ in front of them? Is there a > difference between 'literal' and '__literal'? > Er... looks like a garblement in my post! There are no __ in my original :( It should be: north_american_number_re = (RE().start .literal('(').followed_by.exactly(3).digits.then.literal(')') .then.one.literal("-").then.exactly(3).digits .then.one.dash.followed_by.exactly(4).digits.then.end .as_string()) Thanks for the comments! Cheers b -- http://mail.python.org/mailman/listinfo/python-list
Need help with network script
Hi everyone. I am starting to learn python and I decided to start with what I though was a simple script but I guess now. All I want to do is return what current network location I am using on my mac. Every time I run it, it gives me back a 0. I don't know what I am doing wrong so here is my code. I really hope some one can help me. This script is unique to MACS btw. import sys import subprocess loc = "scselect" srn = "scselect SRN" home = "scselect HOME" a = subprocess.call(loc, shell=True, stdout=subprocess.PIPE) b = subprocess.call(srn, shell=True, stdout=subprocess.PIPE) c = subprocess.call(home, shell=True, stdout=subprocess.PIPE) print "\n# NETWORK SELECTION #" print "\nYour current location is set to \n%s" (a) -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with network script
On Thu, Jul 18, 2013 at 11:44 AM, wrote: > Hi everyone. I am starting to learn python and I decided to start with what I > though was a simple script but I guess now. All I want to do is return what > current network location I am using on my mac. Every time I run it, it gives > me back a 0. I don't know what I am doing wrong so here is my code. I really > hope some one can help me. This script is unique to MACS btw. > > import sys > import subprocess > > loc = "scselect" > srn = "scselect SRN" > home = "scselect HOME" > > a = subprocess.call(loc, shell=True, stdout=subprocess.PIPE) > b = subprocess.call(srn, shell=True, stdout=subprocess.PIPE) > c = subprocess.call(home, shell=True, stdout=subprocess.PIPE) > > print "\n# NETWORK SELECTION #" > print "\nYour current location is set to \n%s" (a) Your last line here looks wrong. Is this really the code you're using? This code will crash with a TypeError, because you're trying to call a string. Copy and paste your actual code, don't re-type it :) ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with network script
Im trying to get the output from "scselect" and display it on a new line. -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with network script
On Wednesday, July 17, 2013 7:50:44 PM UTC-6, Chris Angelico wrote: > On Thu, Jul 18, 2013 at 11:44 AM, > > > Hi everyone. I am starting to learn python and I decided to start with what > > I though was a simple script but I guess now. All I want to do is return > > what current network location I am using on my mac. Every time I run it, it > > gives me back a 0. I don't know what I am doing wrong so here is my code. I > > really hope some one can help me. This script is unique to MACS btw. > > > > > > import sys > > > import subprocess > > > > > > loc = "scselect" > > > srn = "scselect SRN" > > > home = "scselect HOME" > > > > > > a = subprocess.call(loc, shell=True, stdout=subprocess.PIPE) > > > b = subprocess.call(srn, shell=True, stdout=subprocess.PIPE) > > > c = subprocess.call(home, shell=True, stdout=subprocess.PIPE) > > > > > > print "\n# NETWORK SELECTION #" > > > print "\nYour current location is set to \n%s" (a) > > > > Your last line here looks wrong. Is this really the code you're using? > > This code will crash with a TypeError, because you're trying to call a > > string. > > > > Copy and paste your actual code, don't re-type it :) > > > > ChrisA This is as far as I have gotten. THis is all my code and it has been copied and pasted. Thats why I am posting here. I know that the code can be better. Once I learn more it wont look like crap. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python HTTP POST
On 18/07/2013 4:49 AM, Matt Graves wrote: How would I submit a python HTTP POST request to... for example, go to google.com, enter "Pie" into the search box and submit (Search) Other replies have suggested how you could do it by building the request yourself. Another approach is to interact directly with the form using mechanize: http://wwwsearch.sourceforge.net/mechanize/ Unfortunately this doesn't appear to actually work with Google, as its robots.txt won't allow it. But if you're dealing with an intranet-based form in your organisation you should be fine. -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with network script
On 07/17/2013 09:50 PM, Chris Angelico wrote: On Thu, Jul 18, 2013 at 11:44 AM, wrote: Hi everyone. I am starting to learn python and I decided to start with what I though was a simple script but I guess now. All I want to do is return what current network location I am using on my mac. Every time I run it, it gives me back a 0. I don't know what I am doing wrong so here is my code. I really hope some one can help me. This script is unique to MACS btw. import sys import subprocess loc = "scselect" srn = "scselect SRN" home = "scselect HOME" a = subprocess.call(loc, shell=True, stdout=subprocess.PIPE) b = subprocess.call(srn, shell=True, stdout=subprocess.PIPE) c = subprocess.call(home, shell=True, stdout=subprocess.PIPE) print "\n# NETWORK SELECTION #" print "\nYour current location is set to \n%s" (a) Your last line here looks wrong. Is this really the code you're using? This code will crash with a TypeError, because you're trying to call a string. Copy and paste your actual code, don't re-type it :) In addition to reposting using copy/paste, please specify the Python version. There were differences between 2.6 and 2.7. Short answer is that subprocess.call() returns an integral returncode. So zero tells you that shelling to the subprocess succeeded. Perhaps you'd like to use subprocess.check_output() instead of subprocess.call(). -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: Homework help requested (not what you think!)
On 17/07/2013 11:29 PM, Chris Angelico wrote: On Wed, Jul 17, 2013 at 11:20 PM, Neil Cerutti wrote: Markov chains are an advanced technique you could introduce, but you'd need a huge list of names broken into syllables from somewhere. You could use names broken into letters... or skip the notion of names and just generate words. Lists of words are easy to come by (eg /usr/share/dict/words on many Linux systems), so you can have some fun without much effort. I really wanted Dihedral to chime in here. -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with network script
> In addition to reposting using copy/paste, please specify the Python > > version. There were differences between 2.6 and 2.7. > > > > Short answer is that subprocess.call() returns an integral returncode. > > So zero tells you that shelling to the subprocess succeeded. > > > > Perhaps you'd like to use subprocess.check_output() instead of > > subprocess.call(). > > > > > > -- > > DaveA I will try that. I am using Python 2.7 -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter redraw rates
On Thursday, July 18, 2013 9:07:24 AM UTC+8, Dave Angel wrote: > On 07/17/2013 08:44 PM, [email protected] wrote: > > On Thursday, July 18, 2013 1:38:34 AM UTC+8, Dave Angel wrote: > >> On 07/17/2013 09:18 AM, [email protected] wrote: > >>> On Wednesday, July 17, 2013 7:42:45 PM UTC+8, Dave Angel wrote: > On 07/17/2013 07:10 AM, [email protected] wrote: > > On Wednesday, July 17, 2013 6:07:22 PM UTC+8, Dave Angel wrote: > >> On 07/16/2013 11:04 PM, [email protected] wrote: > >>> Noted on the quoting thing. > >>> Regarding the threading, well, first, I'm not so much a programmer as > >>> someone who knows a bit of how to program. > >>> And it seems that the only way to update a tkinter window is to use > >>> the .update() method, which is what I was experimenting with. Start > >>> up a new thread that just loops the .update() with a 1ms sleep until > >>> the download is done. It seems to work, actually. > >> update() is to be used when it's too awkward to return to mainloop. In > >> my second approach, you would periodically call it inside the > >> processing > >> loop. But unless tkinter is unique among GUI's, it's unsafe to do that > >> in any thread besides the GUI thread. > >> DaveA > > Yes, based on advice from this thread, I'm doing that. From my main > > thread, I create a thread that handles the download while updating a > > variable that the mainloop displays as a text output, and in that > > mainloop, I have a while loop that updates the GUI until the > > downloading is done. > I can't figure out what you're really doing, since each message from you > says something different. You don't need a separate while loop, since > that's exactly what app.mainloop() is. > -- > DaveA > > >>> Hm. My apologies for not being very clear. What I'm doing is this: > >>> self.loader_thread = Thread(target=self.loadpages, > >>> name="loader_thread") > >>> self.loader_thread.start() > >>> while self.loader_thread.isAlive(): > >>> self.root_window.update() > >>> sleep(0.05) > >>> Where loadpages is a function defined elsewhere. > > >> Presumably this fragment is from a method of some class you've written. > >>Is it an event handler, or is this happening before you finish setting > >> up the GUI? Somewhere at top-level, you're supposed to fall into a call > >> to mainloop(), which doesn't return till the user cancels the app. > >> -- > >> DaveA > > > This is, indeed, an event handler from a class for my GUI. My entire GUI is > > a bit large, so I'll not copy the entire thing here, but it roughly goes: > > class GUI(object): > > def __init__(self): > > [stuff] > > def init_button(self): > > self.execute = ttk.Button(self.input_frame, text='Tally', > >command=self.execute_now) > > self.execute.grid(column=1, row=2, sticky=(N, S, E, W), > > columnspan=4) > > def execute_now(self): > > [stuff] > > self.loader_thread = Thread(target=self.loadpages, > > name="loader_thread") > > self.loader_thread.start() > self.root_window.after(100, self.test_thread) > return > > while self.loader_thread.isAlive(): > > self.root_window.update() > Nope - don't use that. Instead, post an event on the queue, and return > to the mainloop() from whence we came. > def test_thread(self): > if self.loader_thread.isAlive(): > self.root_window.after(100, self.test_thread) > return > [morestuff] > > sleep(0.05) > > [morestuff] > > if __name__ == "__main__": > > APP = GUI() > > APP.root_window.mainloop() > I probably don't have it quite right, but hopefully you'll get the idea. > self.test_thread() is now a new event that will get repeatedly > invoked, to do the check on the thread status. It returns rapidly > unless the condition has occurred. > There are other things that should be done, like blocking the specific > events that would create duplicate threads. > -- > > DaveA I see, though it should be noted that your method doesn't actually block the rest of the even handler code from running, had to fiddle with it a bit to get that to work. May I ask what exactly is the rationale behind implementing it like this, though? -- http://mail.python.org/mailman/listinfo/python-list
What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)
I wanted to do a little project for learning Python. I thought a chat system will be good as it isn't something that I have ever done. I wanted to know what will I need? I think that would require me these 1 learn network/socket programming 2 find a free server to host my chat server 3 GUI development for clients -I wanted to know whether these are all that I would need or are there more things? -Will I need to learn a web framework like Django? -Will I need to learn something for database management like sql for handling people's account names and password? Is google appengine good for hosting the website or should I look up at django hosting websites? Any other advice for me(a novice programmer)? -- http://mail.python.org/mailman/listinfo/python-list
Why on CentOS, python consumes too much memory ?
Hi: Previously, we found that our python scripts consume too much memory. So I use python's resource module to restrict RLIMIT_AS's soft limit and hard limit to 200M. On my RHEL5.3(i386)+python2.6.2, it works OK. But on CentOS 6.2(x86_64)+python2.6.6, it reports memory error(exceeding 200M). And I tested with a very small script, and result is out of my expect, it still use too much memory on my CentOS 6.2 python: import time time.sleep(200) I use guppy and memory_profiler to see the memory usage and see that python objects just use about 6M memory both on RHEL5.3(i386)+python2.6 and CentOS 6.2(x86_64)+python2.6. But when I cat /proc//status. I found that though VmRss is not very large on both machines. But the VmSize on CentOS 6.2(x86_64)+python2.6 is 140M-180M, while on my RHEL5.3+python2.6, the VmSize is just 6M. And I tested on CentOS 5.7(x86_64)+python2.4.3, the VmSize is 70M. I could understand that 64 bit machines will occupy more virtual memory than that on 32 bit, because the length of some types are not the same. But I don't know why they differs so greatly(6M to 180M), Or is this only caused by that python2.6 on CentOS 6.2's memory allocation is different from python's default one? Could you kindly give me some clues? Thank you very much. Best Regards William -- http://mail.python.org/mailman/listinfo/python-list
Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)
Hi Aseem, First of all great thought and all the best for the learning! On Thu, Jul 18, 2013 at 10:06 AM, Aseem Bansal wrote: > I wanted to do a little project for learning Python. I thought a chat > system will be good as it isn't something that I have ever done. > > I wanted to know what will I need? I think that would require me these > 1 learn network/socket programming > Yes! sockets are the heart and soul of chat sys :-) > 2 find a free server to host my chat server > You can use many, but I would suggest heroku for your free apps. > 3 GUI development for clients > > There are many python libraries Tkinter, PyQt, PyGtk, wxPython through which you have GUI! > -I wanted to know whether these are all that I would need or are there > more things? > I think with above you are good to go! > -Will I need to learn a web framework like Django? > That would really depend upon the type of chat application you are relying upon. For a command line utility I think you can skip it, but if you wish to have good-looking web version then yes, give Django a shot! But yes do see other frameworks as well, just for finding out, learning and knowing more :) > -Will I need to learn something for database management like sql for > handling people's account names and password? > Yes, it will be good decision to use DB to store names and chat histories (with timestamp) and have your logs ready > > Is google appengine good for hosting the website or should I look up at > django hosting websites? > Its good too :) > > Any other advice for me(a novice programmer)? > Make mistakes and fail early! Python is awesome! But do try to learn the best practices. For eg, reverse a string string[::-1] etc. > -- > http://mail.python.org/mailman/listinfo/python-list > Regards ~Vikash -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter redraw rates
On 07/18/2013 12:38 AM, [email protected] wrote: On Thursday, July 18, 2013 9:07:24 AM UTC+8, Dave Angel wrote: On 07/17/2013 08:44 PM, [email protected] wrote: On Thursday, July 18, 2013 1:38:34 AM UTC+8, Dave Angel wrote: On 07/17/2013 09:18 AM, [email protected] wrote: On Wednesday, July 17, 2013 7:42:45 PM UTC+8, Dave Angel wrote: On 07/17/2013 07:10 AM, [email protected] wrote: On Wednesday, July 17, 2013 6:07:22 PM UTC+8, Dave Angel wrote: On 07/16/2013 11:04 PM, [email protected] wrote: Noted on the quoting thing. Regarding the threading, well, first, I'm not so much a programmer as someone who knows a bit of how to program. And it seems that the only way to update a tkinter window is to use the .update() method, which is what I was experimenting with. Start up a new thread that just loops the .update() with a 1ms sleep until the download is done. It seems to work, actually. update() is to be used when it's too awkward to return to mainloop. In my second approach, you would periodically call it inside the processing loop. But unless tkinter is unique among GUI's, it's unsafe to do that in any thread besides the GUI thread. DaveA Yes, based on advice from this thread, I'm doing that. From my main thread, I create a thread that handles the download while updating a variable that the mainloop displays as a text output, and in that mainloop, I have a while loop that updates the GUI until the downloading is done. I can't figure out what you're really doing, since each message from you says something different. You don't need a separate while loop, since that's exactly what app.mainloop() is. -- DaveA Hm. My apologies for not being very clear. What I'm doing is this: self.loader_thread = Thread(target=self.loadpages, name="loader_thread") self.loader_thread.start() while self.loader_thread.isAlive(): self.root_window.update() sleep(0.05) Where loadpages is a function defined elsewhere. Presumably this fragment is from a method of some class you've written. Is it an event handler, or is this happening before you finish setting up the GUI? Somewhere at top-level, you're supposed to fall into a call to mainloop(), which doesn't return till the user cancels the app. -- DaveA This is, indeed, an event handler from a class for my GUI. My entire GUI is a bit large, so I'll not copy the entire thing here, but it roughly goes: class GUI(object): def __init__(self): [stuff] def init_button(self): self.execute = ttk.Button(self.input_frame, text='Tally', command=self.execute_now) self.execute.grid(column=1, row=2, sticky=(N, S, E, W), columnspan=4) def execute_now(self): [stuff] self.loader_thread = Thread(target=self.loadpages, name="loader_thread") self.loader_thread.start() self.root_window.after(100, self.test_thread) return while self.loader_thread.isAlive(): self.root_window.update() Nope - don't use that. Instead, post an event on the queue, and return to the mainloop() from whence we came. def test_thread(self): if self.loader_thread.isAlive(): self.root_window.after(100, self.test_thread) return [morestuff] sleep(0.05) [morestuff] if __name__ == "__main__": APP = GUI() APP.root_window.mainloop() I probably don't have it quite right, but hopefully you'll get the idea. self.test_thread() is now a new event that will get repeatedly invoked, to do the check on the thread status. It returns rapidly unless the condition has occurred. There are other things that should be done, like blocking the specific events that would create duplicate threads. -- DaveA I see, though it should be noted that your method doesn't actually block the rest of the even handler code from running, had to fiddle with it a bit to get that to work. May I ask what exactly is the rationale behind implementing it like this, though? Simply because your goal is normally to have other events working. For example, a user might resize the window while you're doing your network stuff. This way all events are fired from the one place, and you can uniformly decide which ones to block for the special cases. And you don't wind up with the GUI's internal code in a knot. As I said at the beginning, I'm not that familiar with tkinter, but the same principles apply to all of them. Sometimes these variations are equivalent, and sometimes there are problems. For example, you might be testing on Linux, and then later when you try it on Windows, suddenly things don't work. The closer you can conform to the standard way of using the GUI manager, the less likely you are to com
Re: Homework help requested (not what you think!)
On Wednesday, July 17, 2013 4:13:45 AM UTC+5:30, John Ladasky wrote: > Hi folks, > > > > No, I'm not asking for YOU to help ME with a Python homework assignment! > > > > Previously, I mentioned that I was starting to teach my son Python. > > > > https://groups.google.com/d/msg/comp.lang.python/I7spp6iC3tw/8lxUXfrL-9gJ > > > > He just took a course at his high school called Web Technology and Design. > They had the students use tools like Dream Weaver, but they also hand-coded > some HTML and JavaScript. He has a little experience. I am building on it. > > > > Well, a few other parents caught wind of what I was doing with my son, and > they asked me whether I could tutor their kids, too. I accepted the jobs > (for pay, actually). > > > > The kids all claim to be interested. They all want to write the next great > 3D video game. Thus, I'm a little surprised that the kids don't actually try > to sit down and code without me prompting them. I think that they're > disappointed when I show them how much they have to understand just to write > a program that plays Tic Tac Toe. > > > > Where programming is concerned, I'm an autodidact. I started programming > when I was twelve, with little more guidance than the Applesoft Basic manual > and the occasional issue of Byte Magazine. I hacked away. Over the years, I > have acquired a working knowledge of BASIC, 6502 assembly language, Pascal, > C, and finally Python (my favorite). If I knew how to impart a love of > experimentation to my students, I would do that. > > > > One kid looks like he's ready to forge ahead. In the mean time, one parent > has recognized his son's lack of independence, and has asked me to assign > programming homework. I hope it doesn't kill the kid's enthusiasm, but I'm > willing to try it. > > > > So, what I am seeking are suggestions for programming assignments that I can > give to brand-new students of Python. Please keep in mind that none of them > are even up to the task of a simple algorithm like Bubble Sort -- at least, > not yet. > > > > Many thanks! You can use PySide/QtCreator for getting a skeleton UI as easily as in case of Visual Studio. Converting it into .py files is also quite easy. Experiment a little for yourself in the beginning and you'll be able to make a simple Tic-Tac-Toe easily. You can then decide how complex that becomes. Remember that computer's behaviour just might be the most complex thing in this whole thing. You can then take that out, explain the students that the game will work if you can make a function for this, explain the logic and that can be a really nice homework assignment. I think that would be much better than just jumping off to a game engine sidetracking Python completely. If you want to introduce them to programming in general in a fun way http://scratch.mit.edu/ might be much easier for making simple 2D games. It isn't Python but it is even better introduction to programming than Python(I am saying this even when I use Python everyday and I like it). Scratch isn't for long term but initially this could be their dose of excitement and introduction to the basics of programming. That would give you time to make simple games in PySide for taking them to Python gradually without killing their excitement. -- http://mail.python.org/mailman/listinfo/python-list
Re: Need help with network script
On Thu, Jul 18, 2013 at 11:59 AM, wrote: > On Wednesday, July 17, 2013 7:50:44 PM UTC-6, Chris Angelico wrote: >> >> Copy and paste your actual code, don't re-type it :) > > This is as far as I have gotten. THis is all my code and it has been copied > and pasted. Thats why I am posting here. I know that the code can be better. > Once I learn more it wont look like crap. My point is that that can't be the code that always outputs "0", because the code above would not output 0, it would terminate with TypeError. By the way, if you're going to use Google Groups, please read this: http://wiki.python.org/moin/GoogleGroupsPython ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)
On Thu, 18 Jul 2013 00:36:17 -0400, Aseem Bansal wrote: I wanted to do a little project for learning Python. I thought a chat system will be good as it isn't something that I have ever done. I wanted to know what will I need? I think that would require me these 1 learn network/socket programming 2 find a free server to host my chat server 3 GUI development for clients Not discourage you but this is a "been there, done that" kind of project. You could learn more from reading somebody else is code. What hasn't been done, and this would be very cool, is a chat program that works peer-to-peer with no central server. To do this, you would probably need to know about distributed hash tables and methods of piercing address translation firewalls (think UDP). First however, I would suggest taking a look at https://jitsi.org/ and see how they do things. You can learn a lot from these people. They are very smart. -- http://mail.python.org/mailman/listinfo/python-list
Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)
@Eric S. Johansson I am a novice who hasn't done any big project in programming. I haven't done anything I can even call a moderate project. I haven't touched web frameworks ever. I have little or no knowledge of network/socket programming. I have never used databases before. I understand that there are a lot of chat systems out there but I haven't done anything like that before. This is for learning purposes. Reading someone else's code is good but doing it yourself is better. Thanks for the suggestion but for now I'll stick to this idea. I am excited about this and I would need that for a hobby project. -- http://mail.python.org/mailman/listinfo/python-list
Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)
On Thu, Jul 18, 2013 at 2:36 PM, Aseem Bansal wrote: > I wanted to do a little project for learning Python. I thought a chat system > will be good as it isn't something that I have ever done. A good thing to start with. Yes, it's been done before, many times... but if you think about it, it's the fundamental on which pretty much everything else is derived. The step from a multi-person chat system to a multiplayer game is very slight. > I wanted to know what will I need? I think that would require me these > 1 learn network/socket programming > 2 find a free server to host my chat server > 3 GUI development for clients Learn network programming, definitely. As an adjunct to that, learn networking security. For instance, do not think in terms of "the client will only ever send X"; the server has to be able to cope, safely, with any stream of bytes coming from the socket. Also, be sure you understand the difference between bytes (or octets) and Unicode characters, and know what everything is. Python 3 helps with this. Finding hosting (I'll use the word "server" here to mean the program, and will say "hosting" when I mean a computer) is optional though; for your first tests, use your own computer. You can run the server and a number of clients all on the same computer, and alt-tab between them; or, if you have a LAN, you can use that. Then when you want to expand to the full internet and let your friends in on this, you can still host it on your home internet connection, though you may need to choose carefully which port you use (some home connections prevent incoming port 25 and 80 traffic). You won't need to worry about hosting until (a) you need it to be up 24x7 and don't want to depend on your home system, and/or (b) you need more bandwidth/processing than your home connection will do. Neither will be true of your first experiments. GUI development, in my opinion, should be left for Phase Two. Start by making a very simple system that just works with plain text; later on, make a fancy graphical interface. Keep the text version working, and keep them compatible. Trust me, you'll appreciate that text one when you start debugging - it'll be so easy to see what's going on. > -I wanted to know whether these are all that I would need or are there more > things? > -Will I need to learn a web framework like Django? Hmm. I would think not; I'd recommend that a chat system work with TCP sockets directly, for simplicity and performance. Working with a web framework implies working with HTTP, and unless you're running this in a web browser, there's no reason to do that. > -Will I need to learn something for database management like sql for handling > people's account names and password? Optional. Leave that for Phase Two; to start off with, just let people type in their own names, and don't worry about authentication initially (this isn't such a crazy idea - IRC largely works this way). You can add authentication later. > Any other advice for me(a novice programmer)? Get to know as many tools as you can, so that when you're faced with a problem, you can select the right one for the job. You are not Jeremy Clarkson, your toolchest is not all hammers :) In this particular instance, you may find that Python is the best language for the clients, but not for the server. I've written a number of chat-server-like systems, most notably MUD clients and derivatives, and I use Pike for the server. Its biggest advantage (over Python) is that you can tweak the code while it's running; I've had Pike servers running for over two years on commodity hardware (and would still have that uptime today if the UPS hadn't died). Still trying to claw all that back.. up to 25 weeks so far. Pike and Python are extremely similar in semantics (even down to having a nearly-identical internal string representation, as of Python 3.3), but have distinctly different syntax (Pike looks like C), and their optimizations are quite different, so performance varies somewhat. They're both high level languages that let you manipulate functions, dictionaries, etc, as first-class objects, they're both sufficiently high performance/efficiency to run something like this on 0.00 load average (my server's load is more usually from Apache serving PHP pages than it is from either Pike or Python), and both will serve you well in this project. One more tip: Don't be afraid to ask for help! I personally *love* networking, and will gladly help out with any little problems you run into; the same, I am sure, will be true of a good number of people on this list. Networking is a complicated world, and there are a lot of odd concepts to master; but it's also an immensely fun bunch of technologies. Why play with just one computer when you can play with half a dozen! ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)
@vikash agrawal About GUI I discussed it at https://groups.google.com/forum/#!starred/comp.lang.python/M-Dy2pyWRfM and I am thinking about using PySide 1.2 for clients of chat system. I think I'll need downloadable clients if I want to make something like google talk. Then I'll need to implement server side programming also. I think google app engine would be suitable for this as it is going to be always online. In the above scenario I wanted to know whether the database can be stored on google app engine itself? Is it possible? Having a chat system with server online and DB offline isn't going to be good. Should I consider heroku for this or can it be done using google app engine? Is it viable to have the DB on google appengine itself? About using web frameworks, in the above scenario when there isn't an online website for chat would I need web frameworks? I am confused about this. Can server side programming be done in Python or by using a web framework only? -- http://mail.python.org/mailman/listinfo/python-list
Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)
On Thu, Jul 18, 2013 at 4:11 PM, Aseem Bansal wrote: > @vikash agrawal > > About GUI I discussed it at > https://groups.google.com/forum/#!starred/comp.lang.python/M-Dy2pyWRfM and I > am thinking about using PySide 1.2 for clients of chat system. I think I'll > need downloadable clients if I want to make something like google talk. Then > I'll need to implement server side programming also. I think google app > engine would be suitable for this as it is going to be always online. Hrm. Rather than pointing people to Google Groups, which a number here (and not unreasonably) detest, you may want to link to the python-list archive: http://mail.python.org/pipermail/python-list/2013-July/thread.html#651359 > About using web frameworks, in the above scenario when there isn't an online > website for chat would I need web frameworks? I am confused about this. Can > server side programming be done in Python or by using a web framework only? You can certainly do your server-side programming directly in Python; in fact, I recommend it for this task. There's no reason to use HTTP, much less a web framework (which usually consists of a structured way to build HTML pages, plus a bunch of routing and stuff, none of which you need). All you need is a simple structure for separating one message from another. I would recommend either going MUD/TELNET style and ending each message with a newline, or prefixing each message with its length in octets. Both ways work very nicely; newline-termination allows you to use a MUD client for debugging, which I find very convenient (full disclosure: I am the author of multiple MUD clients, including one that's zero-dollar and another that's free). ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)
@Chris Angelico Thanks. That cleared many doubts and your suggestions would definitely be useful. I am asking the next paragraph because you said about Python 3 helping with things. I am not looking for a debate or anything just a opinion. I learnt Python myself and everyone told me that Python 2 is status quo so I learned Python 2 and have been working with it. I am just 1.5 months in Python programming so should I consider switching to Python 3 if it helps with new things or should I stick with Python 2 to get a taste of what is currently out there? About Pike, thanks for the heads up. But for now I'll use Python. I wanted to learn Python through this project. I'll leave Pike for later. Maybe Phase 1.5. Aren't you guys posting in google groups? I thought you were because I can see your posts here. How do I post in python mailing list and see its archives instead of posting on google groups? -- http://mail.python.org/mailman/listinfo/python-list
Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)
On 2013.07.18 01:36, Aseem Bansal wrote: > I learnt Python myself and everyone told me that Python 2 is status quo so I > learned Python 2 and have been working with it. I am just 1.5 months in > Python programming so should I consider switching to Python 3 if it helps > with new things or should I stick with Python 2 to get a taste of what is > currently out there? Python 2 is what some people are stuck with because their projects depend on huge libraries that have not yet made all their code compatible with Python 3 (or on libraries that are not actively maintained or are being replaced by something else). All new code and new Python users should be using Python 3 unless there is a pressing need for a library that requires Python 2. Most popular libraries at this point have either been made compatible or have been replaced by something that supports Python 3. Python 3 is no longer the shiny new thing to look at in the future - 3.0 was released in December 2008. -- CPython 3.3.2 | Windows NT 6.2.9200 / FreeBSD 9.1 -- http://mail.python.org/mailman/listinfo/python-list
Re: What does it take to implement a chat system in Python (Not asking for code just advice before I start my little project)
On Thu, Jul 18, 2013 at 4:36 PM, Aseem Bansal wrote: > @Chris Angelico > > Thanks. That cleared many doubts and your suggestions would definitely be > useful. > > I am asking the next paragraph because you said about Python 3 helping with > things. I am not looking for a debate or anything just a opinion. > > I learnt Python myself and everyone told me that Python 2 is status quo so I > learned Python 2 and have been working with it. I am just 1.5 months in > Python programming so should I consider switching to Python 3 if it helps > with new things or should I stick with Python 2 to get a taste of what is > currently out there? Python 3 is now the current Python. There'll be no more development on Python 2 (bugfixes/security only, and even that won't be forever), so I strongly recommend going to Python 3. You're writing new code, so there's really no reason to use Python 2. All the core libraries you'll be needing (socket, mainly) are available for Py3, and as I mentioned earlier, Unicode handling is far superior (especially as of 3.3). > About Pike, thanks for the heads up. But for now I'll use Python. I wanted to > learn Python through this project. I'll leave Pike for later. Maybe Phase 1.5. Yep. My main point there is: Don't be too stuck on any one tool, learn 'em all. Learn Python now, you may find that you want to use Pike later. Build your system so you can switch one thing out for another. > Aren't you guys posting in google groups? I thought you were because I can > see your posts here. How do I post in python mailing list and see its > archives instead of posting on google groups? Google Groups is one way (and one of the worse ways) of accessing comp.lang.python, which is cross-mirrored with the mailing list [email protected] - the easiest way is to simply subscribe to either the newsgroup or the mailing list, using a newsreader or mail client. As you see, I'm posting from gmail; there are a couple of issues with using gmail here (it doesn't have a "Reply List" option, for instance), but it's orders of magnitude less annoying than Google Groups. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
