Re: brain stuck. whats occurring here?

2008-02-07 Thread Mark Tolonen
; How about: >>> [[[]]*5]*5 [[[], [], [], [], []], [[], [], [], [], []], [[], [], [], [], []], [[], [], [], [], []], [[], [], [], [], []]] --Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Chinese character error

2008-02-08 Thread Mark Tolonen
Chin >> esePod/785 Advanced - .mp3' >> >> I am using python on cygwin, so could this be the source of the error, >> and is there a way to fix this ? > > It has to do with the way the OS reports the filename. Explorers GUI > diplays it as square blocks an

Re: Turn off ZeroDivisionError?

2008-02-10 Thread Mark Dickinson
On Feb 9, 5:03 pm, Neal Becker <[EMAIL PROTECTED]> wrote: > If I use C code to turn off the hardware signal, will that stop python from > detecting the exception, or is python checking for 0 denominator on it's > own (hope not, that would waste cycles). Yes, Python does do an explicit check for a

Re: Turn off ZeroDivisionError?

2008-02-10 Thread Mark Dickinson
hon doesn't assume IEEE 754 hardware; though much of its code could be a lot simpler if it did :-). rywhere ;-). Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Turn off ZeroDivisionError?

2008-02-10 Thread Mark Dickinson
On Feb 10, 3:29 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > platform does".  Except it doesn't in cases like this. All my > platforms do exactly what I want for division by zero: they > generate a properly signed INF.  Python chooses to override > that (IMO correct) platform behavior with someth

Re: Turn off ZeroDivisionError?

2008-02-10 Thread Mark Dickinson
serious numeric programmers would be livid, and justifiably so, if they couldn't get non-stop mode back. The most likely x-platfrom accident so far is that they've been getting non-stop mode in Python since its beginning." Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Turn off ZeroDivisionError?

2008-02-10 Thread Mark Dickinson
are the alternatives? Decimal and Rational are very slow in comparison with float, and historically Decimal wasn't even available until recently. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Turn off ZeroDivisionError?

2008-02-10 Thread Mark Dickinson
ns about how to achieve the above-described state of affairs are welcome! Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Turn off ZeroDivisionError?

2008-02-10 Thread Mark Dickinson
On Feb 10, 7:07 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-02-10, Christian Heimes <[EMAIL PROTECTED]> wrote: > from somemodule import ieee754 > with ieee754: > > ...    r = a/0 > > ...    print r > > inf > > That would be great. Seriously, in some of my crazier moments I've

Re: Regular Expression for Prime Numbers (or How I came to fail at them, and love the bomb)

2008-02-13 Thread Mark Dickinson
esn't translate to a finite state machine, since backreferences are involved. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Turn off ZeroDivisionError?

2008-02-15 Thread Mark Dickinson
oubly extended real line, which has exactly two infinities. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Turn off ZeroDivisionError?

2008-02-15 Thread Mark Dickinson
out speed, then I agree you probably shouldn't be writing in Python. But I can imagine there are use-cases for nonstop arithmetic with nans and infs where speed isn't the topmost concern. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Turn off ZeroDivisionError?

2008-02-15 Thread Mark Dickinson
On Feb 15, 1:38 pm, Grant Edwards <[EMAIL PROTECTED]> wrote: > On 2008-02-15, Mark Dickinson <[EMAIL PROTECTED]> wrote: > > >> If you're doing such serious number-crunching that you really > >> want to handle NANs, you're probably not writing in Python

Re: Floating point bug?

2008-02-15 Thread Mark Dickinson
l is exact' myth has been appearing often enough that I wonder whether it's worth devoting a prominent paragraph to in the docs. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Turn off ZeroDivisionError?

2008-02-15 Thread Mark Dickinson
to apply arithmetic laws like a+c == b+c implies a == b that you get into trouble. In other words, the doubly-extended real line is a perfectly well-defined and well-behaved *set*, and even a nice (compact) topological space with the usual topology. It's just not a field, or a group under a

Re: Turn off ZeroDivisionError?

2008-02-15 Thread Mark Dickinson
∞) commonly found in algebra and calculus. Alephs measure the sizes of sets; infinity, on the other hand, is commonly defined as an extreme limit of the real number line (applied to a function or sequence that "diverges to infinity" or "increases without bound"), or an e

Re: How about adding rational fraction to Python?

