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

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 quick if I do a: (1/x,1.0e99)[x==0] Lazy evaluation: use the (x==0 and 1e99 or 1/x

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

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

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 the

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(:) ... def ipad(N,iterable, default = None): ... return it.islice(it.chain(iterable, it.repeat(default

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

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 Python couldn't

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

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 magical for my tastes;

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 obvious that the second one returns an independent, separate object initially equal to x . x

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 you use Python mostly

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... Like you I

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: 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: 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 'par' is

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.google.com/search?q=separate http://groups-beta.google.com/group/comp.lang.python/search?group

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, and that is the exact

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

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/education/animals/guillemot.html http://www.birdguides.com/html

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 add a few

Re: Speed ain't bad

2004-12-31 Thread Reinhold Birkenfeld
Craig Ringer wrote: On Fri, 2004-12-31 at 11:17, Jeremy Bowers wrote: I would point out a couple of other ideas, though you may be aware of them: Compressing all the files seperately, if they are small, may greatly reduce the final compression since similarities between the files can not be

Re: Parsing a search string

2004-12-31 Thread Reinhold Birkenfeld
Freddie wrote: Happy new year! Since I have run out of alcohol, I'll ask a question that I haven't really worked out an answer for yet. Is there an elegant way to turn something like: moo cow farmer john -zug into: ['moo', 'cow', 'farmer john'], ['zug'] I'm trying to parse a

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

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; } =Py2.3:

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

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

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 to

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 range(10) if

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

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

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

Re: Question about mutexes

2005-06-01 Thread Reinhold Birkenfeld
Jan Danielsson wrote: In OS/2 C, I would do this: main() { ... DosCreateMutexSem(NULL, hmtx, 0UL, FALSE); ... } thread() { ... DosRequestMutexSem(hmtx); Locked! DosReleaseMutexSem(hmtx); ... } How would I go about doing that in Python? I think you will want to create a

Re: decimal and trunkating

2005-06-02 Thread Reinhold Birkenfeld
F. Petitjean wrote: Le Thu, 02 Jun 2005 19:59:08 +1000, Timothy Smith a écrit : i want to trunkate 199.999 to 199.99 round(199.999, 2) # 2 digits after the decimal point Wrong. This will yield 200.00. do i really have to use floats to do this? 19.999 is a float : type(19.999) is

Re: decimal and trunkating

2005-06-02 Thread Reinhold Birkenfeld
Peter Hansen wrote: Reinhold Birkenfeld wrote: He is speaking of Decimals... d = Decimal(199.999) d._round(5, decimal.ROUND_DOWN) Is one really supposed to call the underscore methods like that? Umm... no, I think not ;) But I couldn't find something better. Reinhold -- http

Re: Two questions

2005-06-02 Thread Reinhold Birkenfeld
Richard Lewis wrote: On 2 Jun 2005 06:45:18 -0700, [EMAIL PROTECTED] said: Hi, I've developed in several other languages and have recently found Python and I'm trying to use it in the shape of the PythonCard application development tool. My two questions: 1. What is the easiest way to

Re: mix up a string

2005-06-05 Thread Reinhold Birkenfeld
rbt wrote: What's the best way to take a string such as 'dog' and mix it up? You know, like the word jumble in the papers? ODG. I thought something like mix = random.shuffle('dog') would do it, but it won't. Any tips? py def shuffled(s): ... l = list(s) ... random.shuffle(l) ...

Re: the python way?

2005-06-06 Thread Reinhold Birkenfeld
Grops wrote: Hi All, I've been lurking the list for a month and this is my first post. I am hoping this post is appropriate here, otherwise, my apologies. I'm somewhat new to Python, (I'm reading all the tutorials I can find, and have read through Andre Lessa's Developers Handbook.)

split up a list by condition?

2005-06-06 Thread Reinhold Birkenfeld
Hi, while writing my solution for The python way?, I came across this fragment: vees = [c for c in wlist[::-1] if c in vocals] cons = [c for c in wlist[::-1] if c not in vocals] So I think: Have I overlooked a function which splits up a sequence into two, based on a condition? Such as

Re: the python way?

2005-06-07 Thread Reinhold Birkenfeld
Andrew Dalke wrote: Reinhold Birkenfeld wrote: To make it short, my version is: import random def reinterpolate2(word, vocals='aeiouy'): wlist = list(word) random.shuffle(wlist) vees = [c for c in wlist[::-1] if c in vocals] cons = [c for c in wlist[::-1] if c

Re: split up a list by condition?

2005-06-07 Thread Reinhold Birkenfeld
Raymond Hettinger wrote: while writing my solution for The python way?, I came across this fragment: vees = [c for c in wlist[::-1] if c in vocals] cons = [c for c in wlist[::-1] if c not in vocals] So I think: Have I overlooked a function which splits up a sequence into two, based on a

Re: split up a list by condition?

2005-06-07 Thread Reinhold Birkenfeld
Duncan Booth wrote: Reinhold Birkenfeld wrote: Hi, while writing my solution for The python way?, I came across this fragment: vees = [c for c in wlist[::-1] if c in vocals] cons = [c for c in wlist[::-1] if c not in vocals] So I think: Have I overlooked a function which

Re: without shell

2005-06-10 Thread Reinhold Birkenfeld
Donn Cave wrote: Not according the the docs: Also, for each of these variants, on Unix, cmd may be a sequence, in which case arguments will be passed directly to the program without shell intervention (as with os.spawnv()). If cmd is a string it will be passed to the shell (as with

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

2005-06-27 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: type(Results1)

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 lines into list

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 added

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

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. However,

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

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

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

2005-07-07 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 true: if

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 going to buy you

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

2005-07-11 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 def

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 def

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 this

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 previous keys for

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

Re: Environment Variable

2005-07-11 Thread Reinhold Birkenfeld
[EMAIL PROTECTED] wrote: Sorry for posting twice. Sorry for forgetting my wink. wink 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 anyone

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

  1   2   3   >