From ullrich at math.okstate.edu Fri Jun 15 10:27:39 2001
From: ullrich at math.okstate.edu (David C. Ullrich)
Date: Fri, 15 Jun 2001 14:27:39 GMT
Subject: call-by-reference (was Re: Any other Python flaws?)
References: <9gcu9g$gm4$1@newshost.accu.uu.nl> <9gd4tq$odb$1@news.mathworks.com>
Message-ID: <3b2a1aea.6118580@nntp.sprynet.com>
On 15 Jun 2001 14:08:58 GMT, jcm wrote:
>Martijn Faassen wrote:
>
>> I agree that nobody agrees on whatever 'call-by-reference' means, or what
>> 'call-by-value' means. I mean, I'm here confused why you'd say C++ doesn't
>> support call-by-value while Python apparently does. :)
>
>In my experience, there's good agreement about what call-by-reference
>means just about everywhere but in newsgroups. Python supports only
>call-by-value -- you can't change the value of a variable in your
>caller's scope (globals aside).
It's call-by-value all right. The confusion is caused
by the fact that the values are references. But passing
a reference "by value" is not a call by reference.
David C. Ullrich
*********************
"Sometimes you can have access violations all the
time and the program still works." (Michael Caracena,
comp.lang.pascal.delphi.misc 5/1/01)
From piet at cs.uu.nl Thu Jun 7 10:25:49 2001
From: piet at cs.uu.nl (piet at cs.uu.nl)
Date: 07 Jun 2001 16:25:49 +0200
Subject: Recursive algorithms anyone?
References: <1f0uhtgmhb0vlud6pof6i4mctqjdq8l2eu@4ax.com>
Message-ID:
def add(x,k):
if type(x)==type([]):
return additem(x,k)
return x+k
def additem(l,k):
return [add(x,k) for x in l]
--
Piet van Oostrum
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl
From dwig at advancedmp.net Mon Jun 4 16:18:02 2001
From: dwig at advancedmp.net (Don Dwiggins)
Date: 04 Jun 2001 13:18:02 -0700
Subject: Numeric Programming for Everybody (was Re: I had a thought ...)
References:
Message-ID:
Tim Peters writes:
> [Don Dwiggins]
>> See http://support.microsoft.com/support/kb/articles/Q172/3/38.ASP for
>> one use of Currency having nothing to do with money.
> Cute! In an earlier, unrelated thread, we learned that the Currency type is
> really a 64-bit int, conceptually scaled by a factor of 10000. The
> performance counter API uses 64-bit ints directly. So they're the same
> thing, except that the VB code at the link has to fiddle around multiplying
> the Frequency value by a magic 10000 to get VB to *treat* the value like a
> real 64-bit int. OTOH, in (Ctr2 - Ctr1) / Freq, the 10000's cancel out so
> they dare not play with magic multipliers in *that* context. Oh ya -- I bet
> all the VB programmers understand this in sufficient detail to bet the
> business on .
This, and the various threads on numeric representation and computation,
triggered the following thoughts:
- Common number systems can't be completely and accurately represented in
computers -- some limitations and/or approximations must be accepted.
- This is widely acknowledged among programmers, but not obvious to
newcomers.
- Many of those who acknowledge it don't have a complete understanding of
the "limitations and/or approximations" and the sometimes subtle
consequences for building software that handles numbers "reasonably". (As
evidence, I offer the discussions in this group. I also freely admit
that, if I were to undertake serious floating-point programming again, I'd
have to brush up on the details.)
- For many purposes, a relatively naive level of understanding is sufficient
-- provided it's accompanied by an appreciation that there's more to it,
and that one may be required to learn the details of floating point,
rational representations, etc.
So, what are the implications for "Computer Programming for Everybody"? How
much and what knowledge should the newbie be expected to master, to avoid
falling into various traps? What conceptual model(s) of numbers should a
language (say, for example, Python) present to the learner to be generally
useful without making it too easy to go wrong? How can the language
accommodate the differing needs of the learner and dilettante on the one
hand, and the specialists in various kinds of numeric programming on the
other?
--
Don Dwiggins "Solvitur Ambulando"
Advanced MP Technology
dwig at advancedmp.net
From nas at python.ca Sun Jun 24 11:23:50 2001
From: nas at python.ca (Neil Schemenauer)
Date: Sun, 24 Jun 2001 08:23:50 -0700
Subject: PEP 255: Simple Generators
In-Reply-To: ; from rnd@onego.ru on Sun, Jun 24, 2001 at 05:20:03PM +0400
References:
Message-ID: <20010624082350.A29837@glacier.fnational.com>
Roman Suzi wrote:
> This implementation is cool, but how fast will be recursive generators?
> How large is the overhead to defrost execution frame each time? Will it be
> faster than functional gcomb?
Why don't you write one and we will compare it to Tim's generator
version? :-) I'll stick my neck and speculate that resuming a generator
is measurably faster than calling a function.
Neil
From python at crazypenguins.commandprompt.com Sat Jun 30 02:57:20 2001
From: python at crazypenguins.commandprompt.com (python at crazypenguins.commandprompt.com)
Date: Fri, 29 Jun 2001 23:57:20 -0700
Subject: Python book online (Graphical Programming with Py/QT)
Message-ID: <20010629235720.A6112@crazypenguins.commandprompt.com>
Hello,
I think the subject says it all but over here at OpenDocs we have put up the
first parts of our Graphical Programming with Python: QT Edition. The book
is currently under development and we are actively seeking feedback.
If everyone (who has an interest) could take a moment and browse the text it
would be great. We will are looking for all types of feedback. It can be
constructive or flame based :)
The more feedback we receive the better the book will be.
Here is the URL:
http://www.opendocspublishing.com/entry.lxp?lxpe=93
OpenDocs
From scarblac at pino.selwerd.nl Thu Jun 21 19:20:27 2001
From: scarblac at pino.selwerd.nl (Remco Gerlich)
Date: 21 Jun 2001 23:20:27 GMT
Subject: Pythoin MUD (PyMUD?)
References: <9gqq3t$hvs$1@brokaw.wa.com>
Message-ID:
Jonathan Gardner wrote in comp.lang.python:
> 2) Is there any mud hackers out there with advice or ideas? This thing is
> as fresh as it gets, I want crazy and wacky ideas you've been mulling about
> in your mind for the past 25 years, and I want this mud to be truly unique.
I'm interested. Years ago I was a mud addict, always lpmuds, been admin on
some. And I still think LPC is way cool.
I've been thinking a bit about a mud in Python, the problems come when you
run both the driver and code that was wrriten by wizards in the game (their
areas) in the same interpreter. You need to shield the driver internals from
the mud's objects. Although that's maybe possible with rexec and similar,
it's still easy to do a DOS attack - you need only one drunken wizard to
code an infinite loop, and your driver locks up. I haven't found a solution
yet, haven't thought about it enough. It's very interesting :).
And Stackless microthreads sound rather awesome for a mud like thing.
> 3) Any newbies want to watch a mud being created? (OR - should I put this
> on sourceforge? Or will you throw rotten eggs at me?)
Always a big lack of free time. I'd like to see a mailing list though :-)
--
Remco Gerlich
From uioziaremwpl at spammotel.com Tue Jun 19 18:39:21 2001
From: uioziaremwpl at spammotel.com (Carsten Geckeler)
Date: Wed, 20 Jun 2001 00:39:21 +0200 (CEST)
Subject: Which IDE ?
In-Reply-To: <20010619144900.B7032@harmony.cs.rit.edu>
Message-ID:
On Tue, 19 Jun 2001, D-Man wrote:
> On Tue, Jun 19, 2001 at 05:57:00PM +0100, phil hunt wrote:
> | On Mon, 18 Jun 2001 22:57:13 GMT, VanPopering wrote:
> [Which IDE?]
> |
> | I think professional programmers often prefer simple tools (i.e.
> | text editor and command line).
>
> Sounds like a reasonable guess to me (at least wrt Unix programmers, I
> think more MS Windows programmers use Visual Studio and other similar
> tools). I use vim + bash also. I have tried some other environments,
> but I haven't found any that I like as much. I do sometimes use some
> IDE for a debugger interface (DDD, JBuilder, NetBeans, whatever -
> depends on what machine I'm at and what I'm working on).
Well, let me add my choice of environment, too:
I'm using emacs and bash. I prefer emacs, because the provided Python
mode is very elegent and makes coding much easier and faster. As I don't
like xemacs, I always run emacs -nw. Using a shell as bash seems to me
more flexible than some menu item "Run" in a graphical IDE.
Cheers, Carsten
--
Carsten Geckeler
From aleaxit at yahoo.com Tue Jun 19 12:40:11 2001
From: aleaxit at yahoo.com (Alex Martelli)
Date: Tue, 19 Jun 2001 18:40:11 +0200
Subject: paths: sleeping at the wheel
References: <3B2F7682.D5C65F3@abaqus-sn.com>
Message-ID: <9gnv9d017e3@enews2.newsguy.com>
"david winkler" wrote in message
news:3B2F7682.D5C65F3 at abaqus-sn.com...
> I have been using Python for a while and have just noticed that when
> accessing a script from the command line like this: "python
> scriptname.py", the path must be cwd or fully qualified. I have tried
> setting my system path without success. Is there a workaround to this
> limitation (or a clarification to my misunderstanding)? I already know
> how to avoid this type of situation by running the script like this:
> "scriptname". I also know how to access modules using PYTHONPATH.
There is no workaround that I know of to the limitation you
correctly noticed. python.exe (or the python executable, on
non-Windows platforms) would have to be modified to remove
this limitation (or, to put it the other way 'round, to add
to it some presumably-optional feature to search for the main
script along some kind of 'path' -- presumably only if the
main script is supplied as a bare filename bereft of path
and such a named file is not found in the current directory).
If you want to write down the specifications for the new
requested features, it could go into a PEP -- don't worry
about implementing it, that will be easily done if the PEP
is approved, but rather about the pro's and con's of the
proposed enhancement. Biggest pro I can think of is that
people ASSUME the feature already exists and are surprised
to find out it doesn't -- therefore, on the principle of
least surprise, I guess it should go in, unless some serious
contraindications should emerge...?
Alex
From sholden at holdenweb.com Wed Jun 13 17:53:29 2001
From: sholden at holdenweb.com (Steve Holden)
Date: Wed, 13 Jun 2001 17:53:29 -0400
Subject: a newbie question about gadfly
References: <9g7ter$iqo$1@plutonium.compulink.co.uk>
Message-ID:
wrote in message
news:pn7fitoa7n6u47atng7tv0n9aroc1716ic at 4ax.com...
> On 13 Jun 2001 14:30:51 GMT, gbreed at cix.compulink.co.uk wrote:
>
> >In article ,
> >jm7potter at hotmail.com () wrote:
> >
> >> On 12 Jun 2001 15:34:16 GMT, gbreed at cix.compulink.co.uk wrote:
> >>
> >> >In article ,
> >> >jm7potter at hotmail.com () wrote:
> >> >
> >> >> Why? is namex not a direct replacement for "donna" ????
> >> >
> >> >Um, no, not the way you're doing it. Try replacing that
> >magic
> >> >line with
> >> >
> >> >
> >> >Or even
> >> >
> >> >cursor.execute("insert into students (name, grade) values
> >> >(%(namex)s, %(gradex)s)" % vars())
> >> >
> >> >(that's sure to wordwrap!)
> >> >
> >> >
> >> > Graham
> >>
> >>
> >> Thanks for the help Graham,
> >>
> >> However, your code did not work either. The little program
> >chokes every
> >> time I try to
> >> do anything that is not "hard-wired" into the script.
> >
> >Oops! There is an error:
> >
> >cursor.execute(
> > "insert into students (name, grade) values ('%s', '%s')"
> > % (namex, gradex))
> >
> >might be better. I forgot to quote the arguments, and at least
> >one of them is a string.
> >
>
> It Works?!?!! It is alive!!
>
> Now, if you have the time and inclination --- could you explain why your
first code
> failed and the second worked? (I hate magic)
>
> And further, could you explain to a newbie why *my* code failed?
>
While Graham relaxes after his efforts, allow me to dive and and offer the
explanations you seek. [c.l.py is like this...]. Taking them in reverse
order:
1. Your original problem was why the following didn't work:
namex = 'donna'
gradex = 'grade 2'
cursor.execute("insert into students (name, grade) values (namex, gradex)")
If you had put a print statement in there, you would have seen that the
statement you were trying to execute was, quite literally
insert into students (name, grade) values (namex, gradex)
In other words, simply using a variable name inside a string isn't enough to
get its contents into the string. Perhaps you are a Perl user who is used to
their language replacing variable names (easily spotted becuase they begin
with a dollar sign) automatically substituted in strings. The question then
becomes "How do I build a valid SQL statement with the contents of the
variables in them?"
There are several ways. You could have tried:
cursor.execute("insert into students (name, grade) values ('" + namex + "',
'" + gradex+ "')"
This expression concatenates several strings, some of which are literals and
some of which are variables bound to string values. Note that you needed to
literally include the single quotes which delimit string values in SQL.
Another way would have used the % string substitution operator, where you
could have written
cursor.execute("insert into students (name, grade) values ('%s', '%s')" %
(namex, gradex))
In this case Python would have used the string to the left of the % operator
as a format string, and eaech time it met a "%s" in the format it would
substitute the next value from the tuple to the right of the %. There are
many other format substitutions, and people are usually pointed at the C
language's printf() function for a reference. I'm sure you can find them.
2. Graham's original suggestion (with proper continuation markup) was
cursor.execute("insert into students (name, grade) values" \
"(%(namex)s, %(gradex)s)" % vars())
Note that when Python sees two string literals in juxtaposition this way it
concatenates them automatically. This is a slightly different attempt at
formatting: this time there is a dictionary (the dictionary of current
variables) on the right of the %, and the format codes give the name of the
required dictionary entry between the parentheses. Given the variable values
you had, this would try to execute the SQL statement
insert into students (name, grade) values(donna, grade 2)
The problme with this version was Graham forgetting that SQL requires single
quotes around the string values. So his final version put those in, giving
you the statement
insert into students (name, grade) values('donna', 'grade 2')
Note also that it is really simpler and more efficient to have the SQL
cursor do the value substitution, which I think Graham may have suggested as
an alternative (or was it another poster?). In this case you mark the points
of substitution in your SQL statement with question marks (this is the
simplest style: the DB API allows five different kinds) and then give a
tuple of values as a second argument to execute(). So you could have written
cursor.execute("insert into students (name, grade) values(?, ?)",
(namex, gradex))
and the cursor would have performed the substitution - including adding the
required quotes around the string values, and excaping any single quotes
that might have crept into the values to ensure that the result SQL
statement was well-formed.
Anyway, be that all as it may, congratulations on succeeding in writing your
first Python database program. I am sure it won't be your last.
regards
Steve
http://www.holdenweb.com/
From dalke at acm.org Thu Jun 28 16:24:56 2001
From: dalke at acm.org (Andrew Dalke)
Date: Thu, 28 Jun 2001 14:24:56 -0600
Subject: PEP scepticism
References:
Message-ID: <9hg46o$grc$1@slb5.atl.mindspring.net>
Jason F. McBrayer wrote:
>>>>>> "RS" == Roman Suzi writes:
>RS> There is limit after which more explanation is worse than less:
>
>RS> processed_list = []
>RS> for i in old_list:
>RS> processed_list.append(func(i))
>
>RS> adds nothing but noise, while:
>
>In this trivial case, probably not, but...
A month or so I posted an example where I explained why I liked
list comprehensions
http://mail.python.org/pipermail/python-list/2001-May/042951.html
It boils down to that this trivial case occurs very frequently,
so I put the three lines or so into a function. But I couldn't
think of a good function name. By using list comprehensions
I traded off some strange syntax for the ability to describe
everything in one place - more legibility in the long run.
So my coding recommendation is to use list comprehensions solely
for that trivial case, and use functions for more complex ones.
Andrew
From skip at pobox.com Fri Jun 22 07:57:46 2001
From: skip at pobox.com (Skip Montanaro)
Date: Fri, 22 Jun 2001 06:57:46 -0500
Subject: [Q] python embedding Demo
In-Reply-To:
References:
Message-ID: <15155.12986.801010.331517@beluga.mojam.com>
cyblue> -------------
cyblue> gcc demo.o
cyblue> usr/lib/python1.5/config/libpython1.5.a -lsocket -lnsl -ldl -lreadline -lt
cyblue> ermcap -lm -o demo
cyblue> /usr/bin/ld: cannot find -lsocket
cyblue> collect2: ld returned 1 exit status
cyblue> make: *** [demo] error 1
cyblue> ----------------------
cyblue> what's wrong?
Perhaps you don't need to link with the socket library. Try removing
"-lsocket" from your link line. Same goes for any other libraries ld
complains about.
--
Skip Montanaro (skip at pobox.com)
(847)971-7098
From bokr at accessone.com Thu Jun 14 13:19:05 2001
From: bokr at accessone.com (Bengt Richter)
Date: Thu, 14 Jun 2001 17:19:05 GMT
Subject: [Python-Dev] PEP 259: Omit printing newline after newline
References: <9g4nec0cnr@enews2.newsguy.com> <3b266453.317327753@wa.news.verio.net> <3b2768b5.1425762@nntp.sprynet.com>
Message-ID: <3b28ed01.483389587@wa.news.verio.net>
On Wed, 13 Jun 2001 13:33:51 GMT, ullrich at math.okstate.edu (David C.
Ullrich) wrote:
>On Tue, 12 Jun 2001 19:25:25 GMT, bokr at accessone.com (Bengt Richter)
>wrote:
>
>>[...] In general, I'd prefer that a language
>>provide a clean way to create a solution to a problem,
>>rather than having a particular solution built in.
>>I like orthogonality too.
>
[...]
>So just out of curiosity: Roughly what do you
>mean by "orthogonality" above?
Roughly, zero dot products ;-)
That is, if you view program language feature space
as n dimensional, and writing code using a particular
feature as movement along a feature vector.
Well, roughly something like that. 8-<:^P
From jmarshal at mathworks.com Tue Jun 5 17:30:14 2001
From: jmarshal at mathworks.com (Joshua Marshall)
Date: 5 Jun 2001 21:30:14 GMT
Subject: integers
References: <9fjd8q$qb6$1@charm.magnus.acs.ohio-state.edu> <9fjgqf$rp0$2@brokaw.wa.com>
Message-ID: <9fjj16$4in$1@news.mathworks.com>
Jonathan Gardner wrote:
> Locke wrote:
>> is there such thing as
>> someint++
>> or
>> someint--
>> or
>> someint += 2
>> in python??
>>
>> it is a pain in the butt writing
>> someint = someint + 1
>>
>> Thanks!
> It's also a pain in the butt writing someint += 1 (Yes, I know I am very
> lazy).
> What is the reason that python doesn't have increment or decrement
> operators?
Python isn't C - there's no reason to expect ++ or --. And I'd
personally be against adding these to the language, since += and -= do
increment and decrement nicely. Also, if ++ and -- were introduced
people would probably expect them to be expressions (since they look
like C's ++ and --). This would be another mistake, in my opinion. I
like how Python keeps side-affecting language constructs in the realm
of statements.
From jkn at nicorp.f9.co.uk Wed Jun 20 11:56:09 2001
From: jkn at nicorp.f9.co.uk (Jon Nicoll)
Date: 20 Jun 2001 08:56:09 -0700
Subject: arguments to calldll.call_foreign_function() ?
Message-ID: <8351bb33.0106200756.4776fed5@posting.google.com>
Hi there
I want to experiment with using calldll to access a win32
function: QueryPerformanceCounter(), which has a prototype
BOOL QueryPerformanceCounter(
LARGE_INTEGER *lpPerformanceCount // address of current counter
value
);
I've got as far as this:
:: testcalldll.py
import calldll
# get the handle of a module
m = calldll.load_library('kernel32')
# get the address of my function
f = calldll.get_proc_address(m, 'QueryPerformanceCounter')
# try to call the function
# print calldll.call_foreign_function(f, '', 'l', ())
:: end
but I can't work out the right parameters for the last line - the
call_foreign_function(). Help, please?
Thanks
Jon Nicoll
From ken_chiba at hotmail.com Wed Jun 20 19:45:11 2001
From: ken_chiba at hotmail.com (Ken)
Date: Wed, 20 Jun 2001 23:45:11 GMT
Subject: How to install python on clean RH7.1 install
Message-ID: <3b313462.13451051@news1.on.sympatico.ca>
Hi,
I'm trying to install Python 2.1-5 onto a newly installed RH7.1. The
RH install was done pretty cleanly, so not a lot of the RPMs have been
installed (I've installed some along the way, as dependencies came
up).
My quesions are these:
1). Is it possible to "upgrade" the python 1.5.2 that is installed
with RH7.1? (I couldn't easily avoid installing it - because it was a
dependency for a lot of packages. That said, I cannot easily
uninstall the RPM for 1.5.2).
2). If not, what way is more or less a fail-safe way of installing
python into a new directory. I have tried the following already:
- installing from the src.rpm file -- the installer stopped short of
creating the RPM file... something about it not finding a lot of files
(that it was to have compiled). It made it through the check, and did
about 5 minutes of compiling, then stopped.
- installing from the rpm file. The dependencies failed were
libcrypto, and libssl -- but I have NO idea where to find these
(preferrably RPMs).
Any ideas would be greatly appreciated!
Kc
From grante at visi.com Sun Jun 24 20:55:43 2001
From: grante at visi.com (Grant Edwards)
Date: Mon, 25 Jun 2001 00:55:43 GMT
Subject: How to install python on clean RH7.1 install
References: <3b313462.13451051@news1.on.sympatico.ca> <3B33F025.D275AAB1@student.gu.edu.au> <3b35170a.268083173@news1.on.sympatico.ca> <3B353837.6A68A329@student.gu.edu.au> <3b35deb3.319196179@news1.on.sympatico.ca>
Message-ID:
On Sun, 24 Jun 2001 13:43:55 GMT, Ken wrote:
>As to compiling the src rpm, I tried that - with less success than the
>RPM. It burns through compiling for about 5 minutes (P233MMX, 64mb),
>and then you see a LOT of "unrecognized file type" messages fly by,
>and eventually, the compile fails.
>
>Any other ideas?
Grab the sources.
$ tar xzvf Python-2.1.tgz
$ cd Python-2.1
$ ./configure
$ make
(su root)
# make install
--
Grant Edwards grante Yow! My polyvinyl cowboy
at wallet was made in Hong
visi.com Kong by Montgomery Clift!
From deltapigz at telocity.com Sat Jun 23 17:44:40 2001
From: deltapigz at telocity.com (Adonis)
Date: Sat, 23 Jun 2001 17:44:40 -0400
Subject: creating a matrix in python?
Message-ID: <3B350DC7.748C3903@telocity.com>
how do i go about this?
i have looked into the tutorial 100+ times and cant get anything on
matrices out of it?
only thing i came up with was some thing like:
blah = ['buh', 'blah', 'wassah']
blah[1][0]
'buh'
???
any help would greatly be appreciated.
Adonis
From tim.one at home.com Sun Jun 10 23:12:29 2001
From: tim.one at home.com (Tim Peters)
Date: Sun, 10 Jun 2001 23:12:29 -0400
Subject: Libraries implementation in C or in Python? Evolution of Python, Jython...
In-Reply-To: <3B22D3FE.9FDA579A@earthlink.net>
Message-ID:
[Ron Stephens]
> Are Python's libraries generally written in C or in Python,
Both; e.g., look in your Lib/ directory and you'll find a couple megabytes
of Python library source.
> and why?
Complex coding is easier in Python; low-level fiddling is easier and runs
faster in C.
> Someone commented on another thread that the re.search() function ran
> faster in its 1.5.2 version than in its 2.1 version, because in 1.5.2 it
> was implemented in C and in 2.1 it was implemented in Python. It was
> suggested to instead use the "pre" module, but I see it is old and may
> become obsolete? I am curious as to the reasoning behind why these kinds
> of changes and decisions are made?
sre was primarily motivated by the new need to support Unicode (pre couldn't
handle it). Fredrik also thought he could write a matching engine faster
than pre, and turns out he was right. But any project has to be completed
in finite time, and there can't be a guarantee that every case will be no
slower than before. In the way I use regexps, I almost always find that sre
is faster.
There are no "general reasons" here: each thing has its own reasons.
> In general, as Python evolves from version to version, is Python code
> likely to get slightly faster in execution time, or slightly slower?
Neither, really, although the trend since 1.5.2 has been to get a bit slower
each time. Two things account for that:
1. New features can cost. For example, rich comparisons added many
more possibilities for the runtime code to sort through, and *simple*
comparisons got significantly slower as a more-than-less direct
result. Or cyclic gc removes worries about trash cycles leaking,
but it takes time to find those cycles (before they simply leaked).
2. Fixing ancient bugs. For example, it's possible to crash any Python
through 2.1 by filling a dict with class instance keys, where the
class overrides comparison with a function that mutates the dict
while it's comparing. This isn't sane, but it is possible. Plugging
this hole required additional code in the dict lookup routines, and
that slows them down. Plugging holes often costs a little, and then
plugging many holes adds up to more than a little.
OTOH, current CVS Python is significantly quicker than 2.1 by several
accounts, as people have found 2.1 hotspots and added patches to cool them
off. On the third hand, Python's speed is also significantly affected by
the compiler and OS; for example, on identical hardware, pystone runs
significantly faster under Win2K+MSVC than under Linux+gcc, but test_bufio
runs 10x faster under Linux; etc. "The speed" of a x-platform app is a
slippery concept, because it's not independent of platform.
> Mind you, I am a Pythonista because of the numerous other beauties of
> the language, not because of any speed issues; and I can certainly see
> why Python should be and is optimized for other criteria, not speed, and
> if this sometimes means a little step backwards in speed of code
> execution then so be it. But I am just curious about the trade-offs, and
> why such decisions are made.
Decisions to accept or reject a new feature don't generally take speed into
account, because it's generally impossible to predict in advance. What
happens instead is that if an accepted feature is "too slow", someone who
cares enough will speed it over the next release cycle. It's actually rare
that anyone cares enough to do that, though.
> There have been a few threads about 2.x versions of Python being a
> little slower, in terms of the execution speed of similar code, than
> 1.5.2. Is this speed decrement likely to be permanent?
It's impossible to say without specific code to time on a specific platform.
The only way you'll ever get a clear answer to something as vague as
"similar code is a little slower -- permanent?" is if a developer chimes in
with "Doh! I *knew* I shouldn't have left sleep(1) in the inner loop"
.
> ...
> I hesitate to ask any of this, because my extreme state of newbieness
> and lack of knowledge do not give me any right to even speak up and ask
> such questions. I only rush in where I should fear to tread because the
> tangible beauty of the evolutionary process of a work of art such as the
> Python programming language excites my curiosity and sense of wonder.
Rest assured (or appalled ) that Python is pretty much the same as any
large project in this respect: the speed freaks worry about speed, the
feature freaks push for new features, the good-old-days freaks complain
about change, and nobody has enough time to do all they want to do.
> And then there is Jython. Is Python the mother and Java the father, or
> is it the other way around?
They're more like teenage siblings, who can't believe their parents ever had
sex so each suspects the other of being adopted.
> Does anyone else see the evolution of Python, Jython and future
> offspring as a living work of art?
Undoubtedly. But they usually keep it to themselves .
From kjetiln at kvarteret.uib.no Wed Jun 27 05:04:56 2001
From: kjetiln at kvarteret.uib.no (Kjetil =?iso-8859-1?Q?Nyg=E5rd?=)
Date: Wed, 27 Jun 2001 11:04:56 +0200
Subject: Escaping SQL in python
Message-ID: <3B39A1B8.A7FCE4C7@kvarteret.uib.no>
Is there a method to escape ' " \ and the like in python auto-magiacaly
?
--
Kjetil
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From feedback at netlcr.de Thu Jun 14 18:41:38 2001
From: feedback at netlcr.de (Florian Scholz)
Date: Fri, 15 Jun 2001 00:41:38 +0200
Subject: sorting values in dict
References:
Message-ID: <3B293DA2.DDE4A564@netlcr.de>
> I want to display a dict sorted by value.
>
> This is my dict:
>
> total={}
--------another code-snip---
def swap(el):
return (el[1],el[0]);
total = {}
list = map(swap,total.items());
list.sort();
------ or shorter ------
total = {}
list = map(lambda el : (el[1],el[0]) ,total.items());
list.sort();
From ykingma at accessforall.nl Mon Jun 18 14:47:05 2001
From: ykingma at accessforall.nl (Ype Kingma)
Date: Mon, 18 Jun 2001 19:47:05 +0100
Subject: Function lookup using a directory.
References: <29pX6.14682$cF.320097@news1.nokia.com>
Message-ID: <3B2E4CA6.AF9C5D84@accessforall.nl>
Andy,
In addition to the earlier replies:
Your run() method seems to be checking for
presence of arguments, so you might
consider defining it with an extra '*' as:
class Help0:
def run(self, *which):
if len(which) == 1:
print 'Help no args'
else:
print 'Help args'
This will give you a tuple with the passed arguments,
in your case an empty tuple.
Have fun,
Ype
andy.pevy at nokia.com wrote:
>
> Hi Guys
>
> I am having trouble with the directory data type. What I want to
> do is to set up a directory that I can use to parse a command entered by
> the user, and have a directory return the name of a class to handle the
> command. Like this :-
>
> command_table = {'0': 'Help0',
> '1': 'Help1',
> '2': 'Help2',
> '3': 'Help3' }
>
> class Help0:
>
> def run(self,which):
> if len(which) == 1:
> print 'Help no args'
> else:
> print 'Help args'
>
[snip]
>
> if __name__ == '__main__':
>
> command = user_input()
>
> try:
> h = command_table[command[0]]
> except:
> print command[0]+' not found'
>
> h.run() # Call the run method of the selected class.
>
--
email at xs4all.nl
From sill at optonline.net Sat Jun 16 23:37:01 2001
From: sill at optonline.net (Rainy)
Date: Sun, 17 Jun 2001 03:37:01 GMT
Subject: Newbie Question: Naming Conventions
References:
Message-ID:
On 16 Jun 2001 00:39:01 -0700, Abe wrote:
> I expect that this is a subject that has been beaten to death, but I
> haven't been able to find much info on it:
>
> I've experimented with many many computer languages, and I have to say
> that from what I've seen thus far of Python, it is probably the most
> elegant I've encountered. The combination of its clean syntax, OO
> nature, and functional aspects is excellent. HOWEVER, I'm very
> frustrated over the apparent lack of stylistic conventions for method
> names, etc in an otherwise consistent language.
>
> From a search of the archives, it appears that Guido's stance on this
> is that developers should be free to choose a style that suits them.
> I don't think anyone would disagree with that, but can't we at least
> have some consistency for the standard packages and built in
> functions? The recent trend seems to be towards CapitalWords for
> classes and alllowercase for methods and packages... but then there
> are builtin throwbacks like has_key and raw_input mixed in that stick
> out like a sore thumb.
I think the idea is that really often-used names are lower case because
they'd be hard to type if they weren't, and rarely used ones like
say UserDict are upper case. If you add that rule, it makes sense,
I think.
>
> Coming from the java world where the naming style is very consistent,
> having to use 'has_key' in the same code block as 'hasattr' drives me
> crazy! I could easily modify the C files to alias the 'haskey' and
> 'rawinput' names to the correct methods, but then my code wouldn't
> work on any other python runtime.
Yeah, that's true.. I'm not sure why has_key is different from hasattr,
maybe somebody else can fill this one in..
>
> So my question is: is there any proposal to standardize this sort of
> thing? Would such an initiative be welcome in the python community,
> or is it seen as not important? Does anyone see any obvious
> compatibility problems with providing an extra 'correct' version of
> nonconforming methods and classes until the originals can eventually
> be phased out?
>
> Or if this has all been covered before, please let me know where I can
> find the relevant discussion.
>
> Thanks!
--
Delay not, Caesar. Read it instantly.
-- Shakespeare, "Julius Caesar" 3,1
Here is a letter, read it at your leisure.
-- Shakespeare, "Merchant of Venice" 5,1
[Quoted in "VMS Internals and Data Structures", V4.4, when
referring to I/O system services.]
From jeff at ccvcorp.com Fri Jun 22 19:55:42 2001
From: jeff at ccvcorp.com (Jeff Shannon)
Date: Fri, 22 Jun 2001 16:55:42 -0700
Subject: Running an .exe file with python
References: <9h0jc9$npg$1@bob.news.rcn.net>
Message-ID: <3B33DAFE.E4FAADAD@ccvcorp.com>
Christian Reyes wrote:
> you should try the os.execv method
>
> >>> os.execv('c:\\yourapp.exe')
>
> christian
>
> "Steve Keri" wrote in message
> news:ea903c3a.0106221412.641fcf3 at posting.google.com...
> > Is there a way i can run an .exe file and install a program using
> > python? please help
Or possibly
>>> os.system("c:\\yourapp.exe")
I seem to remember something in the docs regarding execv & family,
and how their behavior differs between unix & win32, but don't recall
details offhand--you can always check the library reference for info
on the os module.
Jeff Shannon
Technician/Programmer
Credit International
From insanc at cc.gatech.edu Fri Jun 15 13:59:36 2001
From: insanc at cc.gatech.edu (Holland King)
Date: 15 Jun 2001 17:59:36 GMT
Subject: bad python display
Message-ID: <9gdie8$r2v$1@solaria.cc.gatech.edu>
sorry for the cross-posting but i am not real sure what is causing the
problem.
i have a python program using the tkinter module to create a gui. my
local system is running woody debian with kde. i am running the program
on a soloris box. on both my system and the solaris system i am using the
same version of ssh, python, and tkinter lib. the problem is when i try
to export the display from the solaris box to my local machine all i get
is the frame and half the boxes and buttons. when i run it locally i get
the correct display and when i try to export the display on other machines
i get the correct display. i think it has something to do with ssh, but i
have tried everything i can think of. can anyone think of what might be
causing the display on my machine to be unusable?
ssh -V == 2.5.2p1
python -v == 1.5
tkinter -v == 1.127
thank you.
--
---
Joseph Holland King | "God whispers to us in our pleasures, speaks in our
| conscience, but shouts in our pains: it is His
| megaphone to rouse a deaf world." C. S. Lewis
From sabren at manifestation.com Wed Jun 20 16:32:15 2001
From: sabren at manifestation.com (Michal Wallace)
Date: Wed, 20 Jun 2001 15:32:15 -0500 (CDT)
Subject: Pythoin MUD (PyMUD?)
In-Reply-To: <9gqq3t$hvs$1@brokaw.wa.com>
Message-ID:
On Wed, 20 Jun 2001, Jonathan Gardner wrote:
> I was tinkering around and I got the base skeleton for a python MUD
> working (you can LOOK and LOOK at something... cool.)
cool. :)
> 1) Is there any existing python muds out there?
Actually, there are a couple you might want to look at:
http://moebius.bofh.net.au/
http://www.strout.net/info/coding/python/intro.html
and one in jython:
http://www.cabochon.com/
Cheers,
- Michal
------------------------------------------------------------------------
www.manifestation.com www.sabren.net www.linkwatcher.com www.zike.net
------------------------------------------------------------------------
From meowbot at meowing.net Sat Jun 2 13:54:16 2001
From: meowbot at meowing.net (Indirect Meowbot)
Date: 02 Jun 2001 13:54:16 -0400
Subject: What does x[:]=[4,5,6] mean?
References: <9fb7cu$lq6$1@newsreaderg1.core.theplanet.net>
Message-ID: <87elt2u5rr.fsf@litterbox.meowing.net>
"Franz GEIGER" wrote:
> In site.py I saw
> sys.path[:] = L
> What does this mean? Why is the '[:]'? Why not simply
> sy.path = L ?
In a language like C you have to work a little bit harder to get a
pointer to something. In Python, you have to work a little bit harder
_not_ to get just a reference.
>>> meow = [1,2,3]
>>> woof = meow
>>> meow[0] = 42
>>> print meow, woof
[42, 2, 3] [42, 2, 3]
>>> # Ewww!
...
>>> meow = [1,2,3]
>>> woof[:] = meow
>>> meow[0] = 42
>>> print meow, woof
[42, 2, 3] [1, 2, 3]
>>> # Yay.
From paustin at eos.ubc.ca Sun Jun 24 22:36:59 2001
From: paustin at eos.ubc.ca (Phil Austin)
Date: 24 Jun 2001 19:36:59 -0700
Subject: tgrind defs for python?
References: <3B365F85.70952299@tundraware.com>
Message-ID:
This one for lgrind was posted ca 1998:
python|Python|py:\
:pb=^\d?(def|class)\d\p(\d|\\|\(|\:):\
:cb=#:ce=$:sb=":se=\e":lb=':le=\e':\
:kw=accept and break class continue def del elif else except\
exec finally for from global if import in is lambda not or\
pass print raise return try while:
Regards, Phil
From aleaxit at yahoo.com Fri Jun 1 06:19:40 2001
From: aleaxit at yahoo.com (Alex Martelli)
Date: Fri, 1 Jun 2001 12:19:40 +0200
Subject: Obsolesence of <>
References:
Message-ID: <9f7q7s02as4@enews1.newsguy.com>
"Lulu of the Lotus-Eaters" wrote in message
news:mailman.991352942.30691.python-list at python.org...
...
> In the end, spelling is arbitrary, of course. But having families of
> corresponding spellings for corresponding semantics makes it easier to
> remember a language, and to teach it.
Exactly. Teaching (and teachees' remembering:-) is my focus
on such issues. "lesser/greater" is the WRONG suggestion to
impart syntactically when desired semantics is "not equal",
given that "ab" and "a <> b" behave differently. Not
that != is ideal, of course, but at least it avoids such
specific "subliminal misinformation"... "Thou shalt not kill,
but needs't not strive // officiously to keep alive", as
Clough might have put it:-).
Alex
From jh at web.de Fri Jun 29 17:20:00 2001
From: jh at web.de (J�rgen Hermann)
Date: Fri, 29 Jun 2001 23:20:00 +0200
Subject: translate()
Message-ID: <9hirel$iqd$00$1@news.t-online.com>
Hi!
I have some issues with string.translate() and want to hear some opinions:
1. The first argument (the translation table) always has to be provided. It
would be nice if I could pass in None to JUST delete some chars:
str.translate(None, "delchars")
2. string is deprecated, but there is no "maketrans" string method; a
possible implementation would be string.maketrans(a,b) ==> a.maketrans(b)
Any thoughts?
Ciao, J?rgen
From castor at snafu.de Wed Jun 6 18:38:41 2001
From: castor at snafu.de (Wolfgang Lipp)
Date: Wed, 06 Jun 2001 22:38:41 GMT
Subject: ExtensionClasses for Python 2.1?
References:
Message-ID: <1107_991867121@ns.seowon.ac.kr>
>On 6 Jun 2001, Wolfgang Lipp wrote:
>> Does anyone know whether Jim Fulton of Zope's ;-)
>> ExtensionClass module is available for Python 2.1
>
> Yes. Zope 2.4 will require Python 2.1, hence EC will be updated. DC
>already released Zope 2.4.0 alpha1, so you can look there.
>
>Oleg.
thanks, i wasn't aware of this. on checking however,
i realized there is (of course) no *binary* release
as yet, and i can't compile right now... >sigh< but
thanks anyway for the tip.
-wolf
From 63.80.158.242 Fri Jun 8 15:12:54 2001
From: 63.80.158.242 (63.80.158.242)
Date: Fri, 08 Jun 2001 19:12:54 GMT
Subject: Cookbook on the DevCenter
References: <84r8wwklqr.fsf@localhost.localdomain>
Message-ID:
Yep! We'll be publishing the "best of" recipes from the Python Cookbook site in book form.
Laura
LLewin at oreilly.com
>
> Are there any plans to bring out a 'dead trees' version of the
> Python cookbook, not unlike the Perl Cookbook ?
>
> -arun
> Stephen> The latest additions to the Python cookbook are now
> Stephen> featured on the front page of the O'Reilly Network Python
> Stephen> Dev Center.
==================================
Poster's IP address: 63.80.158.242
Posted via http://nodevice.com
Linux Programmer's Site
From thecalm at NOSPAM.btinternet.com Mon Jun 25 13:28:00 2001
From: thecalm at NOSPAM.btinternet.com (Gaz)
Date: Mon, 25 Jun 2001 18:28:00 +0100
Subject: how do i run a script without the console showing??
Message-ID: <9h7s9i$khc$1@uranium.btinternet.com>
how do i run a script without the console showing on winME, im writting a
script using Tkinter and while the console is ok showing while im
developing/debugging it, when im finished i want the console to disappear!
:) how do i do that?
gaz.
From uioziaremwpl at spammotel.com Sat Jun 23 05:13:09 2001
From: uioziaremwpl at spammotel.com (Carsten Geckeler)
Date: Sat, 23 Jun 2001 11:13:09 +0200 (CEST)
Subject: PEP 255: Simple Generators
In-Reply-To:
Message-ID:
On Sat, 23 Jun 2001, Tim Peters wrote:
> [Carsten Geckeler]
> > I think we came to the core point. It seems that some people have
> > exactly the other oppinion, i.e. that the differences how a generator
> > is evaluated and used is so different that a different "def" line would
> > be helpful for many people.
>
> Yup, that's it in a nutshell. Generally speaking, though, the people in the
> latter camp have only read about generators, never used them.
>
> > Could you tell me, how e.g. a "generator" statement would
> > be distracting?
>
> Sorry, no: Guido pronounced on this, and that's the end of the argument.
When you make a statement in a post, it may be very nice if you could
comment on it.
> It's been debated to death -- see the Python-Iterators list for dozens of
> repetitions of every argument made here (including this one).
>
> > I can't see how a more clearifying statement could possibly distract
> > people.
>
> But it's not really clarifying if it draws a useless distinction .
Cheers, Carsten
--
Carsten Geckeler
From edcjones at erols.com Wed Jun 20 11:45:49 2001
From: edcjones at erols.com (Edward C. Jones)
Date: Wed, 20 Jun 2001 11:45:49 -0400
Subject: function attributes (ANN: Introducing PLY-1.0 (Python Lex-Yacc))
References: <3B306425.1BA938BE@lemburg.com> <15152.40380.99624.826511@gargoyle.cs.uchicago.edu> <3B30A64D.EB779804@lemburg.com>
Message-ID: <3B30C52D.5040009@erols.com>
David Beazley wrote:
> M.-A. Lemburg writes:
> I'd definitely consider using them if they were syntactically
> convenient to use. However, I'm mostly at a loss as to how you
> would actually go about doing that. I suppose you could
> have something like this:
>
> def p_expr_plus(t):
> .gram = 'expr : expr PLUS expr'
> ...
Perhaps "self" could be made a keyword. Then you could say:
def p_expr_plus(t):
self.gram = 'expr : expr PLUS expr'
...
Ed Jones
From bob at passcal.nmt.edu Wed Jun 6 14:57:35 2001
From: bob at passcal.nmt.edu (Bob Greschke)
Date: Wed, 6 Jun 2001 12:57:35 -0600
Subject: Calling a C function that alters the passed argument?
References: <9flmg3$1s4b$1@newshost.nmt.edu> <9flref$ong$1@nntp6.u.washington.edu>
Message-ID: <9fluas$1vve$1@newshost.nmt.edu>
> The last is by far the best, in most cases. The options do not
> include modifying an integer parameter, that isn't how Python works.
I sorta figured that when I couldn't find any examples of it. I've
got a whole library of C functions to write wrappers for that are
basically like this, and they can't be changed. OK, I'll TRY to
EXCEPT your example. :-)
Thanks!
Bob
"Donn Cave" wrote in message
news:9flref$ong$1 at nntp6.u.washington.edu...
> Quoth "Bob Greschke" :
> | Here's the C function I want to call from Python:
> |
> | char *boo(ANumber)
> | int *ANumber;
> | {
> | *ANumber = 42;
> |
> | if (something went wrong)
> | return "An error message";
> |
> | return (char *)NULL;
> | }
> |
> |
> | How would I write the wrapper function for this? All I can find
are
> | examples where the wrapper functions deal with the returned value
from
> | C functions.
>
> Trying to understand your question, the assumption I'm leaning
> towards is that you want the Python function to preserve this API.
> Don't even think about it. Your choices are basically
>
> error, number = boo(), or
> number, error = boo(), or
> try:
> number = boo()
> except SomeError, val:
> print 'boo error', val
>
> The last is by far the best, in most cases. The options do not
> include modifying an integer parameter, that isn't how Python works.
>
> You may want to look at some examples for the way to set an
exception,
> will probably look something like
> PyErr_SetString(PyExc_ValueError, "error message shredded");
>
> Then return 0 to signal the exception, instead of
PyInt_FromLong(number).
>
> Donn Cave, donn at u.washington.edu
From root at rainerdeyke.com Wed Jun 6 23:29:47 2001
From: root at rainerdeyke.com (Rainer Deyke)
Date: Thu, 07 Jun 2001 03:29:47 GMT
Subject: Interesting speed benchmark
References: <3B1D6FED.4070506@nospam.yahoo.com> <3B1EC430.9020201@nospam.yahoo.com>
Message-ID:
"Michael P. Soulier" wrote in message
news:aRBT6.147831$eK2.35759519 at news4.rdc1.on.home.com...
> On Wed, 06 Jun 2001 18:00:48 -0600, Mahesh Padmanabhan
> wrote:
> >
> > Seems like that poster was correct in pointing out that the memory
> > management scheme of Java vs Python makes a difference.
>
> What are the disadvantages of this kind of "lazy garbage collection"?
Basically that you have to do manual resource management for non-memory
resources.
The following function leaks a file handle under Jython but works correctly
under CPython:
def print_file(fname):
file = open(fname)
print file.read()
--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games - http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor
From loewis at informatik.hu-berlin.de Thu Jun 21 09:56:43 2001
From: loewis at informatik.hu-berlin.de (Martin von Loewis)
Date: 21 Jun 2001 15:56:43 +0200
Subject: Packing a long long type
References: <5c8ecb0b.0106191444.53054b47@posting.google.com>
Message-ID:
crj003 at yahoo.com (Rich J) writes:
> Does anyone know how it would be possible to pack a list containing
> 'long long' types (like 111111111111111L) and other standard types
> (int, string, char). I know you can use the struct module to pack all
> but the 'long long'. I also know you can use the xdrlib module to pack
> the 'long long'. Any ideas?
The Python version in the CVS supports a 'q' format, see
http://python.sourceforge.net/devel-docs/lib/module-struct.html
For Python 2.1, you probably need to split the long long into two
longs, and pack them separately. Notice that the order in which to
pack them depends on endianness.
Regards,
Martin
From phd at phd.fep.ru Mon Jun 4 08:10:43 2001
From: phd at phd.fep.ru (Oleg Broytmann)
Date: Mon, 4 Jun 2001 16:10:43 +0400 (MSD)
Subject: MySQL module
In-Reply-To: <3B1B7717.7E53510F@oek.dk>
Message-ID:
On Mon, 4 Jun 2001, Peter I. Hansen wrote:
> What is the recommended module for MySQL ? Is it the MySQL module or the
> MySQLdb module (which is in v. 0.35 !) ? Or is it something completely
> different ?
MySQLdb
Oleg.
----
Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru
Programmers don't die, they just GOSUB without RETURN.
From pythoneer at diganet.com Wed Jun 13 15:13:17 2001
From: pythoneer at diganet.com (John Tobler)
Date: 13 Jun 2001 12:13:17 -0700
Subject: Python Development: San Diego
Message-ID: <711a10e7.0106131113.6d3d4c9b@posting.google.com>
I am compiling a list of companies doing Python software development in the
San Diego, CA, area. If you know of any, please let me know.
John Tobler
grepninja at diganet.com
http://cyberjet.tripod.com/grepninjalog/
PS: I mis-edited this the first time. Sorry.
From jmarshal at mathworks.com Wed Jun 13 08:55:27 2001
From: jmarshal at mathworks.com (Joshua Marshall)
Date: 13 Jun 2001 12:55:27 GMT
Subject: Python grammar..
References:
Message-ID: <9g7nrv$nnb$1@news.mathworks.com>
John Roth wrote:
> So what you're saying is that if I have a function "Spam(eggs, ham) and a
> function
> scramble(, size = small), then I'd have to write
> Spam(scramble(eggs), ham) as
> Spam scramble eggs ham.
> How do I tell that "ham" is an operand of Spam, and not the second operand
> of scramble? The
> only way this could possibly work is if the parser could tell, at compile
> time, exactly how many
> operands each function had. There are languages where this is possible, but
> Python isn't one of them.
Choose a parsing rule and use parens to group things differently.
Python (and many other languages) already need parens to do this for
binary operators ("1-2-3" parses as "(1-2)-3").
So you'd probably have to write "Spam(scramble(eggs), ham)" as
"Spam (scramble eggs) ham".
From db3l at fitlinxx.com Wed Jun 20 16:03:47 2001
From: db3l at fitlinxx.com (David Bolen)
Date: 20 Jun 2001 16:03:47 -0400
Subject: PEP 255: Simple Generators
References: <9gnv2o$its$1@nntp6.u.washington.edu>
Message-ID:
"Russell E. Owen" writes:
(...)
> Since a generator is very different than a function, why not mark it as
> such right up front?
(...)
> I agree that revealing the internal implementation is bad. I disagree
> that return is reasonable, though it is much less of a concern if a
> generator doesn't look like a function right up front.
But isn't a generator really just a function that is returning an
iterator? That is, why is it "very" different from a function,
internal implementation aside, which we agree it's not necessary to
reveal.
If I have a function that returns a sequence, then the caller is free
to iterate over that sequence. A generator returns an iterator for
which the caller is equally able to do so. Or in either case to apply
any other methods that are applicable to the returned object type.
They're a lot more alike than not to my mind - the yield permits the
generator itself to be written more elegantly, but to the caller its
still largely a function that returns an object supporting a
particular interface.
--
-- David
--
/-----------------------------------------------------------------------\
\ David Bolen \ E-mail: db3l at fitlinxx.com /
| FitLinxx, Inc. \ Phone: (203) 708-5192 |
/ 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \
\-----------------------------------------------------------------------/
From sholden at holdenweb.com Tue Jun 26 08:50:59 2001
From: sholden at holdenweb.com (Steve Holden)
Date: Tue, 26 Jun 2001 08:50:59 -0400
Subject: MS SQL Server
References: <51dgjtsbuureuugfcubid11tldg7077sfa@4ax.com>
Message-ID:
"Ben" wrote in ...
> Hi,
>
> Unfortunately I have to upload data to a MS SQL server ... Can anyone
> recommend a tool for doing this or docs\examples :] ... is it ANSI
> SQL compliant like MySQL and therefore can use the same commands?
>
> greatly appreciate any advice
>
Ben:
The easiest way (assuming you have the ability to connect to both databases
from Python, otherwise this would be an off-topic post, woudn't it ;-) is to
do the whole thing in Python.
You don't make it clear whether the data is coming from other relational
sources or from somewhere else. THe principle is the same in either case,
however.
SQL Server is (like most relational systems) ANSI compliant at the lowest
level. Fortunately, since all you need to use is the INSERT statement, this
should be enough.
ODBC is the easiest way to connect to SQL Server, but look at using mxODBC
rather than the currently-disfunctional odbc module form the win32
extensions.
Hope this helps.
regards
Steve
--
http://www.holdenweb.com/
From andy.elvey at paradise.net.nz Sat Jun 9 18:37:16 2001
From: andy.elvey at paradise.net.nz (Andy Elvey)
Date: Sun, 10 Jun 2001 10:37:16 +1200
Subject: Python for win32 development, GUI, Database, dlls
References: <9fnrc8$lmp$1@newnews.mikom.csir.co.za>
Message-ID: <9fu954$1a82$1@raewyn.paradise.net.nz>
One option you may want to check out is ReportLab (which is done in
Python ) - it is free - http://www.reportlab.com
Also , have a look at the data-plotting package DISLIN - free , works with
Python, very good graphics. http://www.dislin.de/
Getting data from Access (using Python) - the O'Reilly book "Python
programming on Win32" has some very useful code in it - chapter 13
(Databases) would be helpful to you ..... :-) . This is a very good book
for anyone using Python on Win32.
Karel van der Walt wrote in message
news:9fnrc8$lmp$1 at newnews.mikom.csir.co.za...
> I have been approached in a 'time to market situation'.
>
> Python appears to me to be a strategic choice, however:
>
> this is a number crunching application most numeric stuff in existing
> (fortran) dll
> the new development will entail a lot of visualization, pseudo GIS like,
> animation (coloring of contours), plain media (digital picures, video) in
> a rich interactive GUI
>
> then all of this data in MS Access (what else?), with reports and graphs
on
> top of it. OK the latter can be in a reportwriter as long as one can call
an
> .exe with commandline parms from python) Integration with MS Office
formats
> (not ole automation) would be important (thus MS Access for imports
> exports).
>
> Any grave misgivings?
>
> Any pointers?
> Commercial libraries? However the exchange rate doesn't favour that :(
>
> tx k
>
>
>
>
>
From jkraska1 at san.rr.com Sat Jun 16 03:24:18 2001
From: jkraska1 at san.rr.com (Courageous)
Date: Sat, 16 Jun 2001 07:24:18 GMT
Subject: qt or gtk?
References:
Message-ID:
On Sat, 16 Jun 2001 05:52:12 GMT, sill at optonline.net (Rainy) wrote:
>
>I want to learn python gui programming in linux. I think tk looks too ugly, so
>I narrowed down the choice to two main contenders, qt and gtk. Which of these
>has more complete and up-to-date python bindings?
Do recall that Qt is only *half* free. It is free for Linux development, but
costs an arm and a leg on Windows.
I might suggest you take a look at WxWindows while you're doing all
this. It has a reasonably elegant interface, IMO. And, like all good things
in life, it's indeed free.
C//
From jramas at acm.org Sat Jun 30 14:48:58 2001
From: jramas at acm.org (Joseph Ramaswami)
Date: Sat, 30 Jun 2001 14:48:58 -0400
Subject: data from Acces to Excel
References: <9hiie0$84o$1@news.tpi.pl>
Message-ID: <9hl6ph$2m5$1@bob.news.rcn.net>
Sure, you can use python to export a table form Access to Excel, but why
would you? It is really simple to export it directly in Access. Just click
on File, Save As/Export in the menu. Choose "To an External File or
Database" and choose the correct file type. You can even script this in VBA
if you have to.
Hope this helps,
JR
"baton" wrote in message news:9hiie0$84o$1 at news.tpi.pl...
> Hi,
> I wonder if there is a possibilyty to export table from Access database to
> Excel using python language?? If yes, could you tell me how to do it or
> where I can find info how to do it?
>
> Sorry for my English
>
>
From anonymous at anonymous.anonymous Tue Jun 26 16:49:32 2001
From: anonymous at anonymous.anonymous (Anonymous)
Date: Tue, 26 Jun 2001 13:49:32 -0700
Subject: the indentaion for grouping thing
References: <3b34de9a$1_2@anonymous> <9h2qpa$6bg$1@slb0.atl.mindspring.net>
Message-ID: <3b38f4a5_1@anonymous>
"Andrew Dalke" wrote in message
news:9h2qpa$6bg$1 at slb0.atl.mindspring.net...
> Use tabnanny, or run Python with the '-t' or '-tt'
> options. If you're worried, force your version
> control system to run a validation on the code
> before checking it in.
Like I said, all answers like "well, just use product x" don't fly because
it's not just me that has to use the script. I want my scripts to be
maintainable by people I don't necessarily know of. I consider it a design
flaw to have the language dependent upon artificial solutions that are
external to the language in order to have it be maintainable.
Anyway, nothing will change, so is there a product like I asked about that
validates and parsers python with paired delimiters added? Not pindent, and
not comments, because the script has to be unparseable by python without the
pre-processor.
--------== Posted Anonymously via Newsfeeds.Com ==-------
Featuring the worlds only Anonymous Usenet Server
-----------== http://www.newsfeeds.com ==----------
From grante at visi.com Fri Jun 22 23:12:08 2001
From: grante at visi.com (Grant Edwards)
Date: Sat, 23 Jun 2001 03:12:08 GMT
Subject: [OT] MS EULA -- (will ActiveState become outlaws? ;-)
References: <3B33F5E9.45730271@student.gu.edu.au>
Message-ID:
On Sat, 23 Jun 2001 11:50:33 +1000, Joal Heagney wrote:
>> No -- it's not the Slashdot Effect (at least in the performance sense).
>> It's been changed to redirect you to a 'page not found' page.
>> They very clearly removed it.
>> Wiser and cooler heads must have prevailed at MS.
>
>They have those?
Yup. They bring them to Bill's office on platters. Later
they're placed on pikes out in front of the building.
--
Grant Edwards grante Yow! -- I have seen the
at FUN --
visi.com
From gmcm at hypernet.com Wed Jun 27 10:40:31 2001
From: gmcm at hypernet.com (Gordon McMillan)
Date: 27 Jun 2001 14:40:31 GMT
Subject: Im running Macmilan Inc's standalone.py and im having a few difficulties finding modules it requires
References: <9hb4st$j5l$1@neptunium.btinternet.com>
Message-ID: <90CD61E25gmcmhypernetcom@199.171.54.194>
G. Willoughby wrote:
>Im running Macmilan Inc's standalone.py and im having a few difficulties
>finding modules it requires, any idea where these modules can be found?
>
>dos
>mac
>nt.stat
>os2
>posix
>strop.lowercase
>strop.maketrans
>strop.uppercase
>strop.whitespace
>ce
>pwd
>MACFS
>macfs
>MacOs
None of these are problems. Some are names in modules
(the strop stuff, for example), the others are
conditional imports that don't apply to your platform.
The warnings are there because it may be the only way
to trace down a missing module. If your code did
sys.path.append('funny dir')
import vitalmodule
Installer would almost certainly miss vitalmodule unless
you doctored PYTHONPATH or used the pathprefix option.
That's because your (byte)code is analyzed (not executed,
which could have too many side effects), and the
manipulation of sys.path won't be recognized.
- Gordon
From gherman at darwin.in-berlin.de Thu Jun 28 03:35:11 2001
From: gherman at darwin.in-berlin.de (Dinu Gherman)
Date: Thu, 28 Jun 2001 09:35:11 +0200
Subject: PEP 260: simplify xrange()
References:
Message-ID: <3B3ADE2F.ED0D5099@darwin.in-berlin.de>
Tim Peters wrote:
>
> >>> print len(frange(0.0, 1.0, 0.1))
> 11
> >>>
>
> That's the kind of "inexplicable" crap we don't want to have to try to
> explain : repeated addition is a Bad Idea for floats.
IMHO this is not Python's fault, and all other languages that
don't rely on some sort of symbolic algebra should show the
same "phenomenon".
> You can improve the numeric quality of the results by generating via
> [...]
> instead (repeated addition accumulates rounding errors without bound; the
> alternative suffers no more than 2 rounding errors (total) for each element
> produced). Then it returns 10 elements in the example above.
This is an obvious improvement - thanks!
Dinu
From m.hadfield at niwa.cri.nz Mon Jun 25 17:50:58 2001
From: m.hadfield at niwa.cri.nz (Mark Hadfield)
Date: Mon, 25 Jun 2001 21:50:58 +0000 (UTC)
Subject: 'with' statement in python ?
References:
Message-ID: <002a01c0fdc0$f17d1af0$d938a8c0@Hadfield>
From: "asgard"
> Hello,
> writing self before every object's method really drives me
> crazy. Shouldn't there be 'with' statement like in Pascal, ie.
There was an extensive discussion on this recently. Perhaps you'd like to
try a search on Google Groups. IIRC the consensus was that adding this to
Python would not be a good idea, because when "with" blocks are nested they
become hard to read and possibly ambiguous.
---
Mark Hadfield
m.hadfield at niwa.cri.nz http://katipo.niwa.cri.nz/~hadfield
National Institute for Water and Atmospheric Research
--
Posted from clam.niwa.cri.nz [202.36.29.1]
via Mailgate.ORG Server - http://www.Mailgate.ORG
From edcjones at erols.com Thu Jun 14 17:22:02 2001
From: edcjones at erols.com (Edward C. Jones)
Date: Thu, 14 Jun 2001 17:22:02 -0400
Subject: Any other Python flaws?
References: <3B2914A0.6010902@erols.com> <9gb6ap$p10$1@news.mathworks.com>
Message-ID: <3B292AFA.6090809@erols.com>
jcm wrote:
> Edward C. Jones wrote:
>
>
>>It follows from some basic concepts of Python that
>> "array = ([0] * 10) * 10"
>>does not behave as usually intended. This is a well-known "dark
>>corner" of Python; a place it is simply best to avoid.
>>
>
> For this example, what would you say people would usually expect?
>
Here is some correct code:
array = [[0] * 3] *3
print array
array[0][0] = 1
print array
The output is:
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
[[1, 0, 0], [1, 0, 0], [1, 0, 0]]
One might expect:
[[1, 0, 0], [0, 0, 0], [0, 0, 0]]
From dgoodger at bigfoot.com Thu Jun 21 20:50:10 2001
From: dgoodger at bigfoot.com (David Goodger)
Date: Thu, 21 Jun 2001 20:50:10 -0400
Subject: PEP 255: Simple Generators
In-Reply-To:
References:
Message-ID:
Generators are very cool. I'm sure I will use them. I'm glad they're getting
into Python. Thank you Neil, Tim, and Magnus, for all your work.
on 2001-06-21 2:57 PM, Tim Peters (tim at digicool.com) wrote:
> a generator-function returns a generator-iterator
That's what it boils down to. Before generators, all functions returned
objects using explicit 'return' statements. Now, generator-functions return
generator-iterators, but there's *nothing* explicitly saying 'return
generator_iterator'. Before generators, calling a function executed its
code. Now, calling a generator-function doesn't execute the code at all; you
have to execute the magically returned object. Only the 'yield' indicates
any of this variant behavior.
Can I get used to it? Yes, I think I have enough spare brain cells. (Heck, I
used to know Perl! ;-)
Should I get used to it?
"Explicit is better than implicit."
--
David Goodger dgoodger at bigfoot.com Open-source projects:
- Python Docstring Processing System: http://docstring.sf.net
- reStructuredText: http://structuredtext.sf.net
- The Go Tools Project: http://gotools.sf.net
From m.faassen at vet.uu.nl Sun Jun 24 14:21:26 2001
From: m.faassen at vet.uu.nl (Martijn Faassen)
Date: 24 Jun 2001 18:21:26 GMT
Subject: Any other Python flaws?
References: <9gr8o8$hhq$4@newshost.accu.uu.nl>
Message-ID: <9h5b36$cg0$2@newshost.accu.uu.nl>
Remco Gerlich wrote:
> Martijn Faassen wrote in comp.lang.python:
>> The PSU Public License is an open source licence even more infectuous
>> than the GPL. Even software that does not link to it must be released
>> under the PSUPL. Even software on a completely different computer,
>> even on a completely different planet. The PSU therefore holds the
>> exclusive rights over very advanced Klingon first person shooters,
>> which will blow away Quake & co in gore and impressiveness when the PSU
>> releases it to the market.
> Is the PSU license TGPLV (Totalitarian GeeInYou-Script Pubic [sic] License
> Virus) compatible?
> (http://catalog.com/hopkins/text/gnuscript.html)
Yes, like all other software, the PSU license causes any TGPLV'ed software
to be PSUPL-ed. Since PSUPL infection proceeds at a rate faster than
that of the speed of light (it even has access to time travel), the PSUPL
will win.
Regards,
Martijn
--
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?
From kkto at csis.hku.hk Sun Jun 17 03:14:34 2001
From: kkto at csis.hku.hk (Isaac To)
Date: 17 Jun 2001 15:14:34 +0800
Subject: Any other Python flaws?
References:
Message-ID: <7izob7o9wl.fsf@enark.csis.hku.hk>
>>>>> "Michael" == Michael Chermside writes:
Michael> Gee... I had no idea this was possible. Surely it's a bad
Michael> idea... right?
I object. Making it otherwise would make the language very inconsistent.
Consider this. How often do you want to name a local variable as "len" in
Python? How about "buffer" or "chr"? Perhaps you never. I do this
regularly, though. I expect that if I don't need to use these built-in
names in a function, I can use the name in whatever way I'd like.
"None" is no different. You are not assigning to the system "None", but
instead you're creating a new local variable called "None". I don't know
why it has anything to do with the global None.
So you can have two different but consistent rules: allow assignments to
variables which have default built-in bindings, and ignore the issue
completely. Python developers like the latter, and so do I. Just think
about what will happen for the first choice. Programmers have to remember
all the built-in names, other than the reserved words. Once a new built-in
name is added, program can break. If you embed Python to make an extended
interpretor, you'll have to think about whether you want to forbid changing
the new built-in names in that extension. And then you get some
inconsistencies either way. I don't like any of these ideas.
If you don't know there is a thing in Python called "None", and thus assign
something as the local value, chances are that your function simply don't
need the global None value, so that assignment is actually quite safe.
Regards,
Isaac.
From jparlar at home.com Tue Jun 19 10:42:13 2001
From: jparlar at home.com (Jay Parlar)
Date: Tue, 19 Jun 2001 10:42:13 -0400
Subject: Simple example that won't work!
Message-ID: <20010619144752.ZCXI7002.femail4.rdc1.on.home.com@jparlar>
>
>> My exact call was
>> retval = urlretrieve(url)[0], where url is any web address.
>
>Some more code would be appreciated, so we don't have to spend time to
>guess anything.
>
>
>--
>Rikard Bosnjakovic - http://bos.hack.org/cv/ - ICQ: 1158217
>
>Anyone sending unwanted advertising e-mail to my address will be
>charged $250 for network traffic and computing time. By extracting my
>address from this message or its header, you agree to these terms.
>--
>http://mail.python.org/mailman/listinfo/python-list
>
Well, I didn't include anymore code because it was really trivial, and I thought the problem could be found from the
exceptions. However, since you asked, I'll paste the code in as well.
from urllib import urlretrieve
from string import strip
def firstnonblank(lines):
for eachLine in lines:
if strip(eachLine) =='':
continue
else:
return eachLine
def firstlast(webpage):
f = open(webpage)
lines = f.readlines()
f.close()
print firstnonblank(lines),
lines.reverse()
print firstnonblank(lines),
def download(url = 'http://www.opera.com:3600',process = firstlast):
print url
retval= urlretrieve(url)[0]
if retval:
process(retval)
def urlEntry():
url2 = raw_input('Please enter the URL')
download(url2,firstlast)
if __name__ == '__main__':
download()
The error, as stated before, occurs on the call to urlretrieve(), and the exception is as follows:
Traceback (most recent call last):
File "C:\Program Files\Python20\Pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript
exec codeObject in __main__.__dict__
File "C:\Program Files\Python20\scripts\grabweb.py", line 37, in ?
download()
File "C:\Program Files\Python20\scripts\grabweb.py", line 23, in download
retval= urlretrieve(url)[0]
File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 68, in urlretrieve
return _urlopener.retrieve(url, filename, reporthook, data)
File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 198, in retrieve
fp = self.open(url, data)
File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 166, in open
return getattr(self, name)(url)
File "C:\PROGRA~1\PYTHON20\LIB\urllib.py", line 267, in open_http
h = httplib.HTTP(host)
File "c:\program files\python20\lib\httplib.py", line 640, in __init__
self._conn = self._connection_class(host, port)
File "c:\program files\python20\lib\httplib.py", line 330, in __init__
self._set_hostport(host, port)
File "c:\program files\python20\lib\httplib.py", line 336, in _set_hostport
port = int(host[i+1:])
ValueError: invalid literal for int():
Hopefully this is enough information now, and thank you to anyone who's looking at this.
Jay P.
From db3l at fitlinxx.com Thu Jun 21 17:16:35 2001
From: db3l at fitlinxx.com (David Bolen)
Date: 21 Jun 2001 17:16:35 -0400
Subject: Getting info on who is using a file on Windows...
References: <4a249347.0106210606.ef3e16a@posting.google.com>
Message-ID:
bobh at hslda.org (Robert) writes:
> I am on a Windows network and I am trying to see who is connected
> to an access database.
>
> I have been perusing the docs but nothing has jumped out and hit me
> in the head.
>
> Any ideas?
If the file is being shared via Windows networking, and you're using
NT/2K servers (not sure about other platforms), then Server Manager
for Domains (srvmgr.exe - installs with server OS versions, also
available in the resource kit) can connect to a machine and give you
information about open files and files in use along with clients.
That assumes that the access database is being accessed at the file
level across the network, and not via some client/server approach
where the actual file access is local on the server (I don't think
that's usual for access, but I don't have much experience with it).
--
-- David
--
/-----------------------------------------------------------------------\
\ David Bolen \ E-mail: db3l at fitlinxx.com /
| FitLinxx, Inc. \ Phone: (203) 708-5192 |
/ 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \
\-----------------------------------------------------------------------/
From cyberlync at yahoo.com Sat Jun 30 10:55:41 2001
From: cyberlync at yahoo.com (Eric Merritt)
Date: Sat, 30 Jun 2001 07:55:41 -0700 (PDT)
Subject: Python compiler
In-Reply-To: <3B3DA2BC.2E52A118@ActiveState.com>
Message-ID: <20010630145541.94405.qmail@web13007.mail.yahoo.com>
>
> That's a strange thing to hold against a language.
> How does it affect
> you? I could build an executable for you in either
> Java or Python that
> was indistinguishable from one that was native code
> compiled without
> disassembling it.
>
> If your complaint is that Java (or Python) is too
> slow, I think you
> should say that. If your complaint is that you can't
> write standalone
> binaries in it (you can), you should say that. I'd
> like to understand
> what you really need so I can tell you whether
> Python has what you need
> or not.
I wasn't trashing java as a language (or python for
that matter) they are both good languages, python
being better in my opinion. My complaint was about
speed. Most of the time the speed of java and python
is adiquate, but sometimes I require speed. Also it
would be nice to get a big speed increase by just
compiling. Anyhow, I did not meen it as a complaint
just a nice thing to have.
>
> Creating a compiler for Python is difficult and as
> it isn't really
> needed to accomplish most people's goals, nobody has
> done it. We could
> put a bunch of effort into it but we'd come back to
> that executable that
> is basically indistinguishable from the one I could
> give you today
> without the compiler.
Thats why I asked. Thanks four your reply.
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/
From qrczak at knm.org.pl Fri Jun 22 14:22:51 2001
From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk)
Date: 22 Jun 2001 18:22:51 GMT
Subject: function attributes (ANN: Introducing PLY-1.0 (Python Lex-Yacc))
References: <3B306425.1BA938BE@lemburg.com> <15152.40380.99624.826511@gargoyle.cs.uchicago.edu> <3B30A64D.EB779804@lemburg.com> <3B30C52D.5040009@erols.com>
Message-ID:
Wed, 20 Jun 2001 11:45:49 -0400, Edward C. Jones pisze:
> Perhaps "self" could be made a keyword. Then you could say:
>
> def p_expr_plus(t):
> self.gram = 'expr : expr PLUS expr'
Would it assign it when the function is defined (not involed)?
I would find it confusing.
Alas, we do want to assign it when the function is defined!
So "something = expr" at the beginning of the function body
is not a good idea.
--
__("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
\__/
^^ SYGNATURA ZAST?PCZA
QRCZAK
From idi.amin at NOFUCKINGSPAMORILLSUEYOURASSfrisurf.no Sat Jun 2 16:31:50 2001
From: idi.amin at NOFUCKINGSPAMORILLSUEYOURASSfrisurf.no (Polterguy)
Date: Sat, 2 Jun 2001 22:31:50 +0200
Subject: best language for 3D manipulation over web ?
References: <9f6i6b$cd5$1@uranium.btinternet.com> <_PBR6.6643$Gf.857002@news20.bellglobal.com>
Message-ID:
[...snip...]
I agree totally, but fact is 99.99999% of the commersial world uses win32.
So why go through the extra trouble adding cross OS programming when it's
going to increase the cost of releasing a product with a factor of 50?!?
All game companies founded on cross OS releases have either gone broke or
are soon to become so!
How much I may hate Bill Gates and that stupid CEO of him who doesn't even
know what HAL means, there's still the facts.
If you want to be successfule and reach 99.9999% of the world use technology
built on win32, DirectX, C++, hell fucking ay, if you can get away with it
use VB!!. Use OBJECT tags in your HTML, use ASP (especially the new ASPX and
the webforms i find XTREMELY interresting...).
This is my opinion and I realize this will probably become my own social
suicide, but fact is that every successfule software dealer don't give a
shit about anything but windows...
...all though it's really sad, and I wish the world was different...
From nas at python.ca Thu Jun 21 16:44:45 2001
From: nas at python.ca (Neil Schemenauer)
Date: Thu, 21 Jun 2001 13:44:45 -0700
Subject: PEP 255: Simple Generators
In-Reply-To: ; from glyph@twistedmatrix.com on Thu, Jun 21, 2001 at 01:59:08PM -0500
References: <20010621083153.A19734@glacier.fnational.com>
Message-ID: <20010621134445.B20524@glacier.fnational.com>
Glyph Lefkowitz wrote:
> Generators solve *some* problems for which synchronous execution is
> desirable, but not others. They change the semantics of function
> definition (despite the BDFL's pronouncement, my favorite piece of python
> zen is still "explicit is better than implicit" ^_^). They add a keyword.
> They do not fill my needs, or the needs of anyone working with simulation
> code, network dispatching, or massively parallel computing; whereas the
> simpler solutions which *do not* add a keyword and *do not* change the
> semantics of function definition can fill the needs of a far greater
> group, as well as the same set that would require generators.
PEP 255 is not intended to solve everyone's problems. It is an
attempt at doing _something_ useful. Is it better to have
generators in Python 2.2 or should we wait indefinately for
microthreads? Even if we do get microthreads I still see the
extra syntax being useful. Have you ever tried implementing
generators using Stackless's continuation primitives? How would
you explain to new users what those magic functions do?
> Stackless is problematic, but I think that an implementation
> similiar to that of generators could give us microthreads.
> When I get back from vacation I'll write up a PEP; if you'd
> like to give me a hand, feel free to drop me an email :)
This would indeed be great news. I've spent quite a bit of time
thinking about this and the stackless approach is best solution I
can think of.
Neil
From tim.one at home.com Mon Jun 18 20:09:11 2001
From: tim.one at home.com (Tim Peters)
Date: Mon, 18 Jun 2001 20:09:11 -0400
Subject: idle BUG
In-Reply-To: <3b2d9e55.354289@nntp.ix.netcom.com>
Message-ID:
[Mike Clarkson]
> ...
> Tim, I know you're very busy these days (learning to sketch? :-), but
> could you examine the MSVC compile and link flags with a microscope
> for similarities and differences between _tkinter.c and tkappinit.c
> and tkAppinit.c for wish.
You might be able to talk Fredrik into that, but I have to pass: we don't
build Tcl or Tk on Windows, we ship the precompiled versions as installed by
the Scriptics tcl832.exe, from
http://dev.scriptics.com/software/tcltk/downloadnow83.html
My knowledge of Tcl + Tk is 0; IOW, if something's wrong there, I wouldn't
notice it if it stuffed a banana up my nose and gave me a dozen roses.
not-a-gui-guy-ly y'rs - tim
From thamza.nospam at flash.net Tue Jun 26 01:29:12 2001
From: thamza.nospam at flash.net (Tim H)
Date: Tue, 26 Jun 2001 05:29:12 GMT
Subject: win32ras on win98?
References:
Message-ID:
A little preemptive replying here. Yes I searched google and there are
several recent threads on this but they all die out with the suggestion to
use a utility like rasdial95, or the NT util rasdial. That's been in my
C:\bin for years and works fine. By the way another neat program like this
is DOS Dial (ddial.exe) which has a little more functionality and can be
scripted a little bit. I'm not affiliated, etc. I'm sure there are others.
But anyway does the win32ras module work on win9x for anybody?
Tim H
From thinkit8 at lycos.com Tue Jun 12 11:39:37 2001
From: thinkit8 at lycos.com (thinkit)
Date: 12 Jun 2001 08:39:37 -0700
Subject: humans and logic
Message-ID: <9g5d3p0f0p@drn.newsguy.com>
humans should use a power of 2 as a base. this is more logical because it
synchs with binary, which is at the very heart of logic--true and false. it is
more natural perhaps, to use decimal--but logic should, and will, win out.
From jwc3f at Virginia.EDU Thu Jun 21 17:15:53 2001
From: jwc3f at Virginia.EDU (Jeffrey W. Collyer)
Date: 21 Jun 2001 21:15:53 GMT
Subject: Thread safety of UDP sendto
Message-ID: <9gto69$ij2$1@murdoch.acc.Virginia.EDU>
An odd question perhaps, but is Python's UDP socket.sendto() thread safe?
I have a multi-threaded app that I would like to send off some UDP packets.
The data for the packets is gathered in each thread. If I get a socket
handle in each thread it will be less efficient than if I open one upon
program start and then have each thread just do an
ubersocket.sendto(data,ADDR). Or am I missing something more basic?
What I really need is an atomic write function that handles threading, but
I'll settle for a cheap UDP solution.
--
peace
Jeffrey W. Collyer
jwc3f at virginia.edu
From loewis at informatik.hu-berlin.de Tue Jun 12 13:35:31 2001
From: loewis at informatik.hu-berlin.de (Martin von Loewis)
Date: 12 Jun 2001 19:35:31 +0200
Subject: localisation of IDLE?
References:
Message-ID:
Roman Suzi writes:
> it turned out that under Windows IDLE doesn't allow
> cyrillic to be print. People pointed me that the
> problem is with TK support for Unicode, which
> broke cyrillic support.
>
> Is there some edit-the-registry, tweek-Windows solution
> to this problem (that is, solution, which doesn't
> require to change files from Python distribution?
I believe setting the default encoding in site.py should do the trick.
Regards,
Martin
From ullrich at math.okstate.edu Mon Jun 4 10:17:45 2001
From: ullrich at math.okstate.edu (David C. Ullrich)
Date: Mon, 04 Jun 2001 14:17:45 GMT
Subject: random
References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com> <3b19393d.703539923@news.okstate.edu> <3B1ADE2D.A6E86ECE@san.rr.com>
Message-ID: <3b1b978e.3996421@nntp.sprynet.com>
On Mon, 04 Jun 2001 01:02:37 GMT, Darren New wrote:
>"David C. Ullrich" wrote:
>
>> That's assuming that physics is not all wrong. And
>> probably I should not have said what I did the
>> way I did, because my impression is that there
>> is really no such thing as complete information
>> about a physical system.
>
>Last I heard, the "hidden variable" theory was disproved by the Bell
>Inequality. I.e., there's no information in a system that is just
>invisible but really controlling when the atom will decay. Instead, that
>information just isn't there. Apparently, you can actually do
>experiments to tell the difference.
Boggle indeed. Actually the "no-hidden-variables theorem" goes
back to before Bell (I think to VN); coming up with that
inequality and the experiment to test it was kind of incredible.
I forget where I saw this:
"Quantum Mechanics: The dreams stuff is made of."
>Darren New / Senior MTS & Free Radical / Invisible Worlds Inc.
> San Diego, CA, USA (PST). Cryptokeys on demand.
> This is top-quality raw fish, the Rolls-Rice of Sushi!
David C. Ullrich
*********************
"Sometimes you can have access violations all the
time and the program still works." (Michael Caracena,
comp.lang.pascal.delphi.misc 5/1/01)
From daniels at mindspring.com Tue Jun 5 23:01:00 2001
From: daniels at mindspring.com (Alan Daniels)
Date: Tue, 05 Jun 2001 23:01:00 -0400
Subject: Bios calls in Python?
References:
Message-ID:
On Tue, 5 Jun 2001 19:46:28 -0400, Humanity let out a collective sigh
of relief when "Bill Walker" finally typed:
>Is it possible to make BIOS calls in Python (Windows version)? In
>particular, I would like to plot graphic points in EGA resolution to the
>console screen.
Depending on the version of Windows, I don't believe direct BIOS calls
to the screen are possible any longer, unless you're writing a device
driver (and that's one of the few programming tasks Python can't do).
You *could* call DirectX via Python's COM library, but unless you
already know DirectX, it would take forever to learn.
Your best option is to go get SDL (Simple DirectMedia Layer, at
http://www.libsdl.org), which, while not perfect or even 100% complete
yet, has Python bindings and lets you draw directly to the screen.
==============================
Alan Daniels
daniels at alandaniels dot com
From greg at cosc.canterbury.ac.nz Wed Jun 6 01:47:07 2001
From: greg at cosc.canterbury.ac.nz (Greg Ewing)
Date: Wed, 06 Jun 2001 17:47:07 +1200
Subject: I had a thought ... (I know, call the newspapers).
References: <9f5nhn02816@enews2.newsguy.com> <9fb78v$qf5$1@216.39.170.247>
Message-ID: <3B1DC3DB.A9F38F4C@cosc.canterbury.ac.nz>
David LeBlanc wrote:
>
> Currency might be a comfortable metaphor for people,
> especially accounting types who probably think a number is naked without
> a currency symbol.
But you need *some* numbers other than currency.
If I buy 3 widgets at $1.23 each I'm spending
3 * $1.23, not $3 * $1.23, which would give a
result in square dollars.
I don't know what square dollars look like,
but I'm sure my bank wouldn't accept them...
--
Greg Ewing, Computer Science Dept, University of Canterbury,
Christchurch, New Zealand
To get my email address, please visit my web page:
http://www.cosc.canterbury.ac.nz/~greg
From scarblac at pino.selwerd.nl Wed Jun 20 02:36:22 2001
From: scarblac at pino.selwerd.nl (Remco Gerlich)
Date: 20 Jun 2001 06:36:22 GMT
Subject: RFD comp.lang.python.zope & ZPugDC Meeting Tomorrow
References:
Message-ID:
Chris Abraham wrote in comp.lang.python:
> I have two sort notes. First one is I would like to test the waters
> before I take the initiative to put a proposal together for a newsgroup
> for Zope.
I suppose it's more useful to test waters on the Zope mailing list, but then
it's almost certain that this group would get loads of votes.
> I envision this to be a subgroup of comp.lang.python,
> comp.lang.python.zope. As Zope is really an application made of python,
> just as Mason is of Perl and Midgard is of PHP and Enhydra is of Java,
> methinks this is appropriate.
I'm not sure. Just that it's written in Python doesn't seem very relevant,
and it can be extended in Perl now as well. Other options would be
comp.soft-sys.zope or comp.infosystems.www.appservers.zope or something like
that. If you want a smooth news.groups discussion (is that even possible
these days?), at least try to give more explanation why your name is better
in the RFD :).
Would the group mirror the Zope list the way comp.lang.python and the
mailing list do?
Anyway, I'd like to see it happen. Comp.lang.python is a very busy group,
but splitting it won't work well. Maybe the best way is to make some of the
mailing lists into newsgroups, and Zope is obviously big enough.
--
Remco Gerlich
From greg at cosc.canterbury.ac.nz Thu Jun 21 01:12:38 2001
From: greg at cosc.canterbury.ac.nz (Greg Ewing)
Date: Thu, 21 Jun 2001 17:12:38 +1200
Subject: PEP 255: Simple Generators
References:
Message-ID: <3B318246.6E4FD8AA@cosc.canterbury.ac.nz>
Tim Peters wrote:
>
> Since generators produce an iterator
> object, you can very easily tie your head into knots already, if you're
> determined to.
And glossing over the mechanism by which they're produced
makes it even easier!
--
Greg Ewing, Computer Science Dept, University of Canterbury,
Christchurch, New Zealand
To get my email address, please visit my web page:
http://www.cosc.canterbury.ac.nz/~greg
From aleaxit at yahoo.com Wed Jun 6 12:23:17 2001
From: aleaxit at yahoo.com (Alex Martelli)
Date: Wed, 6 Jun 2001 18:23:17 +0200
Subject: random
References: <3b1cf00f.5441109@nntp.sprynet.com> <3b1e43f4.1661099@nntp.sprynet.com>
Message-ID: <9flldm01o6s@enews2.newsguy.com>
"David C. Ullrich" wrote in message
news:3b1e43f4.1661099 at nntp.sprynet.com...
...
> I didn't bother mentioning the semantics before getting straight
> whether the syntax counted as "self-delimiting". It is very
> easy to design a Turing-complete programming language where
> the syntactically valid programs are exactly the bitstrings
> consisting of all 0's terminated by a 1. Assunming that
If so, then the set of Turing-machine program must be
enumerable (alpha-0). But is it?
> "arbitrary binary data" means only finitely much binary
> data that's no problem.
I think there is the rub.
What I find in the "Stanford Encyclopedia of Philosophy", e.g:
"""
A Turing machine is an abstract representation of a computing
device. It consists of a read/write head that scans a (possibly
infinite) two-dimensional tape divided into squares, each of
which is inscribed with a 0 or 1. Computation begins with the
machine, in a given "state", scanning a square. It erases what
it finds there, prints a 0 or 1, moves to an adjacent square,
and goes into a new state. This behavior is completely determined
by three parameters: (1) the state the machine is in, (2) the number
on the square it is scanning, and (3) a table of instructions. The
table of instructions specifies, for each state and binary input,
what the machine should write, which direction it should move in,
and which state it should go into. (E.g., "If in State 1 scanning
a 0: print 1, move left, and go into State 3".) The table can list
only finitely many states, each of which becomes implicitly defined
by the role it plays in the table of instructions. These states are
often referred to as the "functional states" of the machine.
"""
Finite-state machine at the 'core', infinite tape (sorry I
used more than two tape symbols in my previous post and
assumed an 'output' that was not to the tape itself, but
I believe it's easily proved that you can map any finite
number of tapesymbols to two, and use [e.g] even squares
of the tape as 'input' aka 'program' and odd ones for
'output', etc, etc). This is the TM (not yet necessarily
Universal, all depends on that FSM at the core) as I
recalled it, after lo these many years...
[E.g. to treat even and odd squares differently you "just"
have to split the core FSM appropriately, so it 'remembers'
whether it's on an odd or even square of the tape -- that
is just one bit so at most it doubles the FSM's states --
doing it all with 0 and 1 is unwieldy but you can move
to any finite number of symbols by using N squares with
0 and 1 to represent up to 2**N distinct symbols and
complicating the FSM accordingly -- etc, etc... but of
course it's possible to slip in one of these "etc"s:-)]
Alex
From jochen at riekhof.de Thu Jun 14 07:59:53 2001
From: jochen at riekhof.de (Jochen Riekhof)
Date: Thu, 14 Jun 2001 13:59:53 +0200
Subject: substitute for c/java's ?:
References:
Message-ID: <9ga8ue$7aj$07$1@news.t-online.com>
> Trust me, this is true.
Nope.
haha, the usual examples that shall prove how great one's favorite language
is. During the many years of programming I finally
managed to drop the evangelism (am, well... almost ;-). I can encourage
everyone to do the like, as one lives more comfortable and has a greater
chance to be unbiased.
The longish java code can e.g. be rewritten as
/**Utility which returns 'a' or 'an' for a given noun. */
public static final String aan(String name) {
return ("aeiou".indexOf(name.toLowerCase().charAt(0)) < 0) ? "a" :
"an";
}
which, compared to
def aan(name):
"""Utility which returns 'a' or 'an' for a given noun.
"""
if string.lower(name[0]) in ('a','e','i','o','u'):
return 'an '
else:
return 'a '
is not all that bad ;-). Of course you can use if else you like this better.
In particular this is not my favourite use of ?:, I would probably have used
if/else as well here..
But there is often the need to assign one of two values depending on a
simple condition.
if a == 0: result = value1
else: result = value2
This is more readable and faster to understand (just because there is less
code) with ?:.
result = (a == 0) ? value1 : value2;
This is especially important when result is a more longish expression.
With only moderate experience the meaning is clear at a glance. For this
cases I miss ?:. Just my opinion ;-)
What do you think?
Neil and Remco wrote:
>cases = {"dog": Dog, "cat": Cat, "rabbit": Rabbit}
>
> def createPet(type="cat"):
> if casses.has_key(type): return casses[type]() #Good input...
> else: return None # bad input, or 'default' in C/java
Nice trick!
>result = option and value1 or value2
also nice, almost forgot about this feature (result is last evaluated code)!
Thanks!
Ciao
...Jochen
From frank at opticode.co.za Sat Jun 16 04:43:17 2001
From: frank at opticode.co.za (Frank Conradie)
Date: 16 Jun 2001 01:43:17 -0700
Subject: ihooks or imputil?
Message-ID: <233dd1ac.0106160043.5e4bd1a5@posting.google.com>
Hi there
I've searched the archives for everything on custom importers that I
could find, and there seems to be two ways to create them: ihooks or
imputils.
Can anybody please tell me which is the "preferred" or "official" way
to create custom importers, and where I can find *recent* example code
or documentation?
Thanks,
Frank
From ullrich at math.okstate.edu Mon Jun 4 14:53:48 2001
From: ullrich at math.okstate.edu (David C. Ullrich)
Date: Mon, 04 Jun 2001 18:53:48 GMT
Subject: random
References:
Message-ID: <3b1bd138.873545372@news.okstate.edu>
On Sun, 3 Jun 2001 18:14:47 -0400, "Tim Peters"
wrote:
>[David C. Ullrich]
>> ...
>> Not that readers are likely to be reading carefully enough that it's
>> going to matter, but just for the sake of telling no lies: I put
>> my finger on what was bothering me about what I said here.
>> It's not true that the sequence of bits of Omega is recursively
>> enumerable. What's true (assuming that the N-th bit is 1 if the
>> N-th program halts and 0 otherwise) is that the sequence of N
>> for which the N-th bit is 1 is recursively enumerable. The
>> set of N for which the N-th bit is 0 is _not_ recursively
>> enumerable (and hence the sequence of bits of Omega is not
>> recursively enumerable.)
>
>It's the "assuming that the N-th bit is 1 [iff] the N-th program halts"
>that's off. Omega is the probability that "a random" program halts, and it
>won't take long to figure out that "N'th-bit = halts(N-th program)" doesn't
>work for that
Drat. I looked, and of course I did in fact have the definition
bollixed - the method he uses to "generate a program by coin-tossing"
is not what I recalled. We _do_ need a definition of "random
program", and he does give one, but it's not what I thought it
was.
So much of what I said just now about Omega is not correct.
But otoh it's because I mis-recalled the definition of
"generate a program by coin tossing". It is _not_ true that
it doesn't take long to figure out that "n-th bit = 1 iff
n-th TM halts" cannot give the probability that a random
TM halts - the following parenthetical comment cannot
show that Omega could not be what I thought, because
you don't use anything about the particular distribution
Chaitin uses, and with _some_ distributions Omega
_would_ be as I said.
Or to put it another way:
> (e.g., if the 0'th program happens to halt, that would imply
>the halting probability is >= 1/2 across all programs -- but the 0'th
>program isn't generally that smart ).
Nope - this sounds good but it's specious. With the distribution
I thought Chaitin was using it _would_ follow that Omega > 1/2
if the 0-th program happened to halt, and with the distribution
he _does_ use things that are equally winkie-sounding _do_
follow: Pick a program that does happen to halt. If that program
is K bits long then the fact that that particular program halts
_does_ show that Omega > 2^{-K}. That program happens to
be smart enough to imply that the halting probability is
larger than something - with a different distribution it would
just imply that the halting probability is larger than a different
thing.
So I lied, but it's not as obvious as you say that my lie
_must_ have been wrong - as long as we're just talking
about "a random program" without specifying the
distribution what I said could have been right regardless
of questions of how smart the first program is.
I guess I was misled by his display
W = å p halts 2 -|p|
which certainly looks like the binary expansion of a number if you
don't look closely - each program that halts adds a power of
2 to the probability, just like in
W = å pj halts 2
-j
That's the best excuse I can contrive. Oh well.
Thought I had the problem of inexact floating point solved.
David C. Ullrich
***********************
"Sometimes you can have access violations all the
time and the program still works." (Michael Caracena,
comp.lang.pascal.delphi.misc 5/1/01)
From phrxy at csv.warwick.ac.uk Fri Jun 29 15:48:42 2001
From: phrxy at csv.warwick.ac.uk (John J. Lee)
Date: Fri, 29 Jun 2001 20:48:42 +0100
Subject: noncommercial Python+QT on Windows? (was Re: qt or gtk?)
In-Reply-To:
References: <9gk8he$8gl$1@brokaw.wa.com> <16074dce.0106181045.139d80a5@posting.google.com> <3b3b40a0@news.uia.ac.be> <9hfjho05to@enews1.newsguy.com>
Message-ID:
On Fri, 29 Jun 2001, Toby J Sargeant wrote:
> On Thu, Jun 28, 2001 at 05:47:03PM +0200, Alex Martelli wrote:
> > Very interesting -- NOW, is there a way one can develop Python
> > software, cross-platform, using Qt, and redistribute it: legally,
> > for free and with sources?
>
> You should have a look at PyQt. For some reason it's relatively
> unknown,
Isn't PyQt what he was referring to? Maybe I misunderstood...
> PyQt should also be available for mac development, given that Qt is free
> for the mac as well, but I don't think I've ever heard of anyone trying
> to build it there.
Hasn't been released yet, and will only be available for MacOS X. I don't
think Trolltech has stated what the license options will be.
John
From tdelaney at avaya.com Fri Jun 29 00:57:07 2001
From: tdelaney at avaya.com (Delaney, Timothy)
Date: Fri, 29 Jun 2001 14:57:07 +1000
Subject: list of lists, object doesn't support item assignment?
Message-ID:
> >>> xy = (1,2),(2,2)
> >>> print xy, xy[0]
> ((1, 2), (2, 2)) (1, 2)
> >>> xy[1]=(3,4)
> TypeError: object doesn't support item assignment
>
> Is there a way to assign the list (3,4) to an element of xy?
> What am I missing?
Quite simple: (1,2) or 1,2 is not a list, but a tuple. Tuples are immutable.
Lists are created with square backets. Try this:
xy = [(1,2),(2,2)]
print xy, xy[0]
xy[1] = (3,4)
Tim Delaney
From michael at trollope.org Sat Jun 23 14:26:21 2001
From: michael at trollope.org (Michael Powe)
Date: 23 Jun 2001 11:26:21 -0700
Subject: namespace issue?
References: <87k825ljrz.fsf@elbereth.ccraig.org> <87wv64hg87.fsf@elbereth.ccraig.org>
Message-ID: <87ae2z2gtu.fsf@cecilia.trollope.org>
>>>>> "Christopher" == Christopher A Craig writes:
Christopher> Michael Powe writes:
>> Actually, it doesn't contain the dash. The dash is only
>> inserted if I press the enter key, leaving the PN string empty.
>> In the case of an
Christopher> I see that now. I was really only paying attention
Christopher> to the conditional...
>> So now the question is, 'why'? Am I misusing the string.find()
>> function? Okay, string.find() returns -1 when the string is not
>> found, which would seem to be what I expected, a false result.
>> Maybe python doesn't treat -1 as false? Well, I'll try being
>> explicit and testing for -1 return. I probably have just
>> confused myself hopelessly.
Christopher> As others have pointed out, -1 is not false in
Christopher> Python. I would highly recommend you (and anyone
Christopher> else just learning the language) read section 2
Christopher> (Built-in types) of the Library reference thoroughly.
Christopher> There is a lot of very useful information on how
Christopher> builtin types and functions work in there.
Thanks, I'll take a closer look. I've only looked at it piecemeal,
trying to work things out.
Christopher> More importantly though your code (which I quote
Christopher> below for readability), does not initialize Ph if the
Christopher> conditional is false. Even if you fix the logic
Christopher> error in the code, you are left with something that
Christopher> possibly returns an uninitialized value, which is bad
Christopher> practice. I presume that you want the program to
Christopher> return a value even when that condition is false, so
Christopher> you should have an else clause. If you want an error
Christopher> condition to occur when the condition is false then
Christopher> you should assert() the condition.
Right. The end result looks like this:
def GetPhone():
CC = raw_input("Country Code (ENTER for none): ")
AC = raw_input("Area Code: ")
PN = raw_input("Phone Number: ")
if not AC : AC = '503'
if not PN : PN = '000-0000'
i = string.find(PN, '-')
if len(PN) < 8 and i == -1 :
Ph = '(' + AC + ') ' + PN[:3] + '-' + PN[3:]
elif len(PN) >= 8 and i == -1 :
Ph = CC + " " + PN[:4] + '-' + PN[4:]
else :
Ph = AC + PN
return Ph
That seems to be working. Obviously, I don't have any errorchecking
yet. Functionality first.
Thanks for the help, I appreciate it.
mp
--
Michael Powe Portland, Oregon USA
'Unless we approve your idea, it will not be permitted, it will not be
allowed.' -- Hilary Rosen, President, Recording Industry Association
of America
From not.this at seebelow.org Wed Jun 27 23:44:45 2001
From: not.this at seebelow.org (Grant Griffin)
Date: Wed, 27 Jun 2001 22:44:45 -0500
Subject: Check out O'Reilly's Open Source Convention Highlights
References:
Message-ID: <3B3AA82D.1A0FE860@seebelow.org>
Guido van Rossum wrote:
>
> I promise this is a one-time ad! Check out the Python track:
>
> http://conferences.oreillynet.com/cs/os2001/pub/w/os2001/sessions_python.html
Durn--it's in California. Why aren't these things ever held in the
Midwest?--it's centrally located, ya' know.
must-be-some-kindda-darn-conspiracy-for-you-East-Cost-folks-to
-rack-up-frequent-flyer-miles--ly y'rs,
=g2
--
_____________________________________________________________________
Grant R. Griffin g2 at dspguru.com
Publisher of dspGuru http://www.dspguru.com
Iowegian International Corporation http://www.iowegian.com
From menscher+python at uiuc.edu Fri Jun 8 14:37:30 2001
From: menscher+python at uiuc.edu (Damian Menscher)
Date: Fri, 08 Jun 2001 18:37:30 GMT
Subject: run function in background?
Message-ID:
Is there a way to run a function in python in the background?
Ideally I'd want something like
def my_func(params):
stuff here
for i in range(10):
print "starting a process"
my_func(params) &
where the & indicates that shouldn't stop the flow of the program,
so the loop would continue and have all 10 go simultaneously.
(Doing this using map() won't work for me, since my actual problem
is a bit more complex.)
Email replies appreciated, since I check email more often than news.
Damian Menscher
--
--==## Grad. student & Sys. Admin. @ U. Illinois at Urbana-Champaign ##==--
--==## www.uiuc.edu/~menscher/ Ofc:(217)333-0038 ##==--
--==## Physics Dept, 1110 W Green, Urbana IL 61801 Fax:(217)333-9819 ##==--
From uioziaremwpl at spammotel.com Wed Jun 27 15:08:50 2001
From: uioziaremwpl at spammotel.com (Carsten Geckeler)
Date: Wed, 27 Jun 2001 21:08:50 +0200 (CEST)
Subject: PEP 260: simplify xrange()
In-Reply-To: <3B3A1DC0.3583E9D8@ccvcorp.com>
Message-ID:
On Wed, 27 Jun 2001, Jeff Shannon wrote:
[snip]
> To make a long story short, the discussion regarding FP boils down to the
> fact that "1.0" cannot be exactly represented in FP.
Well, 1.0 *can* be represented exactly in floating point. Even 0.5.
>>> 0.5
0.5
>>> 1.0
1.0
>>> 0.1
0.10000000000000001
>>> 438.9375
438.9375
>>> 438.937
438.93700000000001
>>> 438.9374
438.93740000000003
Now can think about the reason, why some real numbers can be represented
exactly in FP, and some not. ;)
Cheers, Carsten
--
Carsten Geckeler
From nhodgson at bigpond.net.au Tue Jun 19 22:16:39 2001
From: nhodgson at bigpond.net.au (Neil Hodgson)
Date: Wed, 20 Jun 2001 02:16:39 GMT
Subject: Re. PythonCard - was Re: Event-driven GUIs ...
References: <73PX6.317$zE1.418988@news.uswest.net> <3B2FE2BD.F210FA8A@home.net> <3B2EA829.39DE6527@earthlink.net>
Message-ID:
Ron Stephens:
> (from SourceForge)
>
> """A card file program (in the spirit of Apple's HyperCard) designed to
> store and search thousands of cards
> containing megabytes of
> text. Uses gzip to compress text.
Uses
> superimposed coding
> (signature file indexing) for fast
> searching. Written in Python"""
One of the most hyped aspects of HyperCard initially was its text
searching feature which used content hints (I imagine a form of lossy/fuzzy
hashed index) to allow fast searching in many cases without the storage
overhead of complete indexing.
Neil
From kamikaze at kuoi.asui.uidaho.edu Sat Jun 2 13:41:09 2001
From: kamikaze at kuoi.asui.uidaho.edu (Mark 'Kamikaze' Hughes)
Date: 2 Jun 2001 17:41:09 GMT
Subject: random
References: <3b17a2f1.411766@nntp.sprynet.com> <9f8f4l0hss@enews1.newsguy.com> <3b17ed86.19508127@nntp.sprynet.com> <9f96f501mkc@enews1.newsguy.com> <3b18ea18.332276@nntp.sprynet.com> <9fb0ju01a8a@enews2.newsguy.com>
Message-ID:
Sat, 2 Jun 2001 17:28:22 +0200 in <9fb0ju01a8a at enews2.newsguy.com>,
Alex Martelli spake:
> "David C. Ullrich" wrote in message
> news:3b18ea18.332276 at nntp.sprynet.com...
>> Probably "is in a state of sin" is not well-defined.
> Presumably was meant as a humorous quip?
IIRC, JVN wrote that in a paper on arithmetic methods of generating
pseudo-random numbers, so the word you're grasping for is "ironic".
>> I take the comment to mean that there is no "percect"
>> arithmetical RNG. It seems extremely clear to me that
>> there isn't, and I haven't heard anything that explains
>> how Chaitin's work _does_ show that there exists
>> a perfect arithemtical RNG.
> I'm not sure what you mean by "perfect" (or "percect" --
> not sure if that was a typo, and if so, whether it was for
> 'percept' or 'perfect'). If you mean one requiring an
> infinite amount of information for prediction,
A true random number generator is not one that requires an infinite
amount of information to predict, it is one that is *impossible* to
predict, regardless of how much information you have.
Anything else is a pale substitute. You can have pseudo-random
algorithms with varying degrees of randomness, but they are ultimately
predictable.
Now, if Chaitin's come up with a better PRNG, that's fine work, and
could be very useful. But he's still "in a state of sin", because it
isn't truly random.
> Meanwhile I still see nothing 'sinful' in dealing with
> randomness finitely,
It's simple. If you have a pseudo-random number generator, you will
eventually repeat, and other people, given the right information, can
duplicate your random numbers. This is, to put it mildly, not a good
thing (the word "catastrophic" comes to mind in crypto applications).
--
Mark Hughes
"I will tell you things that will make you laugh and uncomfortable and really
fucking angry and that no one else is telling you. What I won't do is bullshit
you. I'm here for the same thing you are. The Truth." -Transmetropolitan #39
From john.thai at dspfactory.com Thu Jun 7 11:09:30 2001
From: john.thai at dspfactory.com (John)
Date: Thu, 7 Jun 2001 11:09:30 -0400
Subject: py2exe -i list
Message-ID:
Hi,
What is the syntax for the -l option for py2exe? When I try :
python setup.py py2exe -i "foo.lib.x"
This works. But when I add another module like so:
python setup.py py2exe -i "foo.lib.x, foo.lib.y"
It complains that there is no module named foo....
Thanks,
John
From aahz at panix.com Mon Jun 18 10:05:36 2001
From: aahz at panix.com (Aahz Maruch)
Date: 18 Jun 2001 07:05:36 -0700
Subject: locking dictionaries (was Re: New statement proposal for Python)
References:
Message-ID: <9gl1rg$p45$1@panix2.panix.com>
In article ,
Tim Peters wrote:
>
>One concern: since dicts are crucial to Python's performance, we're loathe
>to add any code to their critical paths, or more memory to the object.
>Indeed, I spent a fair chunk of my life reducing the internal dict bloat
>after 2.1 was released, and we got some nice speedups in return.
OTOH, there's been some discussion of locking dicts during certain
operations to prevent some ugly bugs and crashes. Given the amount of
code simplification that would generate overall, would it maybe make
sense to add an external interface to the locking mechanism?
--
--- Aahz <*> (Copyright 2001 by aahz at pobox.com)
Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista
"It's not what you know, it's what you *think* you know." --Steve Martin
From nas at python.ca Tue Jun 19 23:27:17 2001
From: nas at python.ca (Neil Schemenauer)
Date: Tue, 19 Jun 2001 20:27:17 -0700
Subject: How do I access the last "un-caught" variable in the interpreter?
In-Reply-To: <39503ed5.0106191912.5b054b42@posting.google.com>; from danielm@cronus.res.cmu.edu on Tue, Jun 19, 2001 at 08:12:16PM -0700
References: <39503ed5.0106191912.5b054b42@posting.google.com>
Message-ID: <20010619202717.A15689@glacier.fnational.com>
Dan Moskowitz wrote:
> Pretty simple question:
>
> >>> 2+2
> 4
> >>> # can i access the 4 if i didn't catch it in a var?
>>> _
4
From bokr at accessone.com Fri Jun 15 18:59:28 2001
From: bokr at accessone.com (Bengt Richter)
Date: Fri, 15 Jun 2001 22:59:28 GMT
Subject: Any other Python flaws?
References: <#72#QIT9AHA.262@cpmsnbbsa09>
Message-ID: <3b2a7edd.586265184@wa.news.verio.net>
On Thu, 14 Jun 2001 20:26:10 -0400, "Steve Holden"
wrote:
[...]
>Despite the fact that our Fearless Leader and BDFL has already revered
>himself once on this issue, I'd like to see strict syntactical equity
>between function definitions and class definitions, which is to say that a
>class with no superclasses should be declarable as:
>
> class myClass():
> pass
Why not the other way around? I.e., drop the mandatory "()"
for function defs with no args. A bare 'foo' could still
evaluate to and foo() would do
what it does now.
You could consider '()'-less execution like Pascal, if you
could define a reasonable "__"-ism to condition the definition
of the function for that.
I sort of like the idea of a symbol being able to yield a string
transparently either by plain dereferencing or by having a
function produce it, without any difference in the expression.
Of course, you'd need some kind of quote function if you
wanted to bind another symbol to the function object iself.
From mlh at idi.ntnu.no Thu Jun 7 14:14:00 2001
From: mlh at idi.ntnu.no (Magnus Lie Hetland)
Date: Thu, 7 Jun 2001 20:14:00 +0200
Subject: Dictionary comprehension
Message-ID: <9fog99$gis$1@tyfon.itea.ntnu.no>
It seems to me that dictionary comprehension (in exactly
the same style as list comprehension [1], and as proposed
for set comprehension [2]) might be useful, and I wondered
if anyone else agreed (and perhaps if work had already
been done on this, or if it has already been discussed
somewhere...)
While list comprehension works like this
[expr for var1 in seq1 for var2 in seq2 ... if bool]
set comprehension will (if approved) work in the same manner,
except with curly braces:
{expr for var1 in seq1 for var2 in seq2 ... if bool}
My suggestion for dictionary comprehension syntax is (IMO)
obvious:
{expr1:expr2 for var1 in seq1 for var2 in seq2 ... if bool}
where expr1 is the key corresponding to expr2. Duplicate
keys will overwrite earlier ones, the order being uniquely
determined by the generator part (for var in seq ...).
Any thoughts? Should a PEP be written, or is this just an
Evil(tm) idea? If nothing else, it would give a simple
solution to the frequently asked question "how to I invert
a dictionary (with unique values)?":
inverted = {dict[key]:key for key in dict}
or possibly faster (I don't really know):
inverted = {val:key for key, val in dict.iteritems()}
(assuming that the new dictionary iteration syntax will
make its way into 2.2...)
[1] http://python.sourceforge.net/peps/pep-0202.html
[2] http://python.sourceforge.net/peps/pep-0218.html
--
Magnus Lie Hetland http://www.hetland.org
"Reality is that which, when you stop believing in
it, doesn't go away." -- Philip K. Dick
From Randy.L.Kemp at motorola.com Thu Jun 7 12:04:18 2001
From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971)
Date: Thu, 7 Jun 2001 12:04:18 -0400
Subject: Windows editor?
Message-ID:
Thanks. I hope I didn't send the poor guy to one of those XXX entertainment
sites by mistake.
-----Original Message-----
From: Keith Woeltje [mailto:kwoeltje at mail.mcg.edu]
Sent: Thursday, June 07, 2001 10:04 AM
To: python-list at python.org
Subject: Re: Windows editor?
actually the URL is http://www.ultraedit.com/
>K
Kemp Randy-W18971 wrote:
> Ultra Edit (www.ultra.com) with the macro extension developed for Python
is
> great, and only $30. You have to download the free Python, macro
extension.
>
> -----Original Message-----
> From: Wolfgang Lipp [mailto:castor at snafu.de]
> Sent: Wednesday, June 06, 2001 6:36 PM
> To: python-list at python.org
> Subject: Re: Windows editor?
>
> > > > > >What's a good Python editor for programming under Windows,
> specifically
> > > > > >Windows 2000? According to Google archives it seems this
question
>
> try www.textpad.com
>
> -wolf
From eppstein at ics.uci.edu Fri Jun 15 15:00:45 2001
From: eppstein at ics.uci.edu (David Eppstein)
Date: Fri, 15 Jun 2001 12:00:45 -0700
Subject: coroutines?
Message-ID:
I'm working on writing a prog (using W windowing in MacPython) that handles
a list of items. For each item, it needs to open a dialog and gather some
user information. So, the natural way to structure it is
for each item in list: handle dialog
I guess it would be possible to run that way in a separate application, by
setting up a new instance of W every time, but that wouldn't allow me to
reuse windows and wouldn't work well when running interactively in the IDE.
Instead, what it looks like I would end up doing is to have a queue of list
items sitting around somewhere, and (whenever the ok button of my dialog is
pressed) go on to the next item and reset all the windowing objects. Which
would work, but is logically upside-down.
What I really want is coroutines. That way I could have my outer structure
be
for each item in list: set up dialog then coreturn to W
while the "ok" button of the dialog would simply coreturn to this loop.
The last time I was actually able to write a coroutine was 15 years ago
when I was programming assembler. Most modern languages don't have them.
Threads are not really an appropriate substitute. But I'm new to Python,
and maybe it has something the other languages don't have. Is there a
clean way to do coroutines in Python?
--
David Eppstein UC Irvine Dept. of Information & Computer Science
eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/
From emile at fcfw.fenx.com Tue Jun 26 08:22:47 2001
From: emile at fcfw.fenx.com (Emile van Sebille)
Date: 26 Jun 2001 07:22:47 -0500
Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Jun 26)
Message-ID:
Guido announces the release of Python 2.0.1, a maintenance release
with a revised license that is GPL compatible.
http://groups.google.com/groups?ic=1&q=msgid:mailman.993230040.28120.python-list at python.org
Andrew MacIntyre releases an OS/2 port of python 2.1.
http://groups.google.com/groups?ic=1&q=msgid:mailman.992804846.18097.python-list at python.org
Michael Stroeder releases web2ldap, a web-based generic LDAP client
written in Python.
http://groups.google.com/groups?ic=1&q=msgid:3B3517E0.9571A361 at stroeder.com
David Beazley sparks discussion on function attributes when he
announces PLY-1.0, a 100% Python implementation of the common
parsing tools lex and yacc.
http://groups.google.com/groups?ic=1&q=msgid:mailman.992921580.28727.clpa-moderators at python.org
Markus Gritsch introduces VideoCapture, a Python extension for
Win32 which makes it possible to access the video device.
http://groups.google.com/groups?ic=1&q=msgid:mailman.992921580.28726.clpa-moderators at python.org
Dave Cole announces Sybase module 0.26, which provides a Python
Database API version 2.0 interface to the Sybase relational database
system.
http://groups.google.com/groups?ic=1&q=msgid:m33d8xkuvz.fsf at vole.object-craft.com.au
Robin Becker release version 1.08 of the ReportLab toolkit, which
now includes initial support for Mac OS 9.
http://groups.google.com/groups?ic=1&q=msgid:oX4bSqA5yzL7Ew5m at jessikat.demon.co.uk
Fred Drake issues updates of the 2.2 development version...
http://groups.google.com/groups?ic=1&q=msgid:mailman.993236248.3156.python-list at python.org
...and the 2.1.1 maintenance version documentation.
http://groups.google.com/groups?ic=1&q=msgid:mailman.993234922.2134.python-list at python.org
Michel Pelletier has written the first in a series of articles
on the Zope Object Database (ZODB).
http://groups.google.com/groups?ic=1&q=msgid:mailman.992895416.23209.python-list at python.org
David Goodger starts reStructuredText, a candidate markup syntax
for the Python Docstring Processing System as per PEPs 256, 257 &
258.
http://groups.google.com/groups?ic=1&q=msgid:B7558512.13268%25dgoodger at bigfoot.com
Kevin Altis starts a mailing list to discuss creation of PythonCard.
http://groups.google.com/groups?ic=1&q=msgid:qdVX6.1963$zE1.721339 at news.uswest.net
Paul Prescod shows us where to find pyperl, a module that allows
Perl code to be run from Python...
http://www.cpan.org/modules/by-module/LWP/GAAS/pyperl-1.0.readme
... and Alex Martelli points us to Minotaur, which allows mixing
Python, Perl and TCL.
http://www.equi4.com/minotaur/minotaur.html
Steve Majewski found that Microsoft's EULA for the Mobile Internet
Toolkit Beta 2 restricts developers from distributing the software
in conjunction with Potentially Viral Software.
http://groups.google.com/groups?ic=1&q=msgid:mailman.993174742.10326.python-list at python.org
It appeared the page referred to was quickly removed from Microsoft's
site; then Alastair Burt re-found it.
http://msdn.microsoft.com/downloads/eula_mit.htm
The Vienna Python Interest Group (PIGgie) has just been formed this
month.
http://groups.google.com/groups?ic=1&th=1c92ecc5f025a11f,1
IBM devloperWorks has just published the second part of Uche
Ogbuji's PyXPCOM article. Great quote: "Python is famous for making rapid
development in Java actually possible, and PyXPCOM brings the same
benefit to XPCOM."
http://www-106.ibm.com/developerworks/components/library/co-pyxp2.html
developerWorks is really digging Python these days. They've also
published David Mertz's article on Python and XML:
http://www-106.ibm.com/developerworks/xml/library/l-pxml.html?open&l=913,t=grx,p=xpyth
Python's growth into the educational market continues. Eric Raymond
spotted this endorsement from a university in the land down, under
and a little to the left:
http://it.mycareer.com.au/news/2001/06/05/FFX9ZT7UENC.html
If your local college doesn't provide it then maybe you can get to
Learning Tree's classes in Chicago during the next few hours
(June 26):
http://www.learningtree.com/us/ilt/courses/430.htm
You may have heard that there is now an operating system for Lego
(Lego Mindstorms LegOS). And there is even a Python module to talk
to it. These aren't the inanimate blocks of our childhood!
http://www.hare.demon.co.uk/lego/pylnp.html
A new Python user proclaims that his relationship with Python has moved
to a new level. There's a lot of love in this newsgroup .
http://groups.google.com/groups?ic=1&th=8a31b51350a5fcc9,1
Pgnotify is still wet behind the ears (ver 0.1) but we're proud to
announce it: "a PostgreSQL client-side asynchronous notification
handler for Python."
http://www.post1.com/home/ngps/pgnotify/
Python receives a lot of good press in an article on Slashdot asking
about the next step beyond Visual Basic. While the questioner is
eviscerated (Slashdot style), reviews of Python are positive:
http://slashdot.org/comments.pl?sid=01%2F06%2F08%2F2140257
========================================================================
Everything you want is probably one or two clicks away in these pages:
Python.org's Python Language Website is the traditional
center of Pythonia
http://www.python.org
Notice especially the master FAQ
http://www.python.org/doc/FAQ.html
PythonWare complements the digest you're reading with the
daily python url
http://www.pythonware.com/daily
comp.lang.python.announce announces new Python software. Be
sure to scan this newly-revitalized newsgroup at least weekly.
http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce
Michael Hudson continues Andrew Kuchling's marvelous tradition
of summarizing action on the python-dev mailing list once every
other week.
http://starship.python.net/crew/mwh/summaries/
http://www.amk.ca/python/dev
The Vaults of Parnassus ambitiously collect Python resources
http://www.vex.net/~x/parnassus/
Much of Python's real work takes place on Special-Interest Group
mailing lists
http://www.python.org/sigs/
The Python Software Foundation has replaced the Python Consortium
as an independent nexus of activity
http://www.python.org/psf/
Cetus does much of the same
http://www.cetus-links.de/oo_python.html
Python FAQTS
http://python.faqts.com/
Python To-Do List anticipates some of Python's future direction
http://www.python.org/cgi-bin/todo.py
Python Journal is at work on its second issue
http://www.pythonjournal.com
Links2Go is a new semi-automated link collection; it's impressive
what AI can generate
http://www.links2go.com/search?search=python
Archive probing tricks of the trade:
http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100
http://groups.google.com/groups?meta=site%3Dgroups%26group%3Dcomp.lang.python.*
Previous - (U)se the (R)esource, (L)uke! - messages are listed here:
http://purl.org/thecliff/python/url.html
or
http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python
Suggestions/corrections for next week's posting are always welcome.
[http://www.egroups.com/list/python-url-leads/ is hibernating. Just
e-mail us ideas directly.]
To receive a new issue of this posting in e-mail each Monday morning,
ask to subscribe. Mention "Python-URL!".
-- The Python-URL! Team--
Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and
sponsor the "Python-URL!" project.
--
Cameron Laird
Business: http://www.Phaseit.net
Personal: http://starbase.neosoft.com/~claird/home.html
From kbk at shore.net Wed Jun 6 20:25:13 2001
From: kbk at shore.net (Kurt B. Kaiser)
Date: Thu, 07 Jun 2001 00:25:13 GMT
Subject: floating point in 2.0
References: <3B1E50C9.7D2509F4@shore.net> <9flkoi$ofu$1@panix2.panix.com> <3B1E6A67.2B33C197@shore.net> <9fm9kg05qs@enews1.newsguy.com>
Message-ID: <3B1EC916.C427EFF2@shore.net>
Alex Martelli wrote:
> I did most of my thesis work in APL (then had to redo it in Fortran
> and Assembler, but that's another story) and used APL2 heavily
> later (in IBM Research), and I recall those darned globals that
> broke my routines when used in somebody else's workspaces as
> the worst blights on an otherwise interesting language (if you
> had the right terminal/keyboard/typewriter ball/&c:-).
>
> Alex
balls, you say? I remember being hunched over an IBM 5100 (the first
PC?)
for months on end coding AR filters on semiconductors. The screen was
about 3 inches by 4 inches, about 4 inches off the desk. But it really
worked, was built like a tank, and was only about $15,000, as I
recall...
and APL worked like a charm for that application.
Just don't let anyone mess with your globals =)
But you know, an explict FUZZ brings the float comparison problem
out in the open and promotes documentation. Now, if you are going
to use floats as keys in a dict, heaven help you!
Regards, KBK
From maus at netz.klinik.uni-mainz.de Fri Jun 15 06:07:10 2001
From: maus at netz.klinik.uni-mainz.de (Christian Maus)
Date: Fri, 15 Jun 2001 12:07:10 +0200
Subject: Problems with readlines()
Message-ID: <9gcmt4$d28$1@bambi.zdv.Uni-Mainz.DE>
hello there,
i wrote a function readfile() which reads all lines in a file and stores
them in an array.
infile = open('/tmp/tacfile', 'r')
array = infile.readlines()
infile.close()
return array
the strange thing is, the more often I call this function, the lines read
by it decrease, e.g I have a file containing 838 lines, i get 838 lines,
then 738 lines, then 624 and so on...
When I simply do cut and paste for this code in my program, everything
works fine, only when I call it via it's functionname I get this strange
effect.
Any idea what the problem might be?
best regards
christian
From com-nospam at ccraig.org Thu Jun 28 08:15:29 2001
From: com-nospam at ccraig.org (Christopher A. Craig)
Date: 28 Jun 2001 08:15:29 -0400
Subject: C extension problem (Solaris)
Message-ID: <874rt0hkbi.fsf@elbereth.ccraig.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I was working with the Rational.py that comes with Python trying to
improve it's speed and I decided I could save quite a bit if I wrote
it as a C extension (mainly because I was doing a couple hundred
operations on long integers for each add, which could be done much
faster if I didn't have to go through PyNumber_ each time). So I
wrote (and am nearly finished with) a rational type available at
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/~checkout~/pythonic/crat/cratmodule.c?rev=1.12&content-type=text/plain
(currently cvs only).
Though I have used the C API before, this was my first attempt at
defining a new type with it, and I had a problem. It works fine on my
Linux/Intel box, but when I try to compile it on my Solaris 8
UltraSPARC box it has an item in the module dictionary that contains a
non-working reference to the subtraction routine.
I've looked over it and I didn't define anything as non-static, so I
can't figure out where that reference came from. Any suggestions?
- --
Christopher A. Craig
"In the beginning the Universe was created. This has made a lot of people
very angry and been widely regarded as a bad move." Douglas Adams
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.6 and Gnu Privacy Guard
iEYEARECAAYFAjs7H9gACgkQjVztv3T8pzvktgCfREn2BkxskWmHKNVwZJudpUFY
JvkAoKMxppjgn5KpkqwWILcNmJ/Gyo+w
=AFF2
-----END PGP SIGNATURE-----
From rnd at onego.ru Sun Jun 17 16:03:25 2001
From: rnd at onego.ru (Roman Suzi)
Date: Mon, 18 Jun 2001 00:03:25 +0400 (MSD)
Subject: Event-driven GUIs, PythonWorks, Boa, wxWindows; future directions
of event-driven Python?
In-Reply-To:
Message-ID:
On Sun, 17 Jun 2001, res04o20 wrote:
>Hi y'all. I'm new here so bear with me. ;-)
>
>Now. Here's another way to go. Just use VB or some Office VBE with Forms2
>(or even Word fields or Excel cells) as your gui. The other great book I've
>read, "Programming Python on Win32" shows you how to do it. It's not hard.
>That's of course, if you have access to VB/Office and can stomach using it.
>Some folks just refuse, and I can't blame 'em.
2 months ago I did a simple Visual Basic macro to search-replace and wow!
it was so much fun to see how your screen is filled with trash (even
though I switched screen refresh off), scroll-bar in convulsions, etc.
It was also funny that converting my special markup into HTML+another
markup by Python on Linux was 2 times faster than it takes MS Word to read
HTML + convert another markup (mostly by search-replace regex)! (And what
a pitiful regex MS Word has!!! I wonder, where have they took it.)
Maybe, my approach was too direct, but I had enough "fun" to remember
using MS Word in batch processing mode to guess how it feels in programmed
interactive GUI mode...
Sincerely yours, Roman Suzi
--
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Sunday, June 17, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "Tis better to have loved a short than to never have loved a tall." _/
From mstevens at firedrake.org Fri Jun 22 10:11:48 2001
From: mstevens at firedrake.org (Michael Stevens)
Date: 22 Jun 2001 14:11:48 GMT
Subject: Jython for Servlets
References:
Message-ID:
On Thu, 21 Jun 2001 11:59:08 -0500, Michael Chermside wrote:
>I would like to use Jython to write servlets in python and run them
>on a java application server (WebLogic or one if its ilk). Seem like
>this should be pretty easy to do... does anyone have a "hello world"
>example I can work from?
I wrote this a while ago playing with jython and servlets:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.python.util.PythonInterpreter;
import org.python.core.*;
public class JythonServlet extends HttpServlet {
protected void doGet (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("JythonServlet");
out.println("JythonServlet
");
try {
PythonInterpreter interp = new PythonInterpreter();
interp.exec("import sys");
interp.set("out", out);
interp.exec("out.println(' the jython interpreter lives!
')");
interp.exec("ver = sys.version");
PyObject ver = interp.get("ver");
out.println("The jython version is " + ver + "
");
} catch (PyException e) {
out.println("Help! Python Exception");
}
out.println("