Re: function factory question: embed current values of object attributes

2009-02-21 Thread Alan Isaac
Gabriel Genellina wrote: If you want a "frozen" function (that is, a function already set-up with the parameters taken from the current values of x.a, x.b) use functools.partial: OK, that's also a nice idea. Thanks! Alan -- http://mail.python.org/mailman/listinfo/python-list

Re: function factory question: embed current values of object attributes

2009-02-21 Thread Alan Isaac
Terry Reedy wrote: You are now describing a function closure. Here is an example that might help. It does. Thanks, Alan -- http://mail.python.org/mailman/listinfo/python-list

function factory question: embed current values of object attributes

2009-02-20 Thread Alan Isaac
the time it is manufactured). I do not care if this function is attached to `x` or not. I have a feeling that I am turning something simple into something complex, perhaps for lack of an afternoon coffee or lack of CS training. Suggestions appreciated. Alan Isaac -- http://mail.python.org

Re: is it possible to add a property to an instance?

2009-02-20 Thread Alan Isaac
Attributes are data attributes or callable attributes. Data attributes are variables or properties. Callable attributes are usually method attributes. This seemed about right to me, but a better (or "official") taxonomy would be welcome. Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: Python with Ecmascript

2008-07-11 Thread Alan Isaac
/listinfo/users 2. Did you try to compile it? Is there anything obviously 2.5 incompatible? Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: Python with Ecmascript

2008-07-10 Thread Alan Isaac
Daniel Fetchinson wrote: Is there a way to do similar things on linux? NJSModule? http://en.wikipedia.org/wiki/NJS Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: Market simulations with Python

2008-06-28 Thread Alan Isaac
other library? You could use SimPy. Also see: http://gnosis.cx/publish/programming/charming_python_b10.html http://www.mech.kuleuven.be/lce2006/147.pdf If you plan to share you efforts, please post updates here. Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamically naming objects.

2008-06-06 Thread Alan Isaac
On Jun 7, 1:20 pm, Hans Nowak [user() for i in range(n)] Kalibr wrote: or does it somehow work? how would I address them if they all have the name 'u'? users = list(User() for i in range(n)) for user in users: user.do_something() hth, Alan Isaac -- http://mail.

Re: parser recommendation

2008-06-05 Thread Alan Isaac
One other possibility: SimpleParse (for speed). http://simpleparse.sourceforge.net/> It is very nice. Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: Ideas for master's thesis

2008-06-02 Thread Alan Isaac
e indexing differently. I am confident that you could get a lot of guidance on the NumPy list if you were interested in taking this on. Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: code of a function

2008-05-29 Thread Alan Isaac
Anand Patil wrote: If you're using IPython, you can do svd?? . http://www.scipy.org/doc/numpy_api_docs/numpy.linalg.linalg.html hth, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: make a string a list

2008-05-29 Thread Alan Isaac
characters' position. Why dont the ``find`` or ``index`` methods work for you? http://docs.python.org/lib/string-methods.html Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: should I put old or new style classes in my book?

2008-05-29 Thread Alan Isaac
om http://docs.python.org/ref/metaclasses.html> but it seems right. Thank you, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: observer pattern (notification chain synchronization)

2008-05-10 Thread Alan Isaac
illed". Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

observer pattern (notification chain synchronization)

2008-05-09 Thread Alan Isaac
rtreceived`` values. Is this sensible enough? What are standard and better ways? Thank you, Alan Isaac PS I am drawing on the description of the observer pattern at http://www.dofactory.com/Patterns/PatternObserver.aspx#_self1> The real world aspects are just to add some concrete

Re: python vs. grep

2008-05-08 Thread Alan Isaac
mance grep analog. https://svn.enthought.com/svn/sandbox/grin/trunk/ hth, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: observer pattern question #1 (reference to subject)

2008-05-08 Thread Alan Isaac
Ville M. Vainio wrote: in case of stocks, you are probably monitoring several stock objects, so the stock should probably pass itself to the observer OK. This is related to my question #2 (in a separate thread), where I'd also appreciate your comments. analogous to a typical U

Re: observer pattern question #1 (reference to subject)

