HELP: Searching File Manager written in Python
Hi, I am googeling some hours now ... still without result. So I have a question: Does somebody know a filemanager: - which looks like Norton Commander/7-Zip Filemanager - where I can add python scripts which I can execute on a selected file I already looked at wxpyatol but its not what I search, and its no more developped. Thanks Stephane -- http://mail.python.org/mailman/listinfo/python-list
Re: HELP: Searching File Manager written in Python
To answer to you both: The Norton Commander was a popular file manager for DOS, but the idea of the 2 window concept is still used by a lot of software. On Linux the one I use is Midnight Commander (mc). On Windows there are the 7-zip file manager see http://www.7-zip.org/ (7-zip is also a new compression format which is very good, there exist also a linux command line version) - Speed Commander is also a Windows filemanager. - Atol is based on GTK runs on Linux and Windows (http://atol.sourceforge.net/) but is not written in python or cannot run commands (I also get always error messages at startup that some drives are missing, perhaps my cdrom or my zip drive, but this happens with Gimp too -> so I believe GTK is the problem) But actually I work on Windows, thats why I am searching something which works on windows or better on Windows and Linux Perhaps some Python+wxWindows Application would be best. There exist a port of Atol to python+wxPython on: http://sourceforge.net/projects/wxpyatol But the project is stopped and abandonware ... Thanks a lot for now :-) I will have a look on your suggestions. Stephane -- http://mail.python.org/mailman/listinfo/python-list
Re: Anyone know the solution
On Monday, October 27, 2014 5:33:17 PM UTC-7, alex23 wrote: > On 28/10/2014 1:10 AM, e...@gmail.com wrote: > > Write a program that reads the contents of the two files into two > > separate lists. The user should be able to enter a boy's > > name, a girl's name or both, and the application will display messages > > indicating whether the names were among the most popular. > > This is actually a trick question. This is a classic unsolvable problem > in computer science, known as the Dual Baskets problem. It is > NP-complete, meaning that there is no easy solution. It requires > brute-forcing and can take an indefinite period of time to complete, if > at all. > > The correct answer is "Not possible". Can you elaborate why it is an NP-complete problem or maybe a link to description of problem you are referring to? Thanks. -- https://mail.python.org/mailman/listinfo/python-list
Python Style Question
Let's say I have an incoming list of values *l*. Every element of *l* can be one of the following options: 1) an integer value 2) a string in form of '', e.g. '7' 3) a string with a json serialization of an integer value, e.g. '"7"' 4) something else that should be ignored I need to transform this list into another list with values from options 1)-3) coerced to int. The code below should do this. Variant 1 === values = [] for c in l: # Case 1) or 2) try: c_int = int(c) except ValueError: pass else: values.add(c_int) continue # Case 3) try: c_int = int(json.loads(c)) except ValueError: pass else: values.add(c_int) continue === Is this code ugly? Does it follow EAFP? Am I missing something in language best practice? Or maybe below is more preferable way with a nested try...except clause? Variant 2 === values = [] for c in l: # Case 1) or 2) try: c_int = int(c) except ValueError: # Case 3) try: c_int = int(json.loads(c)) except ValueError: pass else: values.add(c_int) continue else: values.add(c_int) continue === Thanks, Anton. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Style Question
On Wednesday, October 29, 2014 4:43:33 AM UTC-7, Rafael Romero Carmona wrote: > Hi, first in Python 2.7.6 and Python 3.4.0 list haven't got any add > function but they have append. You are right, in my original code I use set instead of array, so it should be either values = set() or values.append() in the original code. > > I think you could do better with something like > > == > import json > l = [1, -1, 0, '1', '-1', '0', json.dumps(-1), json.dumps(1), > json.dumps(0), 'x', 'sqjklsqjk__', (1, 2)] It should also work with cases like [1, json.dumps('-1')], which is case 3), sorry if it was not clear in the initial post. > > values = [] > > for c in l: > try: > c_int = int(c) > except ValueError: > pass > except TypeError: > pass > else: > values.append(c_int) > continue > print(values) > == > > The code has been tested in Python 2.7.6 and 3.4 and returns [1, -1, > 0, 1, -1, 0, -1, 1, 0] > > You don't need to do two try because you can process both exceptions > in the same way. You don't really need to do json.loads because if you > have a json string which is an integer, you could do that directly > with int(c) which can take a string and transform in an integer. In case of 3) an element can be a string like '"1"', which will fail int(...), in this case it tries to parse it with json. -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Style Question
On Wednesday, October 29, 2014 4:59:25 AM UTC-7, Rafael Romero Carmona wrote: > 2014-10-29 12:25 GMT+01:00 Martin Kemp : > Actually it doesn't work because there is no add function and it > doesn't catch the TypeError function to ignore other exceptions than > ValueError. Doesn't it? I tested in Python 2.7.6 and 3.4. Originally I was using set instead of list. So it should have been either values = set() or values.append(), but it is not relevant to the question. Regarding TypeError, I don't catch it on purpose, because I want this type of Exception to bubble up and surface as an error and be logged, because this should never be the case. I expect an element to be either something coercible to int or a string. If for some reason it is an object, then there is something wrong one layer up, so I want it to fail explicitly. -- https://mail.python.org/mailman/listinfo/python-list
Re: Anyone know the solution
On Tuesday, October 28, 2014 10:13:14 PM UTC-7, Gregory Ewing wrote: > No, that's not the correct answer. Being NP-complete doesn't > mean something is impossible, or even hard to do. All it > means is that nobody knows of a cleverer solution than > just trying all possibilities. That's only a difficulty if > the problem is large enough; often it won't be. Why do you need to iterate over all possibilities solving this problem anyway? -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Style Question
On Thursday, October 30, 2014 4:10:23 AM UTC-7, Steven D'Aprano wrote: > I don't particularly like either version. I prefer this: > > def load_int(obj): > if isinstance(obj, int): > # Case 1), an int, e.g. 7 > return obj > elif isinstance(obj, str): > # Case 2) and 3), a str or JSON serialised int. > # E.g. '7' or '"7"'. > try: > return int(obj) > except ValueError: > return int(json.loads(obj)) > raise TypeError('require int or str, got %s' % type(obj).__name__) This will definitely work, but then I don't see a benefit of EAFP and duck-typing: Let's say I have a class class FakeInt(object): def __int__(self): return 42 In this case: >>> fi = FakeInt() >>> isinstance(fi, int) False >>> int(fi) 42 So probably I need to rephrase 1) something, that I can cast to int. Same for > elif isinstance(obj, str): As long as it behaves like string (can be some sort if bytearray). For particularly this case, it will probably won't happen, but again, it looks like an overloaded function with strongly typed argument. or a functional form: > def tolerant_load_int(obj, default=None): > try: > return load_int(obj) > except (ValueError, TypeError): > return default > values = [n for n in map(tolerant_load_int, l) if n is not None] > # alternative to using map > values = [n for n in (tolerant_load_int(obj) for obj in l) if n is not None] I like the idea of wrapping it up in a function and being able to use it in these functional forms. -- https://mail.python.org/mailman/listinfo/python-list
Re: I love assert
On Tuesday, November 11, 2014 11:41:06 AM UTC-8, Peter Cacioppi wrote: > I get the impression that most Pythonistas aren't as habituated with assert > statements as I am. Is that just a misimpression on my part? If not, is there > a good reason to assert less with Python than other languages? > > As far as I can tell, Python supports assert perfectly well. When run with > the optimization flagging, the asserts are truly removed. > > I think one needs to take care with some basic assert coding - it's not a > substitute for unit tests, it doesn't absolve you of normal exception > responsibilities, and, most of all, it should be used for passive inspection > and not action. But given these guidelines, I still find it very useful as > "active comments". I am not sure how and when you use assert, but something that stops me from using assert is that in many cases I would use them to 1) Check type of an incoming argument/returned value 2) Check value of an incoming argument/returned value But the issues I can see here is that assert throws AssertError, while there is a specialized error for each of the case: 1) TypeError 2) ValueError. Moreover for the 1) case it makes it impossible to dynamically substitute an object with another object that implements the same interface. -- https://mail.python.org/mailman/listinfo/python-list
Re: I love assert
On Wednesday, November 12, 2014 2:00:35 PM UTC-8, Anton wrote: > On Wednesday, November 12, 2014 1:41:20 PM UTC-8, Marko Rauhamaa wrote: > > Asserts help the reader of the code understand why some possibilities > > are not considered by the code. They are not considered because the > > writer of the code asserts they are not really possible. > I can see how assert statement can point out what should not happen, can you > give an example. I messed up, meant to say: I can see how assert statement can point out what should not happen, can you give an example when a single assert statement would explain why it should never happen? -- https://mail.python.org/mailman/listinfo/python-list
Re: I love assert
On Wednesday, November 12, 2014 1:41:20 PM UTC-8, Marko Rauhamaa wrote: > Asserts help the reader of the code understand why some possibilities > are not considered by the code. They are not considered because the > writer of the code asserts they are not really possible. I can see how assert statement can point out what should not happen, can you give an example. > I use asserts sparingly, just like comments (which asserts are). I use > them to communicate nonobvious truths to the future maintainer of the > code. > > Or I might indicate the exhaustion of possibilities: > > if status == OK: > ... > elif status == ERROR: > ... > else: > assert status == WARNING > ... Could you elaborate your example here? Basically, this type of error checking does not look familiar to me in Python code. In C when one works with descriptors and has to check status codes after every call it looks natural. Maybe I just haven't used it this way, so I'd really appreciate a more specific use case. -- https://mail.python.org/mailman/listinfo/python-list
Re: I love assert
On Wednesday, November 12, 2014 2:05:17 PM UTC-8, Ian wrote: > On Wed, Nov 12, 2014 at 2:56 PM, Marko Rauhamaa wrote: > > Ethan Furman: > > > >> On 11/12/2014 01:41 PM, Marko Rauhamaa wrote: > >>> > >>> Or I might indicate the exhaustion of possibilities: > >>> > >>> if status == OK: > >>> ... > >>> elif status == ERROR: > >>> ... > >>> else: > >>> assert status == WARNING > >>> ... > >> > >> And here's a nice example of what one should NOT do. Imagine that a > >> new status, CONFUSED is added, the above code is not modified to > >> handle it, and for whatever reason the program is being run optimized > >> -- the assert is not there, and CONFUSED is treated the same as > >> WARNING. > > > > How would it be better if you removed the assert then? > > You don't need to remove it. Just reorganize it to make sure it > indicates actual exhaustion of possibilities. E.g. using the "assert > False" pattern from your post: > > if status == OK: > ... > elif status == ERROR: > ... > elif status == WARNING: > ... > else: > assert False If the code is run optimized and asserts are ignore CONFUSED statement would still not be handled and you will not know about it. I would do something like: if status == OK: ... elif status == ERROR: ... elif status == WARNING: ... else: raise RuntimeError("Unknown errorno") Or if it is at the end of the function, then: if status == OK: ... elif status == ERROR: ... elif status == WARNING: ... raise RuntimeError("Unknown errorno") unless there is a customer exception type I can use for this situation. -- https://mail.python.org/mailman/listinfo/python-list
Re: I love assert
On Wednesday, November 12, 2014 2:42:19 PM UTC-8, Ian wrote: > On Wed, Nov 12, 2014 at 3:13 PM, Anton wrote: > > If the code is run optimized and asserts are ignore CONFUSED statement > > would still not be handled and you will not know about it. > > I would do something like: > > There's no way to make the CONFUSED status be handled without actually > changing the code. The difference is that this version will not > incorrectly treat CONFUSED as WARNING; it just won't do anything at > all if the code is optimized. Right, but the goal is not to make the CONFUSED status be handled without coding, but to be notified about an unknown status code and act accordingly. -- https://mail.python.org/mailman/listinfo/python-list
Re: I love assert
On Wednesday, November 12, 2014 3:03:18 PM UTC-8, Ian wrote: > On Wed, Nov 12, 2014 at 3:48 PM, Anton wrote: > Sure, which is why you and I have both suggested raising a RuntimeError > instead. Yeah, I actually read it after sending my response :) -- https://mail.python.org/mailman/listinfo/python-list
Re: Array of Functions
On Friday, November 14, 2014 2:17:38 PM UTC-8, Richard Riehle wrote: > In C, C++, Ada, and functional languages, I can create an array of functions, > albeit with the nastiness of pointers in the C family. For example, an > array of functions where each function is an active button, or an array of > functions that behave like formulae in a spreadsheet. I am finding this a > bit challenging in Python. > > Example: > > r1c1 r1c2 r1c3 > r2c1 r2c2 r2c3 > r3c1 r3c2 r3c3 > > where r1 is row 1 and c1 is column 1. Suppose I want an array where the > colum three is a set of functions that operates on the other two columns, > depending on the values I set for those rows and columns?As noted, I can > do this pretty easily in most languages (well, except for Java which does not > support any kind of functional programming capability), even if I have to use > pointers. > > I think my difficulty is related to the REPL nature of Python. However, I am > sure some clever Pythonista has found a way to do this. > > Thanks in advance for any suggestions, > > Richard Riehle, PhD, International Technological University, San Jose, CA Could you share a code snippet in C/C++ that would do what you need? -- https://mail.python.org/mailman/listinfo/python-list
Re: loop
for i in (10**p for p in range(3, 8)): print(i) -- https://mail.python.org/mailman/listinfo/python-list
Check if dictionary empty with == {}
Probably a silly question. Let's say I have a dictionary mydict and I need to test if a dictionary is empty. I would use if not mydict: """do something""" But I just came across a line of code like: if mydict == {}: """do something""" which seems odd to me, but maybe there is a valid use case, thus I decided to ask the community. Thanks. -- https://mail.python.org/mailman/listinfo/python-list
Re: When to use assert
safely remove the checks. > > > > Here's my advice when *not* to use assertions: > > > > * Never use them for testing user-supplied data, or for anything > > where the check must take place under all circumstances. > > > > * Don't use assert for checking anything that you expect might fail > > in the ordinary use of your program. Assertions are for extraordinary > > failure conditions. Your users should never see an AssertionError; > > if they do, it's a bug to be fixed. > > > > * In particular, don't use assert just because it's shorter than an > > explicit test followed by a raise. Assert is not a shortcut for > > lazy coders. > > > > * Don't use them for checking input arguments to public library > > functions (private ones are okay) since you don't control the > > caller and can't guarantee that it will never break the > > function's contract. > > > > * Don't use assert for any error which you expect to recover from. > > In other words, you've got no reason to catch an AssertionError > > exception in production code. > > > > * Don't use so many assertions that they obscure the code. > > > > > > > > -- > > Steven I use ORM and often need to write a function that either takes an id of the record or already loaded model object. So I end up writing a piece of code like below: def do_something(instance): if isinstance(instance_or_id, int): instance = Model.get(instance) assert isinstance(instance, Model) # Code that assumes that instance is an object of type Model do_somthing is not a part of public library, though it is a public function, which can and intended to be used by other programmers; and assert should never happen if a client uses the function as planned. I wonder if this use-case is controversial to this part: > Many people use asserts as a quick and easy way to raise an exception if > > an argument is given the wrong value. But this is wrong, dangerously > > wrong, for two reasons. The first is that AssertionError is usually the > > wrong error to give when testing function arguments. You wouldn't write > > code like this: > > > > if not isinstance(x, int): > > raise AssertionError("not an int") > > > > you'd raise TypeError instead. "assert" raises the wrong sort of > > exception. > Thanks, Anton. -- https://mail.python.org/mailman/listinfo/python-list
BCB5 & Py_InitModule in python 2.3.5 crashes sometimes
Hi, I embedded the python 2.3.5 interpreter in my Borland C++ Builder 5 application on WinXP pro Sp2 and all runs fine. (I translated the python23.lib with coff2omf) But from time to time when I call Py_InitModule I get a dialog: Title: Microsoft Visual C++ Runtime Library Text: Program: bla\bla\myapp.exe This application has requested the Runtime to terminate in an unusual way, please contact the applicatio'n team for more information. (This problem appears sometime somewhere else too, but I was not able to localize it) My question is: - has somebody experienced something similar with BCB5? (so I know if its perhaps a bug in bcb only) - or is it a bug in python 2.3.5 - has the python interpreter some threads which are perhaps not completely initialized?? - would python 2.4.1 help (since its linked with VS 2003??) When I go through my code step by step in the bcb debugger all runs fine, only if i "run" over the critical part I get the problem. (thats the reason its so hard to localize) The python interpreter is initialized when I click on a button in my app (not in the startapp of the app) The funny thing: I crash 3 times my app, and when I try it the 4'th time it works. I would be very glad for even a small hint, since actually I have no more ideas :-( Thanks -- http://mail.python.org/mailman/listinfo/python-list
3D plotting with python 2.5 on win32
Hi, I would like to know if some of you knows a - working - actual - out of the box (for me: binaries available) Package/Lib to do 3D plotting out of the box. I know matplotlib. There is MayaVi from enthon but you need to use their python (2.4.3), all other stuff need picking sources etc. IVuPy-0.1 seems to be abandonware, and there are no binaries. I don't get qwtplot3d-0.2.7 to compile on my pc, it seems you need the commercial qt 4.33 (with opensource qt 4.3.3 I doesnt work). Actually there is a big list on python org of 3D software, but I need only plotting facility (like Matlab for example), and some/most of the listed projects seem not be up to date (still based on python 2.4, like PyOpenGL where you get binaries only for python 2.4, seems to be abandonware too, sigh). Thanks for a hint :-) -- http://mail.python.org/mailman/listinfo/python-list
Re: 3D plotting with python 2.5 on win32
Hi Marek, thanks for the link .. I knew VPython already by I forgot it ( the last time it was only python 2.4 compatible) but as I see they support python 2.5 now ;-) I will check it and thanks again. Anton > Hi anton, > >Have you take a look at vpython? Here's their > website:http://www.vpython.org/ > And here is an simple example of how to use > it:http://linuxgazette.net/144/john.html > > Hope this helps :-) > > Cheers, > > Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: 3D plotting with python 2.5 on win32
Hi Jason, I know ctypes, my problem is not PyOpenGL itself, but during my tests with different python based 3D tools, some of them depend on PyOpenGL and since PyOPenGL is only available for python 2.4 the story ends here. Sorry I don't actually remember exactly what tool it was, I tried out (or tried to try out) different tools for doing 3D plotting, but skipped most of them since I did not get them to work. (... yes I am a little bit confused since I didnt find something working out of the box). Anton > > PyOpenGL isn't abandonware. Python 2.5 comes with the ctypes module > [1], so there isn't any need for a binary wrapper module anymore. > > Under 2.5, all pure "wrapper" binary modules are unnecessary. They > can work cross-platform from pure Python, calling directly into the C > function code. Trust me, this is an excellent improvement. > > PyOpenGL probably too low-level for what you want, but it isn't dead > yet. (It's just pining for the symbol table.) > > --Jason > > [1]http://docs.python.org/lib/module-ctypes.html -- http://mail.python.org/mailman/listinfo/python-list
Re: 3D plotting with python 2.5 on win32
Hi Peter, > have setuptools installed. Then, you should run: > > easy_install -fhttp://code.enthought.com/enstaller/eggs/windows/xp > VTK enthought.mayavi[nonets] > > It's important to include "[nonets]" so that you will get scipy and > numpy as well. I have already scipy 0.6.0 and numpy 1.0.4 installed, so I assume I can ignore [nosets] I will try to do tell setuptools to download all the stuff instead of installing it at once, so I can install it on other pc's even without internet connection. (I have to look, I always forget the easy_install parameters) > > Here are some links for getting started with MayaVI: > Mayavi Cookbook:http://scipy.org/Cookbook/MayaVi > MLab:http://www.scipy.org/Cookbook/MayaVi/mlab Thanks. I know scipy.org already, its grea :-) > From your posts it sounds like you really want to use something like > MLab. Yes, exact for the first step. Then I will look if I can integrate a "3D Plot window" in a wxPython application. I want to write an application to analyse log files from nc machines, and display the trajectories of the machine. > On a side note, we are almost done putting together an updated one- > click installer of python + packages for scientific computing. This > will be based on Python 2.5, will include most of what was included in > the 2.4.3-based installer, and will be available for multiple > platforms. Looks nice, its also nice that its possible to use parts of the enthon suite without using the full enthon installer. While it may be nice for some peoples, I personally prefer to install the standard python from python.org and add packages independently. (I tried the 2.4.3 enthon installer some time ago, but since I had already a python 2.4.3 installation with moinmoin and trac for example, I didn't like this too much, ... don't remember exactly what I didn't like exactly, by I deinstalled the whole enthon stuff rather fast. Again: the enthon installer is nice if somebody uses only this suite :-) Its a great work, congratulations !!) Thanks, Peter Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: 3D plotting with python 2.5 on win32
Hi Peter, I tried it, but I have problems downloading with easy_setup. If I download files with firefox and a downloadmanager it works (I also ha transferrates of 3kB/s which is quite slow) > easy_install -fhttp://code.enthought.com/enstaller/eggs/windows/xp > VTK enthought.mayavi[nonets] My question (I didn't figure it out myself for now): Is it possible to tell easy_install to create a list of all files to download like http://code.enthought.com/enstaller/eggs/windows/xp/enthought.mayavi-2.0.2a1-py2.5.egg http://code.enthought.com/enstaller/eggs/windows/xp/VTK-5.0.3.0003_s-py2.5-win32.egg .. .. .. so that I could pass this list to a downloadmanager and then install the stuff like: easy_install -f . enthought.mayavi VTK Any idea ... I tried the -n parameter, but since after every download easy_install had an error telling me that the egg is not a zipfile ... (perhaps it didn't get the complete file) it deleted it afterwards anyway. Bye Anton -- http://mail.python.org/mailman/listinfo/python-list
using re module to find " but not " alone ... is this a BUG in re?
Hi, I want to replace all occourences of " by \" in a string. But I want to leave all occourences of \" as they are. The following should happen: this I want " while I dont want this \" should be transformed to: this I want \" while I dont want this \" and NOT: this I want \" while I dont want this \\" I tried even the (?<=...) construction but here I get an unbalanced paranthesis error. It seems tha re is not able to do the job due to parsing/compiling problems for this sort of strings. Have you any idea?? Anton Example: import re re.findall("[^\\]\"","this I want \" while I dont want this \\\" ") Traceback (most recent call last): File "", line 1, in File "C:\Python25\lib\re.py", line 175, in findall return _compile(pattern, flags).findall(string) File "C:\Python25\lib\re.py", line 241, in _compile raise error, v # invalid expression error: unexpected end of regular expression -- http://mail.python.org/mailman/listinfo/python-list
Re: using re module to find
John Machin lexicon.net> writes: > > On Jun 12, 7:11 pm, anton <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I want to replace all occourences of " by \" in a string. > > > > But I want to leave all occourences of \" as they are. > > > > The following should happen: > > > > this I want " while I dont want this \" ... cut text off > What you want is: > > >> import re > >> text = r'frob this " avoid this \", OK?' > >>> text > 'frob this " avoid this \\", OK?' > >> re.sub(r'(? frob this \\" avoid this \\", OK?' > >> > > HTH, > John > -- > http://mail.python.org/mailman/listinfo/python-list > > First.. thanks John. The whole problem is discussed in http://docs.python.org/dev/howto/regex.html#the-backslash-plague in the section "The Backslash Plague" Unfortunately this is *NOT* mentioned in the standard python documentation of the re module. Another thing which will always remain strange to me, is that even if in the python doc of raw string: http://docs.python.org/ref/strings.html its written: "Specifically, a raw string cannot end in a single backslash" s=r"\\" # works fine s=r"\" # works not (as stated) But both ENDS IN A SINGLE BACKSLASH ! The main thing which is hard to understand is: If a raw string is a string which ignores backslashes, then it should ignore them in all circumstances, or where could be the problem here (python parser somewhere??). Bye Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: What Programing Language are the Largest Website Written In?
2011/7/12 Xah Lee : >23 yandex.ru (Russian) ◇ ? > As far as I know, the site is written in Perl. However, they are using lots of python in their products and for internal use. Anton. -- http://mail.python.org/mailman/listinfo/python-list
Introspecting the variable bound to a function argument
Hello, all. Does Python have an instrospection facility that can determine to which outer variable a function argument is bound, e.g.: v1 = 5; v2 = 5; def f(a): print(black_magic(a)) # or black_magic('a') f(v1) # prints: v1 f(v2) # prints: v2 -- () ascii ribbon campaign -- against html e-mail /\ www.asciiribbon.org -- against proprietary attachments -- https://mail.python.org/mailman/listinfo/python-list
Re: What exactly is a python variable?
Just a couple of days ago I was asking myself a similar question, and found this blog article: https://jeffknupp.com/blog/2013/02/14/drastically-improve-your-python-understanding-pythons-execution-model/ Clarified a lot of things to me. , Anton > On 17 Nov 2016, at 16:19, BartC wrote: > >> On 17/11/2016 12:20, Steve D'Aprano wrote: >> On Thu, 17 Nov 2016 10:37 pm, BartC wrote: > >>> (I don't know how to disassemble code outside a function, not from >>> inside the same program. Outside it might be: 'python -m dis file.py') > >> In the most recent versions of Python, dis.dis() will also accept a string: >> >> py> dis.dis('y = x + 1') >> 1 0 LOAD_NAME0 (x) >> 3 LOAD_CONST 0 (1) >> 6 BINARY_ADD >> 7 STORE_NAME 1 (y) >> 10 LOAD_CONST 1 (None) >> 13 RETURN_VALUE > > > Py2 gave me (for "y=x+1"): > > 0 SETUP_EXCEPT30781 (to 30784) > 3 STORE_SLICE+3 > 4 <49> > > Py3.4 works as you say but after that result I was disinclined to take it > further! > > -- > Bartc > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: When will they fix Python _dbm?
What is your operating system, environment, and Python build? dbm is just a module that might not have been included into your Python build. It's not a bug but a deliberate choice of the package maker. Regards, Anton > On 5 Dec 2016, at 17:45, clvanwall wrote: > > I have been a Perl programmer for 15+ years and decided to give Python a try. > My platform is windows and I installed the latest 3.5.2. Next I decided to > convert a perl program that uses a ndbm database since according to the doc > on python, it should be able to work with it. Needless to say, I get: > dbm.error: db type is dbm.ndbm, but the module is not available > Searching on Python Bug Tracker shows _dbm missing back in 03-03-2012! > That's a long time for a bug to be left open. > John Van Walleghen > > > Sent from my Galaxy Tab® A > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: python 2.7.12 on Linux behaving differently than on Windows
Wow... this thread gets to finally become a holy war. One method is dealing with this is take the environment as granted (Windows/Unix/Linux/MacOS/Dos sucks while my Windows/Unix/Linux/MacOS/Dos is the best) and figure if the hassle of porting (time, tech, AND moral) worth it. He just "do not try. Do or not do." So stop complaining. Just live with it. Regards, Anton > On 7 Dec 2016, at 21:02, BartC wrote: > >> On 07/12/2016 16:53, Michael Torrie wrote: >>> On 12/07/2016 08:48 AM, BartC wrote: >>> I would prefer that the program "t" can be invoked exactly the same way >>> under both systems. I don't want different instructions for Linux, or >>> for the user (of my language) to have to write two lots of code, as that >>> is my job... >> >> Ahh now we come to the crux of your argument. You want all potential >> platforms to conform to your own idea of what is normal. And indeed >> this is the actual issue that started the original thread. But that's >> not the way it works for any platform. I develop a lot of code on Linux >> that I'd like to get running on Windows. I prefer the Linux way of >> doing things but I'm not going to make any headway if I just try to >> brow-beat Windows and Windows' users over the things that aren't >> implement the same way. > > There is a lack of balance. > > If I run a Linux program on Windows, then the application gets to see > parameters such as *.* and can expand them if it wants. > > If I want to run a Windows program on Linux, and that program needs to see > *.* unexpanded, then it can't undo that expansion. The cat is already out of > the bag. > > It seems the only choice, if someone wants a cross-platform application that > is invoked in the same way, is to dumb it down and make it assume that any > parameters such as A* have been expanded, or will be expanded by that extra > step. > > Which means that input of A B* *C will all end up running together so that > you have no idea what is what or which file corresponds to which expansion. > That's assuming these parameters have any connection to the current set of > files at all; if not, then the input you end up is going to be meaningless. > > Now the problem is to determine whether processed input of U V W X Y Z are > intended bona fide inputs, or whether they just happened to result from some > random associations with the files in the current directory. > > But this is what happens when you have to work to the lowest common > denominator. The only proper solution is ban any unescaped ? or * from > inputs, and to add a warning that the program could behave unexpectedly if > they are used inadvertently. > > (I'm in the middle of porting my console editor to Linux. But one problem is > that on one Linux, half the key combinations (eg. Shift+Ctrl+B) are not > recognised. On other Linux, nearly all of those are missing too, plus most of > the rest! Which means I have to adapt the editor, again, to the lowest common > denominator, the minimum set of keys that are guaranteed to work on both. > > Except that was only two Linuxes; perhaps on others, the keyboard will likely > be crippled in some other way. That is, the same universal USB keyboard that > you can buy anywhere for $5 or $10, which has keys marked Shift, Ctrl and > Alt, but whose combinations cannot be recognised consistently. > > How people manage to do anything on such an OS I've no idea. Or maybe they > spend all day just typing elaborate file-matching patterns to pipe between > applications.) > > -- > Bartc > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: MacOSX SpeechRecognition installation problems
I would suggest using virtual environment (virtualenv, for example) for installing such packages. Dealing with directory permissions on MacOS is complicated, and using "sudo" is not the right way. Moreover, during the next OS upgrade the permissions will be updated as well, and chances are that your global package configuration breaks anyways. Regards, Anton >> On 8 Dec 2016, at 09:18, Michael Torrie wrote: >> >> On 12/07/2016 11:09 PM, 3dB wrote: >> trying to install SpeechRecognition for Python results in error: >> >> running install_lib >> creating /Library/Python/2.7/site-packages/speech_recognition >> error: could not create >> '/Library/Python/2.7/site-packages/speech_recognition': Permission denied >> >> >> Any advice on how to fix? > > Are you using sudo? > >> >> Follow information may be helpful: >> >> MacOSX 10.12.1 >> Python 2.7.10 (default, Jul 30 2016, 18:31:42) >> [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin >> >> /usr/local/bin/brew >> /usr/bin/python >> >> pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python >> 2.7) > > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
pip problems
(I am on Windows 10) When I install a new Python version, pip does not update all of the way. In the command line 'pip' still runs the old pip.exe, so I've had to manually move the new pip to C:\Windows . It would be great if you fixed this for future python versions! Thanks, Anton -- https://mail.python.org/mailman/listinfo/python-list
How to find files with a string
Hello everyone! I need to find a file, that contains a string TeNum I try to import os import sys def find_value(fname): value = 0 with open(fname, encoding='cp866') as fn: try: for i in fn: if 'TeNam' in i: print(fname) except IndexError: pass return {fname} def main(): dirname = ('H:\\1\\3') os.chdir(dirname) res = {} for i in os.listdir(dirname): res.update(find_value(i)) print('Filename is: ') if __name__ == "__main__": main() But there are mistakes like C:\Users\Anton\AppData\Local\Programs\Python\Python36-32\python.exe "C:/Users/Anton/PycharmProjects/Работа с файловой системой/Перебор файлов из папки.py" Traceback (most recent call last): File "C:/Users/Anton/PycharmProjects/Работа с файловой системой/Перебор файлов из папки.py", line 21, in main() File "C:/Users/Anton/PycharmProjects/Работа с файловой системой/Перебор файлов из папки.py", line 18, in main res.update(find_value(i)) ValueError: dictionary update sequence element #0 has length 35; 2 is required Process finished with exit code 1 Could you help me to solve this thread? -- https://mail.python.org/mailman/listinfo/python-list
Re: Python obfuscation
Alex Martelli wrote: > Modern equivalent of serialization (publishing one chapter at a time on > the web, the next chapter to come only if the author receives enough > payment for the previous one) have been attempted, but without much > success so far; however, the holy grail of "micropayments" might yet > afford a rebirth for such a model -- if paying for a chapter was > extremely convenient and cheap, enough people might choose to do so > rather than risk the next chapter never appearing. Remember that, by > totally disintermediating publishers and bookstores, a novelist may > require maybe 1/10th of what the book would need to gross in stores, in > order to end up with the same amount of cash in his or her pockets. > > One could go on for a long time, but the key point is that there may or > may not exist viable monetization models for all sorts of endeavours, > including the writing of novels, depending on a lot of other issues of > social as well as legal structures. Let's not be blinded by one model > that has worked sort of decently for a small time in certain sets of > conditions, into believing that model is the only workable one today or > tomorrow, with conditions that may be in fact very different. Maybe this micropayment thing is already working and active. What is the cost of a mouseclick and what is the monetarial value of the fact that someone is clicking on a link? Someone bought virtual property for real money and sold it later with a lot of profit. There are pages where one can buy pixels. Maybe me replying to you will provoke some other chain of events with payoffs for you or me (I hope positive :-) The idea of using a webservice to hide essential secret parts of your application can only work well if one makes some random alterations to the results of the queries. Like GPS signals that are deliberately made less exact. Obfuscated Python code could for example return variable precision numbers with a slight random alteration. I think such things would make it harder to reverse engineer the code behind the server. But the more one messes with the ideal output the more often the user will rather click another link. (or launch another satellite) Anton. what's the current exchange rate for clicks and dollars? -- http://mail.python.org/mailman/listinfo/python-list
Re: Python obfuscation
Bengt Richter wrote: > On Thu, 17 Nov 2005 10:53:24 -0800, [EMAIL PROTECTED] (Alex Martelli) wrote: > > >Anton Vredegoor <[EMAIL PROTECTED]> wrote: > [...] > >> The idea of using a webservice to hide essential secret parts of your > >> application can only work well if one makes some random alterations to > >> the results of the queries. Like GPS signals that are deliberately made > > > >I disagree on this general statement and I have already given two > >counterexamples: > I agree with your disagreement in general, but I think Antoon may be > alluding to the "covert channel" problem, where sometimes randomization > of an external observable is a defense. E.g., if a web site login process > responds faster with a rejection of a bad user name (i.e. is not in the > authorized > user list) than it does for a valid user name and a bad password, the timing > difference can be used over time to eke out the private user name list, and > make subsequent password attacks that much easier. Pardon me, but I'm Anton, not Antoon (well maybe I am but lets keep this distinction in order to avoid mental hash collisions) I agree with Alex and Bengt that my statement was too general and I even admit that as I wrote it down the thought of making it less provocative crossed my mind . However I felt safe because I wrote 'only work *well*' instead of 'only work *if*' and what is working well is open for discussion isn't it? Further in my post I wrote something about adding random fluctuations making it harder to reverse engineer a procedure so I felt even safer. Not so with Alex's thorough analysis though :-) What was mostly on my mind (but I didn't mention it) is that for something to be commercially viable there should be some kind of pricing strategy (NB in our current economic view of the world) where a better paying user gets a vip interface and poor people get the standard treatment. Since one has to have the optimal result anyway in order to sell it to the best payers it would be impractical to recompute less accurate values. Why not just add a random part to make it less valuable for the unpaying user? I'm thinking about things like specifiying a real value interval where the user can extract data from (this is also a data compression method, see arithmetic coding for more info). > Which perhaps gets towards Antoon's point (or my projection thereof ;-) -- > i.e., > that the anwers provided in an experimental probe of an algorithm are "signal" > for what you want to detect, and randomization may put noise in the signal to > defeat detection (even though enough noise might make the algorithm output > unsaleable ;-) > Yeah, sometimes people measure temperature fluctuactions in the CPU in order to get clues about how an algorithm works :-) But in fact my mind works more like some intuitive device that suggests that maybe some point is safe enough to post or not, without always thinking through all the details. > > > >a. a webservice which, for some amount X of money, gives an excellent > >heuristic estimate of a good cutting-path for a woodcutting tool (for a > >set of shapes to be cut out of standard-sized planks of wood by a > >numerically driven cutter): this is a case where ESR, acting as a > >consultant, advised his clients (who had developed a heuristic for this > >task which saved a lot of wood compared to their competitors') to keep > >their code closed-source, and it makes a good use case for the "hide > >essential secret parts" in general; > > If the heuristic always gives the same answer to the same problem it would be easier to predict the results. Oh no, now some mathematician surely will prove me wrong :-) > >b. a (hypothetical) website that, given time-space coordinates (and some > >amount Y of money), produces and returns weather predictions that are > >better than those you can get from its competitors. > > > >It appears to me that any application of this kind could work well > >without at all "making random alterations" to whatever. Point is, if > >you develop a better algorithm (or, more likely, heuristic) for good > >solutions to such problems, or predictions of just about anything which > >might have economic value to somebody, using a webservice to hide the > >essential secret parts of your discovery is an option, and it might be a > >preferable alternative to relying on patents (since software patents may > >not be enforceable everywhere in the world, and even where they're > >nominally enforceable it could prove problematic and costly to actually > >deter all would-be competitors from undercutting you). I do not see > >anything
Re: Python obfuscation
Alex Martelli wrote: > Money is made in many ways, essentially by creating (perceived) buyer > advantage and capturing some part of it -- but market segmentation is > just one of many ways. IF your predictions are ENORMOUSLY better than > those the competition can make, then offering for free "slightly > damaged" predictions, that are still better than the competition's > despite the damage, MIGHT be a way to market your wares -- under a lot > of other assumptions, e.g., that there is actual demand for the best > predictions you can make, the ones you get paid for, so that your free > service doesn't undermine your for-pay one. It just seems unlikely that > all of these preconditions would be satisfied at the same time; better > to limit your "free" predictions along other axes, such as duration or > location, which doesn't require your predictions' accuracy advantage to > be ENORMOUS _and_ gives you a lot of control on "usefulness" of what > you're supplying for free -- damaging the quality by randomization just > seems to be unlikely to be the optimal strategy here, even if you had > determined (or were willing to bet the firm that) marked segmentation is > really the way to go here. Suppose I grant all your theories about optimal marketing strategies. This still doesn't account for the way the market is behaving *now*. It isn't in any way logical or optimal. For example in Holland (where I live) complete governmental departments are dedicated to make life miserable for the unemployed, for asylum seekers, for people that disagree with any official policy. If looking at the recent developments in France I find it hard to believe that such social inequality an injustice develops naturally. To me it looks more like it's caused by organized crime, where *official* legal governmental organizations are either crimimal organizations themselves or are cooperating with such organizations. You seem to tackle the problem of python obfuscation by first proving that it isn't feasible and then giving some kind of solution that will work and give the desired result: webservices. However when I look at obfuscation techniques I see a desire to profit from giving some person the idea that he or she is superior to someone else because he has a better product. In order to avoid copying we now need obfuscation. The difficulty to copy the thing (whether it is a swiss watch, a sportscar, designer clothes, the latest computer game, an ipod, a computer program) is part of the advertising game and is the basis for associating it with a certain status. If you look for a few minutes at a TV screen and notice what the commercials are trying to tell you, you will see that it's almost always that you will be better, stronger, more popular or beautyfull etc. if only you use product X. You are perfectly right if you would say that it is an illogical strategy to make people feel better relative to other people in order to get them to do something you want. Commercial entities could in principle be free of such things but we live in a world that is dominated by this worldview and if one tries to sell something one has to take that into account. So how to get the same kind of market segmentation (as you call it) when you deploy your program as a webservice and where essentially the cost for you (moving a few electrons to produce a solution to a problem) is exactly the same whether you give the user a good or a bad result. If you give optimal results to everyone, users will go to other sites just because these sites give them opportunity to feel better than other people, not because this is objectively better, but just because that is how they think the world "works". > I hope this analogy clarifies why, while I don't think deliberate damage > of result quality can be entirely ruled out, I think it's extremely > unlikely to make any sense compared to ofher market segmentation > tactics, even if you DO grant that it's worth segmenting (free samples > are an extremely ancient and traditional tactic in all kind of food > selling situations, after all, and when well-designed and promoting a > product whose taste is indeed worth a premium price, they have been > repeatedly shown to be potentially quite effective -- so, I'm hoping > there will be no debate that the segmentation might perfectly well be > appropriate for this "analogy" case, whether it is or isn't in the > originally discussed case of selling predictions-via-webservices). I agree it doesn't make sense. Like uncle Harry who thinks he can lay golden eggs. We could cure him but we need the egss :-) Alternatively, lets just forget about obfuscation and try to get people to freely share by promoting open source (and open webservices). Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Python obfuscation
Alex Martelli wrote: > Anton Vredegoor <[EMAIL PROTECTED]> wrote: >... > > Suppose I grant all your theories about optimal marketing strategies. I wish I hadn't done that :-) But seriously, I'm having trouble answering in detail all of your points (which doesn't mean I don't value them highly) because my online time is limited by the time period this library is open, and I also want to scavange as much offline reading material as possible while I'm connected. > > This still doesn't account for the way the market is behaving *now*. It > > isn't in any way logical or optimal. For example in Holland (where I > > live) complete governmental departments are dedicated to make life > > What makes you think that governmental departments are part of the > *market*?! Government behavior is controlled by laws that are vastly > different from those controlling market behavior; if you're interested, > you could study the "theory of public choice". I don't think so, so the question can't be answered. It's the same logic that enabled me to say "payed webservices can only work well if" when in context of replacing obfuscation techniques. From 1+1 == 3 I can derive anything. I know its lame, but my time limitation forces me to go back (or up) one level in order to refute you. > > You seem to tackle the problem of python obfuscation by first proving > > that it isn't feasible and then giving some kind of solution that will > > work and give the desired result: webservices. However when I look at > > That seems to me to be a practicable technical approach, yes. > > > obfuscation techniques I see a desire to profit from giving some person > > the idea that he or she is superior to someone else because he has a > > better product. In order to avoid copying we now need obfuscation. The > > You're discussing the *motivation* for obfuscating, while what I was > giving was a possible way of *implementing* similar effects. Yes, that's the point. If you can produce at zero cost then the whole economic theory falters. You enter another continuum where traditional economic values become meaningless. From obfuscation to webservices is a big step in that direction. > Since redistribution of value, as long as a lot of value is created, can > be dealt with by other means, maximizing the creation of value tends to > be the goal I prefer -- a policy that quashes part or all of value > creation based on redistributive precepts is, by this very fact, going > to be something I look askance at (making the pie smaller to try to > ensure that what little is left gets sliced according to your political > preferences, rather than ensuring the pie is as big as possible as the > first order of business, and dealing with the slicing issues as > _secondary_ ones). I agree with your sentiment, but in order to maximize value creation we should leave material payments out of the equation when they only slow things down. From your writing I gather you already live in those quarters but you are still using materialistic concepts to describe the world. I don't blame you for it because I wouldn't know myself what would be applicable to a zero cost - maximal gain economy. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Why are there no ordered dictionaries?
Christoph Zwerschke wrote: > But of course, it will always be slower since it is constructed on top > of the built-in dict. In end effect, you always have to maintain a > sequence *plus* a dictionary, which will be always slower than a sheer > dictionary. The ordered dictionary class just hides this uglyness of > having to maintain a dictionary plus a sequence, so it's rather an issue > of convenience in writing and reading programs than a performance issue. > > It may be different if the ordered dict would be implemented directly as > an ordered hash table in C. The problem with hashing is that one is storing data from a possibly wildly varying range in a set of values with a limited range. That's where the ordering problems come from in the first place. If one wants to solve it once and for all one has to give up the speed advantage that makes hashing so popular. I wonder if optimized C code using bisect would be very much slower for small ranges? The current set implementation uses dicts to implement sets, while sets are a more basic data type than dicts. At least dicts and sets should be derived from the same type. Just speaking from an intuitive point of view of course :-) Here's a sorted dict implementation without using hashes, which maybe would be fast if implemented in C. The insertion order can be retrieved using the keys and values lists from the object itself, items() gives a sorted sequence. Anton. NB warning untested code. When using mutables as keys which is possible by this implementation, don't change the keys after they're used in the object. from array import array class VDict: def __init__(self,sequence = []): self.keys = [] self.values = [] self.unranks = array('L',[]) for key,value in sequence: self[key] = value def __setitem__(self,key,value): keys = self.keys values = self.values unranks = self.unranks n = len(keys) i = self.bisect_left(key) if i == n or keys[unranks[i]] != key: keys.append(key) values.append(value) unranks.insert(i,n) else: values[i] = value def __getitem__(self,key): i = self.bisect_left(key) return self.values[self.unranks[i]] def bisect_left(self,key, lo=0, hi=None): keys = self.keys unranks = self.unranks if hi is None: hi = len(keys) while lo < hi: mid = (lo+hi)//2 if keys[unranks[mid]] < key: lo = mid+1 else: hi = mid return lo def __contains__(self,key): keys = self.keys unranks = self.unranks n = len(keys) i = self.bisect_left(key) return i < n and keys[unranks[i]] == key def __len__(self): return len(self.keys) def items(self): keys = self.keys values = self.values unranks = self.unranks return [(keys[i],values[i]) for i in unranks] def __iter__(self): return iter(self.items()) def remove(self,key): keys = self.keys values = self.values unranks = self.unranks n = len(keys) i = self.bisect_left(key) x = unranks[i] if i < n and keys[x] == key: del keys[x] del values[x] del unranks[i] for j,k in enumerate(unranks): if k > x: unranks[j] -= 1 def test(): V = VDict() L = [1,2,3] V[L] = 10 print V[L] V[L] = 20 print V[L] V.remove(L) print V.items() V = VDict(zip('edcba',range(5))) print V.items() print V['d'] V.remove('d') print V.items() if __name__=='__main__': test() -- http://mail.python.org/mailman/listinfo/python-list
How to wake up the jython list moderator
I'm trying to post messages to the jython mailing list via gmane. I this possible? I've got all kinds of messages confirming that I exist and that my message has arrived and will be either approved or rejected with an explanation, but since then nothing but silence and my message doesn't show up either. Anton "maybe I'm just impatient" -- http://mail.python.org/mailman/listinfo/python-list
Re: How to wake up the jython list moderator
Thomas Heller wrote: > The easiest solution for this is to join the mailing list (with the > email address that you use to post), disable list delivery, and repost > your message via gmane. > Thanks. Anton -- http://mail.python.org/mailman/listinfo/python-list
Python on a public library computer
This is about how to start a Python interpreter on a very locked down library computer. Some time ago I started a thread about it.(Google won't let me reply to older topics so I'm starting a new topic with the same title) A few days ago I found a Jython console applet that can be run from a webpage: http://tams-www.informatik.uni-hamburg.de/applets/jython/primacheck.html This opens a webpage (well, maybe after some editing, I can't get google to display this link on the same line) which after some time aks the user to sign an applet which then turns out to be a complete Jython editor and interpreter! I'm looking for the sourcecode of a project like this so that I can host such a page myself and include more modules. Can anyone reach the author or has anyone written something like it and is willing to share the code? Alternatively can someone give me some tips about how to write it myself? Currently I'm at the stage where I can compile and run the examples (and the applets!) on the Jython homepage. I'm still wondering about how to sign applets. Maybe the interpreter could be done by using the code.py module from Jython itself and just redirect stdin and stdout to an applet? Anton p.s. John Lee: You remembered correctly, such a thing exists. -- http://mail.python.org/mailman/listinfo/python-list
Re: all possible combinations
John Machin wrote: > You don't need to use random sampling. Paul Rubin has shown how it can > be done deterministically. The following is a generalisation of his > code; it generates all possible assemblies of size n from a list of > parts. Is this helpful? > > def all_size_n_knickers(rqd_size, pieces): > npieces = len(pieces) > knicker_count = npieces ** rqd_size > austen = [npieces ** (rqd_size-k-1) for k in xrange(rqd_size)] > for i in xrange(knicker_count): > knicker = [pieces[j] for j in [(i // d) % npieces for d in austen]] > yield knicker > > for alist in all_size_n_knickers(4, 'abc'): > print ''.join(alist) > > print > print list(all_size_n_knickers(2, [1, 42, 666])) Just testing out my ELCH JythonConsole :-) def unint(i,symbols): res = [] radix = len(symbols) while i: i,r = divmod(i,radix) res.append(symbols[r]) return res[::-1] start = int('1',3) finish = int('2',3) for i in range(start,finish): print ''.join(unint(i,'abc')[1:]) This makes me wonder why we still don't have something like the unint function above in the standard distribution. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: all possible combinations
Steve Holden wrote: > > This makes me wonder why we still don't have something like the unint > > function above in the standard distribution. > > > Because it's not what you'd call (or, at least, it's not what I'd call) > universally required. As you have shown it is relatively easy to hack > something supp when it's needed, so since it isn't something that's > required by the majority it hasn't been added to the library. How about the symmetry argument? One can use int for radix 1 to 32 (I think) but for the reverse problem we only have hex or oct (and cannot choose symbol lists but that's not so very important, if the whole matter has any significance of course :-). Hey, unint might even win the "more general" approval! Anton "or maybe it's just because it's difficult to find a good name for it" -- http://mail.python.org/mailman/listinfo/python-list
Re: Brute force sudoku cracker
Diez B. Roggisch wrote: > As everyone posts his, I'll do the same :) It uses some constraint based > solving techniques - but not too complicated ones. When stuck, it > backtracks. So far it never failed me, but I haven't tested it too > thouroughly. Thanks to all for sharing. I like to program sudoku and review such code. So below here is my current file, I think it uses some techniques not yet posted here. It also has a difficult 16x16 puzzle which I know to be solvable (barring typing mistakes) but which my file can't solve before I get tired of waiting, this might draw some heavyweights in the ring :-) I have also read the sudoku wiki page: http://en.wikipedia.org/wiki/Sudoku which was very helpfull and interesting (especially the link to Knuths paper about dancing links was nice, even though I think (but maybe wrongly so) that we don't need dancing links now that we've got sets, but it's still a very very interesting paper) I think the first important step is to realize that some variations have fewer values so that it is possible to reduce the search space early. Currently I'm exploring ideas about contigengies as explained in the wiki above which seems promising, but I haven't found a nice way to implement them yet. Maybe an easy optimization would be to find values that don't come up often and choose variations containing those. And maybe I should switch to an approach that has possibility values inside the cells instead of computing them on the fly each time, that could make contigency elimination easier. Anton from __future__ import generators from sets import Set as set problem1 = ['063000700','000690008','97002', '002010080','050806090','090070200', '60013','700045000','009000140'] problem2 = ['030009007','01008','000100090', '004905006','02010','500607400', '050001000','40020','700500030'] problem3 = ['030500810','000760090','4', '043905006','01070','600801930', '9','090086000','061002080'] problem4 = ['004530080','060009000','90005', '000800350','0','027006000', '80007','000300040','090072600'] X =[' 1 0 0 0 0 12 0 10 11 7 6 0 0 4 0 0', ' 0 7 0 0 15 13 0 0 0 0 2 0 0 8 0 0', ' 3 0 0 0 4 0 0 0 0 5 0 12 0 16 0 0', ' 0 0 14 2 0 9 0 0 0 0 1 0 0 0 0 0', '10 15 0 1 0 0 0 2 0 16 0 0 3 0 0 0', '12 0 0 3 0 0 15 0 0 13 0 4 0 1 9 5', ' 5 0 11 0 7 0 8 0 0 0 0 0 0 15 0 0', ' 7 13 0 16 0 0 0 6 0 0 0 14 0 10 0 0', ' 0 0 13 0 11 0 0 0 10 0 0 0 1 0 12 0', ' 0 0 7 0 0 0 0 0 0 3 0 16 0 14 0 13', '16 8 0 0 14 0 5 0 0 15 0 0 4 0 0 6', ' 0 0 0 9 0 0 4 0 1 0 0 0 2 0 0 7', ' 0 0 0 0 0 16 0 0 0 0 8 0 10 5 0 0', ' 0 0 4 0 12 0 6 0 0 0 16 7 0 0 0 14', ' 0 0 6 0 0 1 0 0 0 0 12 13 0 0 11 0', ' 0 0 15 0 0 8 11 3 2 0 9 0 0 0 0 1'] problem5 = [row.split() for row in X] class State: def __init__(self,solved,unsolved): self.solved = solved self.unsolved = unsolved self.size = int((len(solved)+len(unsolved))**.25) def choiceset(self,x,y): "the set of possible choices for an empty cell" sz = self.size res = set(range(1,sz*sz+1)) r,c = x/sz*sz,y/sz*sz for (i,j),v in self.solved.iteritems(): if x == i or y == j or (r<=ihttp://mail.python.org/mailman/listinfo/python-list
multimethod (or rather overloading) in Python
Dear pythonistas! I'd like to emulate overloading in Python (like C++). Let's consider an example: class A(object): pass class B(object): pass Of course, there are some standard overloading implementations for Python. For example: def overload(cls): def wrapper(f): gl = f.func_globals next = gl.get(f.func_name, failedOverload_(f.func_name)) def _(obj, *args, **kwargs): if isinstance(obj, cls): return f(obj, *args, **kwargs) else: return next(obj, *args, **kwargs) return _ @overload(A) def foo(_): print '[EMAIL PROTECTED]' @overload(B) def foo(_): print '[EMAIL PROTECTED]' However, it obviously doesn't work for classes: I cannot overload instance methods with such a decorator. The best way I found is closures. Unfortunatley, in this case I need a hack: gl = f.func_globals turns into: gl = sys._getframe(1).f_locals and with this hack one can make the following trick: def poorManOverloadedMethods(someInfo): @overload(A) def _(_): print '%s: [EMAIL PROTECTED]' % someInfo @overload(B) def _(_): print '%s: [EMAIL PROTECTED]' % someInfo return _ PMOM = poorManOverloadedMethods('test') ... Of course, I can imagine some metaclasses magic that would allow to code: class MyClass(WithOverloading): @overloadMethod(A) def someMetod(self, _): ... But it would rather convoluted: the best idea I have so far is to mangle methods name in the manner most of C++ compilers do. Is there better way? Can I unify both @overload and @overloadMethod? with the best regards, anton. -- http://mail.python.org/mailman/listinfo/python-list
Re: multimethod (or rather overloading) in Python
anton muhin wrote: Correction: Of course, I can imagine some metaclasses magic that would allow to code: class MyClass(WithOverloading): @overloadMethod(A) def someMetod(self, _): ... But it would rather convoluted: the best idea I have so far is to mangle methods name in the manner most of C++ compilers do. Stupid me. Of course, name magling is impossible and unnecessary. Sorry. Still the question remains. with the best regards, anton. -- http://mail.python.org/mailman/listinfo/python-list
Re: [perl-python] exercise: partition a list by equivalence
Xah Lee wrote: here's another interesting algorithmic exercise, again from part of a larger program in the previous series. Here's the original Perl documentation: =pod merge($pairings) takes a list of pairs, each pair indicates the sameness of the two indexes. Returns a partitioned list of same indexes. For example, if the input is merge( [ [1,2], [2,4], [5,6] ] ); that means 1 and 2 are the same. 2 and 4 are the same. Therefore 1==2==4. The result returned is [[4,2,1],[6,5]]; (ordering of the returned list and sublists are not specified.) =cut Almost a joke: from numarray import * def merge(*pairs): flattened = reduce(tuple.__add__, pairs, tuple()) m, M = min(flattened), max(flattened) d = M - m + 1 matrix = zeros((d, d), type = Bool) for x, y in pairs: X, Y = x - m, y - m matrix[X, X] = 1 matrix[X, Y] = 1 matrix[Y, X] = 1 matrix[Y, Y] = 1 while True: next = greater(dot(matrix, matrix), 0) if alltrue(ravel(next == matrix)): break matrix = next results = [] for i in range(d): eqls, = nonzero(matrix[i]) if eqls.size(): if i == eqls[0]: results.append(tuple(x + m for x in eqls)) return results Disclaimer: I'm not an expert in numarray and suppose the something can be dramatically imporved. -- http://mail.python.org/mailman/listinfo/python-list
Re: multimethod (or rather overloading) in Python
Nick Coghlan wrote: anton muhin wrote: anton muhin wrote: Correction: Of course, I can imagine some metaclasses magic that would allow to code: class MyClass(WithOverloading): @overloadMethod(A) def someMetod(self, _): ... But it would rather convoluted: the best idea I have so far is to mangle methods name in the manner most of C++ compilers do. PEAK has a fairly sophisticated implementation of method dispatch you may want to look at. http://peak.telecommunity.com/Articles/WhatisPEAK.html http://dirtsimple.org/2004/11/generic-functions-have-landed.html http://peak.telecommunity.com/doc/src/dispatch/__init__.html I'm compelled to point out that PEAK should still be considered a 'work in progress', but PJE's ideas should help you out :) Cheers, Nick. Thank you very much, Nick! anton. -- http://mail.python.org/mailman/listinfo/python-list
Re: Syntax for extracting multiple items from a dictionary
Stefan Behnel wrote: shark schrieb: row = {"fname" : "Frank", "lname" : "Jones", "city" : "Hoboken", "state" : "Alaska"} cols = ("city", "state") Is there a best-practices way to ask for an object containing only the keys named in cols out of row? In other words, to get this: {"city" : "Hoboken", "state" : "Alaska"} Untested: dict( (key,value) for (key,value) in row.iteritems() if key in cols ) Works in Py2.4 Stefan Or dict((key, row[key]) for key in cols). regards, anton. -- http://mail.python.org/mailman/listinfo/python-list
IOError 11 CGI module
Hi list, I have troubles with some python scripts I use as cgi scripts with thttpd. At irregular intervals when a post is made an IOError is raised by the CGI module. My question is how and why does this happen? The exception looks like this: --- Traceback (most recent call last): File "teamadmin.cgi", line 11, in ? iudex_cgi.makeform() File "/wing6/home/jury/iudex/nederlands/lib/iudex_cgi.py", line 24, in makeform form = _extractflat( cgi.FieldStorage() ) File "/usr/lib/python2.3/cgi.py", line 517, in __init__ self.read_urlencoded() File "/usr/lib/python2.3/cgi.py", line 622, in read_urlencoded qs = self.fp.read(self.length) IOError: [Errno 11] Resource temporarily unavailable --- The code: File:iudex_cgi.py --- import sys import time import traceback import cgi import MySQLdb from iudex_tags import * form = None def _extractflat( fields ): form = {} for i in fields.value: if not form.has_key( i.name ): form[i.name] = [] if i.filename: form[i.name].append( ( i.filename, i.value ) ) else: form[i.name].append( i.value ) return form def makeform(): global form form = _extractflat( cgi.FieldStorage() ) --- With kind regards, Anton Jansen -- http://mail.python.org/mailman/listinfo/python-list
Freelance Django developer needed
Hi! (First to everyone not into Django: sorry for the shameless job advertisement!) We are searching for a Freelance Django developer to help us out! We are: - creativesociety.com - based in Vienna, Austria - small team of 4 - pretty cool What you should have: - passion for writing beautiful code - getting things done attitude - knowledge of django, postgres, json, rest, - some knowledge of html/css - good english (talking and reading/writing documentation) What you will have to do: - develop a RESTful api that talks to a partner site - talk to the partners (humands, based in london and/or paris) to specify the api - import a LOT of data from the partner site - implement an upload and post the video files to the partner site - implement a single sign on solution so if the users are logged in on one site, are automatically logged in on the other site. - implement some html templates in django We think the project will take about 8-12 weeks, starting November 1th. If you are interested, send your CV, a "why i am the best for the job"-letter and your rates to: development [at] creativesociety [dot] com Thanks, Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Freelance Django developer needed
Hi Waldek! On Tuesday, 11 October 2011 19:02:15 UTC+2, Waldek M. wrote: > > (First to everyone not into Django: sorry for the shameless job > > advertisement!) > > > Well, if you're sorry then why do you go on? > > There's a much better place to post the job offer: > http://www.python.org/community/jobs/ > > There, you'd probably even earn credit for your posting :-) Ah thanks for the pointer! Posted the job ad on the the website you mentioned. I still posted it here, so i have the most people to read my job ad. Because i want to find the best one, and i think they are not browsing job boards.. ;) greetings from vienna, Anton > > Best regards, > Waldek -- http://mail.python.org/mailman/listinfo/python-list
Re: subset permutations
Steven D'Aprano wrote: > On Fri, 09 Dec 2005 16:03:46 +1100, Ben Finney wrote: > > >> Do you want the result to be: > >> AB, AC, AD, BC, BD, CD > > > > That is the complete set of combinations of the letters. > > > >> Or, do you want AB,BA,AC,CA,AD,DA,BC,CB,BD,DB,CD,DB ? > > > > That is the complete set of permutations of the letters. > > > Only if you are choosing without replacement. If you are choosing with > replacement, you also get AA, BB, CC, DD. > > Unfortunately, there is ambiguity in the terms "permutation" and > "combination", not just between English common usage and mathematics, but > even in mathematics. Why is that unfortunate? Now we can all post our favorite scripts and let them be severely criticized :-) Anton def ncycle(seq,n): while True: for x in seq: i = 0 while i < n: yield x i += 1 def cross(*args): p = 1 R = [] for seq in reversed(args): R.append(ncycle(seq,p)) p *= len(seq) R.reverse() i = 0 while i < p: yield tuple(x.next() for x in R) i += 1 def test(): s1='a1','a2','a3','a4' s2='b1','b2' s3='c1','c2','c3' for x in cross(s1,s2,s3): print x if __name__=='__main__': test() -- http://mail.python.org/mailman/listinfo/python-list
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Michael wrote: > Ilias Lazaridis wrote: > > [ panic, fear, worry ] > > What's wrong with just saying "Congratulations!" ? First thing I thought was > "ooh, maybe Guido will be able to work on P3K there" - after all that would > benefit Google *and* everyone else :-) Google's not a nice company (yeah, I know I'm posting from a google account). If you look at their job requirements it's clear they will only hire people with long backstabbing histories. There seems to be no room left for world improving undamaged souls in that company. > (Especially if he uses PyPy to experiment and play in ... :) Yes PyPy could save Python, or destroy the world. I have the impression not many enough people realize that a selfhosting programming language is something on the same level as a nano assembler or an artificial intelligence. There is not much time anymore for idealists to start trying to save the world, and I don't think we can count on google in that respect. Anton 'make my day, prove me wrong' -- http://mail.python.org/mailman/listinfo/python-list
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Robert Kern wrote: > I have a friend who works at Google. He has no backstabbing history at all. > Stop > insulting my friends. Your friends work for people who would never hire me. My resume sucks, but I'm not a bad person or a mediocre programmer. They sold out. > For Software Engineer: > > """ > Requirements: > > * BS or MS in Computer Science or equivalent (PhD a plus). Right here. > * Several years of software development experience. > * Enthusiasm for solving interesting problems. > * Experience with Unix/Linux or Windows environments, C++ development, > distributed systems, machine learning, information retrieval, network > programming and/or developing large software systems a plus. > """ > > I don't see any "damaged soul" requirement. I do. Experience here is an eufemism for having worked for the man. > >>(Especially if he uses PyPy to experiment and play in ... :) > > > > Yes PyPy could save Python, or destroy the world. I have the impression > > not many enough people realize that a selfhosting programming language > > is something on the same level as a nano assembler or an artificial > > intelligence. > > ??? What the hell are you smoking? We already have self-hosting programming > languages. Yes. We have humans too. > > Anton > > > > 'make my day, prove me wrong' > > Prove yourself right. Ok. That's a bit harder. I suppose we agree that if we have an intelligent program that is more intelligent than a human and have this program design an even more intelligent program than things start to accelerate pretty fast? Now the combination of a programmer with a tool (program) that can be used to make a better tool. This gives a better human-machine combination, which then can be used to further improve the combination. I don't think I have completely proven my point now, but since the danger is very real and big, coming close is already reason enough to watch this carefully. Why hasn't it happened yet with lisp? I don't know, why didn't the world get destroyed by all out atomic warfare? Couldn't it have happened? If we create AI why would AI keep us around if we ourselves won't even hire people that do not comply to absurdly specific preconditions? Don't we let our poor people starve in the undeveloped countries or even in our own cities? If we want to prove we belong to the next world we should start now. Open work communities where everyone can start working and get paid. The same thing as open source code or usenet but now with money for everyone. Anton 'sorry, I don't want to start a flamewar, but I really believe what I wrote here' -- http://mail.python.org/mailman/listinfo/python-list
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Alex Martelli wrote: > Anton Vredegoor <[EMAIL PROTECTED]> wrote: >... > > Google's not a nice company (yeah, I know I'm posting from a google > > account). If you look at their job requirements it's clear they will > > only hire people with long backstabbing histories. > > Such as...? Guido van Rossum? Greg Stein? Vint Cerf? Ben Goodger? > Please DO share your insider-information about the "long backstabbing > histories" of each and every one of these people, I'm sure it will be > most fascinating (as well as useful for self-protection to future > potential victims), and, after all, they ARE all rather public > figures... TIA! No insider information is necessary, the job requirements make it absolutely clear (at least to me) that Google is a company with an elitist culture, just like most universities. In fact I am convinced that universities (and this time I have extensive, first person and historic information) are elitist. We can discuss that if you want but to me it's appararent that *titles* are a strong indication of elitism. Further more I am convinced that universities spend about 95 percent of their effort into maintaining the hierarchy (socializing the students), and spend almost no time on creating new knowledge. A kind of 'piltdown' phenomenon. Also when considering this massive scientific fraude (because that's what it is) it is very illustrative to use the same deconstructing methods that Randi, if that's not the name of a beverage, no: http://en.wikipedia.org/wiki/James_Randi uses to discredit paranormal phenomena. For example, careers are "construed" because scientific success is credited to persons higher in the hierarchy and mistakes are the faults of research assistents or students. Only if this system breaks down we see reports of "scientific fraude" in the media, which according to me is more a sign of the social network around the scientist collapsing than it is a sign of their research data being any more "fabricated" than other scientific data. There is a lot of this inbred and invisible corruption everywhere in our societies and I tried to name it by using the term "working for the man" by which I meant throwing away ones own moral compass and confining ones efforts to further the interests of a small sub-system (like soldiers) and thereby stabbing oneself and the rest of humanity in the back (figuratively) and often not even sparing coworkers in order to please the master. Why is this not absolutely clear and apparent? Because when trying to "feed ones wife and children" it is almost impossible to do so without *proving* that one has *experience* in working for these corrupt entities (and possibly having become corrupt oneself) and doing a lot for the community but still being blind to the faults of ones employer does count as condoning corruption, at least in my world. Most people can survive (without damaging their souls so to speak) when working for corruption themselves in this way, but sooner or later one is asked to corrupt others (defending one's title during a promotion, leading a community and so on). This is the crucial point where corruption definitively occurs: where silence is not enough anymore to keep one employed. The human brain can withstand extreme amounts of conficting sensory data and still maintain a sense of continuity and order while from all sides things seem to fall apart. Such continuity is highly valuable because it is the only thing that keeps chaos at arms length. The same thing can be applied to whole societies (see for example the state American politics is in now). So that is the reason these kind of things normally are swept under the carpet. However for *me* personally, because I am deserted by my government, the university community, friends and family, and left to fend for myself, there is no pressing need to keep up the facade so I can finally see it for what it is. I hope this answers some of your questions about my position. Anyway, I think its better to talk about positive things, like trying to convince google to hire any and all people who can program irrespective of their corruption history. For example to help manning their commercial "ask google" service. I read that nowadays people can get payed for playing *games*, by taking the virtual personae of people who don't have time to play themselves. Oh, and here [1] is another job posting, which seems a lot better than the Google example IMO, but which still misses a plan for what to do when thousands of programmers would apply and which also misses a mission statement for what they plan to do to save the world community from becoming slaves to a select group of elitists hiding behind webservices. The junior/senior divisioning in the job offerring below worries me too. Well I guess it
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Michael Sparks wrote: > Sorry to reply to the thread so late in the day, but I noticed (via > QOTW :-( ) that Anton got worked up at me suggesting that congratulating > someone with a new job was a nice idea (surprised me too - all the > Google employees I've met have been very nice people), read the > thread (got sad) and then saw this: Strange, I *did* get worked up at you some (long) time ago, probably without you ever noticing, it was about your pythagorean proof about anyone being able to learn kamelia quickly because you had some student who had no problems whatsoever with it, http://www.atopia.tk/anamnesis/kittleren.htm while I could not find a clue what your software was supposed to do, except being something very exciting (and I think I know python well enough to not often have that problem), but I did not get worked up at you because of you congratulating Guido. To make it more clear : Congratulations Guido, with your new job! However I still maintain that I was never able to meet these fine people you speak about and which you seem to know because the cost involved (a few hundred euro to visit pycon for example) was too high compared to my food budget. What I was trying to explain was that the world gets closer and closer to the singularity (something I believe other people got worked up at *me* about) and the world is now at the stage where everything gets reinvented in about 5 years. This means that during the next 2.5 years some phenomenon like Google changing internet history (which happened in the last five years) will happen again (in a shorter time period). Since we are going to reinvent ourselves faster and faster there is no need to take old corrupt methods with us into the future. Some people (maybe suffering from a wierd kind of conceptual static typing) equate me talking about 'people having a backstabbing history' with implying those exact people actually stab other people in the back literally. 'Having a backstabbing history' can also be explained as having been into places where backstabbing was common, without implying any actual backstabbing of these people themselves, except maybe the greater whole they belonged to being instrumental to backstabbing, for example mathemathics professors helping to crack codes which are used to decipher or encode messages in a war situation. I've already mentioned somewhere that I meant it figuratively and I will further qualify it now by saying that Googles selection process does them and the world a disservice by using some kind of elitist criteria, or by hiring people who can prove that they -forced by market mechanisms no doubt- have in the past collaborated with or worked for companies that selected them on the basis of elitist criteria. The elitist selection process suffers from the same problems that for example IQ-tests have: Trying to scale something in one (or at least too few) dimensions, where that something is very, very, very multidimensional. It is insulting, inappropriate and denigrating when applied to humans. Of course, irony will have people using elitist selection processes being very personally offended by people pointing out that it is unfair. Just like those who stole my money and job opportunities now claim I'm a parasite or some wrathfull loser who doesn't want to work. In fact, although I still don't condone corruption, my vision has cleared up a lot by not eating its fruits anymore. I am not jealous at anyone still 'inside' and although I dream about trying to save people from places where people get murdered randomly (the dreaded backstabbing reference again), it gets less and less often as time goes by. My current worry is about how I can survive for another 2.5 years (the projected time period for the world to renew itself again) without me jumping off a ledge because I dont want to be (and possibly live forever without dying) with irrational people who don't deserve my company or get offed by someone who can't stand me not joining corruption. It's possible some next generation of people don't want the current population to survive because they are not advancing fast enough or lack compassion with lower lifeforms. If anything, my post was about trying to save the world from that fate by trying to induce that compassion into this newsgroup. I think it would be beneficial for our people working for google (and for google itself) if they freed themselves of any remaining corruption so that world evolution will be synchronized with social evolution and no unnecessary tensions will occur. Anton 'workout' -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: Degrees as barriers to entry [was Re: - E04 - Leadership! Google, Guido van Rossum, PSF]
ing experience, which with my diverse background would be too thin in any specific way. My allergy to resumes, not getting accepted because my education being to high, my experience being to low for anything specific, brought me me into further major trouble with the social security office. It was just not allowed to experience traumatic consequences because of their treatment, because what they did was just the law, and what could be wrong with that, even if it meant forcing me day in day out to apply for jobs till I snapped. I decided to prevent that and rather be without any money from my government than be continously tortured and degraded. Since then I haven't heard anything from them anymore, I lost my social contacts one by one because poverty doesn't make one popular, and I broke with my family because for some reason they seem to think what the government did was "good for me" when it nearly drove me to suicide. Maybe this further clarifies my objections against elitist selection procedures, based on degrees. Even if I have a degree, it always was the wrong one. The degree system itself is also funny. There have been many reforms in the Netherlands and each time those working at universities have automatically upgraded their degrees to the highest level while such upgrading is not possible for those without a job. The system works like this: We have ranks a,b,c were a is lowest and c is highest. People start at 'a' progress to 'b' and finally want to do 'c'. However, just before reaching 'c', a new 'c' is created and the previous categories 'a' and 'b' are taken together and put in a new category 'a'. (I am planning to write a nice Python script showing this algorithm sometime). This has happened a few times now in the Netherlands and one wonders about the ingenuity with which people having fixed positions at universities have come up with new requirements, distinctions and titles to secure their jobs and justify their never changing authority on all matters scientific. We have computer science professors who cannot operate a mouse, mathematical professors who only visit congresses or 'guide' students. Never mind that most of the times the student does all the work and receives almost no payment, and the professors know next to nothing about the subject (except from times long gone) and enjoy luxurious quarters and working conditions, foreign travel arrangements and a big secure salary check each month. Anton 'excuse me if I sound a bit bitter and as if suffering from a sense of untitlement' -- http://mail.python.org/mailman/listinfo/python-list
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Alex Martelli wrote: > Anton Vredegoor <[EMAIL PROTECTED]> wrote: > >> However I still maintain that I was never able to meet these fine >> people you speak about and which you seem to know because the cost >> involved (a few hundred euro to visit pycon for example) was too high >> compared to my food budget. > > Europython is cheap to attend, and has been held twice in Charleroi, > Belgium, for example -- if you're in the Netherlands, you could have > bycicled there, crashed with somebody (I've seen lots of impecunious > people offered hospitality that way), and not spent more on food than > you would by staying in the Netherlands. You'll have to invent some > better excuse, to explain why you chose not to attend it. I already sent some reply via google, got a server error, resent, got a confirmation that my message was posted, but it doesn't show up and also there's no way to retrieve my message except fishing in the cache? Yesterday I had a post not showing up (in another group) but today it was there. This makes me feel insecure enough about whether or not my replies come through via google to start using another provider. It's not like I'm on a secret google no fly list no? (slightly paranoic) Anyway, I'm not typing all that again. Maybe it will show up tomorrow. The gist of it is that for me a few hundred euros is and was a *lot* of money, and that this talk about 'cheap to attend' irritates me a lot. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Alex Martelli wrote: > Anton Vredegoor <[EMAIL PROTECTED]> wrote: > > > However I still maintain that I was never able to meet these fine > > people you speak about and which you seem to know because the cost > > involved (a few hundred euro to visit pycon for example) was too high > > compared to my food budget. > > Europython is cheap to attend, and has been held twice in Charleroi, > Belgium, for example -- if you're in the Netherlands, you could have > bycicled there, crashed with somebody (I've seen lots of impecunious > people offered hospitality that way), and not spent more on food than > you would by staying in the Netherlands. You'll have to invent some > better excuse, to explain why you chose not to attend it. I looked it up: 160 euro (early registration). My food budget is about 16 euro a week now, maybe even less if I want to keep feeding myself a bit longer, maybe in 2003 my reserves were a bit higher than now, but I had not yet learned then to be without a regular income, so I was very scared to become pennyless at that time. I am perfectly used to sleeping at other peoples' places, for example I was at many go (baduk) tournaments and if the prices and atmosphere would be anything comparable to that I guarantee you that I would have been present. IIRC I got an offer from Laura Creighton at the time to borrow me the money, so one could say it was a choice, although by that time the price had gone up to 270 euro. But frankly indeed, I just don't even like to participate to events that claim to be open for all but don't even acknowledge that the barriers are extremely high compared to some participants budgets. Your hype about it being cheap has a very chilling effect on my enthousiasm, it's the same way with pypy congresses, which I also would have liked to attend (and this thing even seems to be sponsored by public EU money). Probably I am still a *rich* person, on a global scale, because I live in a place with free internet (from a public library). You *do* realize that even posting to usenet is impossible (or at least very hard) for a lot of people, including me for at least 6 months. I had to find someone to invite me to gmail and also a way to access my previous internet account, which I lost access to when they cut my phone line, to recieve the mail that finally enabled me to post via google. Nowadays it's probably possible to open a hotmail account and get invited to gmail from there, so one can post to usenet. Theoretically I have now yet another option to post (except via google), but IMO it remains true that one needs at least one link to corruption to be able to post to usenet. Anton 'hey, and my laptop doesn't even have a cdrom, needs almost continous electricity, it's keyboard is broken (but it works fine with external keyboard), and it networks via a pcmcia card with a *cable* ' -- http://mail.python.org/mailman/listinfo/python-list
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Alex Martelli wrote: > Anton Vredegoor <[EMAIL PROTECTED]> wrote: > > > However I still maintain that I was never able to meet these fine > > people you speak about and which you seem to know because the cost > > involved (a few hundred euro to visit pycon for example) was too high > > compared to my food budget. > > Europython is cheap to attend, and has been held twice in Charleroi, > Belgium, for example -- if you're in the Netherlands, you could have > bycicled there, crashed with somebody (I've seen lots of impecunious > people offered hospitality that way), and not spent more on food than > you would by staying in the Netherlands. You'll have to invent some > better excuse, to explain why you chose not to attend it. I looked it up: 160 euro (early registration). My food budget is about 16 euro a week now, maybe even less if I want to keep feeding myself a bit longer, maybe in 2003 my reserves were a bit higher than now, but I had not yet learned then to be without a regular income, so I was very scared to become pennyless at that time. I am perfectly used to sleeping at other peoples' places, for example I was at many go (baduk) tournaments and if the prices and atmosphere would be anything comparable to that I guarantee you that I would have been present. IIRC I got an offer from Laura Creighton at the time to borrow me the money, so one could say it was a choice, although by that time the price had gone up to 270 euro. But frankly indeed, I just don't even like to participate to events that claim to be open for all but don't even acknowledge that the barriers are extremely high compared to some participants budgets. Your hype about it being cheap has a very chilling effect on my enthousiasm, it's the same way with pypy congresses, which I also would have liked to attend (and this thing even seems to be sponsored by public EU money). Probably I am still a *rich* person, on a global scale, because I live in a place with free internet (from a public library). You *do* realize that even posting to usenet is impossible (or at least very hard) for a lot of people, including me for at least 6 months. I had to find someone to invite me to gmail and also a way to access my previous internet account, which I lost access to when they cut my phone line, to recieve the mail that finally enabled me to post via google. Nowadays it's probably possible to open a hotmail account and get invited to gmail from there, so one can post to usenet. Theoretically I have now yet another option to post (except via google), but IMO it remains true that one needs at least one link to corruption to be able to post to usenet. Anton 'hey, and my laptop doesn't even have a cdrom, needs almost continous electricity, it's keyboard is broken (but it works fine with external keyboard), and it networks via a pcmcia card with a *cable* ' -- http://mail.python.org/mailman/listinfo/python-list
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Alex Martelli wrote: > I just don't understand, always assuming you're in the Netherlands, how > attending Europython in Belgium (as opposed to Pycon in the US) could > have cost hundreds of euros. Conference registration is free to > speakers, bicycling NL->BE not costly (many were driving from NL, so > bumming a ride was far from impossible either), many attendants arranged > to "crash" for free thanks to the hospitality of others, food costs in > Belgium aren't much different from those in NL. Ah, I see. You're approaching this from a 'speaker' scenario. You already have a lot of contacts, know where you can sleep, where to eat and so on. > I'm not saying a few hundred euros is 'cheap' -- it obviously isn't, if > your income is low to nonexistent; rather, I'm wondering where that > "hundreds" amount comes from. You originally mentioned only pycon > (where the need to fly to the US, for people living in Europe, can > obviously account for "hundreds of euros" already); Europython is > specifically held in Europe to be cheaper and more convenient to attend > for Europeans, and I've always met many people there who fell in the > "income low to nonexistent" bracket for one reason or another. Now going back to my claim that elitism is bad, I think you are the perfect proof of my point. You live in luxurious (with respect to community, education and financial aspects of being a computer scientist or programmer) conditions and can just not understand why some people have problems entering that same environment and privileged conditions as yourself. This attitude is very common and needs only some kind Blair-alike kind of selfhypnosis in order to effectively not being aware of lying. What is shunned is any form selfanalysis, because it would immediately reveal that you yourself are violently keeping all these people out of opportunities (the backstabbing), in your case for example by requesting certain degrees, without realizing that what you are selecting for is not what you think it is. It is selection for socialization and belonging to some kind of social group, not any mental ability really, not even the likeliness of being able to grasp Haskell which you somehow seem to link to having a mathematical education. Seriously, this is just a fraction of a unit above craniometry and you would be wiser if you dropped this attitude. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Armin Rigo wrote: > We have some procedure now for funding > travel costs, although it's admittedly very bureaucratic :-( Since next sprint is in Palma de Mallorca I trust I can count on PyPy to refund me the money? > Anyway, independently of this, there are some people we are happy to see > come back again and again to PyPy sprints even though we know their budget > is extremely limited. We have always arranged things for them to minimize > the costs. It's nothing like a "congress" where you have to pay XXX/day > for having water and cake brought to the tables by the staff at 10am. I > can certainly say that attending a PyPy sprint is not expensive at all; > I'd expect the major problem to be rather to find a week's free time for > it. There seems to have been a relatively inexpensive sprint in Heidelberg. So yes sometimes PyPy sprints can be inexpensive. But the associated costs if one has to rent a room in a hotel would still make it impossible for me to attend. What prompted me to cluster PyPy sprints with the expensive stuff was this sprint: http://www.trillke.net/images/HomePagePictureSmall.jpg Although I can't find pricing info now, I believe that at the time I considered the costs involved with the rent of the meeting place exorbitant. > On the bureaucratic side: Alex, we *have* a procedure at this point, and > we have been trying to contact you several time in the past months -- with > no success as far as I know, so I'll try via comp.lang.python this time > :-) If you still feel like seeing your money back in exchange for some > papers to fill and sign, please show up... Maybe Mr Martelli will ease his conscience (it's hard to see how it would not bother him to refuse to pick up checks while his opponents barely have enough to feed themselves) by donating the money to me, so that I might increase my efforts to squelch any remaining trace of elitism at google. Anton "I'd even look into PyPy sprint options at Maastricht, so you'd get extra value for your money" -- http://mail.python.org/mailman/listinfo/python-list
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
x27;t even funny. Wait till I remove all hashing code from dictionaries. Sometimes giving up speed in the short term, results in speeding up the process as a whole because it becomes possible to use intermediary results more effectively. I have seen groups of mathematicians splitting up and each going into their own room and after each had solved their own interpretation of their piece of the problem, the resulting code was not even using the same dataformats. Sometimes adding an attractive female to a group of young male coders will slow down the developments while it wouldn't matter in a team of female coders. One has to consider the *complete* system, which is another fault in your monocultural elitist selection process. Sometimes adding a very strange element to a team can prevent it from being a 'linear combination of social peer pressure vectors'. Face your fears. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: - E04 - Leadership! Google, Guido van Rossum, PSF
Alex Martelli wrote: > Anton Vredegoor <[EMAIL PROTECTED]> wrote: >... > > You are not my superior (or even considered to be more succesfull) as > > you seem to imply. > > Depends on who does the considering, I'm sure. If the considerer loves > the English language, for example, a horrible mis-spelling such as > "successfull" with two final L's would count for a lot in their judgment > (English is neither your native language nor mine, so it's not unfair to > either of us to consider it...;-). Well this sums it all up for me, about you. Making stupid claims to superiority while comfortably sitting at a computer *with a spellchecker* and denying me the same priviliges, not even by correcting google's _usenet_ interface (while its mail interface includes at least a minimally functional editor/spellchecker) to the point where a comparison would be fair. Stop whining and being insulted, your elitist selection policies have far more worldwrecking consequences than a few artificially magnified and misunderstood 'insults'. Anton 'you could always join the dutch unemployment inquisition' -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: Degrees as barriers to entry [was Re: - E04 - Leadership! Google, Guido van Rossum, PSF]
Steve Holden wrote: > Consider yourself excused. Thanks. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Sudoku solver: reduction + brute force
ago wrote: > You can see my amended code in the link above. Thanks, I will look into it sometime. At the moment I'm at a library computer, which severely limits my Python options. Meanwhile I have been thinking about the sudoku problem, maybe it will prompt you, me or someone else to make some kind of other implementation which would resemble what I am thinking about now. Imagine a sudoku representation which is inside a 9x9x9 cube. The values in the cubes' cells are just 1 or 0. The height of a '1' is determined by the value in the original (flat) sudoku grid. There are 81 filled cells in the cube, just like in a sudoku solution. If one would look at the cube from a side it would always be the case that a filled cell at some depth inside the cube would block your line of vision wichever column one would be looking at. In a way a sudoku is a special case of a magic square, and a magic square can be transformed to this view, and this way it can be seen as the solution to the problem of making a cube not transparent by filling the minimum number of cells. Now such a cube can be mirrored in 48 ways and it would still be the same 'kind' of solution. Also it would be possible to swap horizontal layers at will and still have some kind of solution that is the 'same' in some way. One could also swap vertical layers iff (and only if) one would stay inside a 3-block group of layers. On the other hand it would be possible to swap complete 3-block groups of layers (if I'm still making sense) and maybe there are other symmetries that would leave the original solution somewhat intact. Suppose one would be able to generate all these possible symmetries and only use the 'smallest' representation of the original position, this 'hash code' would consist of just letting Python sort the possible 'same' cubes and selecting the smallest. It could be used to prevent us from computing the same cube twice since we could check if we already saw something with the same hash code. Now to the optimization part. If we find empty cells in the cube where there are only few positions in the same row, column, or depth available, we can limit the search space considerably because cutting off leaves early is most profitable. Maybe it would even pay off to consider complete layers and selecting possible fillable cells that have minimal fillable layers' sums. Sorry, I guess I'm getting a little bit pataforical here, expect my Python script any day now :-). It will be implemented as a sparse matrix based on sets of triplets (3-tuples) where for example tuple (0,0,0) will mean that the cell with x , y and z coordinate having value '0', is filled (virtually has a '1' inside, the 'unfilled' cells in the cube (the zeros) are not represented). I wonder if I still make sense, it's hard to stay programming Python without a computer to correct my thinking. Can someone write an implementation to check my ideas? Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: excellent book on information theory
Paul Rubin wrote: > For an absolutely amazing translation feat, try Michael Kandel's > Polish-to-English translation of Stanislaw Lem's "The Cyberiad". Returning to the original book, why did they write a lot of it (at least the first few pages until I gave up, after having trouble understanding formulas about concepts I have no such trouble with when framed in less jargonized from) in unintelligible mathemathical notation when there's Python? I prefer a nice Python function over some strange latech symbols. If not Python there's always pseudo code or good old natural language. Don't tell me those math formulas are what it 'really' is, or even that it's more precise that way. The old trick of 'but there are some things that cannot be expressed in any other way than by using formulas' doesn't get one many optimization points in my world. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: excellent book on information theory
Juho Schultz wrote: > Last month I spent about an hour trying to explain why > a*2.5e-8 = x > raises a SyntaxError and why it should be written > x = a*2.5e-8 > The guy who wrote the 1st line has MSc in Physics from Cambridge (UK). > In mathematics, there is no difference between the two lines. Some time ago I tried to 'sell' Python to a mathematician. The crucial point was that it was not (in standard Python) possible to have a matrix A and a matrix B and then do for example: A = A * B and have a matrix multiplication performed. Since the whole conversation started because there was a need to use this notation for a standard mathematics course this didn't result in adopting Python for it. Meanwhile there has been some progress in Python use there, and of course there are specialized Python packages that enable this kind of notation, but it remains true that there *is* an abyss between computer science and mathematics. Mathematics should change ;-) But that doesn't mean that I wouldn't like standard Python to have A*B for matrices. The problem is that so called 'conventional' mathematical notations leave many options for interpretation, depending on the context and on mutual understanding between mathematicians, excluding non-mathematicians very effectively. A (Python) interpreter has no such problems and will allow precise inspection of what is meant by a piece of code. It has additional advantages in that it can function as a kind of "mathematical spellchecker" for people like me who often miscode things. Some mathematicians I know can write formulas page after page, while I, if I were to write (or read) a page of formulas there would be at least one mistake throwing me of course for the rest of the document, so that I would need to go back again and again. Does that make me a bad mathematician or does it signify that mathematical notation should change? For me the answer is clear, but that could be because I can't read the stuff without the documentation, and the documentation (mathematics) is considered to be known to everyone (with a math education of course) but I doubt if that is really the case and, even if it were the case it doesn't imply that being explicit (in giving the procedures in computer and human readable form at the same time, for example in Python) wouldn't be even better. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Sudoku solver: reduction + brute force
ago wrote: > Do you think it is possible to reduce the set of all possible solutions > to a small enough set? I personally doubt it, but IF that was the case > an efficient solver could be easily created. No I don't think so, but it's a great idea :-) . Iff we would have some ultimate symmetry detector we could reduce all positions to variations of a few base types and start *generating* solutions from there in stead of checking possible mistakes. > In reducing the set of all solutions for instance you could always swap > the numbers (3rd axis) so that the first submatrix reads > [[1,2,3],[4,5,6],[7,8,9]]. By this we reduced the set of solutions by > 362880. You can then always move blocks, columns and rows to fix the > following elements (1,4)=4, (4,1)=2, (9,9)=9. Further reductions are > still possible, but I do not know how far can this go and if the end > result is a small enough set. I think one could reduce more than just a factor 9! . A 3-dim cube has 48 symmetric mirror images and we could multiply 9! by this. Then there are the horizontal slice swaps and the whole 3-slice swaps. Anyway I wasn't thinking about a grand unified theory but more about limiting the search space (in a depth first tree) early. If for example some field would allow only 2 values it would pay off to check that field first in the search (before fields that can have say 9 values) because that would be the next best thing to having that value as a fixed starting value. Similarly if we would only check a subtree position once (by using the hash) it could save some computations, but I have no idea how effective it would be, all this mirrorring could be expensive too. On the other hand this is done on the single leaf level, perhaps cutting off whole branches, so it might indeed pay off very much. Remember that some subtrees can be identical even though the routes to get to there were different. Here's the idea to make all the mirrors (I have the code at home, but I can't reach it now, but it should be easy to code): Say one has dimension x with values [0,1,,8] Now rescale this to [-4,-3,...,+4] Then do this for all x,y and z coordinates. Now to generate all mirrors, make all 6 permutations and all +- variations of all coordinate points x,y,z for each mirror. So x,y,z gives 6 permutations and doing +-x,+-y,+-z for each of these makes for 48 (6*2**3) mirror images of each point. for example a coordinate [-3,-2,-1] mirrored through mirror [z,-x,y] would give coordinate point [-1,3,-2]. Do this for all points. Repeat for each mirror. Now convert back to [0,1,..8] coordinates and select the smallest mirrored cube. Eh, maybe math notation wouldn't be such a bad idea after all, only then I wouldn't be able to read what I wrote here. I hope you can :-) Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: excellent book on information theory
Terry Hancock wrote: > On 19 Jan 2006 13:57:06 +0100 > Anton Vredegoor <[EMAIL PROTECTED]> wrote: > > Some time ago I tried to 'sell' Python to a mathematician. > > The crucial point was that it was not (in standard Python) > > possible to have a matrix A and a matrix B and then do for > > example: > > > > A = A * B > > > > and have a matrix multiplication performed. > > Um, why not? I'm trying to think what would be the stumbling > block. I don't use matrix multiplies much, but I have > implemented 3D vector math so that "*" is the "dot product" > and "%" is the "cross product", which is pretty trivial to > do. Of course ! And to think that I even have used this trick a few times, for example to implement set operations using long integers. I feel ashamed. In my defense I can only explain what happened. Four years ago (when I knew a lot less of Python) I tried to use Numeric to do A*B for matrices, but that resulted in something else than expected. So I redefined the star operator by subclassing a *numeric python* object but then it didn't work (the subclassing IIRC). Then it turned out there was a Matrix module for Numeric that did exacly what was asked, but by that time I was trying to understand Numeric by reading the docs and 'selling Python' at the same time, which didn't work too well ... The main reason for that was that it was necessary to convince someone not having any Python knowledge to install Python *and* some module that I didn't know about and then that module needed *another* install which I didn't know about, and the docs for Numeric were separate from Python. Just too much at once. I believe if I just had implemented matrix multiplication myself at the time in plain Python I wouldn't have overcomplicated the matter in such a way that I couldn't convince anyone else anymore :-) So I got lost in Numerics complexities and that made me forget the basic option. By now I have used Numeric enough to make it likely that I could explain its use to someone. But even when I cured myself of this deficiency, the memory of failure stayed in my head. Witness a classic freudian fixation phenomenon in a Python learning curve :-) In order to prevent such mental damage for future Python programmers, I propose to add a simple matrix multiplication module to the standard distribution. > > The only obstacle I've run into is that you can't > (easily) define *new* operators and precedence levels. > > There *is* a trick for doing this that was posted on > the list some time back, which involved overloading an > operator to "apply an operator": > > It would've allowed you to do something like this: > > a |dot| b > a |cross| b > > or perhaps > > a b > a b > > I don't remember where this is posted. The trick was in > overloading the <, >, or | to interact specially with > "operator" objects. That's very nice. Thanks to you for mentioning this and to Jorge, who provided the link to activestate for this recipe in another message. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Sudoku solver: reduction + brute force
ago wrote: [Something I mostly agree with] > According to Anton the number of possible solutions can be reduced > using 1) number swapping, 2) mirroring, 3) blocks/rows/columns > swapping. All those operations create equivalent matrices. For a 9X9 > grid, this should give a reduction factor = (9!)*(48)*(6^12) minus the > number of duplicated combinations given by the methods above. I am not > sure how to calculate the number of duplicated combinations and > therefore do not know if the result is "good enough". As mentioned, I > doubt that it is a viable approach, but I find it an intriguing > approach nevertheless. We could start hunting down net sites giving sudoku problems and claim they are trying to sell us the same problem twice :-) Or produce counterfeit problems ourselves and get rich quick. But I wonder about that 6^12 term. Within each 3-row block there are 6 permutations. There are 3 3-row blocks and 3 3-column blocks. Then between blocks (swapping complete 3-row blocks) permutations also give a factor 6. So in my count (but I suck at math) this term schould be: 6**8 (also switching to Python exponentiation notation) Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: excellent book on information theory
Paul Rubin wrote: > The first few pages are a review of probability theory but I think > they assume you've seen it before. The book's subject matter is more > mathematical by nature than what most programmers deal with from day > to day, and as such, the book is not for everyone. And so the cycle repeats itself. We teach our students the world is all about money, and sure enough, the world is all about money. If we would continue to keep the interesting things away from most of the people, by hiding it behind mathematical jargon we end up believing that functional programming is connected to having a math degree and more such self serving and self fullfilling prophecies. An excellent book would break with this jargon advertising salesmanship. Anton "but I'll give it one more try" -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: excellent book on information theory
Paul Rubin wrote: > signal processing, for example. Perhaps it could be improved by being > more explicit about what the reader needs to know, and giving > references to other books where the prerequisites can be found. There are lots of good explanations, graphs, diagrams and such things in the margins (I'm a few pages further in the book now) but the main course seems to be mathematical formulas. The author should reverse the roles these presentations play, move the archaic math jargon to the margin, or better to a separate latech document, suitable for those unwilling to join the rest of humanity. A separate Python library would be handy too, and if not in the main text it could still be useful for those who lack training in obscure scientific dialects and want to understand things without any agreed upon beforehand gibberish that is mainly meant to exclude those not in the guild. > I also don't think presenting the math in Python would make things any > easier conceptually. The math in Sussman and Wisdom's "Structure and > Interpretation of Classical Mechanics" is all presented in Scheme, but > it's still the same math that's normally presented as equations, and > you have to think just as hard to understand it. The problem for me is that I recognize many of the used concepts, but they seem to be deliberately put in cryptic greek letters and undecipherable gibberish. It would not be necessary to present the math in Python, any reasonably consistent kind of pseudocode (but not Scheme or math notation) would made things a lot more clear to me. Something on a related subject with a presentation I like a bit better (but it has its problems too, while your book has more of these nice explanations and stuff, although in the margin): http://www.math.mtu.edu/~kreher/cages.html The authors of this book also seems to think we cannot do without obscure math notation, something which I disagree with very much, but at least they provide some pseudo code and some computer code, unfortunately in C but still better than nothing. The text of the book is not downloadable, but the algorithms source codes are. All of the books writers seem to have not caught up with the idea of hyperlinks and continue to dwell in neolithical paper dreams :-) If they only woke up and let someone like me write some Visual Python code to illustrate the algorithms or even let me just write Python implementations of the algorithms to accompany the books, I'd probably have work for years to come. > Math is a beautiful subject, and is not at all secret or inaccessible. > Try to broaden your horizons a bit ;-). I hope you're not trying to outexpertize me. You seem to be thinking that you know more about math than me, probably because you have a formal education in the subject? If so, you're proving my point, and thank you very much. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: integer to binary...
[EMAIL PROTECTED] wrote: > does anyone know a module or something to convert numbers like integer > to binary format ? > > for example I want to convert number 7 to 0111 so I can make some > bitwise operations... >>> def bits(i,n): return tuple((0,1)[i>>j & 1] for j in xrange(n-1,-1,-1)) >>> bits(7,4) (0, 1, 1, 1) Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: An oddity in list comparison and element assignment
Alex Martelli wrote: [snip] Can somebody please shut down this bot? I think it's running out of control. It seems to be unable to understand that "don't be evil" might be good when you're small (at least it's not very bad) but that it becomes distinctly evil when you're big. What is good when you're big? I really don't know and I think there's even not many other people who do. But simply forbidding things that are not precisely definable -the way mathematicians have been doing before physicists shook them out of it- seems to do more harm than good. In my opinion it looks like there is a path from rigid rule adherence to slowly accepting more doubt and inconsistencies -because we're all adults here- and this has something to do with letting go of things like childish adherence to static typing and confusion between equality and identity. Let me qualify that last paragraph before anyone concludes I have become disfunctional too and will lead everyone to their destruction. There seem to always be certain unclear parts in a programming language and people are constantly trying out new structures in order to map some new territory. I remember sets, generators and metaclasses. Only after people noticing problems (don't modify the thing you're iterating over) ways are found to solve them (you can if you put everything back just at the right moment) and finally these ways are condensed into officially endorsed coding practices. Now we're struggling with immutability and sequences. They're not a problem if you know what you're doing, but what exactly is it that those who know what they're doing do? It indicates that maybe it's the birth of a new language construct. But why should it stop there? I expect a certain openness and willingness to discuss controversial matters from a community even if it were only to educate newcomers. But it might be the case that such willingness to accept doubt, without it turning into actively seeking it -that seems to be foolish, but who am I to judge even that- is what makes it possible to develop higher language and cognitive structures. Anton 'even if it means turning into lisp before moving on' -- http://mail.python.org/mailman/listinfo/python-list
Re: An oddity in list comparison and element assignment
Alex Martelli wrote: > <[EMAIL PROTECTED]> wrote: >> Can somebody please shut down this bot? I think it's running out of > > Much as you might love for somebody to "shut me down", that > (unfortunately, no doubt, from your viewpoint) is quite unlikely to > happen. Although "making predictions is always difficult, especially > about the future", the most likely course of events is that I shall > continue for a while to survive, probably in tolerable health. You've got that completely wrong. I was not trying to kill you but I was trying to revive you. A process that is not evolving is dead. Stopping it frees up valuable resources that enable it to become alive again. Anton 'being alive is being mutable' -- http://mail.python.org/mailman/listinfo/python-list
[OT] code is data
With the inclusion of ElementTree (an XML-parser) in Python25 and recent developments concerning JSON (a very Pythonesque but somewhat limited XML notation scheme, let's call it statically typed XML) Python seems to have reached a stage where it now seems to be possible to completely swallow lesser languages code, modify it, and spit out new source code targeting the original language the code was written in, or even make a translation to other languages. The idea is that we now have a fast parser (ElementTree) with a reasonable 'API' and a data type (XML or JSON) that can be used as an intermediate form to store parsing trees. Especially statically typed little languages seem to be very swallow-able. Maybe I will be able to reimplement GFABasic (my first love computer language, although not my first relationship) someday, just for fun. Then there are things like cTypes (calling functions from native DLL's) and PyPy (implementing Python in Python). All this taken together, to me it starts looking like we're now entering a territory that traditionally was exclusively in the Lisp domain. Yes, Python had eval and exec for a long time already, and metatypes and generators are having some strange unexplored possibilities too, but the day will come soon (and at last when PyPy is reaching execution speeds close to cPython) where Python will be able to swallow smaller languages, and finally it will be able to swallow its own tail, like Lisp but then more powerful (because of the widely used standard data types and the code exchange between languages that that makes possible). Your thoughts please. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] code is data
bruno at modulix wrote: > I still don't get the point. Well, I've got to be careful here, lest I'd be associated with the terr.., eh, the childp..., eh the macro-enablers. The idea is to have a way to transform a Python (.py) module into XML and then do source code manipulations in XML-space using ElementTree. But rest assured, there is no such module, nor will we ever need it for anything. Anton "use cases are for the faint-hearted" -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] code is data
Diez B. Roggisch wrote: <...> >> The whole point of a code transformation mechanism like the one Anton is >> talking about is to be dynamic. Else one just needs a preprocessor... > > No, it is not the whole point. The point is > > "" > The idea is that we now have a fast parser (ElementTree) with a > reasonable 'API' and a data type (XML or JSON) that can be used as an > intermediate form to store parsing trees. Especially statically typed > little languages seem to be very swallow-able. Maybe I will be able to > reimplement GFABasic (my first love computer language, although not my > first relationship) someday, just for fun. > """ > > No on-the-fly code generation here. He essentially wants lisp-style-macros > with better parsing. Still a programming language. Not a data-monger. The 'problem' is that a lot of incredibly smart people are reading and replying here who are seeing a lot more into my post than I was prepared for :-) Anyway, the last few weeks I have been busy transforming MsWord documents into XML using Open Office, and next parsing this XML and transforming it into a special subset of HTML using ElementTree's XMLWriter class. Then the output of the XMLWriter was put into a Zope/Plone page but I added special markup for footnotes, making them plone objects that could be separately edited, and I added image tags for images that were retrieved from a separate server using an XSLT script. To accomplish that a special zope parser was written to recognize my nonstandard footnote and image tags, and to create the necessary objects, and to insert them into the page. After that I came across some turbogears code (which is stacking code at different levels like it were those things you put under your beer glass) and still later I saw some JSON equivalents of XML. JSON looks a lot like Python dicts which makes it seem likely that javascript will be able to interface with Python more efficiently. Remember that ElementTree comes from the same place that brought us PIL which is a package that can transform images into different types. So if we can transform documents, images and XML, why not sourcecode? Especially if it's not a conversion into a 'lossy' file format, (I consider dynamically typed code versus statically typed code the analog thing to JPEG versus bitmaps) it would be easy to convert all datatypes into the datatypes of another language, thereby making it possible to exchange code between languages. Algorithms just being things that convert sets of data-objects into other sets of data-objects. Now if one would equate standardized code exchange between languages and within a language with macros then I guess there is nothing left for me to do but wait till a certain google bot comes knocking at my ip-address port 80 and transfers me to the google equivalent of Guantanamo. But the whole point of distinguishing macros from official language structures *is* standardization, as some other clever poster already pointed out, so it would be extremely unfair to equate trans-language standardized code exchange with the guerrilla type macro activities that are plaguing the Lisp community. Then there are some people who keep insisting they don't understand what I'm talking about until I simplify things enough to get them on-board, but then simply dismiss my ideas with 'you can already do that easily with this standard python construct'. This strategy was also eloquently refuted by some other poster, so I don't need to repeat it :-) I've gotten a lot of things to think about, so thanks all for your thoughts, but since this is getting way above my head I'll just wimp out and leave the rest of the thread to the experts! Regards, Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] code is data
Bruno Desthuilliers wrote: > You mean like 'converting' javascript to python or python to ruby (or > converting any home-grown DSL to Python, etc) ? Yes, but also what some other posters mentioned, making Pythons internal parsing tree available to other programs (and to Python itself) by using a widely used standard like XML as its datatype. >> Then there are some people who keep insisting they don't understand what >> I'm talking about until I simplify things enough to get them on-board, > > count me in then :( Sorry about that. >> but then simply dismiss my ideas with 'you can already do that easily >> with this standard python construct'. This strategy was also eloquently >> refuted by some other poster, so I don't need to repeat it :-) >> >> I've gotten a lot of things to think about, so thanks all for your >> thoughts, but since this is getting way above my head I'll just wimp out >> and leave the rest of the thread to the experts! > > No way you will escape from your responsabilities so easily !-) Ok, count me back in then too :-) Of course I will be available for further discussion. If more than ten people demand a PEP and no better champion is available (very unlikely) I'll even write a proposal. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: How to generate all permutations of a string?
Girish Sahani wrote: > I want to generate all permutations of a string. I've managed to > generate all cyclic permutations. Please help :) http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496724 anton -- http://mail.python.org/mailman/listinfo/python-list
Re: code is data
Paul Boddie wrote: > Anton Vredegoor wrote: >> Yes, but also what some other posters mentioned, making Pythons internal >> parsing tree available to other programs (and to Python itself) by using >> a widely used standard like XML as its datatype. > > http://pysch.sourceforge.net/ast.html Very interesting, it led me to some sxml describing pages and it also tricked me into reading some Python documentation that I had always considered to be hiding some arcane deep Python magic. I guess now that Python is officially entering tree territory (as opposed to providing third party functionality) it seems unavoidable that Python's officially endorsed tree datatype will also be used for some of its internal structures, thereby making it more accessible to programmers like me and to outside programmers. > I was going to write a long reply to one of your previous messages, but > the above link references a project which may intersect with some of > your expectations. Meanwhile, it should be noted that the availability Somehow I get the impression of getting away with my posts luckily, while you now are duping other interested readers into not reading your innermost feelings about this subject. Let's get it in the open, don't spare me :-) > of Python AST processing tools is not a recent thing: the compiler > module has been around for a long time, and it is possible to modify > the AST and to generate bytecode from it; my own experiments have > centred on producing other representations from the AST, and other more > successful projects (eg. ShedSkin) produce other languages (eg. C++) > from the AST. Well maybe this trick of vehemently denying the existence of something on Usenet worked again, by materializing the thing as a reaction. However, I knew of the existence of such languages but I am mostly interested in standardized code interchange, like for example with JSONP which fetches some external javascriptcode from another server using JSON and places the translated javascript into a webpage at the request of the clients browser or so it seems. Maybe a Python webserver could also emit pieces of javascript code by getting them from a *Python* code library after translating Python code on the fly? That would open up the web to Python programmers without browsers needing to understand Python. Like Jython, but now as separately distributed functions from different servers. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: why a main() function?
[EMAIL PROTECTED] wrote: > I think I read a suggestion somewhere to wrap the code where a Python > script starts in a main() function, so one has > What are the advantages of doing this? Others have stated all the good ones, so I'll state a slightly dumber one for us part time amateur hackers :) If you start off writing all your python module inside a main function then as you chop your code up into other functions (refactoring), the code inside main is already at the proper indentation level for the new top level functions. No more indenting it one level further to suit the functions indentation. -- Cheers Anton -- http://mail.python.org/mailman/listinfo/python-list
proof of concept python and tkinter gnugo interface
For the last few days I've been doodling with a script that provides a graphical interface to gnugo by using its GTP protocol. At the moment the script is *very* basic, in fact the only thing it does is to allow one to click on a coordinate and place a move there OR press the space bar in order to let gnugo generate a move. However, I feel that this idea has some potential, it could be made to undo or redo moves or load sgf-games. But most importantly: It could load the list of move suggestions from gnugo, do some computations itself in *Python* on that list and then generate a move. So I thought that it would be best to present this script while it is still small and modifications can be done easily. In the end there's possibly a lot of potential and I think I'm going to need some help from people that are enthousiastic about Python or gnugo. What I want to accomplish with this post is to get to know whether it would be a good idea to make it a sourceforge project (it would be even better if some more experienced sourceforger would do it for me :-) or whether I should just go on doodling on this script by myself, gradually adapting it to fit my personal interests and come back to you in a few years with a more complete script. Is there any need for such a beast for *more* people than just me to work on? Here's the proof of concept, just copy it to some dir and run the Python script: http://home.hccnet.nl/a.vredegoor/gnugo/ It needs Python 2.5 which you can get at: http://www.python.org/ Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: How do I access a main frunction from an import module?
Jim wrote: > I have created an import module. And would like to access a function > from the main script, e.g., > > file abc.py: > ### > def a(): > m() > return None > > > file main.py: > # > from abc import * > def m(): > print 'something' > return None > > a() import sys def a(): sys.modules['__main__'].m() return None Anton 'now why would anyone want to do *that* ?' -- http://mail.python.org/mailman/listinfo/python-list
Re: proof of concept python and tkinter gnugo interface
grindel wrote: > Anton Vredegoor wrote: [...] >> Here's the proof of concept, just copy it to some dir and run the >> Python script: >> >> http://home.hccnet.nl/a.vredegoor/gnugo/ >> >> It needs Python 2.5 which you can get at: >> >> http://www.python.org/ > If you talking about a simple gui for gnu go it's been done to death. > see any misc. pandanet client and numerous other softwares such as > durish or go knot. If your client is going to do something uniquely > different from programs like this then you should focus in this aspect > of the program and develop other features later. It's also important > that it be able to read and write sgf files It's uniquely different from numerous other softwares in that it is completely open source and runs from a standard Python installation (but of course one has to get a Gnugo executable from somewhere). I also implemented reading and writing SGF files and browsing through the move history now. Total command set at the moment: -click on a coordinate: generate a move there and go out of replay mode -space bar: computer makes a move and goes out of replay mode -up key: save an SGF file (only the moves) -down key: read an SGF file -left key: go into replay mode and undo a move -right key: show next move, if at end goes out of replay mode Remember we're still only talking about a proof of concept script! I just want to attract people, and put this script into an SVN somewhere. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: permutations - fast & with low memory consumption?
Gerard Flanagan wrote: > No claims with respect to speed, but the kslice function here: > > http://gflanagan.net/site/python/utils/sequtils/ > > will give the 'k-subsets' which then need to be permuted - > alternatively Google. Maybe the function below could then do these permutations. Anton. def _sorted(seq): """ Return a sorted copy of seq, preserving the type. """ res = seq[0:0] decorated = ((x,i) for i,x in enumerate(seq)) for x,i in sorted(decorated): res += seq[i:i+1] return res def _swap_and_reverse_tail(R,i,j): """ Swap R[i] and R[j], reverse R[i+1:]. Returns a copy, preserving the type. """ a,b,c,d,e = R[:i],R[i:i+1],R[i+1:j],R[j:j+1],R[j+1:] return a+d+(c+b+e)[::-1] def permutations(seq): """ Generate sorted permutations of any sequence that can be indexed and sliced, preserving the type. e.g. seq can be a string, list, tuple or array. """ n = len(seq) if n == 1: yield seq[:] elif n >= 2: R = _sorted(seq) while True: yield R i,j = n-2,n-1 while R[i] >= R[i+1] : i -= 1 if i == -1: return while R[i] >= R[j]: j -= 1 R = _swap_and_reverse_tail(R,i,j) def test(): seq = 'gkDr217sKGMNLPsrtqeiczxyq' P = permutations(seq) for i,x in enumerate(P): print '%s' %(x) if i == 10: break if __name__ == '__main__': test() -- http://mail.python.org/mailman/listinfo/python-list
Re: Fast generation of permutations
Paul Rubin wrote: > def deals(): > for i in xrange(13**5): > cards = [(i//p) % 13 for p in (1, 13, 169, 2197, 28561)] > yield cards This gives hands like [0,0,0,0,1] and [0,0,0,1,0] which are permutations of one another. Below is a piece of code that avoids this. Here's how to interprete its output. Suppose one gets a hand like [0,1,2,3,4]. This means that it would be possible to create 1024 (4**5) poker hands from this, by "coloring" the cards. Another hand, for example [0,0,1,2,3], would allow only 384 colorings, because the two zeros would contribute choose 2 out of 4 (colors), so 6 colorings. The other numbers remain available for 4 colorings, which gives 6*4**3 (==384) colorings for this hand. Similar things happen for other partionings of the hands into numbers. In fact I am now investigating a description based on integer partitions of the number 5. I am not sure whether I want to partition based on colors or on numbers, that seems to arbitrary. This is very fascinating. Maybe someday I'll make a tkinter script with a visual tree structure allowing all kinds of numbers of "cards", and arbitrary numbers of variables to partition by. This would then give result sets like those strange quantum particles, such as quarks. Have fun, Anton def hands(L = [0]): if len(L) == 6: if L[1] != L[-1]: #no five of a kind yield L[1:] else: for i in range(L[-1],13): for H in hands(L+[i]): yield H def pprint(i,hand): print '%5i: ' %i, for x in hand: print '%2i ' % x, print def test(): H = hands() total = 0 for i,x in enumerate(H): pprint(i,x) if __name__=='__main__': test() -- http://mail.python.org/mailman/listinfo/python-list
Re: "Intro to Pyparsing" Article at ONLamp
Paul McGuire wrote: > I just published my first article on ONLamp, a beginner's walkthrough for > pyparsing. > > Please check it out at > http://www.onlamp.com/pub/a/python/2006/01/26/pyparsing.html, and be sure to > post any questions or comments. I like your article and pyparsing. But since you ask for comments I'll give some. For unchanging datafile formats pyparsing seems to be OK. But for highly volatile data like videotext pages or maybe some html tables one often has the experience of failure after investing some time in writing a grammar because the dataformats seem to change between the times one uses the script. For example, I had this experience when parsing chess games from videotext pages I grab from my videotext enabled TV capture card. Maybe once or twice in a year there's a chess page with games on videotext, but videotext chess display format always changes slightly in the meantime so I have to adapt my script. For such things I've switched back to 'hand' coding because it seems to be more flexible. (Or use a live internet connection to view the game instead of parsing videotext, but that's a lot less fun, and I don't have internet in some places.) What I would like to see, in order to improve on this situation is a graphical (tkinter) editor-highlighter in which it would be possible to select blocks of text from an (example) page and 'name' this block of text and select a grammar which it complies with, in order to assign a role to it later. That would be the perfect companion to pyparsing. At the moment I don't even know if such a thing would be feasible, or how hard it would be to make it, but I remember having seen data analyzing tools based on fixed column width data files, which is of course in a whole other league of difficulty of programming, but at least it gives some encouragement to the idea that it would be possible. Thank you for your ONLamp article and for making pyparsing available. I had some fun experimenting with it and it gave me some insights in parsing grammars. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Fast generation of permutations
Paul Rubin wrote: > Cool, I'd still like to know why (13**5)-13 = C(52,5) other than > by just doing the arithmetic and comparing the results. Maybe your > tkinter script can show that. That seems to be very hard :-) Unless I'm missing something. Anton def noverk(n,k): return reduce(lambda a,b: a*(n-b)/(b+1),range(k),1) print noverk(52,5) print 13**5-13 #prints: 2598960 371280 -- http://mail.python.org/mailman/listinfo/python-list
Re: Fast generation of permutations
Anton Vredegoor wrote: > Paul Rubin wrote: > > > Cool, I'd still like to know why (13**5)-13 = C(52,5) other than > > by just doing the arithmetic and comparing the results. Maybe your > > tkinter script can show that. > > That seems to be very hard :-) Unless I'm missing something. Like a factor seven, you mentioned that a few posts back. Sorry about that. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: "Intro to Pyparsing" Article at ONLamp
Paul McGuire wrote: > There are two types of parsers: design-driven and data-driven. With > design-driven parsing, you start with a BNF that defines your language or > data format, and then construct the corresponding grammar parser. As the > design evolves and expands (new features, keywords, additional options), the > parser has to be adjusted to keep up. > > With data-driven parsing, you are starting with data to be parsed, and you > have to discern the patterns that structure this data. Data-driven parsing > usually shows this exact phenomenon that you describe, that new structures > that were not seen or recognized before arrive in new data files, and the > parser breaks. There are a number of steps you can take to make your parser > less fragile in the face of uncertain data inputs: > - using results names to access parsed tokens, instead of relying on simple > position within an array of tokens > - anticipating features that are not shown in the input data, but that are > known to be supported (for example, the grammar expressions returned by > pyparsing's makeHTMLTags method support arbitrary HTML attributes - this > creates a more robust parser than simply coding a parser or regexp to match > "' > For example, I had this > > experience when parsing chess games from videotext pages I grab from my > > videotext enabled TV capture card. Maybe once or twice in a year > > there's a chess page with games on videotext, but videotext chess > > display format always changes slightly in the meantime so I have to > > adapt my script. For such things I've switched back to 'hand' coding > > because it seems to be more flexible. > > > > Do these chess games display in PGN format (for instance, "15. Bg5 Rf8 16. > a3 Bd5 17. Re1+ Nde5")? The examples directory that comes with pyparsing > includes a PGN parser (submitted by Alberto Santini). Ah, now I remember, I think this was what got me started on pyparsing some time ago. The dutch videotext pages are online too (and there's a game today): http://teletekst.nos.nl/tekst/683-01.html But as I said there can be transmission errors and human errors. And the dutch notation is used, for example a L is a B, a P is a K, D is Q, T is R. I'd be interested in a parser that could make inferences about chess games and use it to correct these pages! > > What I would like to see, in order to improve on this situation is a > > graphical (tkinter) editor-highlighter in which it would be possible to > > select blocks of text from an (example) page and 'name' this block of > > text and select a grammar which it complies with, in order to assign a > > role to it later. That would be the perfect companion to pyparsing. > > > > At the moment I don't even know if such a thing would be feasible... > > There are some commercial parser generator products that work exactly this > way, so I'm sure it's feasible. Yes, this would be a huge enabler for > creating grammars. And pave the way for a natural language parser. Maybe there's even some (sketchy) path now to link computer languages and natural languages. In my mind Python has always been closer to human languages than other programming languages. From what I learned about it, language recognition is the easy part, language production is what is hard. But even the easy part has a long way to go, and since we're also using a *visual* interface for something that in the end originates from sound sequences (even what I type here is essentially a representation of a verbal report) we have ultimately a difficult switch back to auditory parsing ahead of us. But in the meantime the tools produced (even if only for text parsing) are already useful and entertaining. Keep up the good work. Anton. -- http://mail.python.org/mailman/listinfo/python-list
Re: two generators working in tandem
Michael Spencer wrote: > This returns an iterator that 'nests' an arbitrary number of sequences > (odometer-style). > > def nest(*sequences): > def _nest(outer, inner): > for outer_item in outer: > if not isinstance(outer_item, tuple): > outer_item = (outer_item,) > for inner_item in inner: > yield outer_item + (inner_item,) > return reduce(_nest, sequences) Nice! Here's a nonrecursive version. It creates a list of iterators that are repeating their values just enough times to sychronize the nesting. I wonder if 'ncycle' would be a useful generalization for itertools' 'cycle' function. Anton def ncycle(seq,n): while True: for x in seq: for dummy in xrange(n): yield x def cross(*args): p = 1 R = [] for arg in args[::-1]: L = list(arg) R.append(ncycle(L,p)) p *= len(L) R.reverse() for dummy in xrange(p): yield [x.next() for x in R] def test(): s1='a1','a2','a3','a4' s2='b1','b2' s3='c1','c2','c3' for x in cross(s1,s2,s3): print x if __name__=='__main__': test() -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on a public library computer
John J. Lee wrote: > Why not Jython? There's no command prompt! The file menu from IE is also gone. There is a sun Java console but it looks like this: Java(TM) Plug-in: Version 1.4.2_06 Using JRE version 1.4.2_06 Java HotSpot(TM) Client VM User home directory = C:\Documents and Settings\x c: clear console window f: finalize objects on finalization queue g: garbage collect h: display this help message l: dump classloader list m: print memory usage o: trigger logging p: reload proxy configuration q: hide console r: reload policy configuration s: dump system properties t: dump thread list v: dump thread stack x: clear classloader cache 0-5: set trace level to Thanks for replying anyway! Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on a public library computer
John J. Lee wrote: > Why not Jython? There's no command prompt! The file menu from IE is also gone. There is a sun Java console but it looks like this: Java(TM) Plug-in: Version 1.4.2_06 Using JRE version 1.4.2_06 Java HotSpot(TM) Client VM User home directory = C:\Documents and Settings\x c: clear console window f: finalize objects on finalization queue g: garbage collect h: display this help message l: dump classloader list m: print memory usage o: trigger logging p: reload proxy configuration q: hide console r: reload policy configuration s: dump system properties t: dump thread list v: dump thread stack x: clear classloader cache 0-5: set trace level to Thanks for replying anyway! Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on a public library computer
Timothy Smith wrote: > how locked down is the computer? there's a few (brave) public access > unix shell providers out there. if you could run telnet you could use them Sorry, no telnet. Every executable that is not listed is blocked. For example I can download: http://prdownloads.sourceforge.net/scintilla/Sc1.exe but if I run it I get two error messages: a) a 15 seconds "appguard" message b} 'access to the specified device, path or file is denied' Maybe some shell provider is a good idea, however I still think I should make a cherrypy form of 24 lines or so and run it over there and simulate a python interpreter on a webpage which I can access from here. Has this been tried before? How can I use cookies to identify interpreter sessions? Anton 'webpython_3000_server_at_xxx.xxx.xxx.xxx_>>>' -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on a public library computer
Robert Kern wrote: > There is a Java SSH client that runs in the browser. > > http://www.oit.duke.edu/sa/security/ssh.html Great! I have a terminal. I can't figure out how to start jython from there though. Anton -- http://mail.python.org/mailman/listinfo/python-list
Re: Python on a public library computer
Chris Lambacher topposted: > usb key and moveable python. > http://www.voidspace.org.uk/python/movpy/ I have a usb card reader and I can use it. That saves me from having to have remote storage at least. However I can only save files, not open them, except if I use word, excel or powerpoint. The moveable python is great indeed. This worked here before, but then I could even access *other* peoples usb sticks in this whole building ... Crazy. Not anymore though. They could really use someone like me here for a sensible security policy that doesn't cripple the users. I can't even set internet options, that means I can't remove my history or clear my cache :-( Anton 'security doesn't mean shooting everyone in the foot' -- http://mail.python.org/mailman/listinfo/python-list