2008-02-16 Thread Mark Dickinson
on 2.6 and Python 3.0, thanks largely to the work of Jeffrey Yaskin. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: How about adding rational fraction to Python?

2008-02-16 Thread Mark Dickinson
On Feb 16, 1:35 pm, Lie <[EMAIL PROTECTED]> wrote: > Would all these problems with floating points be a rational reason to > add rational numbers support in Python or Py3k? (pun not intended) Forgot to give the link: http://docs.python.org/dev/library/fractions.html M

Re: Turn off ZeroDivisionError?

2008-02-16 Thread Mark Dickinson
On Feb 16, 7:08 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Fri, 15 Feb 2008 17:31:51 -0800, Mark Dickinson wrote: > > Not sure that alephs have anything to do with it.  And unless I'm > > missing something, minus aleph(0) is nonsense. (How

Re: Turn off ZeroDivisionError?

2008-02-16 Thread Mark Dickinson
On Feb 16, 7:30 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: > The real line, considered as a topological space, has limit points. > Two of them. Ignore that. It was nonsense. A better statement: the completion (in the sense of lattices) of the real numbers is (isomorphic to

Re: Turn off ZeroDivisionError?

2008-02-16 Thread Mark Dickinson
On Feb 16, 9:39 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 16 Feb 2008 17:47:39 -0800, Mark Dickinson wrote: > > I've no clue where your (Steven's) idea that 'all ordinals are surreal > > numbers' came from.  They'

Re: Querying a complex website

2008-02-20 Thread Mark Lim
On 2/19/08 11:55 AM, "schweet1" <[EMAIL PROTECTED]> wrote: > Greetings, > > I am attempting to use python to submit a query to the following URL: > > https://ramps.uspto.gov/eram/patentMaintFees.do > > The page looks simple enough - it requires submitting a number into 2 > form boxes and then s

[ANN] Shed Skin (restricted) Python-to-C++ compiler 0.0.27

2008-02-24 Thread Mark Dufour
e previous release we have a nice tutorial online. It explains in detail how to install and use Shed Skin, how to use it to build (simple) extension modules and how to combine Shed Skin with numpy and parallel processing solutions such as Parallel Python. Thanks, Mark Dufour. -- "One of my mo

Re: [ANN] Shed Skin (restricted) Python-to-C++ compiler 0.0.27

2008-02-24 Thread Mark Dufour
Of course I forgot to add the URL: http://shedskin.googlecode.com Mark Dufour. -- "One of my most productive days was throwing away 1000 lines of code" - Ken Thompson -- http://mail.python.org/mailman/listinfo/python-list

Re: How about adding rational fraction to Python?

2008-02-24 Thread Mark Dickinson
lt;= n of the highest power of p not exceeding n. So for n = 100, it's: 64 * 81 * 25 * 49 * 11 * 13 * 17 * ... rest of primes up to 100. For general n, this number is of roughly the same order of magnitude as e**n. See http://www.research.att.com/~njas/sequences/A003418 for more. Mark

Re: PyEuler

2008-02-25 Thread Mark Dickinson
one trying to write Haskell in Python. And that's a truly horrible way of finding a least common multiple: much better to do lcm(a, b) = a*(b//gcd(a, b)), with gcd computed using the usual algorithm (written *iteratively*, not recursively). Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: PyEuler

2008-02-25 Thread Mark Dickinson
r was a hamster, and your father smelt of elderberries.) Gratuitous insulting'ly yours, Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: How about adding rational fraction to Python?

2008-02-26 Thread Mark Dickinson
> supposed to give a float). And smaller numbers are problematic too: >>> from __future__ import division >>> 10**50/10**40 100.0 >>> 10**60/10**50 99.981 This despite the fact that the quotient *is* exactly representable as a float... Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: How about adding rational fraction to Python?

2008-02-26 Thread Mark Dickinson
you pass a list of floats, complex numbers, Fractions, or Decimal instances to mean() then it'll work just fine. But if you pass a list of ints or longs, it'll silently return the wrong result. True division and floor division are different operations. It doesn't seem ridiculous to

Re: How about adding rational fraction to Python?

2008-02-26 Thread Mark Dickinson
On Feb 26, 11:55 pm, Paul Rubin <http://[EMAIL PROTECTED]> wrote: > So use:  return sum(number_list) / float(len(number_list)) > That makes it somewhat more explicit what you want.  Otherwise But that fails for a list of Decimals... Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Place n indistinguishable items into k distinguishable boxes

