Re: Proposal for adding symbols within Python

2005-11-14 Thread Reinhold Birkenfeld
Rocco Moretti wrote: Pierre Barbier de Reuille wrote: Please, note that I am entirely open for every points on this proposal (which I do not dare yet to call PEP). I still don't see why you can't just use strings. As does Guido. Reinhold --

Re: Iterator addition

2005-11-13 Thread Reinhold Birkenfeld
[EMAIL PROTECTED] wrote: Tom Anderson: And we're halfway to looking like perl already! Perhaps a more pythonic thing would be to define a then operator: all_lines = file1 then file2 then file3 Or a chain one: all_lines = file1 chain file2 chain file3 That's certainly not better than the

Re: [Info] PEP 308 accepted - new conditional expressions

2005-10-01 Thread Reinhold Birkenfeld
Ron Adam wrote: It will be A if B else (C if D else F) So this evaluates as if there are parentheses around each section.. Hmm? (A) if (B) else ( (C) if (D) else (F) ) The first 'if' divided the expr, then each succeeding 'if' divides the sub expressions, etc... ? So ...

Re: [Info] PEP 308 accepted - new conditional expressions

2005-10-01 Thread Reinhold Birkenfeld
Erik Max Francis wrote: Dave Benjamin wrote: Hooray! After years of arguing over which syntax to use, and finally giving up since nobody could agree, the Benevolent Dictator did what only a dictator can do, and just made a damn decision already. Thank you, Guido! =) Yes, hear hear.

Re: [Info] PEP 308 accepted - new conditional expressions

2005-10-01 Thread Reinhold Birkenfeld
Sam wrote: Jaime Wyant writes: On 9/30/05, Sam [EMAIL PROTECTED] wrote: Reinhold Birkenfeld writes: Hi, after Guido's pronouncement yesterday, in one of the next versions of Python there will be a conditional expression with the following syntax: X if C else Y which

[Info] PEP 308 accepted - new conditional expressions

2005-09-30 Thread Reinhold Birkenfeld
Hi, after Guido's pronouncement yesterday, in one of the next versions of Python there will be a conditional expression with the following syntax: X if C else Y which is the same as today's (Y, X)[bool(C)] or C and X or Y (only if X is True) Reinhold --

Re: [Info] PEP 308 accepted - new conditional expressions

2005-09-30 Thread Reinhold Birkenfeld
Fredrik Lundh wrote: Reinhold Birkenfeld wrote: after Guido's pronouncement yesterday, in one of the next versions of Python there will be a conditional expression with the following syntax: X if C else Y which is the same as today's (Y, X)[bool(C)] hopefully, only one of Y or X

Re: 2.4.2 compilation

2005-09-30 Thread Reinhold Birkenfeld
pnm wrote: I have a standard Debian x86 system with Python 2.4.1 (compiled from source). Attempts to compile 2.4.2 fail with references to Unicode -- is there a basic system library that's missing? ++ output from make: libpython2.4.a(funcobject.o)(.text+0x96): In function

Re: [Info] PEP 308 accepted - new conditional expressions

2005-09-30 Thread Reinhold Birkenfeld
Rocco Moretti wrote: Reinhold Birkenfeld wrote: Hi, after Guido's pronouncement yesterday, in one of the next versions of Python there will be a conditional expression with the following syntax: X if C else Y Any word on chaining? That is, what would happen with the following

Re: User-defined augmented assignment

2005-09-29 Thread Reinhold Birkenfeld
Pierre Barbier de Reuille wrote: So, what I would suggest is to drop the user-defined augmented assignment and to ensure this equivalence : a X= b = a = a X b with 'X' begin one of the operators. It can be done, but it's unnecessary for mutable objects like sets or lists. A new object

Re: What tools are used to write and generate Python Library documentation.

