Re: Bug Report / Patch (1159139 cgi.py invalid REQUEST_METHOD set)

2005-07-26 Thread Reinhold Birkenfeld
Joe wrote: > Back in March I submitted a patch for cgi.py to sourceforge to fix a problem > with the handling of an invalid REQUEST_METHOD. > > I thought I followed all the steps to properly submit the bug and patch but > the patch is still sitting there in limbo. > > This is the first patch I

Re: finding out the calling function

2005-07-27 Thread Reinhold Birkenfeld
flupke wrote: > Hi, > > i have a property in a class that gets changed > and i would want to know who changes it. > Is there a way i can find out the calling function of a property? You're looking for sys._getframe. Reinhold -- http://mail.python.org/mailman/listinfo/python-list

Re: multiple inheritance super()

2005-07-28 Thread Reinhold Birkenfeld
Michele Simionato wrote: >> http://fuhm.org/super-harmful/ > > That is a pretty good page; I must say that my position is more radical > (i.e. it is not super which > is harmful, it is multiple inheritance itself that it is harmful: was I > going to design a new language > I would implement it *wi

Re: Path inherits from basestring again

2005-07-30 Thread Reinhold Birkenfeld
NickC wrote: > [Re: alternatives to overloading '/'] > > Is there a reason the Path constructor is limited to a single argument? > If it allowed multiple arguments, the following would seem very > straightforward: > > p = Path(somePath, user.getFolder(), 'archive', oldPath + ".bak") That's a qui

Re: [path-PEP] Path inherits from basestring again