2008-02-27 Thread Mark Dickinson
Here's a possible solution. I'm sure others will comment on how to fix up its inefficiencies (like the potentially slow string concatenations...). def comb(n, k): if n == k == 0: yield '' else: if n > 0: for x in comb(n-1, k): yield ' ' + x

Re: Place n indistinguishable items into k distinguishable boxes

2008-02-27 Thread Mark Dickinson
On Feb 27, 11:38 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: >             yield map(len, (''.join(s)).split('|')) That line should have been just: yield map(len, s.split('|')) of course. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Place n indistinguishable items into k distinguishable boxes

2008-02-28 Thread Mark Dickinson
port combinations as c; boxings=lambda n,k:([s[i +1]+~s[i] for i in range(k)] for s in [[-1]+list(t)+[n-~k] for t in c(range(n-~k),k-1)]) You'll need to check out and compile the latest svn sources to make it work, though. And it doesn't work when k == 0. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Command line arguments in Windows

2008-03-03 Thread Mark Tolonen
;%1" %* My guess is your command line looks something like this: Python.File="C:\Python25\python.exe" "%1" The script name is being passed, but not the rest of the arguments. I vaguely remember seeing this on an older version one of ActiveState's ActivePython installers. What version of Python are you running? --Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: help needed with regex and unicode

2008-03-03 Thread Mark Tolonen
to indicate Unicode. >>> s=open('chinese.txt','r').read().decode('utf8') >>> s u'\ufeff\u6211\u662f\u7f8e\u56fd\u4eba\u3002 W\u01d2 sh\xec M\u011bigu\xf3r\xe9n. I am an American.' If working with Unicode strings, the re module should be provided Unicode strings also: >>> print re.search(ur'[\u4E00-\u9FA5]',s).group(0) 我 >>> print re.findall(ur'[\u4E00-\u9FA5]',s) [u'\u6211', u'\u662f', u'\u7f8e', u'\u56fd', u'\u4eba'] Hope that helps you. --Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: How about adding rational fraction to Python?

2008-03-04 Thread Mark Dickinson
. with precision comparable to that of float) gives >>> check_accuracy(Decimal) 310176 Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: How about adding rational fraction to Python?

2008-03-04 Thread Mark Dickinson
On Mar 4, 9:39 am, Mark Dickinson <[EMAIL PROTECTED]> wrote: > On Mar 4, 8:46 am, NickC <[EMAIL PROTECTED]> wrote: > > > The increased number of inaccurate answers with Decimal (31% vs 10%) > > is probably due to the fact that it is actually more precise than > >

Re: Bit twiddling floating point numbers

2008-03-05 Thread Mark Dickinson
Any suggestions? One alternative to using struct is to use math.ldexp and math.frexp: >>> m, e = frexp(pi) >>> m 0.78539816339744828 >>> e 2 >>> int(m*2**53) 7074237752028440L Then you can do your bit twiddling on int(m*2**53), before using ldexp to 'repack' the float. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: float / rounding question

2008-03-07 Thread Mark Dickinson
ed as something > that could be described as 53.601 -- will actually be printed > as 53.6. There are issues with doing this portably and reliably. See http://bugs.python.org/issue1580 for a recent discussion. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: float / rounding question

2008-03-08 Thread Mark Dickinson
orms as well as the usual ones. This means adding, maintaining and testing hundreds of lines of complicated code, where right now a few C library calls suffice. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: float / rounding question

2008-03-08 Thread Mark Dickinson
On Mar 8, 11:34 am, Mark Dickinson <[EMAIL PROTECTED]> wrote: > following, which arises from Python arbitrarily stripping trailing > zeros from the result returned by the C library functions: Correction: on closer examination it's not Python doing the stripping of trailing

Re: Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Mark Dickinson
which also works if a and b are something other than integers (e.g. rational numbers). Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Mark Dickinson
On Mar 8, 8:48 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Sat, 08 Mar 2008 17:09:11 -0800, Mark Dickinson wrote: > > I prefer: > > > ceiling(a/b) = -(-a)//b > > Unfortunately it doesn't give the right answer. > > >>&

Re: Arbitrary precision integer arithmetic: ceiling?