2005-09-28 Thread Reinhold Birkenfeld
Kenneth McDonald wrote: I have a module I'd like to document using the same style... The Python Library documentation is written in LaTeX and converted to HTML with latex2html. The relevant style and source files are in the Python CVS tree. Reinhold --

Re: cannot write to file after close()

2005-09-26 Thread Reinhold Birkenfeld
Rainer Hubovsky wrote: Thank you Reinhold, that was the solution. But just because I am curious: what is this statement without the parentheses? After all it is a valid statement... Rainer In article [EMAIL PROTECTED], Reinhold Birkenfeld wrote: Is the above exactly your code? If yes

Re: Determine type of a socket

2005-09-26 Thread Reinhold Birkenfeld
Peter Hansen wrote: Tor Erik Sønvisen wrote: How can I determine the type of a socket (TCP or UDP) object? In what context? Do you have some code that gets passed a socket object but it could have been created with either SOCK_STREAM or SOCK_DGRAM? And you want a way of determining by

Re: cElementTree clear semantics

2005-09-25 Thread Reinhold Birkenfeld
D H wrote: Igor V. Rafienko wrote: This gave me the desired behaviour, but: * It looks *very* ugly * It's twice as slow as version which sees 'end'-events only. Now, there *has* to be a better way. What am I missing? Try emailing the author for support. I don't think that's needed.

Re: cElementTree clear semantics

2005-09-25 Thread Reinhold Birkenfeld
D H wrote: Reinhold Birkenfeld wrote: D H wrote: Igor V. Rafienko wrote: This gave me the desired behaviour, but: * It looks *very* ugly * It's twice as slow as version which sees 'end'-events only. Now, there *has* to be a better way. What am I missing? Try emailing the author

Re: cElementTree clear semantics

2005-09-25 Thread Reinhold Birkenfeld
D H wrote: Reinhold Birkenfeld wrote: Well, if I had e.g. a question about Boo, I would of course first ask here because I know the expert writes here. Reinhold Reinhold Birkenfeld also wrote: If I had wanted to say you have opinions? fuck off!, I would have said you have

Re: Re: cElementTree clear semantics

2005-09-25 Thread Reinhold Birkenfeld
D H wrote: D H wrote: Reinhold Birkenfeld wrote: Well, if I had e.g. a question about Boo, I would of course first ask here because I know the expert writes here. Reinhold Reinhold Birkenfeld also wrote: If I had wanted to say you have opinions? fuck off!, I would have said you

Re: Struggling with basics

2005-09-25 Thread Reinhold Birkenfeld
Jason wrote: A week ago I posted a simple little hi-score routine that I was using to learn Python. I've only just managed to examine the code, and the responses that people gave, and I'm now seriously struggling to understand why things aren't working correctly. At present my code is

Re: Re: cElementTree clear semantics

2005-09-25 Thread Reinhold Birkenfeld
D H wrote: Reinhold Birkenfeld wrote: D H wrote: D H wrote: Reinhold Birkenfeld wrote: Well, if I had e.g. a question about Boo, I would of course first ask here because I know the expert writes here. Reinhold Reinhold Birkenfeld also wrote: If I had wanted to say you have opinions

Re: cElementTree clear semantics

2005-09-25 Thread Reinhold Birkenfeld
Paul Boddie wrote: Reinhold Birkenfeld wrote: D H wrote: I would recommend emailing the author of a library when you have a question about that library. You should know that yourself as well. Well, if I had e.g. a question about Boo, I would of course first ask here because I know

Re: cannot write to file after close()

2005-09-25 Thread Reinhold Birkenfeld
Rainer Hubovsky wrote: Hello Python-Gurus, == f = open(LOGFILE,'w') f.write(time + '\n') f.close command = 'ping -n 20' + target + '' + LOGFILE system(command) == produces an error saying that a file cannot be accessed because it is

Re: Struggling with basics

2005-09-25 Thread Reinhold Birkenfeld
Jason wrote: Rather than reply to those individuals, just a big thanks to those that have helped. It's definitely making sense, the fact that I need to show the two-element tuple to show correctly was one of those head-slapping moments. And Dennis Lee Bieber hit the nail on the head