2005-07-30 Thread Reinhold Birkenfeld
Ivan Van Laningham wrote: > Hi All-- > > Tony Meyer wrote: >> >> So far, there have been various statements that look like +0 for __div__, >> but no-one with a +1. (And I've said this a couple of times now, which >> really is just trolling for a +1 from someone). >> >> > It's not a question of

Re: PEP on path module for standard library

2005-07-30 Thread Reinhold Birkenfeld
Mike Orr wrote: > The main changes I'd like to see in Path (some of these have been made > in Python CVS at nondist/sandbox/path/path.py) are: Thanks for the comments! They are greatly appreciated. > - When methods create path objects, use self.__class__() instead of > Path(). > This makes it

Re: Path inherits from basestring again

2005-07-30 Thread Reinhold Birkenfeld
NickC wrote: > [Re: how to get at the base class] > > Do you really want to have a "only works for Path" way to get at the > base class, rather than using the canonical Path.__bases__[0]? > > How about a new property in the os.path module instead? Something like > os.path.path_type. > > Then os.

Re: A replacement for lambda

2005-07-30 Thread Reinhold Birkenfeld
Stefan Rank wrote: > on 30.07.2005 10:20 Paolino said the following: >> why (x**2 with(x))<(x**3 with(x)) is not taken in consideration? >> >> If 'with' must be there (and substitue 'lambda:') then at least the >> syntax is clear.IMO Ruby syntax is also clear. >> > > I am sorry if this has alre

Re: Comparison of functions

2005-07-30 Thread Reinhold Birkenfeld
Steven D'Aprano wrote: > On Sat, 30 Jul 2005 08:13:26 -0400, Peter Hansen wrote: > >> Beginners should not be comparing lambdas. >> >> Neither should you. ;-) > > Actually, yes I should, because I'm trying to make sense of the mess that > is Python's handling of comparisons. At least two differe

Re: [path-PEP] Path inherits from basestring again

2005-07-30 Thread Reinhold Birkenfeld
phil hunt wrote: > On Fri, 29 Jul 2005 14:38:23 +1200, Tony Meyer <[EMAIL PROTECTED]> wrote: >>> def functions_which_modifies_some_file_in_place(path): >>> output = open(path+'.tmp', 'w') >>> . >>> >>> I dont want a seperator inserted between path and the new extension. >> >>Fair enough. Fo

Re: [path-PEP] Path inherits from basestring again

2005-07-30 Thread Reinhold Birkenfeld
phil hunt wrote: > def normalizePath(p, *pathParts): >""" Normalize a file path, by expanding the user name and getting >the absolute path.. >@param p [string] = a path to a file or directory >@param pathParts [list of string] = optional path parts >@return [string] = the same

Re: [path-PEP] Path inherits from basestring again

2005-07-30 Thread Reinhold Birkenfeld
Steven D'Aprano wrote: > On Sat, 30 Jul 2005 14:10:52 +0200, Reinhold Birkenfeld wrote: > >> Above all, nobody can tell me that there's any programmer who doesn't >> instantly recognize '/' as a directory separator. > > Is classic Macintosh OS s

Re: Comparison of functions

2005-07-30 Thread Reinhold Birkenfeld
Georg Neis wrote: > * Reinhold Birkenfeld <[EMAIL PROTECTED]> wrote: >> Steven D'Aprano wrote: >>>>>> 1+0j == 1 > 0 >>> True >> >> (1+0j == 1) yields True, which is comparable to 0. > > "a == b > c" is equivalent

Re: Comparison of functions

2005-07-30 Thread Reinhold Birkenfeld
Steven D'Aprano wrote: > On Sat, 30 Jul 2005 15:32:45 +0200, Reinhold Birkenfeld wrote: > >>> Um, I didn't ask to compare complex numbers using comparison operators. I >>> asked to sort a list. And please don't tell me that that sorting is >>>

Re: Path inherits from basestring again

2005-07-30 Thread Reinhold Birkenfeld
Michael Hoffman wrote: > Reinhold Birkenfeld wrote: > >> It's much the same as with @ decorators. Those who have used them much >> don't object to the syntax any more. > > I do and I still think they are ugly. Shouldn't have generalized that. Add "

Re: PEP on path module for standard library

2005-07-30 Thread Reinhold Birkenfeld
Peter Hansen wrote: > Reinhold Birkenfeld wrote: >> Mike Orr wrote: >>>- I saw in a thread that .name and .parent were removed. I use them >>>very frequently, along with .ext and .namebase. I don't want to call >>>methods for these. >>

Re: [path-PEP] Path inherits from basestring again

2005-07-31 Thread Reinhold Birkenfeld
phil hunt wrote: > On Sat, 30 Jul 2005 19:01:49 +0200, Reinhold Birkenfeld <[EMAIL PROTECTED]> > wrote: >>phil hunt wrote: >> >>> def normalizePath(p, *pathParts): >>>""" Normalize a file path, by expanding the user name and getting

Re: [path-PEP] Path inherits from basestring again

2005-08-01 Thread Reinhold Birkenfeld
phil hunt wrote: > On Sun, 31 Jul 2005 09:48:45 +0200, Reinhold Birkenfeld <[EMAIL PROTECTED]> > wrote: >>> >>> An improvement to what? To how the class is implemented, or to how >>> it is used? >> >>No, the second function is cleaner and more

Re: Wheel-reinvention with Python

2005-08-01 Thread Reinhold Birkenfeld
phil hunt wrote: > On Sun, 31 Jul 2005 12:09:48 -0700, Cliff Wells <[EMAIL PROTECTED]> wrote: >>On Sun, 2005-07-31 at 10:07 -0700, Kay Schluehr wrote: >> >>> Some other people already abandoned Python not for the worst reasons: >>> >>> http://www.kevin-walzer.com/pivot/entry.php?id=69 >> >>Being a

Re: Getting not derived members of a class

2005-08-01 Thread Reinhold Birkenfeld
Franz Steinhaeusler wrote: > The background: > I want to create a code completition for an editor component. > It should distinguish between inherited and non inherited members. > Reason is, that on wxPython, most classes are derived from wxWindow. > For example if I want Code completition for wx.

Re: Wheel-reinvention with Python

2005-08-01 Thread Reinhold Birkenfeld
Kay Schluehr wrote: > Reinhold Birkenfeld wrote: > >> > In practise any Python GUI is going to contain code from otyher >> > languages since if it was coded all the way down in python it would >> > be too slow. >> >> Oh, I could imagine that a MFC-li

Re: Is this Pythonic?

2005-08-02 Thread Reinhold Birkenfeld
Delaney, Timothy (Tim) wrote: > Peter Hansen wrote: > >> Change those to "raise NotImplementedError('blah')" instead and you'll >> be taking the more idiomatic approach. > > One thing I've noticed, which I may raise on python-dev ... > NotImplementedError does *not* play well with super() ... >

Re: Setting a drive's volume label

2005-08-03 Thread Reinhold Birkenfeld
Bob Greschke wrote: > Looks like the "label" system command will do it in Windows. That's good > enough for this exercise. So, in Linux...??? "mlabel" in the "mtools" package will do what you need. "mkfs.vfat" can also be given a volume label, but it will not allow you to set the label without

Re: why no arg, abs methods for comlex type?

2005-08-05 Thread Reinhold Birkenfeld
Erik Max Francis wrote: > Daniel Schüle wrote: > >> maybe I confuse, in german one would say "45 Grad" >> I took a freedom to translate it directly :) >> well, my calculator shows a "D" >> which most likely stands for Degree, I cannot tell for sure > > Probably. In English, you have degrees and

Re: Do I need to have site.py available or not ?

2005-08-05 Thread Reinhold Birkenfeld
Terry Reedy wrote: > <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Hi, >> on startup my embedded python comes up with "import site failed use >> -v". Later python crashes on Pyrun_file(). This is the first time I >> have used python and I would like to know does it require site.

Re: Decline and fall of scripting languages ?