2008-05-08 Thread Alan Isaac
Alan Isaac <[EMAIL PROTECTED]> writes: Is anything lost by not maintaining this reference (other than error checking ...)? If I feel the observer needs access to the subject, what is wrong with just having the subject pass itself as part of the notification? Ville M.

observer pattern question #2 (notification chain)

2008-05-08 Thread Alan Isaac
s, which are only for illustration. Thank you, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

observer pattern question #1 (reference to subject)

2008-05-08 Thread Alan Isaac
m/ASPN/Cookbook/Python/Recipe/131499). Is anything lost by not maintaining this reference (other than error checking ...)? If I feel the observer needs access to the subject, what is wrong with just having the subject pass itself as part of the notification? Thank you, Alan

Re: Help me on function definition

2008-04-04 Thread Alan Isaac
aeneng wrote: > WHAT IS WRONG WITH MY CODE? > def cross(u,v) Missing colon. hth, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: method to create class property

2008-03-18 Thread Alan Isaac
value): self._value = value Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: no more comparisons

2008-03-13 Thread Alan Isaac
case that is really uncomfortable? Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: no more comparisons

2008-03-13 Thread Alan Isaac
1 for > negative) and i is a string representing the absolute > value of the integer. So Does this do it? :: key= lambda x: (-x[1],int(x2)) Here I am depending on the lexicographic sorting of tuples. Without that there would be real trouble. Cheers, Alan Isaac

Re: no more comparisons

2008-03-13 Thread Alan Isaac
not as bad as I feared. What are some use cases that will clearly be harder (i.e., at least require a slightly elaborate wrapper) after this change? Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: no more comparisons

2008-03-13 Thread Alan Isaac
27;m overlooking something obvious ... how is this supposed to work if __cmp__ is no longer being called? (Which was my understanding.) Thank you, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: no more comparisons

2008-03-12 Thread Alan Isaac
gestion to use ``key``: this is already possible when it is convenient, but it is not always convenient. (Even aside from memory considerations.) By the way, I even saw mention of even removing the ``cmp`` built-in. Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

no more comparisons

2008-03-12 Thread Alan Isaac
/pipermail/python-3000/2008-January/011764.html Is that going anywhere? Also, what is the core motivation for removing this functionality? Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: Can't get items out of a set?

2008-03-08 Thread Alan Isaac
Cruxic wrote: > people = set( [Person(1, 'Joe'), Person(2, 'Sue')] ) > ... > p = people.get_equivalent(2) #method doesn't exist as far as I know > print p.name #prints Sue def get_equivalent(test, container): for p in container: if p == test

Re: Is it possible to return a variable and use it...?

2008-03-03 Thread Alan Isaac
Nathan Pinno wrote: > Is it possible to return a variable and then use it I think you are asking about the ``global`` statement. http://docs.python.org/ref/global.html> > like the following: Presumably not. ;-) Cheers, Alan Isaac -- http://mail.python.org/mailman/listin

Re: tuples, index method, Python's design

2008-03-02 Thread Alan Isaac
Paul Boddie wrote: > Here's the tracker item that may have made it happen: > http://bugs.python.org/issue1696444 > I think you need to thank Raymond Hettinger for championing the > cause. ;-) Yes indeed! Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: tuples, index method, Python's design

2008-03-02 Thread Alan Isaac
On April 12th, 2007 at 10:05 PM Alan Isaac wrote: > The avoidance of tuples, so carefully defended in other > terms, is often rooted (I claim) in habits formed from > need for list methods like ``index`` and ``count``. > Indeed, I predict that Python tuples will eventually ha

Re: more pythonic

2008-02-29 Thread Alan Isaac
alent generator expressions: someNewList = list( elementDerivedFrom(smthg) for smthg in someSequence if condition(smthg) ) Tastes vary of course. Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: Pythons & Ladders

2008-02-28 Thread Alan Isaac
when I last used it, some tinkering was required. You could work on adding features. http://docutils.sourceforge.net/sandbox/rst2wordml/readme.html If you get good enough a docutils, provide an option to have the number for the note be superscripted, like the note reference can be. fwiw, Alan

Re: asynchronous alarm

2008-02-24 Thread Alan Isaac
Paul Rubin wrote: > a = Event() > Thread(target=f, args=(a,)).start() > raw_input('hit return when done: ') > a.set() Simple and elegant. Thank you. Alan -- http://mail.python.org/mailman/listinfo/python-list