Re: C#3.0 and lambdas

2005-09-23 Thread Reinhold Birkenfeld
Erik Wilsher wrote: Python developement is discussed, decided and usually developed within the members of python-dev. Have you seen any discussions about xml-literals in python-dev lately? No. I don't need them, so I don't start a discussion. If you need them, or you want them, feel free to

Re: C#3.0 and lambdas

2005-09-23 Thread Reinhold Birkenfeld
Fredrik Lundh wrote: Reinhold Birkenfeld wrote: And I think the discussion that followed proved your point perfectly Fredrik. Big discussion over fairly minor things, but no big picture. Where are the initiatives on the big stuff (common documentation format, improved build system

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

Re: C#3.0 and lambdas

2005-09-22 Thread Reinhold Birkenfeld
Erik Wilsher wrote: And I think the discussion that followed proved your point perfectly Fredrik. Big discussion over fairly minor things, but no big picture. Where are the initiatives on the big stuff (common documentation format, improved build system, improved web modules, reworking the

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: 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 pyshell#119, 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't

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 high-order

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 object to be

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' File stdin, line 1 print 'hello'

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 --

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 --

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. But expressing the

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.Bar import

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. This term is ambiguous

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: PyObject*

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: 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 to mean

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 module (which can be confusing on its own

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) x = _ in iterable So, no further tinkering with yield, I'm afraid. Reinhold

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 advantage in using __metaclass__ except that you can set it globally for all classes

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 becoming the standard

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 know of to do this

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 me?

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 --

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

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) fails to show up in the final PDF. I

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 really broken part is that

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 buildin

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 --

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 demonstrates why

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)) != '': # ... work on c I

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 ['any', 'old',

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 global

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: 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 it says XP and

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 me another integer.

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?

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 gradians, which

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.py to be

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 creating

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() ... class A

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 readable than the first, IMHO. True, but the first function

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 developer requires

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

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-like wrapper around win32gui, or another one around Xlib

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 the absolute path.. @param p [string] = a path to a file

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 quite good

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 saving

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

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 already been

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 difference senses

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. Forget using '+' for

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 path,

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 still supported on Python? Because Mac programmers who

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 to a == b and b c: Right. Stupid me :) Doesn't do much to the point, though. 1 == 1+0j 0 Traceback

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 implemented with comparison operators. That just means

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 most of where you like. Reinhold -- http

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. They are now named .basename and .directory. Reinhold, is .parent now

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 *without*

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: 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 have

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

2005-07-25 Thread Reinhold Birkenfeld
Tony Meyer wrote: [...] Open issues: [...] What about path * 4? If you keep the current join meaning of __div__, then assigning any sort of multiplication meaning to __mul__ would not be a good idea, IMO. It's natural to expect that __div__ and __mul__ are opposites. I suppose this

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

2005-07-25 Thread Reinhold Birkenfeld
Andrew Dalke wrote: Reinhold Birkenfeld wrote: Okay. While a path has its clear use cases and those don't need above methods, it may be that some brain-dead functions needs them. brain-dead? Consider this code, which I think is not atypical. Okay, convinced. Reinhold -- http

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

2005-07-25 Thread Reinhold Birkenfeld
Reinhold Birkenfeld wrote: Hi, the arguments in the previous thread were convincing enough, so I made the Path class inherit from str/unicode again. Current change: * Add base() method for converting to str/unicode. * Allow compare against normal strings. Reinhold -- http

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

2005-07-25 Thread Reinhold Birkenfeld
Stefan Rank wrote: on 25.07.2005 10:44 Michael Hoffman said the following: Reinhold Birkenfeld wrote: Tony Meyer wrote: Do people really like using __div__ to mean join? Of course, one can use joinwith() if he doesn't like '/'. Personally, I'm -0 on __div__, but I suppose if anyone here claimed