2005-08-06 Thread Reinhold Birkenfeld
Kay Schluehr wrote: > No good news for scripting-language fans: > > http://www.phpmag.net/itr/news/psecom,id,23284,nodeid,113.html The study was conducted by Evans Data Corporation. Look here: http://www.evansdata.com/n2/about_us_clients.shtml Do you see the PSF or Larry Wall on the list? Rein

Re: Euclid's Algorithm in Python?

2005-08-07 Thread Reinhold Birkenfeld
Erik the Red wrote: > So, I did the following: > --- > a=input("Give me an integer") > b=input("Give me another integer") > > def gcd(a,b): > > if a < b: > a, b = b, a > while b != 0: > a, b = b, a % b > return a > --- > But, in the xterm, it terminates after "Give m

Re: How to determine that if a folder is empty?

2005-08-08 Thread Reinhold Birkenfeld
could ildg wrote: > I want to check if a folder named "foldername" is empty. > I use os.listdir(foldername)==[] to do this, > but it will be very slow if the folder has a lot of sub-files. > Is there any efficient ways to do this? try: os.rmdir(path) empty = True except OSError: empty

Re: IronPython 0.9 Released

2005-08-08 Thread Reinhold Birkenfeld
Al Christians wrote: > EP wrote: >> >> yes, my apologies to all things Iron and or Python. >> >> "language" and "version" can be confusing if one stays up late without >> coffee, or perhaps if one has not been debugging their English code properly. >> > > Still, it's a bit of a PITB to me that

Re: Syntax error after upgrading to Python 2.4

2005-08-09 Thread Reinhold Birkenfeld
Michael Hudson wrote: > [EMAIL PROTECTED] writes: > >> On Sat, Aug 06, 2005 at 05:15:22PM -0400, Terry Reedy wrote: >>> In any case letting developers add new features is part of the price of >>> getting unpaid bug fixes for free software. But note that PSF does not >>> make you to upgrade. He

Re: What is Python?!

2005-08-11 Thread Reinhold Birkenfeld
Evil Bastard wrote: > bruno modulix wrote: >> You can tell buy the most common use. bash is a scripting language, >> javascript is a scripting language, perl is a scripting language, php is >> a scripting language, Python is *not* a scripting language !-) > > Perhaps a better definition - the term

Re: Printing literal text of an argument

2005-08-13 Thread Reinhold Birkenfeld
Rex Eastbourne wrote: > Thanks. I adapted it a bit: > > def debug(foo): > print foo, 'is:' > exec('pprint.pprint(' + foo + ')') > > But I'm getting "NameError: name 'foo' is not defined," since foo is > not defined in this scope. (The function works beautifully when I'm > dealing with glo

Re: Using for in one-liner

2005-08-17 Thread Reinhold Birkenfeld
BranoZ wrote: > Paul Watson wrote: >> Using a '$' before the string works in the ksh that is part of FC4. >> However, it does not work on the pdksh that is in FC3 and Cygwin. It >> also does not work on AIX ksh. >> >> $ print $'now' >> $now > > In bash you can also use Ctrl-v followed by special

Re: String functions deprication

2005-08-17 Thread Reinhold Birkenfeld
Dan wrote: >> http://www.python.org/doc/2.4.1/lib/node110.html >> >> These methods are being deprecated. What are they being replaced >> with? > > They're being made methods of the string class itself. > > For example: > >>> s = 'any old string' > >>> string.split(s, ' ') # Old way > [

Re: while c = f.read(1)

2005-08-21 Thread Reinhold Birkenfeld
John Machin wrote: > ... AND it's about time that list is updated to include False explicitly > -- save nitpicking arguments about whether False is covered by > "numeric zero of all types" :-) Done. >> If I try: >> >> f = open("blah.txt", "r") >> while (c = f.read(1)) != '': >> #

Re: overload builtin operator

2005-08-25 Thread Reinhold Birkenfeld
Shaun wrote: > Hi, > > I'm trying to overload the divide operator in python for basic arithmetic. > eg. 10/2 ... no classes involved. > > I am attempting to redefine operator.__div__ as follows: > > # my divide function > def safediv(a,b): > return ... > > # reassign bui

Re: RE Despair - help required

2005-08-25 Thread Reinhold Birkenfeld
Yoav wrote: > Don't think it will do much good. I need to get them from a file and > extract the last folder in the path. For example: > if I get "c:\dos\util" > I want to extract the string "\util" Then os.path.basename should be for you. Reinhold -- http://mail.python.org/mailman/listinfo/py

Re: variable hell

2005-08-25 Thread Reinhold Birkenfeld
rafi wrote: > Adriaan Renting wrote: >> You might be able to do something along the lines of >> >> for count in range(0,maxcount): >> value = values[count] >> exec(eval("'a%s=%s' % (count, value)")) > > why using the eval? > > exec ('a%s=%s' % (count, value)) > > should be fine And this de