asynchronous alarm

2008-02-23 Thread Alan Isaac
Goal: turn off an audible alarm without terminating the program. For example, suppose a console program is running:: while True: sys.stdout.write('\a') sys.stdout.flush() time.sleep(0.5) I want to add code to allow me to turn off this alarm

Re: basic output question

2008-01-25 Thread Alan Isaac
John Deas wrote: > My problem is that f.read() outputs nothing Since ``open`` did not give you an IOError, you did get a handle to the files, so this suggests that the files you read are empty... Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: find minimum associated values

2008-01-25 Thread Alan Isaac
[EMAIL PROTECTED] wrote: > I'd use the first solution. It can be speeded up a bit with a try/except: for k,v in kv: try: if d[k] > v: d[k] = v except KeyError: d[k] = v Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: find minimum associated values

2008-01-25 Thread Alan Isaac
Alan Isaac wrote: > #sort by id and then value > kv_sorted = sorted(kv, key=lambda x: (id(x[0]),x[1])) > #groupby: first element in each group is object and its min value > d =dict( g.next() for k,g in groupby( kv_sorted, key=lambda x: x[0] ) ) > > Yes, that appears to

Re: find minimum associated values

2008-01-25 Thread Alan Isaac
Paul Rubin wrote: > How about something like: > > kv_sorted = sorted(kv, key=lambda x: (id(x[0]), x[1])) You mean like this? #sort by id and then value kv_sorted = sorted(kv, key=lambda x: (id(x[0]),x[1])) #groupby: first element in each group is object and its min value d =dict( g.next() fo

Re: find minimum associated values

2008-01-25 Thread Alan Isaac
Steven Bethard wrote: > [3rd approach] Seems "pretty" enough to me. ;-) I find it most attractive of the lot. But its costs would rise if the number of values per object were large. Anyway, I basically agree. Thanks, Alan -- http://mail.python.org/mailman/listinfo/python-list

find minimum associated values

2008-01-25 Thread Alan Isaac
I have a small set of objects associated with a larger set of values, and I want to map each object to its minimum associated value. The solutions below work, but I would like to see prettier solutions... Thank you, Alan Isaac

Re: pairs from a list

2008-01-22 Thread Alan Isaac
Arnaud Delobelle wrote: > pairs4 wins. Oops. I see a smaller difference, but yes, pairs4 wins. Alan Isaac import time from itertools import islice, izip x = range(51) def pairs1(x): return izip(islice(x,0,None,2),islice(x,1,None,2)) def pairs2(x): xiter = iter(x) while T

Re: pairs from a list

2008-01-22 Thread Alan Isaac
http://bugs.python.org/issue1121416> fwiw, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: pairs from a list

2008-01-22 Thread Alan Isaac
I suppose my question should have been, is there an obviously faster way? Anyway, of the four ways below, the first is substantially fastest. Is there an obvious reason why? Thanks, Alan Isaac PS My understanding is that the behavior of the last is implementation dependent and not guaranteed

pairs from a list

2008-01-21 Thread Alan Isaac
, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: simple try/except question

2007-10-29 Thread Alan Isaac
Gabriel Genellina wrote: > Perhaps you reassigned TypeError? Yes, that was it. Sheesh. Thanks! Alan -- http://mail.python.org/mailman/listinfo/python-list

Re: simple try/except question

2007-10-29 Thread Alan Isaac
False alarm. Fresh start of interpreter and all is well. Apologies. Still tracking. Alan -- http://mail.python.org/mailman/listinfo/python-list

Re: simple try/except question

2007-10-29 Thread Alan Isaac
Tim Chase wrote: > It works for me(tm)... > Python 2.4.3 Sorry to have left out that detail. Yes, it works for me in Python 2.4, but not in 2.5.1. The code I posted was copyied from the interpreter. Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

simple try/except question

2007-10-29 Thread Alan Isaac
Is the behavior below expected? If so, why is the exception not caught? Thanks, Alan Isaac >>> x,y='','' >>> try: x/y ... except TypeError: print 'oops' ... Traceback (most recent call last): File "", line 1, in TypeError: u

Re: Python and Combinatorics

