Re: iterate start at second row in file not first

2008-05-20 Thread Mark d.
How about: mov = open(afile) line = mov.readline() ...(process your ':' line) for line in mov.readlines(): ... On May 20, 1:34 pm, [EMAIL PROTECTED] wrote: > i have a big file with sentences, the first file of each sentence > contains a colon(:) somewher eon that line > i want to jump past th

subscribe

2008-05-20 Thread Deverter,Mark
-- http://mail.python.org/mailman/listinfo/python-list

Bug in floating-point addition: is anyone else seeing this?

2008-05-21 Thread Mark Dickinson
" for more information. >>> a = 1e16-2. >>> a 9998.0 >>> a+0.999 # gives expected result 9998.0 >>> a+0. # doesn't round correctly. 1.0 The last result here should be 9998.0, not 100

Re: Bug in floating-point addition: is anyone else seeing this?

2008-05-21 Thread Mark Dickinson
ug report: it's not clear how to fix this, or whether it's worth fixing, but it seems like something that should be documented somewhere... Thanks again, everyone! Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Bug in floating-point addition: is anyone else seeing this?

2008-05-22 Thread Mark Dickinson
ly, it looks as though libm (and hence the Python math module) might need the extended precision: on my machine there's a line in /usr/include/fpu_control.h that says #define _FPU_EXTENDED 0x300 /* libm requires double extended precision. */ Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Bug in floating-point addition: is anyone else seeing this?

2008-05-22 Thread Mark Dickinson
d the above mentioned paper; I found it extremely helpful. http://bugs.python.org/issue2937 Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Why is math.pi slightly wrong?

2008-05-22 Thread Mark Dickinson
f math.pi. math.pi is exactly equal to 884279719003555/281474976710656, which is the closest C double to the actual value of pi. The problem in (2) occurs because floating-point numbers are stored in binary, but printed in decimal. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: convert binary to float

2008-06-01 Thread Mark Tolonen
) George tagData still contains your data, but it is being displayed two different ways. Consult the documentation about str() and repr(). -Mark -- http://mail.python.org/mailman/listinfo/python-list

PyInstaller: problem to build exe with PyQt4

2008-06-02 Thread Mark Delon
Hi, I need to generate single EXEcutable via PyInstaller. It will be genereated -> i get one single executable. AFTER CALL (exe) I get an error: "no module named _gt" Build command: 1. Configure.py 2. Makespec.py -F

Re: pythton 调用 so 共享库不能转换参数类型

2008-06-03 Thread Mark Tolonen
xcept myff()" - 出错提示为 ctypes.ArgumentError: argument 1: 'exceptions.TypeError'>: Don't know how to convert parameter 1 这是什么原因? --Mark (马克) -- http://mail.python.org/mailman/listinfo/python-list

Re: ctypes help

2008-06-06 Thread Mark Tolonen
r(value)) # call the function with a pointer to the instance value c_long(10) Hope that helps. -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing a path to components

2008-06-07 Thread Mark Tolonen
ath,abspath x=r'\foo\\bar/baz//spam.py' normpath(x) '\\foo\\bar\\baz\\spam.py' normpath(abspath(x)) 'C:\\foo\\bar\\baz\\spam.py' normpath(abspath(x)).split(os.sep) ['C:', 'foo', 'bar', 'baz', 'spam.py'] -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: time module methods give an am or pm value ?

2008-06-07 Thread Mark Tolonen
rftime('%I:%M:%S %p',localtime(time())) '07:23:24 AM' strftime('%I:%M:%S %p',gmtime(time())) '02:23:39 PM' -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is slow

2008-06-08 Thread Mark Tarver
look at Norvig's analysis which supports your view about Python being slow. http://norvig.com/python-lisp.html Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does python not have a mechanism for data hiding?

2008-06-08 Thread Mark Wooding
Paul Rubin wrote: > This is bogus about 95% of the time though. For the cases where it is > really desired, I think it's best to require the target class to be > enable it specifically somehow, maybe by inheriting from a special > superclass. That could let the compiler statically resolve membe

Re: Why does python not have a mechanism for data hiding?