Re: Setting the encoding in pysqlite2

2005-08-26 Thread Reinhold Birkenfeld
Michele Simionato wrote: > An easy question, but I don't find the answer in the docs :-( > I have a sqlite3 database containing accented characters (latin-1). > How do I set the right encoding? For instance if I do this: I think you should ask on the pysqlite-devel list. Reinhold -- http://mail.

reportlab and custom fonts

2005-08-26 Thread Reinhold Birkenfeld
Hi, I'm trying to get reportlab working together with the Tahoma font (by Microsoft ;) So far it's up and running (converted the ttf with ttf2pt1), but the Euro sign (which is in position 0x80 in the WinAnsiEncoding) fails to show up in the final PDF. I investigated a bit and saw that in the afm

Re: reportlab and custom fonts

2005-08-26 Thread Reinhold Birkenfeld
Reinhold Birkenfeld wrote: > Hi, > > I'm trying to get reportlab working together with the Tahoma font > (by Microsoft ;) > > So far it's up and running (converted the ttf with ttf2pt1), but the > Euro sign (which is in position 0x80 in the WinAnsiEncoding) fail

Re: Bug in string.find; was: Re: Proposed PEP: New style indexing, was Re: Bug in slice type

2005-08-26 Thread Reinhold Birkenfeld
Bryan Olson wrote: > Steve Holden wrote: > > Bryan Olson wrote: > >> Antoon Pardon wrote: > > >> > It probably is too late now, but I always felt, find should > >> > have returned None when the substring isn't found. > >> > >> None is certainly a reasonable candidate. > [...] > >> The rea

Re: What are new-style classes?

2005-08-28 Thread Reinhold Birkenfeld
Terry Hancock wrote: > On Sunday 28 August 2005 04:47 am, Vaibhav wrote: >> I recently heard about 'new-style classes'. I am very sorry if this >> sounds like a newbie question, but what are they? I checked the Python >> Manual but did not find anything conclusive. Could someone please >> enlighten

Re: What are new-style classes?

2005-08-30 Thread Reinhold Birkenfeld
Colin J. Williams wrote: I recently heard about 'new-style classes'. I am very sorry if this sounds like a newbie question, but what are they? I checked the Python Manual but did not find anything conclusive. Could someone please enlighten me? Thanks! >>> >>>"New style" classes are

Re: Yielding a chain of values

2005-08-30 Thread Reinhold Birkenfeld
Bengt Richter wrote: > On Tue, 30 Aug 2005 12:18:59 GMT, Michael Hudson <[EMAIL PROTECTED]> wrote: > >>Talin <[EMAIL PROTECTED]> writes: >> >>> I'm finding that a lot of places within my code, I want to return the >>> output of a generator from another generator. Currently the only >>> method I kn

Re: Yielding a chain of values

2005-08-31 Thread Reinhold Birkenfeld
Matt Hammond wrote: >> Well, maybe it's right both ways ;-) I.e., even though yield "is" now >> an expression, it is valid to use it as an expression-statement which >> evaluates the expression and discards the value. So I think you could >> still use the currently illegal "yield in" token sequence

Re: What are new-style classes?

2005-08-31 Thread Reinhold Birkenfeld
Terry Hancock wrote: > On Tuesday 30 August 2005 04:09 pm, Reinhold Birkenfeld wrote: >> The customary way is to use "class new_class(object):". There's no advantage >> in using >> __metaclass__ except that you can set it globally for all classes in that >

Re: Yielding a chain of values

2005-08-31 Thread Reinhold Birkenfeld
Kay Schluehr wrote: > Reinhold Birkenfeld wrote: > >> >x = [ yield r for r in iterable ] >> >> Which is quite different from >> >> x = (yield) in iterable >> >> which is currently (PEP 342) equivalent to >> >> _ = (yield) >

Re: What are new-style classes?

2005-08-31 Thread Reinhold Birkenfeld
Steve Holden wrote: > Reinhold Birkenfeld wrote: >> Terry Hancock wrote: >> >>>On Tuesday 30 August 2005 04:09 pm, Reinhold Birkenfeld wrote: >>> >>>>The customary way is to use "class new_class(object):". There's no >>>>

Re: PyBool_FromLong

2005-09-03 Thread Reinhold Birkenfeld
Michael Hoffman wrote: > Andrew MacKeith wrote: >> In the C API Docs, the signature of PyBool from long seems to be incorrect. >> >> int PyBool_FromLong(long v) >> Returns Py_True or Py_False depending on the truth value of v. New >> in version 2.3. >> >> The description would suggest: >> >

Re: pickling the objects returned by array.array()