Re: Path PEP: What should Path(None) do?

2005-07-25 Thread Reinhold Birkenfeld
Michael Hoffman wrote: Currently it returns Path('None'). This means I have to do a check on input before pathifying it to make sure it is not None. Perhaps it should throw ValueError? The problem is that Path() currently acts like str() and will therefore accept almost anything that has a

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

2005-07-25 Thread Reinhold Birkenfeld
Peter Hansen wrote: Reinhold Birkenfeld wrote: Peter Hansen wrote: Would basestring() be a better name? tobase? tostring? tobasestring? Of these choices, the latter would be preferable. Alternative is to set a class attribute Base of the Path class. Or export PathBase

Re: Path PEP: What should Path(None) do?

2005-07-25 Thread Reinhold Birkenfeld
Peter Hansen wrote: Michael Hoffman wrote: Currently it returns Path('None'). This means I have to do a check on input before pathifying it to make sure it is not None. Perhaps it should throw ValueError? Without checking, I suspect it is merely doing str(x) or unicode(x) on whatever

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

2005-07-25 Thread Reinhold Birkenfeld
[EMAIL PROTECTED] wrote: Reinhold Right, that was a concern of mine, too. Reinhold tobase? Reinhold tostring? Reinhold tobasestring? If we're on a filesystem that understands unicode, would somepath.tostring() return a unicode object or a string object encoded with some

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

2005-07-25 Thread Reinhold Birkenfeld
Bengt Richter wrote: BTW, more OT, wouldn't '|' be more platform-neutral as the joining operator? I, on the other hand, would certainly prefer U+01C1. Reinhold -- http://mail.python.org/mailman/listinfo/python-list

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

2005-07-24 Thread Reinhold Birkenfeld
Peter Hansen wrote: Reinhold Birkenfeld wrote: [on comparing Paths and stings] Do you have a use case for the comparison? Paths should be compared only with other paths. I can think of lots, though I don't know that I've used any in my existing (somewhat limited) code that uses Path

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

2005-07-24 Thread Reinhold Birkenfeld
Reinhold Birkenfeld wrote: Hi, the arguments in the previous thread were convincing enough, so I made the Path class inherit from str/unicode again. Further changes by now: * subdirs() is now dirs(). * fixed compare behaviour for unicode base (unicode has no rich compare) * __iter__

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

2005-07-24 Thread Reinhold Birkenfeld
Michael Hoffman wrote: Reinhold Birkenfeld wrote: * __iter__() iterates over the parts(). * the following methods raise NotImplemented: capitalize, expandtabs, join, splitlines, title, zfill Why? They *are* implemented. I do not understand this desire to wantonly break basestring

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

2005-07-24 Thread Reinhold Birkenfeld
Peter Hansen wrote: Reinhold Birkenfeld wrote: Peter Hansen wrote: if mypath.splitpath()[0] == 'c:/temp': vs. if mypath.splitpath()[0] == Path('c:/temp'): But you must admit that that't the cleaner solution. Cleaner? Not at all. I'd say it's the more expressive solution

Re: tuple to string?

2005-07-23 Thread Reinhold Birkenfeld
John Machin wrote: Reinhold Birkenfeld wrote: Berthold Höllmann wrote: Francois De Serres [EMAIL PROTECTED] writes: hiho, what's the clean way to translate the tuple (0x73, 0x70, 0x61, 0x6D) to the string 'spam'? . t = (0x73, 0x70, 0x61, 0x6D) . ''.join('%c' % c for c in t) 'spam

[path-PEP] Path inherits from basestring again

2005-07-23 Thread Reinhold Birkenfeld
Hi, the arguments in the previous thread were convincing enough, so I made the Path class inherit from str/unicode again. It still can be found in CVS: /python/nondist/sandbox/path/{path.py,test_path.py} One thing is still different, though: a Path instance won't compare to a regular string.

  1   2   3   >