2008-03-08 Thread Mark Dickinson
sization gem (see next to last line): def isqrt(n): """Find the closest integer to sqrt(n), for n a positive integer.""" a, b = n, 1 while a != b: a, b = a -- n // a >> 1, a return a Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: How to factor using Python?

2008-03-11 Thread Mark Dickinson
ne real-world formula, or something that appeared in an elementary number theory textbook? Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: How to factor using Python?

2008-03-11 Thread Mark Dickinson
1) Ignore the formula Gerry gave you. It's completely impractical as a way of determining primality, and I'm certain that Gerry knew this. (2) Learn some elementary number theory before trying to crack RSA. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: urllib proxy support confusion

2008-03-11 Thread Mark Dickinson
python.org/view?view=rev&rev=26181 ) as a fix for http://bugs.python.org/issue523415 but this doesn't seem to help much with figuring out what the docs intend to say. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: urllib proxy support confusion

2008-03-11 Thread Mark Dickinson
e overcome by using URLopener or FancyURLopener directly instead. And it doesn't make a lot of sense that urlopen accepts proxies, but urlretrieve does not. But that's a different issue... Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: List Combinations

2008-03-12 Thread Mark Dickinson
. >>> from itertools import product >>> for c in product(['3'], ['9', '1'], ['5'], ['4'], ['2', '5', '8']): print c ... ('3', '9', '5', '4', '2') (&#

Re: How about adding rational fraction to Python?

2008-03-12 Thread Mark Dickinson
and x will either be equal or differ by exactly 1ulp (except perhaps in rarely-occurring corner cases). But for decimal numbers, (x/y)*y and x could be as much as 5 ulps apart. Mark > -- > Piet van Oostrum <[EMAIL PROTECTED]> > URL:http://pietvanoostrum.com[PGP 8DAE142BE17999C4

Re: ValueError in pickle module during unpickling a infinite float (python 2.5.2)

2008-03-12 Thread Mark Dickinson
t it would be worth having people look at it. I'm assuming that you're on Windows? I can't reproduce the problem on OS X. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: no more comparisons

2008-03-13 Thread Mark Dickinson
p with a key that works, but it's not quite as straightforward as writing a custom __cmp__. This isn't a totally contrived example: the internal Decimal format isn't so different from this. Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: no more comparisons

2008-03-13 Thread Mark Dickinson
On Mar 13, 5:10 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote: > (1, '14') represents 14 should be -14, of course. -- http://mail.python.org/mailman/listinfo/python-list

Re: no more comparisons

2008-03-13 Thread Mark Dickinson
the realm of arcane trickery... Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: urllib proxy support confusion

2008-03-14 Thread Mark Dickinson
On Mar 11, 11:35 am, Grant Edwards <[EMAIL PROTECTED]> wrote: > Reading through the doc athttp://docs.python.org/lib/module-urllib.html, > there are several paragraphs (including code examples) showing > how you specify what proxies to use when calling urlopen(): See http://bugs.python.org/issue22

Getting started with OS X Leopard

2008-03-15 Thread Mark Carter
One thing I really liked about Ubuntu was that Nautilus allowed you to add scripts to a directory which could be accessed via the RMB. It was a very simple thing to do. I've recently switched to Leopard, and I'm trying to do the same thing. I'm fairly experienced with Python, but new to OS X. I

Re: Getting started with OS X Leopard

2008-03-15 Thread Mark Carter
has wrote: > On 15 Mar, 18:05, Mark Carter <[EMAIL PROTECTED]> wrote: >> The sorts of things I want to do are: >> * copy the directory of Finder to the clipboard >> * add a new file to Finder's directory. >> * find out the size of a directory >> * open a

Re: Getting started with OS X Leopard

2008-03-15 Thread Mark Carter
Arnaud Delobelle wrote: > Is there a particular reason you want python from MacPorts? OSX > Leopard comes with python 2.5, that's what I use on my mac. I heard from somewhere that Apple's version was a bit wonky, and that I would be better off with a "proper" build. -- http://mail.python.org/ma

Re: Getting started with OS X Leopard

2008-03-15 Thread Mark Carter
[EMAIL PROTECTED] wrote: > if you are not satisfied with the native version, why not install the > official version directly from python site > http://www.python.org/download/ (macpython) instead of using that of > macports. It moreover is provided with many utilities > > There is a macpython list

Re: struct unpack

2008-03-17 Thread Mark Tolonen
, testValue) > File "struct.py", line 87, in unpack >return o.unpack(s) > error: unpack requires a string argument of length 2 > > any ideas? raw_input doesn't understand escape sequences. You have to decode them. import struct testValue=raw_input() # input '\x02\x00' junk = struct.unpack('h',testValue.decode('string_escape')) --Mark -- http://mail.python.org/mailman/listinfo/python-list