2005-09-03 Thread Reinhold Birkenfeld
Raymond Hettinger wrote: > John Machin wrote: >> Looks like arrays are NOW (2.4.1) pickleable but not unpickleable > > Please file a bug report and assign to me. Done. http://python.org/sf/1281383 Reinhold -- http://mail.python.org/mailman/listinfo/python-list

Re: documentation error

2005-09-04 Thread Reinhold Birkenfeld
tiissa wrote: > bill wrote: >>>From 3.2 in the Reference Manual "The Standard Type Hierarchy": >> >> "Integers >> These represent elements from the mathematical set of whole >> numbers." >> >> The generally recognized definition of a 'whole number' is zero and the >> positive integers. > > T

Re: Simplifying imports?

2005-09-13 Thread Reinhold Birkenfeld
Terry Hancock wrote: > On Monday 12 September 2005 10:09 pm, [EMAIL PROTECTED] wrote: >> I like to keep my classes each in a separate file with the same name of >> the class. The problem with that is that I end up with multiple imports >> in the beginning of each file, like this: >> >> from foo.Ba

Re: Windows Python 2.4: Unbuffered flag causes SyntaxError on interactive sessions?

2005-09-14 Thread Reinhold Birkenfeld
Irmen de Jong wrote: > Michael Hoffman wrote: >> Lonnie Princehouse wrote: >> >>> C:\>python -u >>> Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] >>> on win32 >>> Type "help", "copyright", "credits" or "license" for more information. >>> >> print 'hello' >>> >>> >>> F

Re: List of integers & L.I.S. (SPOILER)

2005-09-14 Thread Reinhold Birkenfeld
n00m wrote: > Tim Peters wrote: >> The chance that Raymond Hettinger is going to recode _your_ >> functions in C is approximately 0 ;-) > Who is Raymond Hettinger? See python-dev and, wrt this thread, http://docs.python.org/whatsnew/node12.html. Reinhold -- http://mail.python.org/mailman/listin

Re: List of integers & L.I.S. (SPOILER)

2005-09-14 Thread Reinhold Birkenfeld
n00m wrote: > Got it! He is a kind of pythonic monsters. > > Btw, why it's impossible to reply to old threads? > Namely, there're no more "Reply" link in them. > Only "Reply to author" etc. Perhaps because you are not using a real Usenet client? Reinhold -- http://mail.python.org/mailman/listin

Re: round() wrong in Python 2.4?

2005-09-14 Thread Reinhold Birkenfeld
Robert Kern wrote: > Grant Edwards wrote: >> On 2005-09-14, Robert Kern <[EMAIL PROTECTED]> wrote: >> >>>Antoon Pardon wrote: >> 0.0225 isn't representable and it happens that the actual number you get differ. Now which number python should choose when it is fed 0.0225, I don't know.

Re: python optimization

2005-09-15 Thread Reinhold Birkenfeld
David Wilson wrote: > For the most part, CPython performs few optimisations by itself. You > may be interested in psyco, which performs several heavy optimisations > on running Python code. > > http://psyco.sf.net/ > > Defining a function inside a loop in CPython will cause a new function > objec

Re: 2.3 -> 2.4: long int too large to convert to int

2005-09-17 Thread Reinhold Birkenfeld
Grant Edwards wrote: > I give up, how do I make this not fail under 2.4? > > fcntl.ioctl(self.dev.fileno(),0xc0047a80,struct.pack("HBB",0x1c,0x00,0x00)) > > I get an OverflowError: long int too large to convert to int > > ioctl() is expecting a 32-bit integer value, and 0xc0047a80 has > the hi

Re: slicing functionality for strings / Python suitability for bioinformatics

2005-09-19 Thread Reinhold Birkenfeld
[EMAIL PROTECTED] wrote: rs='AUGCUAGACGUGGAGUAG' rs[12:15]='GAG' > Traceback (most recent call last): > File "", line 1, in ? > rs[12:15]='GAG' > TypeError: object doesn't support slice assignment > > You can't assign to a section of a sliced string in > Python 2.3 and there doesn'

Re: Monitoring a directory for changes

2005-09-20 Thread Reinhold Birkenfeld
Florian Lindner wrote: > Hello, > is there a python lib (preferably in the std lib) to monitor a directory for > changes (adding / deleting files) for Linux 2.6? There isn't, but if you don't want to use dnotify/inotify, it is trivial to implement: use a timer and check the listdir() return value.

Re: Object default value