2007-10-25 Thread Alan Isaac
none wrote: > Is there some package to calculate combinatorical stuff like (n over > k), i.e., n!/(k!(n - k!) ? Yes, in SciPy. Alan Isaac >>> from scipy.misc.common import comb >>> help(comb) Help on function comb in module scipy.misc.common: comb(N, k, exact=

Re: unpickle from URL problem

2007-10-10 Thread Alan Isaac
is also unpickles just fine on my machine, but in addition the urllib download of this file unpickles just fine. Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: unpickle from URL problem

2007-10-10 Thread Alan Isaac
ects for an exercise, and I need not to worry about their directory structure.) Can you explain the differences I see? Thank you, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: unpickle from URL problem

2007-10-10 Thread Alan Isaac
Marc 'BlackJack' Rintsch wrote: > Pickles are *binary* files, not text files Actually not: http://docs.python.org/lib/node316.html These were created with protocol 0. But my question is about the different outcomes I observed. Thank you, Alan Isaac -- http://mail.python.org/mai

unpickle from URL problem

2007-10-09 Thread Alan Isaac
change the filetype to unix. I upload again. I try to unpickle from the URL. Now it works. Try it: x1, x2 = pickle.load(urllib.urlopen('http://www.american.edu/econ/notes/hw/example2')) Why the difference? Thank you, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

announcement: OpenOpt and GenericOpt

2007-09-10 Thread Alan Isaac
OpenOpt and GenericOpt == Introducing two new optimization packages. OpenOpt and GenericOpt are 100% Python with a single dependency: NumPy. For more detail see below and also https://projects.scipy.org/scipy/scikits/wiki/Optimization> OpenOpt --- OpenOpt is new open sour

Re: Any syntactic cleanup likely for Py3? And what about doc standards?

2007-09-05 Thread Alan Isaac
t pass a "self" > parameter to them. http://www.kylev.com/2004/10/13/fun-with-python-properties/ fwiw, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: create Powerpoint via com

2007-09-02 Thread Alan Isaac
Well, my needs were very limited so the result is too, but in case someone else just needs to get started: http://econpy.googlecode.com/svn/trunk/utilities/mso.py Comments, suggestions, additions welcom. Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: create Powerpoint via com

2007-08-31 Thread Alan Isaac
>>How about chart creation (in Ppt 2003)? >>I do not see how to do this with Python. [EMAIL PROTECTED] wrote: > You probably need to browse the COM object using PythonWin, which is a > part of the ActiveState distro. You can also use Python's builtin > function, dir, to find out various methods of

Re: create Powerpoint via com

2007-08-30 Thread Alan Isaac
[EMAIL PROTECTED] wrote: > OK, creating bulleted lists, or tables, or adding pictures is all straightforward. How about chart creation (in Ppt 2003)? I do not see how to do this with Python. Thanks, Alan -- http://mail.python.org/mailman/listinfo/python-list

Re: create Powerpoint via com

2007-08-30 Thread Alan Isaac
[EMAIL PROTECTED] wrote: > Hope that helps! Yes indeed. Thanks! Alan -- http://mail.python.org/mailman/listinfo/python-list

create Powerpoint via com

2007-08-30 Thread Alan Isaac
Can someone point me to a simple example or better yet tutorial for creating a Powerpoint using Python. Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: Fastest way to convert a byte of integer into a list

2007-07-12 Thread Alan Isaac
> On Jul 13, 9:54 am, Matimus <[EMAIL PROTECTED]> wrote: >>num = 255 >>numlist = [num >> i & 1 for i in range(8)] Godzilla wrote: > Thanks matimus! I will look into it... Watch out for the order, which might or might not match your intent. Cheers, Ala

Re: bool behavior in Python 3000?

2007-07-12 Thread Alan Isaac
> Alan Isaac skrev: >>http://www.python.org/dev/peps/pep-0285/ Nis Jørgensen wrote: > You forgot to quote this bit: [4)] Actually not. That is a different point. Ben seems bothered by this, but not me. I do not mind that True+1 is 2. I won't do it, but I do not object to it b

Re: bool behavior in Python 3000?

2007-07-11 Thread Alan Isaac
arithmetic. I mentioned Python 3000 since that is an opportunity for an ideal world. Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: bool behavior in Python 3000?

2007-07-11 Thread Alan Isaac
ce of certain arguments, not proposing an implementation. Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: bool behavior in Python 3000?

2007-07-10 Thread Alan Isaac
Bjoern Schliessmann wrote: > Is there any type named "bool" in standard Python? >>> type(True) Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: bool behavior in Python 3000?

2007-07-10 Thread Alan Isaac
Stargaming wrote: > I think Bjoern just wanted to point out that all those binary > boolean operators already work *perfectly*. >>> bool(False-True) True But reread Steven. Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: allow scripts to use .pth files?

2007-07-10 Thread Alan Isaac
s the script > that wanted to import it. Right. > I'm curious whether you think that the OP's use of ".pth" was a typo, > and whether you have read this: > http://docs.python.org/lib/module-site.html You seem to understand what I'm getting at.

bool behavior in Python 3000?

2007-07-10 Thread Alan Isaac
Is there any discussion of having real booleans in Python 3000? Say something along the line of the numpy implementation for arrays of type 'bool'? Hoping the bool type will be fixed will be fixed, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: disappearing documentation of `coerce`

2007-07-05 Thread Alan Isaac
> On 2007-07-05, Alan Isaac <[EMAIL PROTECTED]> wrote: >>Once upon a time, `coerce` was documented >>with the other built-ins. Neil Cerutti wrote: > It's now documented in Library Reference 2.2 Non-essential > Built-in Functions. > Apparently it is no longer

disappearing documentation of `coerce`

2007-07-04 Thread Alan Isaac
Once upon a time, `coerce` was documented with the other built-ins. http://pydoc.org/1.5.2/__builtin__.html Now it is not. http://docs.python.org/lib/built-in-funcs.html Reason? Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: allow scripts to use .pth files?

2007-07-04 Thread Alan Isaac
> On Jul 3, 7:35 am, Alan Isaac <[EMAIL PROTECTED]> wrote: >>Suppose I have a directory `scripts`. >>I'd like the scripts to have access to a package >>that is not "installed", i.e., it is not on sys.path. >>On this list, various people have describe

allow scripts to use .pth files?

2007-07-03 Thread Alan Isaac
assuming there is not one. (?) How about allowing a `scripts.pth` file in such a `scripts` directory, to work like a path configuration file? (But to be used only when __name__=="__main__".) Drawbacks? Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-07-01 Thread Alan Isaac
lly not identical in this sense. Of course you can make them so if you wish, but it is odd. So *nothing* is wrong here, imo. Btw: >>> a = 12 >>> b = 12 >>> a == b True >>> a is b True Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: equality & comparison by default (was Re: Too many 'self' in python.That's a big flaw in this language.)

2007-06-28 Thread Alan Isaac
once told me. Then your math teacher misspoke. You have two different cars in the set, just as expected. Use `is`. http://docs.python.org/ref/comparisons.html This is good behavior. Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: guidance needed: best practice for script packaging

2007-06-28 Thread Alan Isaac
My thanks to Gabriel and Josiah. Alan -- http://mail.python.org/mailman/listinfo/python-list

guidance needed: best practice for script packaging

2007-06-26 Thread Alan Isaac
uestion in an unhelpful way. If my question is still unclear, I would appreciate any leads on how to clarify it. Thank you, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

relative import question: packaging scripts

2007-06-23 Thread Alan Isaac
test.py rely on the user having done this? Thank you, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: Python plain-text database or library that supports joins?

2007-06-22 Thread Alan Isaac
Not Python, but maybe relevant: http://www.scriptaworks.com/cgi-bin/wiki.sh/NoSQL/HomePage Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

cannot have test scripts in packages?

2007-06-21 Thread Alan Isaac
ser to take the step of inserting the package location into sys.path and have test.py rely on the user having done this? What is the recommended handling of demo or test scripts for a package? Thank you, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: File processing - is Python suitable?

2007-06-19 Thread Alan Isaac
nstructs that Python can use to process these files? Someone can. ;-) However if the file is structured, awk may be faster, since this sounds like the kind of report generation it was designed for. Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: docs patch: dicts and sets

2007-05-20 Thread Alan Isaac
s surprised as I was. As I said, I am not attached to any language, and in fact I just used the proposals of others. I just wanted there to be some clue for users who read the docs. If you prefer to leave such users baffled, so be it. My effort is exhausted. Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: docs patch: dicts and sets

2007-05-19 Thread Alan Isaac
I submitted the language based on Bill and Carsten's proposals: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1721372&group_id=5470 That language has been rejected. You many want to read the discussion and see if acceptible language still seems discoverable. Alan

docs patch: dicts and sets

2007-05-15 Thread Alan Isaac
the scope of the containing program. Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

docs patch: dicts and sets

2007-05-11 Thread Alan Isaac
python.org/lib/types-set.html: append a new sentence to 2nd par. Iteration over a set returns elements in an indeterminate order,which generally depends on factors outside the scope of the containing program. Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: change of random state when pyc created??

2007-05-11 Thread Alan Isaac
d par. Iteration over a set returns elements in an indeterminate order, which generally depends on factors outside the scope of the containing program. Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: change of random state when pyc created??

2007-05-10 Thread Alan Isaac
>> Alan Isaac requested: >> http://docs.python.org/lib/typesmapping.html: to footnote (3), add phrase >> http://docs.python.org/lib/types-set.html: append a new sentence to 2nd paragraph "Hamilton, William " <[EMAIL PROTECTED]> wrote in message news:[EMAIL

Re: change of random state when pyc created??

2007-05-09 Thread Alan Isaac
set.html: append a new sentence to 2nd paragraph Iteration over a set returns elements in an arbitrary order, which may depend on the memory location of the elements. fwiw, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: change of random state when pyc created??

2007-05-09 Thread Alan Isaac
trary > order." If this wording is not present for sets, something to this > effect should be added. Even Robert did not claim that *that* phrase was adequate. I note that you cut off "which is non-random"! Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: change of random state when pyc created??

2007-05-09 Thread Alan Isaac
"Robert Kern" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Actually, the root cause of Peter's specific example is the fact that the > default implementation of __hash__() and __eq__() rely on identity comparisons. > Two separate invocations of the same script give different objec

Re: change of random state when pyc created??

2007-05-09 Thread Alan Isaac
an ordinary users. Did this thread not demonstrate that even sophisticated users do not see into this "implication" immediately? Replicability of results is a huge deal in some circles. I think the docs for sets and dicts should include a red flag: do not use these as iterators if you w

Re: change of random state when pyc created??

2007-05-09 Thread Alan Isaac
"Peter Otten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Alan Isaac wrote: > There is nothing wrong with the random module -- you get the same numbers on > every run. When there is no pyc-file Python uses some RAM to create it and > therefore y

Re: change of random state when pyc created??

2007-05-08 Thread Alan Isaac
outcome (result2) - the two outcomes are different (result1 != result2) Do you see something different than this if you run the test as I suggested? If not, how can in not involve the .pyc file (in some sense)? Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: change of random state when pyc created??

2007-05-07 Thread Alan Isaac
files. Explanation welcome!! Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: change of random state when pyc created??

2007-05-05 Thread Alan Isaac
ully-pure module as a > script") I'm not going to call this a bad practice, since it has clear virtues. I will say that it does not seem to be a common practice, although that may be my lack of exposure to other's code. And it still does not address the common need of playing with a "package in progress" or a "package under consideration" without installing it. Cheers, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: change of random state when pyc created??

2007-05-05 Thread Alan Isaac
The files are not appropriate for posting. I do not yet have a "minimum" case. But surely I am not the first to notice this! Alan Isaac PS I'll send you the files off list. -- http://mail.python.org/mailman/listinfo/python-list

Re: change of random state when pyc created??

2007-05-05 Thread Alan Isaac
unlikely. Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

change of random state when pyc created??

2007-05-04 Thread Alan Isaac
he shell. I get result1. I execute it again; I get result2. >From then on I get result2, unless I delete module.pyc again, in which case I once again get result1. Can someone explain this to me? Thank you, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: relative import broken?

2007-05-03 Thread Alan Isaac
t; """ To change my question somewhat, can you give me an example where this behavior (when __name__ is '__main__') would be useful for a script? (I.e., more useful than importing relative to the directory holding the script, as indicated by __file__.) Thanks, Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

  1   2   >