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

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 s

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

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 s

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 &

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

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

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

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 B

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 bec

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

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

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

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 -- http://mail.python.org/mailman/listinfo/p

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 ob

[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 -- http://mail.python.org/mailman/listin

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

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

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

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

2005-09-30 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... ? >

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

2005-09-30 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,

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

2005-09-30 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 >&g

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 bet

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 -- http://mail.python.org/mailman/listinfo/py

Re: Parsing a search string

2004-12-31 Thread Reinhold Birkenfeld
M.E.Farmer wrote: > As I noted before shlex requires a file like object or a open file . > py> import shlex > py> a = shlex.shlex('fgfgfg dgfgfdgfdg') > py> a.get_token() > Traceback (most recent call last): > File "", line 1, in ? > File ".\shlex.py", line 74, in get_token > raw = self.read_token(

Re: Parsing a search string

2004-12-31 Thread Reinhold Birkenfeld
M.E.Farmer wrote: > Ah! that is what the __future__ brings I guess. > Damn that progress making me outdated ;) > Python 2.2.3 ( a lot of extensions I use are stuck there , so I still > use it) I'm also positively surprised how many cute little additions are there every new Python version.

Re: what is lambda used for in real code?

2004-12-31 Thread Reinhold Birkenfeld
Adam DePrince wrote: >> So, those are my thoughts on how lambdas are "really" used. If others >> out there have real-life code that uses lambdas in interesting ways, >> feel free to share them here! >> > > Lets not forget the "real reason" for lambda ... I really hoped you would point out th

Re: Looping using iterators with fractional values

2005-01-01 Thread Reinhold Birkenfeld
drife wrote: > Hello, > > Making the transition from Perl to Python, and have a > question about constructing a loop that uses an iterator > of type float. How does one do this in Python? > > In Perl this construct quite easy: > > for (my $i=0.25; $i<=2.25; $i+=0.25) { > printf "%9.2f\n", $i; >

Re: Looping using iterators with fractional values

2005-01-01 Thread Reinhold Birkenfeld
Mike Meyer wrote: > Or - and much safer when dealing with floating point numbers - iterate > over integers and generate your float values: > > for j in range(1, 9): > i = j * .25 > print "%9.2f" % i There's a glitch there, though - should be range(1, 10). Reinhold PS: I'm wondering whe

Re: What can I do with Python ??

2005-01-01 Thread Reinhold Birkenfeld
BOOGIEMAN wrote: > Beginners question, but really what can you do with it ? > How hard is Python to learn compared with other languages > (let's say C#). Can you make fullscreen game with it (for example) ? > I've looked at http://www.python.org but nothing concrete there For fullscreen games, s

Re: What can I do with Python ??

2005-01-02 Thread Reinhold Birkenfeld
Jabaru wrote: >> BTW, I don't know of >> a way to write fullscreen games in C#... >> > > Directx, Opengl, Gdi+, win32api, SDL... the list goes on Yes, that's right, but most of those you can use in Python, too. I should have inserted the word "specific" at the right point in my sentence Reinhol

Re: ? about file() and open()

2005-01-03 Thread Reinhold Birkenfeld
Sean wrote: > Was wondering if there was any difference between these two functions. > I have read some text that said file() wasn't introduced until 2.2 and > that it was synonymous with open(). Does this mean that I should be > using file() where I used open() before? FYI, I submitted a patch t

Re: else condition in list comprehension

2005-01-09 Thread Reinhold Birkenfeld
Luis M. Gonzalez wrote: > Hi there, > > I'd like to know if there is a way to add and else condition into a > list comprehension. I'm sure that I read somewhere an easy way to do > it, but I forgot it and now I can't find it... > > for example: > z=[i+2 for i in range(10) if i%2==0] > what if I w

Re: else condition in list comprehension

2005-01-09 Thread Reinhold Birkenfeld
Matteo Dell'Amico wrote: > Luis M. Gonzalez wrote: >> Hi there, >> >> I'd like to know if there is a way to add and else condition into a >> list comprehension. I'm sure that I read somewhere an easy way to do >> it, but I forgot it and now I can't find it... >> >> for example: >> z=[i+2 for i in

Re: tuples vs lists

2005-01-11 Thread Reinhold Birkenfeld
Antoon Pardon wrote: > Op 2005-01-10, Bruno Desthuilliers schreef <[EMAIL PROTECTED]>: >> Antoon Pardon a écrit : >>> Op 2005-01-08, Bruno Desthuilliers schreef <[EMAIL PROTECTED]>: >>> worzel a écrit : >I get what the difference is between a tuple and a list, but why would I >ev

Re: Free python server.

2005-01-13 Thread Reinhold Birkenfeld
Kartic wrote: > And yes, they have python installed... Python 2.1! Reinhold -- http://mail.python.org/mailman/listinfo/python-list

Re: reference or pointer to some object?

2005-01-13 Thread Reinhold Birkenfeld
Torsten Mohr wrote: > Hi, > >> Could you give us a more concrete use case? My suspicion is that >> anything complicated enough to be passed to a method to be modified will >> probably be more than a simple int, float, str or tuple... In which >> case, it will probably have methods to allow you t

Re: Octal notation: severe deprecation

2005-01-14 Thread Reinhold Birkenfeld
Simon Brunning wrote: > On Thu, 13 Jan 2005 16:50:56 -0500, Leif K-Brooks <[EMAIL PROTECTED]> wrote: >> Tim Roberts wrote: >> > Stephen Thorne <[EMAIL PROTECTED]> wrote: >> > >> >>I would actually like to see pychecker pick up conceptual errors like this: >> >> >> >>import datetime >> >>datetime.da

Re: Octal notation: severe deprecation

2005-01-14 Thread Reinhold Birkenfeld
Bengt Richter wrote: > On Thu, 13 Jan 2005 08:18:25 -0500, Peter Hansen <[EMAIL PROTECTED]> wrote: > >>[EMAIL PROTECTED] wrote: >>> In Mythical Future Python I would like to be able to use any base in >>> integer literals, which would be better. Example random syntax: >>> >>> flags= 2x00011010101

Re: Why would I get a TypeEror?

2005-01-14 Thread Reinhold Birkenfeld
It's me wrote: > Sorry if my question was a little "lazy" and yes, I was asking about the > "lazy evaluation". :=) > > I am surprised about this (and this can be dangerous, I guess). > > If this is true, I would run into trouble real quick if I do a: > > (1/x,1.0e99)[x==0] > > and that's not g

Re: Why would I get a TypeEror?

2005-01-14 Thread Reinhold Birkenfeld
It's me wrote: > Say again??? > > "Reinhold Birkenfeld" <[EMAIL PROTECTED]> wrote in > message news:[EMAIL PROTECTED] >> It's me wrote: >> > Sorry if my question was a little "lazy" and yes, I was asking about the >> > &quo

Re: Why would I get a TypeEror?

2005-01-14 Thread Reinhold Birkenfeld
Steven Bethard wrote: > It's me wrote: >> Say again??? > > Please stop top-posting -- it makes it hard to reply in context. > >> "Reinhold Birkenfeld" wrote... >>>It's me wrote: >>>>If this is true, I would run into trouble real qu

Re: [perl-python] 20050114 if statement

2005-01-15 Thread Reinhold Birkenfeld
Xah Lee wrote: > . # here's an example of if statement in python. > . > . x=-1 > . if x<0: > . print 'neg' > . elif x==0: > . print 'zero' > . elif x==1: > . print 'one' > . else: > . print 'other' > . > . # the elif can be omitted. > . -- > . # here'

Re: How to del item of a list in loop?

2005-01-15 Thread Reinhold Birkenfeld
skull wrote: > Hi everybody, it is my first post in this newsgroup. > I am a newbie for python though I have several years development experience > in c++. > recently, I was stumped when I tried to del item of a list when iteration. > > here is the wrong way I did: > > lst = [1, 2, 3] > for i in

Re: How to del item of a list in loop?

2005-01-15 Thread Reinhold Birkenfeld
Reinhold Birkenfeld wrote: > skull wrote: >> Hi everybody, it is my first post in this newsgroup. >> I am a newbie for python though I have several years development experience >> in c++. >> recently, I was stumped when I tried to del item of a list when iteration. >

Re: Assigning to self

2005-01-17 Thread Reinhold Birkenfeld
Frans Englich wrote: > Hello, > > I am having trouble with throwing class instances around. Perhaps I'm > approaching my goals with the wrong solution, but here's nevertheless a > stripped down example which demonstrates my scenario: > > #

Re: [perl-python] 20050118 keyed list

2005-01-18 Thread Reinhold Birkenfeld
Jay Tilton wrote: >: # the syntax of keyed list in Perl is too complex >: # to be covered in a short message. JFTR: "keyed lists" are called dictionaries in Python. > > [1]Message-ID: <[EMAIL PROTECTED]> > This guy's wish-wash is starting to be funny, after all! Reinhold -- http://mail.pyth

Re: [perl-python] 20050118 keyed list

2005-01-18 Thread Reinhold Birkenfeld
Jürgen Exner wrote: >> © # see "perldoc perldata" for an unix-styled course. > > Excuse me? Do you mind explaining where exactly perldata is "Unix-styled"? Remember: Perl == Unix == Satan. Reinhold -- http://mail.python.org/mailman/listinfo/python-list

What YAML engine do you use?

2005-01-20 Thread Reinhold Birkenfeld
Hello, I know that there are different YAML engines for Python out there (Syck, PyYaml, more?). Which one do you use, and why? For those of you who don't know what YAML is: visit http://yaml.org/! You will be amazed, and never think of XML again. Well, almost. Reinhold -- http://mail.python.or

Re: What YAML engine do you use?

2005-01-21 Thread Reinhold Birkenfeld
A.M. Kuchling wrote: > On Fri, 21 Jan 2005 18:54:50 +0100, > Fredrik Lundh <[EMAIL PROTECTED]> wrote: >> judging from http://yaml.org/spec/current.html (750k), the YAML designers are >> clearly insane. that's the most absurd software specification I've ever >> seen. they >> need help, not

Re: make install with python

2005-01-21 Thread Reinhold Birkenfeld
Uwe Mayer wrote: > Hi, > > I am writing a Python application and use the GNU auto-tools to compile what > needs compilation (i.e. Qt's .ui files). > However, I don't know how to write an automake file that installs the main > file (lmc.py) and some library files (i.e. ClassA.py, ClassB.py) into th

Re: default value in a list

2005-01-22 Thread Reinhold Birkenfeld
Michael Spencer wrote: > Alex Martelli wrote: > [explanation and the following code:] > >> >>> a, b, c = it.islice( >> ... it.chain( >> ... line.split(':'), >> ... it.repeat(some_default), >> ... ), >> ... 3) >> ...

Re: default value in a list

2005-01-22 Thread Reinhold Birkenfeld
Nick Coghlan wrote: > Reinhold Birkenfeld wrote: >>>Why not put these together and put it in itertools, since the requirement >>>seems >>>to crop up every other week? >>> >>> >>> line = "A:B:C".split(":") >>

Re: How do I convert arithemtic string (like "2+2") to a number?

2005-02-06 Thread Reinhold Birkenfeld
Michael Hartl wrote: > Adam brings up a good point: eval is a very general function which > evaluates an arbitrary Python expression. As a result, it (and its > close cousin exec) should be used with caution if security is an issue. To get a secure eval for simple mathematical expressions, it sho

Re: Multiple constructors

2005-02-06 Thread Reinhold Birkenfeld
vincent wehren wrote: > Philip Smith wrote: >> Call this a C++ programmers hang-up if you like. >> >> I don't seem to be able to define multiple versions of __init__ in my matrix >> class (ie to initialise either from a list of values or from 2 dimensions >> (rows/columns)). >> >> Even if Pytho

Re: Python versus Perl ?

2005-02-06 Thread Reinhold Birkenfeld
[EMAIL PROTECTED] wrote: > I've read some posts on Perl versus Python and studied a bit of my > Python book. > > I'm a software engineer, familiar with C++ objected oriented > development, but have been using Perl because it is great for pattern > matching, text processing, and automated testing

Re: Beginner question: Converting Single-Element tuples to list

2005-06-26 Thread Reinhold Birkenfeld
[EMAIL PROTECTED] wrote: > Hi, > > Thanks for your reply! A new thing learned > > Allow me to follow that up with another question: > > Let's say I have a result from a module called pyparsing: > > Results1 = ['abc', 'def'] > Results2 = ['abc'] > > They are of the ParseResults type: > >>>

Re: turn text lines into a list

2005-06-27 Thread Reinhold Birkenfeld
Xah Lee wrote: > i have a large number of lines i want to turn into a list. > In perl, i can do > > @corenames=qw( > rb_basic_islamic > sq1_pentagonTile > sq_arc501Tile > sq_arc503Tile > ); > > use Data::Dumper; > print Dumper([EMAIL PROTECTED]); > > -- > is there some shortcut to turn l

Re: noob question

2005-06-27 Thread Reinhold Birkenfeld
Alan Gauld wrote: > The only place I've ever found Hungarian notation useful was > in C which is a weird mix of static typing and no-typing, > and there the prefix code gives a clue as to what kind of > value you might expect to find. But when I moved to C++ I > dropped the prefixes because they a

Modules for inclusion in standard library?

2005-06-27 Thread Reinhold Birkenfeld
Hello, at the moment python-dev is discussing including Jason Orendorff's path module into the standard library. Do you have any other good and valued Python modules that you would think are bug-free, mature (that includes a long release distance) and useful enough to be granted a place in the st

Re: Modules for inclusion in standard library?

2005-06-28 Thread Reinhold Birkenfeld
George Sakkis wrote: >> "bruno modulix" <[EMAIL PROTECTED]> wrote: > >> George Sakkis wrote: >> > I'd love to see IPython replace the standard interpreter. >> I dont. > > Care to say why ? For an easy, quick interactive interpreter, it's way to overloaded with functions and too slow in startup.

Re: strange __call__

2005-06-29 Thread Reinhold Birkenfeld
Rahul wrote: > If you do C = wrap(C) C no longer remains a class..it becomes a > function. Does that matter? Reinhold -- http://mail.python.org/mailman/listinfo/python-list

Re: Accepted Summer of Code proposals

2005-07-02 Thread Reinhold Birkenfeld
A.M. Kuchling wrote: > For anyone who's interested: the Python wiki now contains a list of the > PSF-mentored proposals that were accepted for Google's Summer of Code: > http://wiki.python.org/moin/SummerOfCode Is it right that two Wax proposals were accepted? Reinhold -- http://mail.pytho

Re: Use cases for del

2005-07-06 Thread Reinhold Birkenfeld
Ron Adam wrote: > Ron Adam wrote: > >> And accessing an undefined name returned None instead of a NameError? > > I retract this. ;-) > > It's not a good idea. But assigning to None as a way to unbind a name > may still be an option. IMO, it isn't. This would completely preclude the usage of

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-06 Thread Reinhold Birkenfeld
Ron Adam wrote: > Given the statement: > > a = None > > And the following are all true: > > a == None Okay. > (a) == (None) Okay. > (a) == () Whoops! a (which is None) is equal to the empty tuple (which is not None)? > (None) == () > > Then this "conceptual" comparison should also be tr

Re: Use cases for del

2005-07-10 Thread Reinhold Birkenfeld
Ron Adam wrote: >> >>> 'abc' is 'abcd'[:3] >> False > > Well of course it will be false... your testing two different strings! > And the resulting slice creates a third. > > Try: > > ABC = 'abc' > > value = ABC > if value is ABC: # Test if it is the same object > pass That's not

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-10 Thread Reinhold Birkenfeld
Kay Schluehr wrote: > Dan Sommers schrieb: > >> How about this: >> >> def __init__(self, self.x, y, self.z): >> # self.x, self.z from first and third explicit parameters >> do_something_with_y() > > Can you tell me in which way it is anyhow better than the original > proposal

Re: __autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

2005-07-11 Thread Reinhold Birkenfeld
Dan Sommers wrote: > Without thinking it all the way through, I suppose these: > >def method_1(self, *self.l): >pass >def method_2(self, **self.d): >pass > > could act as if they were these: > > def method_1(self, *args): > self.l = args > del args >

Re: regular expression questions in Python

2005-07-11 Thread Reinhold Birkenfeld
Jeremy wrote: > I am (very) new top regular expressions and I am having a difficult time > understanding how to do them. I have the following in my script: > > zaidsearch = r'''^ {5,}([\d]{4,5})(.\d{2,2}c)''' > ZAIDSearch = re.compile(search, re.IGNORECASE) > > When I do: ZAID.search(...) then

Re: Tricky Dictionary Question from newbie

2005-07-11 Thread Reinhold Birkenfeld
Mark Jackson wrote: > "Ric Da Force" <[EMAIL PROTECTED]> writes: > >> It is hard to explain but this is what I mean: >> >> Dict = {'rt': 'This is repeated', 'sr': 'This is repeated', 'gf': 'This is >> not'} >> >> I want this to return a new dict with string keys and lists containing the >> pre

Re: Environment Variable

2005-07-11 Thread Reinhold Birkenfeld
[EMAIL PROTECTED] wrote: > Is it possible to set an environment variable from inside the python > script which will be retained after the script exits. > > If I use the following code: > > import os > os.putvar("name", "tuxlover") > > the enivironment variable name is visible to only the sub-pro

Re: Environment Variable

2005-07-11 Thread Reinhold Birkenfeld
[EMAIL PROTECTED] wrote: > Sorry for posting twice. > Sorry for forgetting my . Reinhold -- http://mail.python.org/mailman/listinfo/python-list

Re: set and frozenset unit tests?

2005-07-12 Thread Reinhold Birkenfeld
Jacob Page wrote: > I have released interval-0.2.1 at > http://members.cox.net/apoco/interval/. IntervalSet and > FrozenIntervalSet objects are now (as far as I can tell) functionality > equivalent to set and frozenset objects, except they can contain > intervals as well as discrete values. >

Re: re.IGNORECASE and re.VERBOSE

2005-07-18 Thread Reinhold Birkenfeld
Jeremy wrote: > I am using regular expressions and I would like to use both > re.IGNORECASE and re.VERBOSE options. I want to do something like the > following (which doesn't work): > > matsearch = r'''^\ {0,4}([mM]\d+) ''' > MatSearch = re.compile(matsearch, re.VERBOSE, re.IGNORECASE) > > Does

Re: re.IGNORECASE and re.VERBOSE

2005-07-18 Thread Reinhold Birkenfeld
Simon Brunning wrote: > On 7/18/05, Jeremy <[EMAIL PROTECTED]> wrote: >> I am using regular expressions and I would like to use both >> re.IGNORECASE and re.VERBOSE options. I want to do something like the >> following (which doesn't work): >> >> matsearch = r'''^\ {0,4}([mM]\d+) ''' >> MatSearch

Re: PEP on path module for standard library

2005-07-21 Thread Reinhold Birkenfeld
FYI: I modified the path module a bit so that it fits many of the suggestions from python-dev, and put the result in the Python CVS tree under nondist/sandbox/path. Most prominent change is that it doesn't inherit from str/unicode anymore. I found this distinction important, because as a str subcl

Re: PEP on path module for standard library

2005-07-22 Thread Reinhold Birkenfeld
Michael Hoffman wrote: > Reinhold Birkenfeld wrote: >> FYI: I modified the path module a bit so that it fits many of the suggestions >> from python-dev, and put the result in the Python CVS tree under >> nondist/sandbox/path. >> >> Most prominent change is that it

Re: PEP on path module for standard library

2005-07-22 Thread Reinhold Birkenfeld
Michael Hoffman wrote: > [EMAIL PROTECTED] wrote: >> I really love Jason's 'path' module. Sadly, I've encountered a serious >> problem with using it. When you try to 'freeze' an application module, >> and Jason's 'path' module is present in any of the directories that are >> looked at by freeze's

Re: PEP on path module for standard library

2005-07-22 Thread Reinhold Birkenfeld
mmended here on c.l.p. I submitted an RFE to add it to the Python >> standard library, and Reinhold Birkenfeld started a discussion on it in >> python-dev >> <http://mail.python.org/pipermail/python-dev/2005-June/054438.html>. >> >> The upshot of the discuss

Re: PEP on path module for standard library

2005-07-22 Thread Reinhold Birkenfeld
Andrew Dalke wrote: > Duncan Booth wrote: >> Personally I think the concept of a specific path type is a good one, but >> subclassing string just cries out to me as the wrong thing to do. > > I disagree. I've tried using a class which wasn't derived from > a basestring and kept running into plac

Re: tuple to string?

2005-07-22 Thread Reinhold Birkenfeld
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' Or: t = (0x73, 0x70, 0x61,

Re: tuple to string?

2005-07-22 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 (

[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. O

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

2005-07-23 Thread Reinhold Birkenfeld
Peter Hansen wrote: > Reinhold Birkenfeld wrote: >> One thing is still different, though: a Path instance won't compare to a >> regular >> string. > > Could you please expand on what this means? Are you referring to doing > < and >= type operations

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

2005-07-23 Thread Reinhold Birkenfeld
Peter Hansen wrote: > Reinhold Birkenfeld wrote: >> Peter Hansen wrote (on Paths not allowing comparison with strings): >>>Could you please expand on what this means? Are you referring to doing >>>< and >= type operations on Paths and strings, or == and != o

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

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

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 th

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

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

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 th

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

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

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

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

2005-07-25 Thread Reinhold Birkenfeld
Peter Hansen wrote: > Reinhold Birkenfeld wrote: >> Current change: >> >> * Add base() method for converting to str/unicode. > > Would basestring() be a better name? Partly because that seems to be > exactly what it's doing, but more because there are (or u

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 b

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 >

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 encod

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

  1   2   3   >