2005-09-22 Thread Reinhold Birkenfeld
ago wrote: > Is it possible to have a default value associated python objects? I.e. > to flag an attribute in such a way that the assignment operator for the > object returns the default attribute instead of the object itself, but > calls to other object attributes are properly resolved? (I don't t

Re: string issue

2005-02-07 Thread Reinhold Birkenfeld
Alex Martelli wrote: > Bill Mill <[EMAIL PROTECTED]> wrote: >... >> > > You are modifying the list as you iterate over it. Instead, iterate over >> > > a copy by using: >> > > >> > > for ip in ips[:]: >... >> Once you know it, it's neat, and I use it sometimes. However, it's a >> little too

Re: python code with indention

2005-02-07 Thread Reinhold Birkenfeld
Xah Lee wrote: > is it possible to write python code without any indentation? Yes. Reinhold -- http://mail.python.org/mailman/listinfo/python-list

Re: string issue

2005-02-07 Thread Reinhold Birkenfeld
Alex Martelli wrote: > So, *WHAT ON EARTH* could possibly > make this weird 'x[:]' form preferable to 'x*1'?! It's MUCH more > obvious that the second one returns an independent, separate object > initially equal to x .>> x = 2 .>> y = x*1 .>> x is y True .>> just-kidding-ly yours, Reinhold --

Re: string issue

2005-02-08 Thread Reinhold Birkenfeld
Alex Martelli wrote: > Reinhold Birkenfeld <[EMAIL PROTECTED]> wrote: > >> Alex Martelli wrote: >> >> > So, *WHAT ON EARTH* could possibly >> > make this weird 'x[:]' form preferable to 'x*1'?! It's MUCH more >&

Re: Python versus Perl ?

2005-02-08 Thread Reinhold Birkenfeld
Fredrik Lundh wrote: > m" <[EMAIL PROTECTED]> wrote: > If Python is better than Perl, I'm curious how really significant those advantages are ? >> >> speedwise, i think perl is faster than python and python performed the >> slowest as shown in >> http://www.flat222.org/mac/bench/ > > if

Re: PHP session equivalent?

2005-02-12 Thread Reinhold Birkenfeld
Walter Burleigh wrote: > Erik Johnson wrote: > >> There are a lot of things about PHP I was not too keen on and hence >> why >> my company is primarily doing Python these days, but one thing I was quite >> impressed with was the ease with which it provided session >> functionality... > >

Re: [perl-python] exercise: partition a list by equivalence

2005-02-19 Thread Reinhold Birkenfeld
Xah Lee wrote: > here's the answer to the partition by equivalence exercise. Your Python solution is, as expected, wrong (try with [[10, 8], [7, 3], [1, 7], [5, 4], [2, 2], [3, 8], [7, 10], [2, 3], [6, 10], [3, 2]] for example). The solution by John Lenton is wrong, too. The solution by Brian Be

Re: [perl-python] exercise: partition a list by equivalence

2005-02-20 Thread Reinhold Birkenfeld
Reinhold Birkenfeld wrote: > My solution (which may not be the fastest or most effective, but till > now is the shortest and it works): > > def merge(pairings): > sets = {} > for x1, x2 in pairings: > newset = (sets.get(x1, frozenset([x1])) >

Re: exercise: partition a list by equivalence

2005-02-21 Thread Reinhold Birkenfeld
John Machin wrote: > Reinhold Birkenfeld wrote: >> Reinhold Birkenfeld wrote: >> >> > My solution (which may not be the fastest or most effective, but > till >> > now is the shortest and it works): > > [snip RB] >> >> A recursive solution (

Re: function expression with 2 arguments

2005-02-26 Thread Reinhold Birkenfeld
Xah Lee wrote: > is there a way to write a expression of a function with more than 1 > argument? > > e.g., i want a expression that's equivalent to > > def f(x,y) > return x+y Looking for lambda? Reinhold -- http://mail.python.org/mailman/listinfo/python-list

Re: How to write python plug-ins for your own python program?

2005-03-05 Thread Reinhold Birkenfeld
David M. Cooke wrote: > Simon Wittber <[EMAIL PROTECTED]> writes: > >>> You mean like 'import'? :) >> >> That's how I would do it. It's the simplest thing, that works. >> >> exec("import %s as plugin" % pluginName) >> plugin.someMethod() >> >> where pluginName is the name of the python file, minus

Re: programmatically calling a function

2005-03-05 Thread Reinhold Birkenfeld
Doug Schwarz wrote: > Dave, > > I think eval might be what you're looking for: > > f = eval('len') > length = f([1,2,3]) But only if the string given to eval is checked thorougly for allowed contents. Better use getattr. Reinhold -- http://mail.python.org/mailman/listinfo/python-list

Re: programmatically calling a function

2005-03-05 Thread Reinhold Birkenfeld
Doug Schwarz wrote: >> > Dave, >> > >> > I think eval might be what you're looking for: >> > >> > f = eval('len') >> > length = f([1,2,3]) >> >> But only if the string given to eval is checked thorougly for allowed >> contents. Better use getattr. > > Actually, upon reading Peter Hansen's repl

Re: function with a state

2005-03-06 Thread Reinhold Birkenfeld
Xah Lee wrote: > is it possible in Python to create a function that maintains a variable > value? > > something like this: > > globe=0; > def myFun(): > globe=globe+1 > return globe You could work with function attributes: def myFun(): try:myFun.globe += 1 except: myFun.globe =

Re: python -i (interactive environment)

2005-03-06 Thread Reinhold Birkenfeld
Michael Hoffman wrote: > Joe wrote: > >> Are there any differences between that and the actual interactve prompt that >> I should be aware of? > > I don't know, unfortunately. > >> Would you consider that a better method than using (thanks to those who >> suggested this other option): >> >> i

Re: function with a state

2005-03-07 Thread Reinhold Birkenfeld
Reinhold Birkenfeld wrote: > or with a default function argument: > > > class Dummy: pass > > def myFun(globe=Dummy()): > try:globe.globe += 1 > except: globe.globe = 1 > > return globe.globe A quicker way: def myFun(globe=[0]): gl

Re: Is there a short-circuiting dictionary "get" method?

2005-03-09 Thread Reinhold Birkenfeld
Dave Opstad wrote: > In this snippet: > > d = {'x': 1} > value = d.get('x', bigscaryfunction()) > > the bigscaryfunction is always called, even though 'x' is a valid key. > Is there a "short-circuit" version of get that doesn't evaluate the > second argument if the first is a valid key? For now

Re: PEP 309 (Partial Function Application) Idea

2005-03-11 Thread Reinhold Birkenfeld
Steven Bethard wrote: > Chris Perkins wrote: >> Random idea of the day: How about having syntax support for >> currying/partial function application, like this: >> >> func(..., a, b) >> func(a, ..., b) >> func(a, b, ...) >> >> That is: >> 1) Make an Ellipsis literal legal syntax in an argument li

Re: Python-list Digest, Vol 18, Issue 208

2005-03-15 Thread Reinhold Birkenfeld
Jeff Shannon wrote: > Steven Bethard wrote: > >> Jeff Shannon wrote: >> >>> now that almost the entire industry has standardized on power-of-2 >>> word sizes, octal is nearly useless but is still carried about for >>> backwards compatibility. >> >> So do you think it's worth lobbying for its r

Re: Why tuple with one item is no tuple

2005-03-15 Thread Reinhold Birkenfeld
Bill Mill wrote: > On Tue, 15 Mar 2005 10:47:28 -0800, James Stroud <[EMAIL PROTECTED]> wrote: >> On Tuesday 15 March 2005 08:25 am, Roy Smith wrote: >> > a = () # tuple of zero elements >> > a = (1,) # tuple of one element >> > a = 1, # tuple of one element >> > a = (1) # scal

Re: Pre-PEP: Dictionary accumulator methods

2005-03-18 Thread Reinhold Birkenfeld
Raymond Hettinger wrote: > [Michele Simionato] >> +1 for inc instead of count. > > Any takers for tally()? Well, as a non-native speaker, I had to look up this one in my dictionary. That said, it may be bad luck on my side, but it may be that this word is relatively uncommon and there are many ot

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Reinhold Birkenfeld
Peter Hansen wrote: > Michele Simionato wrote: >> +1 for inc instead of count. > > -1 for inc, increment, or anything that carries a > connotation of *increasing* the value, so long as > the proposal allows for negative numbers to be > involved. "Incrementing by -1" is a pretty silly > picture. >

Re: FAQ 1.7.3 : How can I have modules that mutually import each other

2005-03-19 Thread Reinhold Birkenfeld
MackS wrote: > Hi > > I'm new to Python, I've read the FAQ but still can't get the following > simple example working: > > # file main_mod.py: > > global_string = 'abc' > > def main(): > > import auxiliary_mod > instance = auxiliary_mod.ClassA() > instance.fun() > return > > m

Re: Pre-PEP: Dictionary accumulator methods

2005-03-19 Thread Reinhold Birkenfeld
John Machin wrote: > Raymond Hettinger wrote: >> I would like to get everyone's thoughts on two new dictionary > methods: > > +1 for each. > >> PROBLEMS BEING SOLVED >> - >> >> The readability issues with the existing constructs are: >> >> * They are awkward to teach, create,

Re: Pre-PEP: Dictionary accumulator methods

2005-03-20 Thread Reinhold Birkenfeld
Mike Rovner wrote: > Paul Rubin wrote: > >> If the compiler can do some type inference, it can optimize out those >> multiple calls pretty straightforwardly. > > It can be tipped like that: > > di = dict(int) > di.setdefault(0) > di[key] += 1 Interesting, but why do you need to give the int typ

Re: Pre-PEP: Dictionary accumulator methods

2005-03-20 Thread Reinhold Birkenfeld
John Machin wrote: > Reinhold Birkenfeld wrote: >> John Machin wrote: >> Are you kidding? If you know what "set" and "default" means, you will > be >> able to guess what "setdefault" means. Same goes for updateBy. >> > > No I'

Re: Pre-PEP: Dictionary accumulator methods

2005-03-20 Thread Reinhold Birkenfeld
George Sakkis wrote: >> -1 form me. >> >> I'm not very glad with both of them ( not a naming issue ) because i >> think that the dict type should offer only methods that apply to each >> dict whatever it contains. count() specializes to dict values that are >> addable and appendlist to those that a

Re: How two modules call functions defined in each other?

2005-03-20 Thread Reinhold Birkenfeld
Tian wrote: > I am python beginner, I have a question about the interdependence of > modules. > > For example, when I have two modules: > > module1.py > - > def plus(x): > return add(x,1) > > > module2.py > - > def add(x,y): > return x+y > > def plus2(x): > return

Re: style query: function attributes for return codes?

2004-12-10 Thread Reinhold Birkenfeld
holger krekel wrote: > Hi George, > > [george young Fri, Dec 10, 2004 at 10:45:47AM -0500] >> [python 2.3.3, x86 linux] >> I recently found myself writing something like: >> >> def get_connection(): >> if tcp_conn(): >> if server_allows_conn(): >> return 'good_conn' >>

Re: question about modules

2004-12-10 Thread Reinhold Birkenfeld
Jon wrote: > Hi Jeff, > > That makes sense -- thanks. However now when I use "re.capwords (sentence)" > I get a different error message: > > AttributeError: 'module' object has no attribute 'capwords' > > Each of the other two suggested implimentations produce a similar error > message. Is the

Re: input record sepArator (not sepErator)

2004-12-21 Thread Reinhold Birkenfeld
Peter Otten wrote: > Terry Reedy wrote: > >> 'separate' (se-parate == take a-part) and its derivatives are perhaps the >> most frequently misspelled English word on clp. Seems to be 'par' for the >> course. It has 2 e's bracketing 2 a's. It derives from the Latin >> 'parare', as does pare, so '

Re: input record sepArator (not sepErator)

2004-12-21 Thread Reinhold Birkenfeld
Peter Otten wrote: > Reinhold Birkenfeld wrote: > >>> the web: 4% >>> python: 9% >>> slashdot: 26% >>> perl: 29% * >> >> How did you get these data points? > > I copied the numbers from these pages: > > http://www.

Re: What is on-topic for the python list [was "Re: BASIC vs Python"]

2004-12-21 Thread Reinhold Birkenfeld
Doug Holton wrote: > Hans Nowak wrote: >>> Quote: >>> "this is comp.lang.python, not comp.lang.boo." >> >> >> Which is obviously not the same as "Boo should not be mentioned on this >> newsgroup". > > I used the exact same phrase in another note except using the term > "logo" instead of "boo

Re: input record sepArator (not sepErator)

2004-12-21 Thread Reinhold Birkenfeld
Reinhold Birkenfeld wrote: > Peter Otten wrote: >> Reinhold Birkenfeld wrote: >> >>>> the web: 4% >>>> python: 9% >>>> slashdot: 26% >>>> perl: 29% * >>> >>> How did you get these data points? >> >>

Re: [Re: newbie question]

2004-12-22 Thread Reinhold Birkenfeld
Doug Holton wrote: > Peter Hansen wrote: >> Luis M. Gonzalez wrote: >> >>> As far as I could see, everythime the word "boo" is typed, some sort of >>> censorship or plain bashing comes up, and I think this is not fair. >> >> I think doing this by defending Doug's postings, however, might weaken >>

Re: Why tuples use parentheses ()'s instead of something else like <>'s?

2004-12-29 Thread Reinhold Birkenfeld
Roy Smith wrote: > "John Roth" <[EMAIL PROTECTED]> wrote: >> > If Python had originally been invented in a unicode world, I suppose we >> > wouldn't have this problem. We'd just be using guillemots for tuples >> > (and have keyboards which made it easy to type them). >> >> I suppose the forces of

Re: Why tuples use parentheses ()'s instead of something else like <>'s?

2004-12-29 Thread Reinhold Birkenfeld
Grant Edwards wrote: > On 2004-12-29, Reinhold Birkenfeld <[EMAIL PROTECTED]> wrote: > >> Perl6 experiments with the use of guillemots as part of the syntax. > > As if Perl didn't look like bird-tracks already... > > http://www.seabird.org/educ

Re: Why tuples use parentheses ()'s instead of something else like <>'s?

2004-12-30 Thread Reinhold Birkenfeld
Alex Martelli wrote: > Jeff Shannon <[EMAIL PROTECTED]> wrote: >... >> to remember and type some arcane alt-keycode formula to be able to do >> basic scripting would be obnoxious, to say the least. Most keyboards >> worldwide provide decent support for the ASCII character set (though >> some

<    1   2   3   >