2008-06-08 Thread Mark Wooding
Hrvoje Niksic <[EMAIL PROTECTED]> wrote: > How about #define class struct Won't work. Consider `template ...'. -- [mdw] -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does python not have a mechanism for data hiding?

2008-06-08 Thread Mark Wooding
Russ P. <[EMAIL PROTECTED]> wrote: > The idea of being able to discern properties of an object by its name > alone is something that is not normally done in programming in > general. Really? You obviously haven't noticed Prolog, Smalltalk, Haskell, ML, or Erlang then. And that's just the ones

Re: Why does python not have a mechanism for data hiding?

2008-06-08 Thread Mark Wooding
Fuzzyman <[EMAIL PROTECTED]> wrote: > So, you are stating that no API programmer using Python *ever* has a > valid or genuine reason for wanting (even if he can't have it) genuine > 'hiding' of internal state or members from consumers of his (or > her...) API? I don't want to speak for whoever yo

Re: Newbie question, list comprehension

2008-06-08 Thread Mark Wooding
Johannes Bauer <[EMAIL PROTECTED]> wrote: > import time > localtime = time.localtime(1234567890) > fmttime = "%04d-%02d-%02d %02d:%02d:%02d" % (localtime[0], localtime[1], > localtime[2], localtime[3], localtime[4], localtime[5]) > print fmttime > > fmttime = "%04d-%02d-%02d %02d:%02d:%02d" % ([l

Re: How to get full path to script?

2008-06-08 Thread Mark Tolonen
t os.path.abspath(__file__) -Mark -- http://mail.python.org/mailman/listinfo/python-list

EXE is very slow by starting (>10sec.) (build with PyInstaller)

2008-06-10 Thread Mark Delon
y idea... Best Regards Mark -- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer -- http://mail.python.org/mailman/listinfo/python-list

Re: Point Of intersection between two plotted functions

2008-06-13 Thread Mark Westwood
e good enough for plotting. How straightforward any of this is depends entirely on the nature of your functions. Regards Mark On Jun 13, 7:34 am, [EMAIL PROTECTED] wrote: > Is there anyway one could find ot the point of intersection between > any two plotted functions and also display them usin

Re: Iterate creating variables?

2008-06-16 Thread Mark Tolonen
for i in range(10): code = "%d + %d" % (i, i) print eval(code) Don't do this. You want for idx in range(10): setattr(self, 'checkbox_%i' % idx) Assuming create_checkbox() is the function to create a checkbox, this will create a list of 25 checkboxes:: checkbox = [create_checkbox() for i in xrange(25)] --Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: 2Q's: How to autocreate instance of class;How to check for membership in a class

2008-06-17 Thread Mark Wooding
asdf <[EMAIL PROTECTED]> wrote: (Presumably nothing to do with the Common Lisp system-definition utility.) > So for example if I know that var1=jsmith. Can I somehow do > var1=User(). Something like this might work. class User (object): def __init__(me, name): me.name = name class Users

Re: Multiprecision arithmetic library question.

2008-06-18 Thread Mark Wooding
Michael Press <[EMAIL PROTECTED]> wrote: > I already compiled and installed the GNU multiprecision library > on Mac OS X, and link to it in C programs. > How do I link to the library from Python? You know that Python already supports multiprecision integer arithmetic, right? If you desperately

Re: advanced listcomprehenions?

2008-06-19 Thread Mark Wooding
Gabriel Genellina <[EMAIL PROTECTED]> wrote: > [(not x%3 and not x%5 and "FizzBuzz") or (not x%3 and "Fizz") or (not x%5 > and "Buzz") or x for x in xrange(1,101)] Rather unpleasant. Note that a number is zero mod both 3 and 5 if and only if it's zero mod 15. But we can do better. A simple

Re: advanced listcomprehenions?

2008-06-19 Thread Mark Wooding
Duncan Booth <[EMAIL PROTECTED]> wrote: > [['Fizz', 'Buzz', 'FizzBuzz', str(i)][62/(pow(i, 4, 15) + 1)%4] for i in > xrange(1, 101)] Cute! ;-) -- [mdw] -- http://mail.python.org/mailman/listinfo/python-list

Re: Accent character problem

2008-06-20 Thread Mark Tolonen
g the results of a successful match will help you debug the problems also. matchobj = richre.match(value) if matchobj: print matchobj.group() else: print 'no match' As written you will only get a successful match if your string starts with a-zA-Z0-9, which is why #1 and #3 p

Re: advanced listcomprehenions?

2008-06-21 Thread Mark Wooding
Terry Reedy <[EMAIL PROTECTED]> wrote: > The lookup table is a constant. If made a tuple, it will be compiled as > a constant (as least in 2.6, maybe 2.5). Force of habit. I tend to work on lists by indexing and/or iterating, and on tuples by destructuring, and choose types based on the kind

Re: optparse functionality missing

2008-06-21 Thread Mark Wooding
Jeff Keasler <[EMAIL PROTECTED]> wrote: > In a scripting environment, I often want to strip some of the command > line options off the argument list, and then pass the remaining > options to another module that is deeper in the tool chain. The difficulty is that you can't do an accurate parse wit

Re: Using Python to run SSH commands on a remote server

2008-06-23 Thread Mark Wooding
John Salerno <[EMAIL PROTECTED]> wrote: > Generally speaking, what tools would I use to do this? Is there a built-in > module for it? There's paramiko (q.g.). I can't personally vouch for it, but it seems popular... It seems to depend on a separate crypto library. > Is Telnet and SSH even th

Re: Question: How do I format printing in python

2008-06-23 Thread Mark Tolonen
4 May 13 2004 aclget 12020 May 13 2004 aclput 115734 Jun 2 2004 adb 46518 Jun 4 2004 admin 66750 Sep 16 2002 ali 1453 Sep 15 2002 alias 28150 Jun 4 2004 alog 15 May 12 2005 alstat '''.split('\n') for line in data: elements = line.split() print '%-11s%-6s%-4s%-8

Re: String question

2008-06-23 Thread Mark Tolonen
ine 1, in ValueError: too many values to unpack v1,v2,v3 = s.split(' ',2)# limit to two splits maximum v1 'this' v2 'is' v3 'a test' -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: binary representation of an integer

2008-06-24 Thread Mark Dickinson
t;>> bin(13) '0b1101' Interestingly, unlike hex and oct, bin doesn't add a trailing 'L' for longs: >>> bin(13L) '0b1101' I wonder whether this is a bug... Mark -- http://mail.python.org/mailman/listinfo/python-list

RE: I Need A Placeholder

2008-06-26 Thread Deverter,Mark
I typically use pass for a place holder. try: # Do some code here var = 1 # For example except: pass HTH, Mark -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ampedesign Sent: Thursday, June 26, 2008 12:04 PM To: python-list

Re: complex numbers should respect the "I" representation

2008-06-28 Thread Mark Dickinson
You could set "I = 1j" at the start of your scripts. Then you can happily write your complex numbers in the form: 3+4*I Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting sorting order

2008-06-30 Thread Mark Tolonen
'c'] slave2=[1,4,3,2] Hope it is more clear now. Thanks, leodp How about: master=[1,4,3,2] slave1='d c b a'.split() slave2=[1,2,3,4] x=zip(master,slave1,slave2) x.sort() master,slave1,slave2=zip(*x) master (1, 2, 3, 4) slave1 ('d', 'a', 'b', 'c') slave2 (1, 4, 3, 2) --Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: ctypes - swig - pointer

2008-06-30 Thread Mark Tolonen
or: _type_ must have storage info x=c_int(5)# make an instance (C equiv. is "int x=5;") px=pointer(x) # int* px = &x; ppx=pointer(px) # int** ppx = &px; x c_long(5) px ppx --Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: re.search much slower then grep on some regular expressions

2008-07-05 Thread Mark Dickinson
s a lack of agreement on what 'regular expression' means. Strictly speaking, PCREs aren't regular expressions at all, for some values of the term 'regular expression'. See http://en.wikipedia.org/wiki/Regular_expression Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: The Yield statement

2008-07-06 Thread Mark Tolonen
6) ( 5, 7) (5, 8) (5, 9) (6, 0) (6, 1) (6, 2) (6, 3) (6, 4) (6, 5) (6, 6) (6, 7) (6, 8) (6, 9) (7, 0) (7, 1) (7, 2) (7, 3) (7, 4) (7, 5) (7, 6) (7, 7) (7, 8) (7, 9) (8, 0) (8, 1) (8, 2) (8, 3) (8, 4) (8, 5) (8, 6) (8, 7) (8, 8) (8, 9) (9, 0) (9, 1) (9, 2) (9, 3) (9, 4) (9, 5) (9, 6) (9, 7) (9,

Re: Nested generator caveat

2008-07-06 Thread Mark Wooding
Dieter Maurer <[EMAIL PROTECTED]> wrote: > I met the following surprising behaviour [code moved until later...] > The apparent reason is that the free variables in nested generator > definitions are not bound (to a value) at invocation time but only at > access time. No. This is about the diff

Re: re.search much slower then grep on some regular expressions

2008-07-06 Thread Mark Wooding
Sebastian "lunar" Wiesner <[EMAIL PROTECTED]> wrote: > I just wanted to illustrate, that the speed of the given search is somehow > related to the complexity of the engine. > > Btw, other pcre implementation are as slow as Python or "grep -P". I tried > a sample C++-code using pcre++ (a wrapper

Re: re.search much slower then grep on some regular expressions

2008-07-06 Thread Mark Wooding
Sebastian "lunar" Wiesner <[EMAIL PROTECTED]> wrote: > # perl -e '("a" x 10) =~ /^(ab?)*$/;' > zsh: segmentation fault perl -e '("a" x 10) =~ /^(ab?)*$/;' (Did you really run that as root?) > It'd be interesting to know, how CL-PPCRE performs here (I don't know this > library). Stack o

Re: how are strings immutable in python?

2008-07-06 Thread Mark Tolonen
list('foo') a += list('bar') a ['f', 'o', 'o', 'b', 'a', 'r'] b ['f', 'o', 'o', 'b', 'a', 'r'] --Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: numeric emulation and __pos__

2008-07-08 Thread Mark Dickinson
ds a Decimal to the current context, and it also (mistakenly, in my opinion) changes -0.0 to 0.0: >>> +Decimal('-0.0') Decimal("0.0") >>> +Decimal('123456789123456789123456789123456789') Decimal("1.234567891234567891234567891E+35") Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Python pack and unpack question

2008-07-14 Thread Mark Tolonen
ata (287454020,) hex(data[0]) '0x11223344' Yes, it treats the incoming data as big-endian. The Python data type returned varies as needed to hold the value. You'd get the same results on a big-endian and little-endian local machine. How the Python data type is represented

Re: Unicode confusion

2008-07-15 Thread Mark Tolonen
g/peps/pep-0263.html for details The encoding of the source file can be declared: # coding: latin-1 units = u"°" import test test.units u'\xb0' print test.units ° Make sure to use the correct encoding! Here the file was saved in latin-1, but declared utf8: # c

reading one byte from stdin

2008-07-15 Thread Mark McDuff
I'm trying to read one byte from stdin, without the newline. If I try something like: >>> import os, sys >>> os.read(sys.stdin.fileno(),1) I can input a character, but then I have to press enter, which leaves a newline character in the stdin buffer and requires two keypresses. Is there any

Re: new itertools functions in Python 2.6

2008-07-16 Thread Mark Dickinson
te('abcde')) ... eee dee dde ddd cee cde cdd cce ccd ccc bee bde bdd bce bcd bcc bbe bbd bbc bbb aee ade add ace acd acc abe abd abc abb aae aad aac aab aaa Generalization left as an exercise for the reader. Mark -- http://mail.python.org/mailman/listinfo/python-list

Multiple variable control in for loops. Doable in Python?

2008-07-18 Thread mark floyd
o handle this style for loop in Python and haven't been able to find an appropriate way to handle this control style. We have this style for loop all over the place and not being able to find a similar structure in Python could be a problem. Any pointers to a Python equivalent structure would be much appreciated - Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: round function error???

2008-07-18 Thread Mark Dickinson
n yes, I'd agree that's less than ideal, though I don't consider it a particularly serious bug. It's been on my list of things to fix for a while. (See http://bugs.python.org/issue1869 ). Contributions welcome! Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: round function error???

2008-07-18 Thread Mark Dickinson
rintf does correct rounding: Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> x = 3499.35 >>> x 3499.34999 >>> print '%.1f' % x 3499.3 >>> print round(x, 1) 3499.4 Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: round function error???

2008-07-20 Thread Mark Dickinson
On Jul 19, 12:20 am, John Machin <[EMAIL PROTECTED]> wrote: > On Jul 19, 8:05 am, Mark Dickinson <[EMAIL PROTECTED]> wrote: > > for more information.  But I'm guessing that you're > > questioning the fact that a value that's apparently > > *le

Re: getting with statement to deal with various exceptions

2008-07-20 Thread Mark Tolonen
ith_statement class ExceptionManager(object): def __enter__(self): pass def __exit__(self,exc_type,exc_value,tb): if exc_type == IOError: print 'IOError',exc_value[1] return True # suppress it with ExceptionManager(): with open('test.txt') as f: f.read() -- Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: imported module no longer available

2008-07-21 Thread Mark Tolonen
_', '__file__', 'func', '__name__', 'os', '__doc__'] Traceback (most recent call last): File "C:\dev\python\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 414, in ImportFile exec codeObj in __main__.__dict__ File "", line 1, in File "test.py", line 10, in func() File "test.py", line 7, in func print os UnboundLocalError: local variable 'os' referenced before assignment Check in the function that caused the error to see if later in the code the module name is being used as a local variable. --Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: ctypes and reading value under pointer passed as param of a callback

2008-07-25 Thread Mark Tolonen
tions? Try: cbfunc = CFUNCTYPE(c_int, c_char_p, c_int) ctypes understands c_char_p as a null-terminated character string and will pass a string to your callback instead of a list of ints. --Mark -- http://mail.python.org/mailman/listinfo/python-list

How do I find out from inside pdb which namespace contains an object?

2008-08-03 Thread Jonathan Mark
I am inside a Pdb-like Plone debugging tool and I get the following error at the prompt. I was wondering how to find out from inside the debugger which namespace the collective.dancing.channel object is located in. : collective.dancing.channel.tool_added(DelegateNichols.portal_newsletters, None) c

Re: How do I find out from inside pdb which namespace contains an object?

2008-08-03 Thread Jonathan Mark
Never mind. I had to run "import collective.dancing" first. -- http://mail.python.org/mailman/listinfo/python-list

Re: Books to begin learning Python

2008-08-08 Thread Mark Summerfield
On 7 Aug, 21:10, Mike Driscoll <[EMAIL PROTECTED]> wrote: > On Aug 7, 1:12 pm, Beliavsky <[EMAIL PROTECTED]> wrote: > > > > > On Aug 6, 4:08 pm, Mike Driscoll <[EMAIL PROTECTED]> wrote: > > > > On Aug 6, 2:56 pm, Edward Cormier <[EMAIL PROTECTED]> wrote: > > > > > Which computer books are the best

Re: python 64bits on macosx.5 /leopard

2008-08-14 Thread Mark Dickinson
make fails: There was a thread on the Pythonmac-SIG about this recently. See e.g. http://mail.python.org/pipermail/pythonmac-sig/2008-June/020095.html and the following messages. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: deleting a line from a file

2008-03-31 Thread Mark Wooding
Paul Rubin wrote: > You could do it "in place" in all those systems afaik, either opening > the file for both reading and writing, or using something like mmap. > Basically you'd leave the file unchanged up to line N, then copy lines > downward starting from line N+1. At the end you'd use ftrunc

Re: deleting a line from a file

2008-04-01 Thread Mark Wooding
Paddy <[EMAIL PROTECTED]> wrote: > Why not use the fileinput modules functionality to iterate over a file > in-place,printing just those lines you want? >From the Python 2.5 manual: : *Optional in-place filtering:* if the keyword argument `INPLACE=1' is : passed to `input()' or to the `FileInput

Re: Best way to check if string is an integer?

2008-04-05 Thread Mark Dickinson
.isdigit() -> bool Return True if all characters in S are digits and there is at least one character in S, False otherwise. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: sine in python

2008-04-06 Thread Mark Wooding
Astan Chee <[EMAIL PROTECTED]> wrote: > I have a math function that looks like this > sin (Theta) = 5/6 > How do I find Theta (in degrees) in python? import math theta = math.asin(5/6) * 180/math.pi -- [mdw] -- http://mail.python.org/mailman/listinfo/python-list

Re: A funnily inconsistent behavior of int and float

2008-04-06 Thread Mark Dickinson
en fixed for Python 3.0. It was decided not to risk breakage by changing this in Python 2.x. See: http://bugs.python.org/issue1779 Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: A funnily inconsistent behavior of int and float

2008-04-07 Thread Mark Dickinson
iate place in the documentation. And I agree that it could be made clearer exactly what strings are acceptable here. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: A funnily inconsistent behavior of int and float

2008-04-07 Thread Mark Dickinson
16. The only base 0 versus base 10 difference I could find was the following: >>> int('033', 0) Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 0: '033' [38720 refs] >>> int('033') 33 Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: A funnily inconsistent behavior of int and float

2008-04-07 Thread Mark Dickinson
On Apr 7, 3:53 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: > The only base 0 versus base 10 difference I could find was the > following: > > >>> int('033', 0) > > Traceback (most recent call last): > File "", line 1, in > ValueError:

Re: A funnily inconsistent behavior of int and float

2008-04-07 Thread Mark Dickinson
On Apr 7, 4:59 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > "Mark Dickinson" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > Thank you for the corrections. Here is my revised proposal: > > int([number | string[, radix]) &g

Re: what's the reasonale of loghelper() in mathmodule.c

2008-04-09 Thread Mark Dickinson
ation) and on the number of bits required to represent 10**600. You're not going to learn much about math function implementations from mathmodule.c: all it does it wrap the platform libm functions. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3.0 new integer division

2008-04-09 Thread Mark Dickinson
airly efficient. An alternative representation that's gained popularity recently is DPD (densely packed decimal), which packs 3 decimal digits into 10 bits in a clever way that allows reasonably efficient extraction of any one of the 3 digits. Decimal doesn't use this either. :) Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3.0 new integer division

2008-04-09 Thread Mark Dickinson
on my todo list to try this, but so far down that it's not looking like it'll end up at the top of the list before Christmas 20??. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Rounding a number to nearest even

2008-04-11 Thread Mark Dickinson
e: >>> x = -0.5 + 2**-54 >>> x # not an exact half... -0.49994 >>> x % 1 # ... and yet x%1 == 0.5 0.5 But for x positive, it should be safe. And for this particular application, it turns out that it doesn't matter: it gives the right result

Re: Rounding a number to nearest even

2008-04-11 Thread Mark Dickinson
'll get many takers for this point of view. If X is a random variable uniformly distributed on the interval [0, 1) then the probability that X == 0.5 is indeed exactly 0, using conventional definitions. (And if you're not using conventional definitions, you should say so) Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Rounding a number to nearest even

2008-04-13 Thread Mark Dickinson
ents don't change the fact that the average rounding error is strictly positive for positive quantized results, under round-half-away-from-zero. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: What can we do about all the spam that the list is getting?

2008-04-16 Thread Mark Shroyer
a "real" NNTP client for whatever platform you're on and give its spam filter a shot; clearly Google is not interested in fighting spam itself. -- Mark Shroyer http://markshroyer.com/contact/ -- http://mail.python.org/mailman/listinfo/python-list

Re: def power, problem when raising power to decimals

2008-04-16 Thread Mark Dickinson
lidOperation: 0 ** 0 Most mathematicians consider 0**0 to be either 1 or undefined. Which answer you get depends on who you ask (or in Python, whether you're working with floats or Decimals, as you see above). Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: def power, problem when raising power to decimals

2008-04-17 Thread Mark Dickinson
both operands are zero, or if the left-hand operand is less than zero and the right-hand operand does not have an integral value[7] or is infinite, an Invalid operation condition is raised, the result is [0,qNaN], and the following rules do not apply." I'm hoping that this will change

Re: What can we do about all the spam that the list is getting?

2008-04-17 Thread Mark Shroyer
In article <[EMAIL PROTECTED]>, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-04-16, Mark Shroyer <[EMAIL PROTECTED]> wrote: > > In article > ><[EMAIL PROTECTED]>, > > Mensanator <[EMAIL PROTECTED]> wrote: > > > >> On Apr

Re: Integer dicision

2008-04-17 Thread Mark Wooding
bdsatish <[EMAIL PROTECTED]> wrote: > How does (a/b) work when both 'a' and 'b' are pure integers ? > >>> (9/2) > 4 > >>> (-9/2) > -5 > > Why is it -5 ? I expect it to be -4 ? Because, in C/C++, 9/2 is 4 and > so negative of it, (-9/2) is -4. Some background on the situation: Integer division and

Tidy module?

2008-04-17 Thread Mark Reed
Is there an easy_installable egg with an interface to libtidy? I found µTidy, but it looks like an inactive project, with no updates since 2004, so I'm skeptical of its reliability. I found mxTidy, but it's only available as part of some larger distribution, and I don't want to replace my Python

Re: Building an RPM

2008-04-17 Thread Mark Lim
You could use the module compileall to create .pyc and .pyo (http://www.python.org/doc/1.5.1p1/tut/node43.html) and do this in your %build stage. Or if you don't need to ship them, strike them from the package as they will be generated as necessary. On 4/17/08 2:19 PM, "John Sutherland" <[EMAI

Re: Inheritance confusion

2008-04-19 Thread Mark Shroyer
message is actually trying to tell you is that you are attempting to call a module as a function somewhere -- and in this particular case, I think it's referring to the time module. Are you sure that line 98 in Hook_m.py should not instead be: dt = self.Date(time.time()) The time mod

Re: Is massive spam coming from me on python lists?

2008-04-21 Thread Mark Shroyer
luge of backscatter and filling up your inbox, should be groveling on their knees and begging *you* for forgiveness. ;) (I haven't seen any such spam messages myself; but the way I'm set up, I wouldn't receive them even if that is the case.) -- Mark Shroyer, http://marks

Re: Code question

2008-04-21 Thread Mark Wooding
<[EMAIL PROTECTED]> <[EMAIL PROTECTED]> wrote: > If anyone has time, I was wondering if you could share your thoughts > on whether this is an efficient way to do something like this, if it's > horrible and slow, etc. If your lists are fairly short then your algorithm is probably the best way to d

Re: Working around buffering issues when writing to pipes

2008-04-22 Thread Mark Wooding
sven _ <[EMAIL PROTECTED]> wrote: > In short: unless specifically told not to, normal C stdio will use > full output buffering when connected to a pipe. It will use default > (typically unbuffered) output when connected to a tty/pty. Wrong. Standard output to a terminal is typically line-buffere

Re: Segfault accessing dictionary in C Python module

2008-04-22 Thread Mark Wooding
Mitko Haralanov <[EMAIL PROTECTED]> wrote: > value = PyDict_GetItem (new_dict, key); You're not calling Py_DECREF on this value are you? That's a no-no, since you're borrowing the dictionary's reference. -- [mdw] -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python 2.4/2.5] subprocess module is sorely deficient?

2008-04-22 Thread Mark Wooding
Nick Craig-Wood <[EMAIL PROTECTED]> wrote: > Harishankar <[EMAIL PROTECTED]> wrote: >> 1. Create non-blocking pipes which can be read in a separate thread >> [...] > > You are correct on both of those points. I must be missing something. What's wrong with spawning the subprocess with subprocess

Re: Where to get BeautifulSoup--www.crummy.com appears to be down.

2008-04-22 Thread Mark Wooding
Kenneth McDonald <[EMAIL PROTECTED]> wrote: > Sadly. python-beautifulsoup is a Debian package, so ftp://ftp.debian.org/debian/pool/main/b/beautifulsoup/beautifulsoup_3.0.4.orig.tar.gz should be a copy of the (unmodified) upstream source. -- [mdw] -- http://mail.python.org/mailman/listinfo/p

Re: Python Success stories

2008-04-23 Thread Mark Wooding
Gabriel Genellina <[EMAIL PROTECTED]> wrote: > Because Python doesn't follow the "boxed variables" model. Be careful here. `Boxed types' or `boxed objects' is a technical term essentially meaning `heap-allocated objects, probably with reference semantics', which Python most definitely does use

Re: [Python 2.4/2.5] subprocess module is sorely deficient?

2008-04-23 Thread Mark Wooding
Harishankar <[EMAIL PROTECTED]> wrote: > On Wednesday 23 Apr 2008 15:11:21 Ben Kaplan wrote: >> I don't know about all Linux distros, but my Ubuntu machine (8.04 Beta), >> has the 'TERM' (xterm) and 'COLORTERM' (gnome-terminal) keys in os.environ. > This is set on Debian too. Thanks. I should be ab

Pythonically extract data from a list of tuples (getopt)

2008-04-23 Thread Mark Reed
So the return value from getopt.getopt() is a list of tuples, e.g. >>> import getopt >>> opts = getopt.getopt('-a 1 -b 2 -a 3'.split(), 'a:b:')[0]; opts [('-a', '1'), ('-b', '2'), ('-a', '3')] what's the idiomatic way of using this result? I can think of several possibilities. For options not a

Re: Ideas for parsing this text?

2008-04-24 Thread Mark Wooding
Eric Wertman <[EMAIL PROTECTED]> wrote: > I have a set of files with this kind of content (it's dumped from > WebSphere): > > [propertySet "[[resourceProperties "[[[description "This is a required > property. This is an actual database name, and its not the locally > catalogued database name. The

Re: Receive data from socket stream

2008-04-27 Thread Mark Tolonen
file objects? Maybe unbuffered? I think you meant: while totalsent < len(data): Python also has the sendall() function. -Mark -- http://mail.python.org/mailman/listinfo/python-list

RE: Newbie to python --- why should i learn !

2008-05-08 Thread Mark Jordaan
pls dont learn it Move on The world is full enough of 9 to 5 coders Mark> From: [EMAIL PROTECTED]> Subject: Newbie to python --- why should i learn !> Date: Thu, 8 May 2008 03:25:17 -0700> To: [email protected]> > Hi,> > i was reading/learning some hello wor

Re: How to print first(national) char from unicode string encoded inutf-8?

2008-09-01 Thread Mark Tolonen
t problem is that the character in the OP's example string 'Ł' is not present in the latin-1 encoding, but using utf-8 encoding demonstrates that the full two-byte UTF-8 encoded character is collected: >>> import urllib >>> name = urllib.quote(u'Ł

Python training in Colorado, October 15-17

2008-09-09 Thread Mark Lutz
Python author and trainer Mark Lutz will be teaching another 3-day Python class at a conference center in Longmont, Colorado, on October 15-17, 2008. This is a public training session open to individual enrollments, and covers the same topics as the 3-day onsite sessions that Mark teaches, with

Re: Generating test data from an XML Schema

2008-09-17 Thread Mark Thomas
chema: http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.wst.xmleditor.doc.user/topics/tcrexxsd.html As can XML IDEs such as Stylus Studio and XML Spy. -- Mark. -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparing float and decimal

2008-09-24 Thread Mark Dickinson
his requirement? For other arithmetic operations: should the sum of a float and a Decimal produce a Decimal or a float? Why? It's not at all clear to me that either of these types is 'higher up' the numerical tower than the other. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Comparing float and decimal

2008-09-25 Thread Mark Dickinson
lessly. But then there are a whole host of decisions one has to make about rounding, significant zeros, ... (And then, as you point out, Cowlishaw might come out with a new version of the standard that does include interactions with floats, and makes an entirely different set of decisions...) Mark -- http://mail.python.org/mailman/listinfo/python-list

<    42   43   44   45   46   47   48   49   50   51   >