Colorado Python training in May

2008-03-18 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 May 14-16, 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 hands

Re: Newbie: unsigned shift right

2008-03-26 Thread Mark Dickinson
What answer were you hoping for, and why? 2**31-1? 2**63-1? If you're thinking of the -1 as representing a particular fixed-width bit pattern, try doing a bitwise 'and' operation with a suitable mask first. For example, if you're thinking of -1 as a 32-bit quantity, then (

Re: spawning pyhon apps...

2009-01-09 Thread Mark Wooding
bruce wrote: > toying with an idea.. trying to figure out a good/best way to spawn > multiple python scripts from a parent python app. i'm trying to figure > out how to determine when all child apps have completed, or to > possibly determine if any of the child processes have died/halted.. You d

Re: why cannot assign to function call

2009-01-09 Thread Mark Wooding
in Perl is an explicit SV, AV or HV object (for `scalar-', `array-' and `hash-value' respectively. Calling a subroutine involves marking a position on a stack, pushing a number of SVs, and then executing the subroutine's code, which receives the items between the stack poin

Re: why cannot assign to function call

2009-01-09 Thread Mark Wooding
Steven D'Aprano wrote: > Er, perhaps you missed that I was replying to Joe Strout. Yes, evidently. My apologies for the mix up! -- [mdw], who obviously should put the keyboard down now. -- http://mail.python.org/mailman/listinfo/python-list

Re: why cannot assign to function call

2009-01-10 Thread Mark Wooding
[Another tome. I hope this contains sufficient new material to continue to be of interest to other readers.] Steven D'Aprano wrote: > On Fri, 09 Jan 2009 20:23:11 +0000, Mark Wooding wrote: > > > No: not directly. The Python program deals solely with references; > > an

Re: why cannot assign to function call

2009-01-10 Thread Mark Wooding
[email protected] wrote: > Agreed. I think the docs, especially those that develop > the conceptual model of how Python work at runtime, could > use some major attention. If we can achieve consensus in this (still remarkably civil) discussion, we might be able to amend the docs. > I would be wil

Re: why cannot assign to function call

2009-01-10 Thread Mark Wooding
[email protected] wrote: > What is the observable difference between converting an > array to a reference (pointer) to that array and passing > the reference by value, and passing the array by reference? For one: #include static size_t foo(char v[]) { return sizeof v; } int main(void) { char

Re: why cannot assign to function call

2009-01-10 Thread Mark Wooding
Steven D'Aprano wrote: > There are actually three fundamental characteristics of pass-by-reference: > > * passing a value by reference does not lead to the value being copied, > in contrast with pass-by-value where it does; > > * modifications to the value passed by reference are visible to th

Re: why cannot assign to function call

2009-01-10 Thread Mark Wooding
Steven D'Aprano wrote: > I don't believe it is a red-herring. As I understand it, Mark and Joe > insist that C is pass-by-value *even in the case of arrays*, despite the > semantics of array passing being identical to the semantics of pass-by- > reference in (say) Pas

Re: why cannot assign to function call

2009-01-11 Thread Mark Wooding
[email protected] wrote: > Mark Wooding wrote: > > [email protected] wrote: > > > >> What is the observable difference between converting an > >> array to a reference (pointer) to that array and passing > >> the reference by value, and passi

Re: why cannot assign to function call

2009-01-11 Thread Mark Wooding
Aaron Brady wrote: > True or not, it requires the reader to know what references are. And, > since your definition conflicts with the C++ definition, it's not > clear that the requirement is good. I blame C++ for coopting a perfectly good word with a established well-understood meaning, and app

Re: why cannot assign to function call

2009-01-11 Thread Mark Wooding
Steven D'Aprano wrote: > I guess this is where you explain again that arrays in C are "bizarre", > and that while "int arr[2]" inside a function body means "declare an > array of two ints and call it 'arr'", the exact same declaration in a > function parameter list means something else. I qu

Re: Is negative seek() from EOF of a GzipFile supported on Python 2.5.2 ?

2009-01-11 Thread Mark Tolonen
nt = offset - self.offset for i in range(count // 1024): self.read(1024) self.read(count % 1024) -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: why cannot assign to function call

2009-01-11 Thread Mark Wooding
[email protected] wrote: > But if you'll note, I said "if ..." referring to a couple of > hypothetical C-like languages, so your chapter-and-verse quote from > the standard, while interesting and appreciated, was basically > irrelevant. Ah, what you actually said was still quoted above (thanks):

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-11 Thread Mark Wooding
Carl Banks wrote: [Dynamically adding and removing instance attributes...] > Here's a couple examples of where it's useful: > > 1. Sometimes classes are initialized without calling __init__, [...] > 2. Some classes have factory classmethods [...] > 3. Some objects, such as proxies, have uncerta

Re: why cannot assign to function call

2009-01-13 Thread Mark Wooding
Steven D'Aprano wrote: > I found it interesting. Well, that's something, at any rate. > I think this conversation is reaching it's natural end. Frustration > levels are rising. I think you may be right. That said... > So I'm going to take a different tack in an attempt to reduce > frustrat

Re: ctype problem

2009-01-13 Thread Mark Tolonen
byref(i)) cl /LD /W4 x.c -> x.dll #include struct interface { int a; int b; char* c; }; __declspec(dllexport) void myfunction(struct interface* iface) { printf("%d %d %s\n",iface->a,iface->b,iface->c); } -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: read string in bits

2009-01-14 Thread Mark Smith
On Jan 14, 7:44 am, ts wrote: > On Jan 14, 3:32 pm, Chris Rebert wrote: > > > > > On Tue, Jan 13, 2009 at 11:21 PM, ts wrote: > > > hi, is there a way to read a character/string into bits in python? > > > > i understand that character is read in bytes. Do i have to write a > > > function to conv

Re: read string in bits

2009-01-14 Thread Mark Smith
On Jan 14, 7:44 am, ts wrote: > On Jan 14, 3:32 pm, Chris Rebert wrote: > > > > > On Tue, Jan 13, 2009 at 11:21 PM, ts wrote: > > > hi, is there a way to read a character/string into bits in python? > > > > i understand that character is read in bytes. Do i have to write a > > > function to conv

Re: why cannot assign to function call

2009-01-14 Thread Mark Wooding
Steven D'Aprano wrote: > > Ah! (say I) but assignment in C and Pascal looks different from the way > > it looks in C > > I'm sorry, that confuses me. Assignment in C looks different from the way > it looks in C? I guess the second C should be Python. Yes, you're right. Stupid mistake on my par

Re: why cannot assign to function call

2009-01-14 Thread Mark Wooding
Aaron Brady wrote: > On Jan 13, 5:06 pm, Mark Wooding wrote: > snip > > I'm going to move away from the formal semantics stuff and try a > > different tack. Here's what I think is the defining property of > > pass-by-value (distilled from the formal approach

Re: Wx broken?

2009-01-15 Thread Mark Smith
lled 'new.py' in your working directory, or you have one in your pythonpath. --Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: List comprehension - NameError: name '_[1]' is not defined ?

2009-01-15 Thread Mark Wooding
mario ruggier writes: > Some info on its security is at: > http://evoque.gizmojo.org/usage/restricted/ > Tell you what, if you find a security hole there (via exposed template > source on a Domain(restricted=True) setup) I'll offer you a nice > dinner (including the beer!) somewhere, maybe at s

Lazy List Generator Problem

2009-01-15 Thread Mark Hahnenberg
I'm trying to make a lazy, (theoretically) infinite prime number sieve using generators. The code I have thus far is: #!/usr/bin/env python import itertools def sieve(): nats = naturals(2) while True: elem = nats.next() yield elem nats = itertools.ifilterfalse(lambda x:

Re: List comprehension - NameError: name '_[1]' is not defined ?

2009-01-15 Thread Mark Wooding
mario ruggier writes: > 2009-01-15 22:26:18,704 ERROR [evoque] AttributeError: 'function' > object has no attribute 'func_globals': File "", line 1, in > Damn. So that doesn't work. :-( > But even if inspect did have the func_globals attribute, the "open" > builtin will not be found on __bu

Re: tp_base, ob_type, and tp_bases

2009-01-17 Thread Mark Wooding
Jeff McNeil writes: > Thank you! It was tp_base that was confusing me. The tp_bases member > makes sense as Python supports multiple inheritance. It wasn't > immediately clear that tp_base is there for single inheritance > reasons. It's all quite clear now. > > Is that an optimization of sorts?

Re: Relax Syntax for Augmented Arithmetic?

2009-01-19 Thread Mark Wooding
Steven D'Aprano writes: > There's a practical reason too. You create a new Foo instance, mutate > it with the augmented assignment operator, and then a tenth of a > millisecond later the garbage collector throws it away because it has > a reference count of zero. Only in this specific example.

Re: ifconfig in python

2009-01-19 Thread Mark Wooding
"James Mills" writes: > On Tue, Jan 20, 2009 at 10:28 AM, Nehemiah Dacres > wrote: >> Is ther an easy way to get the resolved ip address of the machine a >> script is running on? socket.gethostbyname(socket.gethostname) has >> only returned the ip address of my loop back interface ... not very

Re: ifconfig in python

2009-01-20 Thread Mark Wooding
Дамјан Георгиевски writes: > Something *like* this could work: > > myip = urllib2.urlopen('http://whatismyip.org/').read() This is going to cause all manner of problems. Firstly, many users are stuck behind NAT routers. In this case, the external service will report the address of the r

Re: Doubts related to subprocess.Popen()

2009-01-20 Thread Mark Wooding
srinivasan srinivas writes: > Does subprocess.Popen() count a new open file for each suprocess? I > mean does it occupy an entry in file descriptor table of parent > process? If so, wat is each file descriptor connected to? On Unix, subprocess.Popen will use up a file descriptor in the parent f

Re: Doubts related to subprocess.Popen()

2009-01-20 Thread Mark Wooding
"Diez B. Roggisch" writes: > Usually, each new process has three file-descriptors associated with > it - stdin,stdout and stderr. > > So when you span a process, the overall count of FDs should increase > by three. Yes, but that's irrelevant. There are two file limits which are relevant: * t

Re: ifconfig in python

2009-01-20 Thread Mark Wooding
"[email protected]" writes: > one way to get your head around this is - IP Addresses are associated > with the interface and not the computer. distinction may be subtle but > critical. Actually this is wrong for most Unix systems, which use the `weak end-system model' described in RFC11

Re: ifconfig in python

2009-01-20 Thread Mark Wooding
"bruce" writes: [a top-posted monstrosity] > so the question really starts to look like: > > -what's the default listening address for my app (insert nic)? > -what's the default sending address for my app (insert nic)? > -what's the default listening address for my server? > -what's the defa

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-20 Thread Mark Wooding
"Russ P." writes: > Actually, in addition to the enforcement of "private," you also need > the enforcement of "protected." Oh, heavens. If you want C++ or any of its progeny, you know where to find them. Besides, those languages have a horrific design mistake because they conflate the class sy

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-20 Thread Mark Wooding
Steven D'Aprano writes: > The consequence of this dynamism is that the Python VM can't do many > optimizations at all, because *at any time* somebody might mess with the > implementation. But 90% of the time nobody does, so Python is needlessly > slow 90% of the time. Wouldn't it be nice if th

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-20 Thread Mark Wooding
"Russ P." writes: > Rather than waste more time replying to your post, Let me just refer > you to an excellent post that you may have missed earlier in this > thread by Mr. D'Aprano: I've responded to that now. (Steven and I can't even agree on a description for simple parts of Python semantics

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-21 Thread Mark Wooding
"Russ P." writes: > Which is why I was hoping that Python might get enforced data hiding > as well as optional static type declarations that can actually be used > for static verification. But maybe that's all just a pipe dream on my > part -- or "onanism." I think that, if you want static assur

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-21 Thread Mark Wooding
"Russ P." writes: > I'm not sure what you mean by "conflating module and class systems." > Are you referring to the fact that Java requires each class to be in > its own file of the same name (I don't use Java, but that's what I've > heard)? If so, I agree that is a bad idea. No. I mean that us

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-21 Thread Mark Wooding
Scott David Daniels writes: > Nowhere in this discussion is a point that I find telling: Python's > policy of accessibility to the full data structure allows simple > implementation of debugging software, rather than the black arcana > that is the normal fare of trying to weld debuggers into the

<    38   39   40   41   42   43   44   45   46   47   >