Re: Python for a 10-14 years old?

2005-03-25 Thread Paul Rubin
You might like the book "Mindstorms", by Seymour Papert. The intro is here: http://www.papert.org/articles/GearsOfMyChildhood.html -- http://mail.python.org/mailman/listinfo/python-list

Re: embedded python example: PyString_FromString doesnt work?

2005-03-25 Thread Denis S. Otkidach
On Thu, 24 Mar 2005 21:12:18 + David Harris wrote: DH> int DH> main(int argc, char *argv[]) DH> { DH> PyObject *pName, *s, *pModule, *pDict, *pFunc; DH> PyObject *pArgs, *pValue; DH> int i; DH> DH> if (argc < 3) { DH> fprintf(stderr,"Usage: call pythonfile funcname [ar

Re: Anonymus functions revisited : tuple actions

2005-03-25 Thread George Sakkis
"Kay Schluehr" <[EMAIL PROTECTED]> wrote: > To make my intention clear for another time, also for George who > mistrusts these exercises alltogether. I want to derive a syntax and > semantics for anonymus functions ( called "tuple-actions" ) that are > generalizations of rules that are already use

Re: Queue.Queue-like class without the busy-wait

2005-03-25 Thread Antoon Pardon
Op 2005-03-24, Paul L. Du Bois schreef <[EMAIL PROTECTED]>: > Has anyone written a Queue.Queue replacement that avoids busy-waiting? > It doesn't matter if it uses os-specific APIs (eg > WaitForMultipleObjects). I did some googling around and haven't found > anything so far. I started once, using

Grouping code by indentation - feature or ******?

2005-03-25 Thread Tim Tyler
What do you guys think about Python's grouping of code via indentation? Is it good - perhaps because it saves space and eliminates keypresses? Or is it bad - perhaps because it makes program flow dependent on invisible, and unpronouncable characters - and results in more manual alignment issues

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Peter Otten
Tim Tyler wrote: > What do you guys think about Python's grouping of code via indentation? This is a Python newsgroup. Assume that we all have been brainwashed. > How would you have dealt with the issue of how to group statements? Off the top of my head I can think of one other way: associate a

Re: Python docs [was: function with a state]

2005-03-25 Thread John Bokma
Xah Lee wrote: > The Python doc is relatively lousy, from content organization to the > tech writing quality. So write your own or fork the current one. I doubt if that's a problem. Did you read Dive into Python? -- John Small Perl scripts: http://johnbokma.com/perl/

Re: Python docs [was: function with a state]

2005-03-25 Thread John Bokma
Martin Ambuhl wrote: > Apologies to these various newsgroups, but I have no idea which one Xah > Lee actually reads or posts from. F'ups set. Probably none, since they are all crowded with crazy linux zealots :-D. -- John Small Perl scripts: http://johnbokma.com/perl/

Re: Queue.Queue-like class without the busy-wait

2005-03-25 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes: > I started once, using the Timer class in the Threading Module to > break the lock. However the Timer class uses the same kind of > sleep-polling loop, to delay the exection and allow an intermediate > cancel, as the loop that is used in Queue.Queue, so th

Re: Distributing closed source modules

2005-03-25 Thread Fuzzyman
Dave Brueck wrote: > Jiri Barton wrote: [snip..] Hello Dave, > > Protecting code in any language is pretty tough and/or futile, but you can > Google the archives if you're interested in reading more on that. > It's certainly something lot's of people are interested in. I guess it depends who yo

Re: Queue.Queue-like class without the busy-wait

2005-03-25 Thread Antoon Pardon
Op 2005-03-25, Paul Rubin schreef : > Antoon Pardon <[EMAIL PROTECTED]> writes: >> I started once, using the Timer class in the Threading Module to >> break the lock. However the Timer class uses the same kind of >> sleep-polling loop, to delay the exection and allow an intermediate >> cancel, as t

Re: embedded python example: PyString_FromString doesnt work?

2005-03-25 Thread Brano Zarnovican
> wierd. does: http://www.python.org/doc/2.3.­2/ext/pure-embedding.html work > for you ? Yes. It does. > ./test_String script1.py multiply 4 5 Don't run it with the ".py" suffix. The argv[1] is a module name, not a filename.. Even if you do, it may not find the module. Depending of what you ha

POST data with 401 authentication using urllib(2)

2005-03-25 Thread Pieter Edelman
Hi all, I'm trying to submit some data using a POST request to a HTTP server with BASIC authentication with python, but I can't get it to work. Since it's driving me completely nuts, so here's my cry for help. The server is an elog logbook server (http://midas.psi.ch/elog/). It is protected with

Re: Python docs [was: function with a state]

2005-03-25 Thread axel
In comp.lang.perl.misc Xah Lee <[EMAIL PROTECTED]> wrote: > The Python doc is relatively lousy, from content organization to the > tech writing quality. Which has precisely what to do with most of the groups to which you cross-posted? > Problem: They all have the same priority (which is higher th

Re: embedded python example: PyString_FromString doesnt work?

2005-03-25 Thread David Harris
On Fri, 25 Mar 2005 11:09:35 +0300, Denis S. Otkidach wrote: > DH> Calling the program gives an error; > DH> "[EMAIL PROTECTED]:~/source/python> ./test_String script1.py multiply 4 > DH> 5 import went bang... > DH> ImportError: No module named script1.py" > DH> script1.py exists and it is in the

Re: An Abridged Python Tutorial

2005-03-25 Thread bruno modulix
Michael Spencer wrote: An Abridged Python Tutorial (snip fine piece of art) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list

[newbie] smtplib.login()?

2005-03-25 Thread PA
Hello, I'm trying to use smtplib.login() to authenticate against a SMTP server... server = smtplib.SMTP( 'localhost', 10025 ) server.set_debuglevel(1) server.login( 'user', 'password' ) send: 'ehlo host.local\r\n' reply: '250-host.local Hello localhost\r\n' reply: '250-AUTH LOGIN PLAIN\r\n' reply

Re: Queue.Queue-like class without the busy-wait

2005-03-25 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes: > > I've never checked this code but it wouldn't have occurred to me that > > Queue uses any kind of timeout loop. Can't it work the obvious way > > with a semaphore? > > And how is this semaphore going to be released if the timeout is > reached? I meant

Re: Anonymus functions revisited

2005-03-25 Thread Duncan Booth
Ron wrote: > It's interesting that there is a whole is_"type"_() group of functions > in the inspect module, but not a is_defined(). Maybe I just haven't > found it yet. I've never found any need for an is_defined function. If in doubt I just make sure and initialise all variables to a suitable

Re: Queue.Queue-like class without the busy-wait

2005-03-25 Thread Antoon Pardon
Op 2005-03-25, Paul Rubin schreef : > Antoon Pardon <[EMAIL PROTECTED]> writes: >> > I've never checked this code but it wouldn't have occurred to me that >> > Queue uses any kind of timeout loop. Can't it work the obvious way >> > with a semaphore? >> >> And how is this semaphore going to be rel

Re: winapi32.GetFileVersionInfo() - problem

2005-03-25 Thread Heiko Wundram
> Do you actually think anybody will reply to your mail if you keep reposting at this frequency? It'll rather make most people here kill-file you. One post is enough; we've seen your problem, and it seems as though nobody here has a better solution than what Dennis Lee Bieber has already offer

Re: Queue.Queue-like class without the busy-wait

2005-03-25 Thread Paul Rubin
Antoon Pardon <[EMAIL PROTECTED]> writes: > > I meant a semaphore to synchronize the queue when adding or removing > > objects. > > Last I looked there was a lock used for that. OK, that amounts to the same thing. > The loop is only for when you cant remove or add an element immediatly > and th

Re: [newbie] smtplib.login()?

2005-03-25 Thread PA
On Mar 25, 2005, at 11:04, PA wrote: What am I doing wrong? Why is the user name being encoded twice? Ok... turns out that this is/was a bug in the python smtplib as recently as Dec 6 2004: Patch #1075928: AUTH PLAIN in smtplib. "smtplib can not log in to some server using command AUTH PLAIN, it

SimpleRPCServer

2005-03-25 Thread Esben Pedersen
I am trying to restrict some of the methods available by RPC to whether the user is connected through a ssh-tunnel eg. connecting from localhost. class UserRPC: '''Methods available to users''' pass class AdminRPC(UserRPC): '''Methods available only when connecting from localhost'''

gnuplot -reverse

2005-03-25 Thread Cousin Stanley
Experimenting with the gnuplot package under Debian Linux, I've found that the -reverse option when used to start gnuplot from the command-line will produce plots that are color-reversed and render with white text on a black background However, I'm too dense to see how to easily achieve the

Re: Queue.Queue-like class without the busy-wait

2005-03-25 Thread Antoon Pardon
Op 2005-03-25, Paul Rubin schreef : > Antoon Pardon <[EMAIL PROTECTED]> writes: >> > I meant a semaphore to synchronize the queue when adding or removing >> > objects. >> >> Last I looked there was a lock used for that. > > OK, that amounts to the same thing. > >> The loop is only for when you c

How to move insert to position in Text widget (Tkinter)

2005-03-25 Thread Harlin Seritt
I am working on a Find Text dialog box. Once you find a string in a Text widget, how do you at least move the cursor to that index (position)? Even better how can one 'select' the string one finds? ---code--- def searchText(): while 1: pos = self.mainEdit.search(findStr

modern kjbuckets anywhere?

2005-03-25 Thread Robin Becker
I'm trying to get pySimplex working in Python 2.4, but I find that kjbucketsmodule.c makes reference to rename2.h which doesn't seem to be present in Python 2.4. I suppose that kjbucketsmodule.c needs to be brought up to date. It occurs to me that someone may have already done this so is there

Re: Archives and magic bytes

2005-03-25 Thread Jim
This is something I've recently thought about; perhaps you wouldn't mind some points? 1) I've been running 'file' via os.popen, and I've had trouble with it incorrectly spotting file types (Fedora Core 1). I can name a specific example where it thinks a plain text README file is HTML (despite tha

Re: modern kjbuckets anywhere?

2005-03-25 Thread Robin Becker
Robin Becker wrote: I'm trying to get pySimplex working in Python 2.4, but I find that kjbucketsmodule.c makes reference to rename2.h which doesn't seem to be present in Python 2.4. I suppose that kjbucketsmodule.c needs to be brought up to date. It occurs to me that someone may have already do

Re: How to move insert to position in Text widget (Tkinter)

2005-03-25 Thread Fredrik Lundh
Harlin Seritt wrote: >I am working on a Find Text dialog box. Once you find a string in a > Text widget, how do you at least move the cursor to that index > (position)? widget.mark_set(INSERT, pos) > Even better how can one 'select' the string one finds? widget.tag_add(SEL, pos, endpos)

Interface selection

2005-03-25 Thread ias0nas
Hello, How can I select on wich interface a socket will connect to? Say I have a pc with one network card and a 56K modem, how can I select on wich interface will the socket connect? Thank you -- http://mail.python.org/mailman/listinfo/python-list

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Skip Montanaro
>> What do you guys think about Python's grouping of code via >> indentation? Peter> This is a Python newsgroup. Assume that we all have been Peter> brainwashed. +1 QOTW. Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: How to move insert to position in Text widget (Tkinter)

2005-03-25 Thread Harlin Seritt
Frederik, Thanks! Just looking at your site (effbot and pythonware). I don't know what I'd do without it! Cheers, Harlin -- http://mail.python.org/mailman/listinfo/python-list

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Antoon Pardon
Op 2005-03-25, Tim Tyler schreef <[EMAIL PROTECTED]>: > What do you guys think about Python's grouping of code via indentation? > > Is it good - perhaps because it saves space and eliminates keypresses? I think it was a mistake, but I'm probably in the minority here. -- Antoon Pardon -- http://

Re: Interface selection

2005-03-25 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Hello, > > How can I select on wich interface a socket will connect to? > Say I have a pc with one network card and a 56K modem, how can I select > on wich interface will the socket connect? you need to specify the ip address that interface has been assigned to in the

Re: SimpleRPCServer

2005-03-25 Thread Skip Montanaro
Esben> What i don't know is how to the client ip. I would think I should Esben> override the _marshalled_dispatch method but I can't quite grasp Esben> it all. First, from my reading of SimpleXMLRPCServer, I don't think _dispatch() belongs at that level. It belongs in the request han

Re: Interface selection

2005-03-25 Thread ias0nas
Actually its not a server. I dont do any binding call, just a connect. -- http://mail.python.org/mailman/listinfo/python-list

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread John Roth
"Antoon Pardon" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Op 2005-03-25, Tim Tyler schreef <[EMAIL PROTECTED]>: What do you guys think about Python's grouping of code via indentation? Is it good - perhaps because it saves space and eliminates keypresses? I think it was a mistake,

Example Code - Named Pipes (Python 2.4 + ctypes on Windows)

2005-03-25 Thread Srijit Kumar Bhadra
Hello, Here is an example of Multithreaded Pipe Server and Client using the excellent ctypes library (Windows). Reference - MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipc/base/multithreaded_pipe_server.asp and http://msdn.microsoft.com/library/default.asp?url=/library/

Re: DBAPI Paramstyle

2005-03-25 Thread Bob Parnes
On Thu, 24 Mar 2005 15:03:13 +0100, Fredrik Lundh <[EMAIL PROTECTED]> \ wrote: > Bob Parnes wrote: > >> I must be missing something, so perhaps someone can explain >> the benefit of a paramstyle over the usual Python formatting >> style and maybe suggest a test to show it. Thanks. > > set the par

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Kent Johnson
Tim Tyler wrote: What do you guys think about Python's grouping of code via indentation? Is it good - perhaps because it saves space and eliminates keypresses? Or is it bad - perhaps because it makes program flow dependent on invisible, and unpronouncable characters - and results in more manual al

Re: Python for a 10-14 years old?

2005-03-25 Thread Lucas Raab
Leif B. Kristensen wrote: R.Meijer wrote: Jot nad.com> writes: If she's really gifted i hope she dumps that obsolete monolithic kernel as soon as she realizes that such beautiful language as python shouldn't be used on top of ugly, badly designed software. Did somebody say off-topic? I'd say it

Re: Interface selection

2005-03-25 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Actually its not a server. I dont do any binding call, just a connect. Then where is your problem? The two interfaces have been assigned distinct IPs, so connect to the appropriate one. -- Regards, Diez B. Roggisch -- http://mail.python.org/mailman/listinfo/python-l

Re: Interface selection

2005-03-25 Thread Serge Orlov
[EMAIL PROTECTED] wrote: > Actually its not a server. I dont do any binding call, just a connect. Bind is not only for server sockets. Googling for "bind client socket" reveals an example: http://woozle.org/~neale/papers/sockets.html Serge. -- http://mail.python.org/mailman/listinfo/python-li

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Antoon Pardon
Op 2005-03-25, John Roth schreef <[EMAIL PROTECTED]>: > > "Antoon Pardon" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Op 2005-03-25, Tim Tyler schreef <[EMAIL PROTECTED]>: >>> What do you guys think about Python's grouping of code via indentation? >>> >>> Is it good - perhaps

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread projecktzero
Tim Tyler wrote: > What do you guys think about Python's grouping of code via indentation? > > Is it good - perhaps because it saves space and eliminates keypresses? > > Or is it bad - perhaps because it makes program flow dependent on > invisible, and unpronouncable characters - and results in mor

[Tutor] Re: Reading text lines from a socket

2005-03-25 Thread Sandip Bhattacharya
[Reposting to the general list too] Lloyd Kvam wrote: > Sockets deal with packetized data. The network protocols do not guarantee > keeping the data in line oriented chunks - even if the data starts out > that way. > > You need to deal with extracting lines from chunks. So long as the > connecti

Re: [Tutor] Re: Reading text lines from a socket

2005-03-25 Thread Lloyd Kvam
Well, I've never used it, but sockets do have the makefile method. That would seem to fit what you're trying to do. Sandip Bhattacharya wrote: > [Reposting to the general list too] > > Lloyd Kvam wrote: > >> Sockets deal with packetized data. The network protocols do not >> guarantee >> keeping

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Antoon Pardon
Op 2005-03-25, Carl Banks schreef <[EMAIL PROTECTED]>: > > Tim Tyler wrote: >> What do you guys think about Python's grouping of code via > indentation? >> >> Is it good - perhaps because it saves space and eliminates > keypresses? > > It's good, but this is only a minor reason. > > The reason this

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Carl Banks
Tim Tyler wrote: > What do you guys think about Python's grouping of code via indentation? > > Is it good - perhaps because it saves space and eliminates keypresses? It's good, but this is only a minor reason. The reason this is good is because it exactly reflects the way human beings mentally g

[perl-python] limericks

2005-03-25 Thread Xah Lee
Better: there is a Python, pithy mighty, lissome, and tabby algorithms it puffs conundrums it snuffs and cherished by those savvy there is a camel, kooky ugly, petty, ungainly hacking it supports TIMTOWTDI it sports and transports DWIM-wit's fancy Xah [EMAIL PROTECTED] â http://xahlee.org/Pag

Re: [newbie] smtplib.login()?

2005-03-25 Thread Gerhard Häring
PA wrote: On Mar 25, 2005, at 11:04, PA wrote: What am I doing wrong? Why is the user name being encoded twice? Ok... turns out that this is/was a bug in the python smtplib as recently as Dec 6 2004: Patch #1075928: AUTH PLAIN in smtplib. "smtplib can not log in to some server using command AUT

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Diez B. Roggisch
> Structure/Disciplined programming is a burden in general. I have > never found putting braces or what ever delimiter such a problem. > I don't see people argueing that putting the right number of parenthesis > and or brackets is an extra burden. Oh, not the right number. But I have seen wars wag

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Antoon Pardon
Op 2005-03-25, Diez B. Roggisch schreef <[EMAIL PROTECTED]>: >> Structure/Disciplined programming is a burden in general. I have >> never found putting braces or what ever delimiter such a problem. >> I don't see people argueing that putting the right number of parenthesis >> and or brackets is an

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Diez B. Roggisch
> Normally one is the project leader. He decides. Whishful thinking. Another problem I have with code that is _not_ layouted the way I'm used to it is that the perception of what very code does gets more difficult to me. You seem to have the same troubles, I take that from your desire to reflect

Version Number Comparison Function

2005-03-25 Thread Keith
Is there a function for comparing version numbers? E.g. 0.1.0 < 0.1.2 1.876b < 1.876c 3.2.2 < 3.4 Keith -- http://mail.python.org/mailman/listinfo/python-list

Re: Version Number Comparison Function

2005-03-25 Thread TZOTZIOY
On 25 Mar 2005 07:34:38 -0800, rumours say that "Keith" <[EMAIL PROTECTED]> might have written: >Is there a function for comparing version numbers? > >E.g. > >0.1.0 < 0.1.2 >1.876b < 1.876c >3.2.2 < 3.4 > >Keith Convert your version numbers into tuples: (0, 1, 0) < (0, 1, 2) (1, 876, 'b') < (1,

Re: Version Number Comparison Function

2005-03-25 Thread Bill Mill
On 25 Mar 2005 07:34:38 -0800, Keith <[EMAIL PROTECTED]> wrote: > Is there a function for comparing version numbers? > > E.g. > > 0.1.0 < 0.1.2 > 1.876b < 1.876c > 3.2.2 < 3.4 > Not by default AFAIK. How about something like (untested): def test_version(v1, v2): v1, v2 = v1.split('.'), v2.

Re: Version Number Comparison Function

2005-03-25 Thread Fredrik Lundh
"Keith" wrote: > Is there a function for comparing version numbers? > > E.g. > > 0.1.0 < 0.1.2 > 1.876b < 1.876c > 3.2.2 < 3.4 the following works for many common cases: import re def cmpver(a, b): def fixup(i): try: return int(i) except ValueError: r

Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Jordan Rastrick
First, a disclaimer. I am a second year Maths and Computer Science undergraduate, and this is my first time ever on Usenet (I guess I'm part of the http generation). On top of that, I have been using Python for a grand total of about a fortnight now. Hence, I apologise if what follows is a stupid s

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Jordan Rastrick
Sorry about the mangled formatting... like i said, first time on Usenet Suggestions, comments, replies, etc most welcome. This definitely includes replies of the form: "This is stupid, because..." provided it isnt followed with "youre a jerk who knows nothing. Period." Heres a follow up rant in

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Larry Bates
Python's way of grouping is VERY good. Over the last 30+ years I've seen a lot of code (good and bad) in many languages. IMHO good code (independent of language) always uses indentation, even when other block constructs (like braces) is available. Python developers thought that this was redundant

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Andrew Koenig
"Jordan Rastrick" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > def combineIntoRecord(): # This is an acceptor function > optionalline = None # We may not get given a value for this line > accept firstline > accept secondline > if condition(secondline): >

Re: Version Number Comparison Function

2005-03-25 Thread Keith
I can't assume there are the same number of '.'s or there are the same number of digits per version. I don't know how the tuple comparison works offhand. But that seems like it would work if you split it. The suggestion with the "re" module seems generic enough and looks like it will work as is.

(no subject)

2005-03-25 Thread python-list-bounces+archive=mail-archive . com
#! rnews 1995 Newsgroups: comp.lang.python Path: news.xs4all.nl!newsspool.news.xs4all.nl!transit.news.xs4all.nl!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.abs.net!attws2!ip.att.net!NetNews1!xyzzy!nntp From: Jeff Sandys <[EMAIL PROTECTED]> Subject: Re: Python for a 10-14 years old? X-Nntp

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Tim Hochberg
Jordan Rastrick wrote: [CHOP] Behold: # An Acceptor/Generator!!! def combineIntoRecords(): optionalline = None # We may not get given a value for this line accept firstline accept secondline if condition(secondline): accept optionalline accept lastline

Re: Version Number Comparison Function

2005-03-25 Thread Dan Sommers
On 25 Mar 2005 07:34:38 -0800, "Keith" <[EMAIL PROTECTED]> wrote: > Is there a function for comparing version numbers? > E.g. > 0.1.0 < 0.1.2 > 1.876b < 1.876c > 3.2.2 < 3.4 How about a simple string comparison? Python 2.3.3 (#1, Mar 9 2004, 14:21:31) [GCC 3.3 20030304 (Apple Computer, Inc. b

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Ivan Van Laningham
Hi All-- Larry Bates wrote: > > Secondly, Python "nudges" me into writing better > (easier to maintain and clearer to understand) code by > influencing me towards splitting my code into smaller > functions/classes. If I find myself with more than 3-4 > levels of indentation, I probably need to

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Jordan Rastrick
Thanks for the very fast feedback :) I specifically set optionalline = None to deal with that bug you mentioned, with the implicit assumption createRecord knows how to deal with a None argument. If that guard got destroyed in the copy paste process, my bad. As for you solution, yes, you could do

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Michael Spencer
Tim Hochberg wrote: Jordan Rastrick wrote: itertools.groupby enables you to do this, you just need to define a suitable grouping function, that stores its state: For example, if short lines should be appended to the previous line: from itertools import groupby linesource = """\ Here is a long lin

Re: Distributing closed source modules

2005-03-25 Thread Dave Brueck
Fuzzyman wrote: Dave Brueck wrote: It's certainly something lot's of people are interested in. I guess it depends who your audience is. If ytour code isn't for *mass* distribution - the chances of people putting a lot of effort into breaking it are greatly reduced. I don't htink it's necessarily f

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Jordan Rastrick
Yes, granted. This is basically the same as Andrew's reply, except with Iterators in place of generators, so I'll let my answer to that stand. In fact, its my solution, but with iter.next() in place of accept :) This is probably something like how I wanted to solve the problem when I first was lo

Re: Anonymus functions revisited : tuple actions

2005-03-25 Thread Ron_Adam
On 24 Mar 2005 22:16:10 -0800, "Kay Schluehr" <[EMAIL PROTECTED]> wrote: >It's all developed during this discussion. Sometimes I'm a bit >surprised were it goes. I enjoy exploring ideas this way. Many times it leads to dead ends or you just end up with a long way back to where you started, but so

Re: Version Number Comparison Function

2005-03-25 Thread Robert Kern
[Pardon the piggybacking. My news-server does not see the OP's message.] Fredrik Lundh wrote: "Keith" wrote: Is there a function for comparing version numbers? E.g. 0.1.0 < 0.1.2 1.876b < 1.876c 3.2.2 < 3.4 distutils has a set of version classes with comparisons. In [1]:from distutils import versi

Re: Version Number Comparison Function

2005-03-25 Thread Mark Rowe
On Mar 26, 2005, at 3:34 AM, Keith wrote: Is there a function for comparing version numbers? E.g. 0.1.0 < 0.1.2 1.876b < 1.876c 3.2.2 < 3.4 FWIW, >>> from distutils import version >>> version_list = "3.4 3.2.2 1.867c 1.867b 0.1.2 0.1.0".split() >>> version_list = map(version.LooseVersion, version_

Re: Version Number Comparison Function

2005-03-25 Thread Keith
distutils is one of the places I looked: http://www.python.org/doc/2.3.5/lib/module-distutils.html But I didn't see the functions documented. I am new to Python so I didn't know where else to look. Using distutils seems like it would be the most generic and supported way to compare version numbe

Re: Python docs [was: function with a state]

2005-03-25 Thread Ulrich Hobelmann
[EMAIL PROTECTED] wrote: The Python doc, though relatively incompetent, but the author have Really, how could those morons even dream of creating a language, and even writing docs to accompany it?? tried the best. This is in contrast to documentations in unix related things (unix tools, perl, apa

Re: Python 2.4 | 7.3 The for statement

2005-03-25 Thread Facundo Batista
On 24 Mar 2005 19:49:38 -0800, brainsucker <[EMAIL PROTECTED]> wrote: > foo = 0 > for item1 in range(10) until foo == 2: > for item2 in range(10) until foo == 2: > foo = item1 + item2 > if foo == 2: print "Let's see" > print foo In this case, I'll use the following: try: for item1

Re: Minidom output of XML escaped characters

2005-03-25 Thread Derek Basch
Thanks effbot. I haven't had much use for XML comments so far and I guess other people haven't either because it seems they are hardly ever mentioned. http://groups-beta.google.com/groups?hl=en&lr=&c2coff=1&q=xml+comment+python&qt_s=Search+Groups -- http://mail.python.org/mailman/listinfo/python

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Rocco Moretti
Antoon Pardon wrote: I have problems with all languages currently available, so I use those which rub me wrong the least. ... [I]t doesn't weight heavy enough to go and use an other language, although I keeping looking at the other languages. I think the operational definition of a "zealot" is som

Re: Anonymus functions revisited : tuple actions

2005-03-25 Thread Reinhold Birkenfeld
Ron_Adam wrote: > What if you could: > > x = lambda{ x, y: x+y} > Hmm comma creates a problem here. so... >>> from __future__ import braces SyntaxError: not a chance >>> Reinhold ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: Anonymus functions revisited

2005-03-25 Thread Ron_Adam
On 25 Mar 2005 10:09:50 GMT, Duncan Booth <[EMAIL PROTECTED]> wrote: >I've never found any need for an is_defined function. If in doubt I just >make sure and initialise all variables to a suitable value before use. >However, I'll assume you have a good use case. I admit that that is the better

Re: Version Number Comparison Function

2005-03-25 Thread Steve M
I recently saw this: http://www.egenix.com/files/python/mxTools.html mx.Tools.verscmp(a,b) Compares two version strings and returns a cmp() function compatible value (<,==,> 0). The function is useful for sorting lists containing version strings. The logic used is as follows: the string

mod_python, user missing

2005-03-25 Thread KasiKuula
apache conf SetHandler mod_python PythonHandler mod_python.publisher and this is in /python-publisher/index.py __auth_realm__ = 'VIP' def __auth__(req, user, passwd): if user == 'noppa' and passwd == 'potti': return True else: return False def __access__(req, use

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Diez B. Roggisch
> > I'll try to reduce my pages of ranting to a single question. In > posting, i was wondering if the "syntactic sugar" (Acceptors) that i > invented to implement the solution is of any general interest. So are > there maybe examples less straightforward than this one, where > Acceptors work bette

Suggest more finesse, please. I/O and sequences.

2005-03-25 Thread Qertoip
Would you like to suggest me any improvements for the following code? I want to make my implementation as simple, as Python - native, as fine as possible. I've written simple code, which reads input text file and creates words' ranking by number of appearence. Code: --

Re: Version Number Comparison Function

2005-03-25 Thread Robert Kern
Keith wrote: distutils is one of the places I looked: http://www.python.org/doc/2.3.5/lib/module-distutils.html But I didn't see the functions documented. I am new to Python so I didn't know where else to look. The source! I don't think they're documented elsewhere. Using distutils seems like it w

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Jordan Rastrick
Wow, if I'm going to get replies (with implemented solutions!) this quickly, I'll post here more often :-) This is the most different to my solution, and also the shortest, and therefore the most interesting, reply so far. Its also the last one I'll reply to before I go to bed. Its taken

Re: Python 2.4 | 7.3 The for statement

2005-03-25 Thread Ron_Adam
>-- Your code >foo = 0 >for item1 in range(10): > for item2 in range(10): >foo = item1 + item2 >if foo == 2: > print "Let's see" > break # let's go > if (item1 + item2) == 2: >break # one more time >print foo The outer loop never reaches 1, so we can get rid of it along wi

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Michael Spencer
Jordan Rastrick wrote: Wow, if I'm going to get replies (with implemented solutions!) this quickly, I'll post here more often :-) That is indeed typical of this most attentive group :-) Its taken me a while to get a rough understanding of this code, but I think I have some idea. It is just an exam

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Terry Reedy
"Antoon Pardon" <[EMAIL PROTECTED]> wrote in message > 1) It makes it hard to see how many levels are dedented at the end of > a suite, and sometime makes it difficult to see where the end > of a suite is. If e.g. you are looking at the code spread over > two pieces of paper, it is sometime

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Terry Reedy
"Tim Tyler" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > What do you guys think about Python's grouping of code via indentation? A major plus. I was fanatic about carefully indenting my C code. > Is it good - perhaps because it saves space and eliminates keypresses? It elimin

Re: Version Number Comparison Function

2005-03-25 Thread Bengt Richter
On Fri, 25 Mar 2005 17:02:31 +0100, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote: >"Keith" wrote: > >> Is there a function for comparing version numbers? >> >> E.g. >> >> 0.1.0 < 0.1.2 >> 1.876b < 1.876c >> 3.2.2 < 3.4 > >the following works for many common cases: > >import re > >def cmpver(a, b): >

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Serge Orlov
Michael Spencer wrote: > > Still, this is fascinating going to have to spend some time > > experimenting with groupby as soon as I get a chance > > > Experimenting is good. So is the the documentation: > http://docs.python.org/tut/tut.html Reading documentation is a good idea, but I think

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Terry Reedy
Terminology: To me and some (most?) others posting here and, I believe, both the docs and the common meaning of 'generator', a Python generator is the particular kind of iterator that produces multiple values on request and which is created by the generator function that you write. Acceptors (c

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread James Stroud
On Friday 25 March 2005 08:39 am, Ivan Van Laningham wrote: > As far as grouping by indentation goes, it's why I fell in love with > Python in the first place.  Braces and so on are just extraneous cruft > as far as I'm concerned.  It's the difference between Vietnamese verbs > and Latin verbs;-)

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Bengt Richter
On Fri, 25 Mar 2005 08:46:12 -0800, Michael Spencer <[EMAIL PROTECTED]> wrote: >Tim Hochberg wrote: >> Jordan Rastrick wrote: >> > >itertools.groupby enables you to do this, you just need to define a suitable >grouping function, that stores its state: > >For example, if short lines should be app

Re: Suggesting a new feature - "Inverse Generators"

2005-03-25 Thread Scott David Daniels
Michael Spencer wrote: itertools.groupby enables you to do this, you just need to define a suitable grouping function, that stores its state: Michael, this would make a great Python Cookbook Recipe. --Scott David Daniels [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list

Re: Grouping code by indentation - feature or ******?

2005-03-25 Thread Robert Kern
James Stroud wrote: On Friday 25 March 2005 08:39 am, Ivan Van Laningham wrote: As far as grouping by indentation goes, it's why I fell in love with Python in the first place. Braces and so on are just extraneous cruft as far as I'm concerned. It's the difference between Vietnamese verbs and Lati

  1   2   >