Re: SciPy python 2.4 wintel binaries
jelle schrieb: > I dearly miss having the power of SciPy on my python 2.4 installation. > The topic of SciPy python 2.4 wintel binaries has been discussed before > on this list, but I haven't been able to find a compiled binary. If you really need SciPy, you should install Python 2.3 (Enthought Edition) in a separate directory as long as a Python 2.4 SciPy binary is not available. Python 2.3 EE comes with a bunch of useful additions, e.g. SciPy. -- http://mail.python.org/mailman/listinfo/python-list
Re: Zope vs Php
Steve schrieb: >>From what I can tell you can't just do > <% > #python code > %> > some title > > this is what we would like to do with session support and things that > php provides? Google for "python web frame works". Most have session support, and some offer Python Code embedded in HTML (e.g. Webware, mod_python and Spyce). I never realized what's so great about this because <% #python code %> some title and print output(python-code) + " some title". are equivalent. Another approach is using Templates. Most web frameworks have Templates. My favorite is Cheetah. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') -- -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding a restricted python interpreter
Craig Ringer schrieb: That is my understanding. In fact, I'd say with Python it's nearly impossible given how dynamic everything is and the number of tricks that can be used to obfuscate what you're doing. Think of the fun that can be had with str.encode / str.decode and getattr/hasattr . It would certainly be difficult to track all harmful code constructs. But AFAIK the idea of a sandbox is not to look at the offending code but to protect the offended objects: files, databases, URLs, sockets etc. and to raise a security exception when some code tries to offend them. Jython is as dynamic as C-Python and yet it generates class files behaving well under the JVM's security regime. I looked into this, and my conclusion ended up being "Well, I'm using Python because I want it's power and flexibilty. If I want a secure scripting environment, I should use something like Lua or Qt Script for Applications instead." It would be good for Python if it would offer a secure mode. Some time ago I asked my hosting provider whether I could use mod_python with apache to run Python scripts in the same way as PHP scripts. He denied that pointing to Python security issues and to PHP safe. mode. Python IS powerful but there are many areas where it is of vital interest who is allowed to use its power and what can be done with it. I think it would be a pity to exclude Python from these areas where a lot of programming/computing is done. Python is a very well designed language but progress is made by criticism not by satisfaction ;) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding a restricted python interpreter
Jp Calderone schrieb: But mod_python is an apache module and runs in the same apache process with other users' scripts. I am uncertain as to how this differs from mod_php (the alternative discussed in the OP's story). I've been away from PHP for a while, so perhaps mod_php has gained some features of which I am unaware? I think PHP has a safe mode which solves the probem of isolating scripts of different users on application level. This is not optimal but better than nothing. Best solution would probably be to create a thread for each request that can operate only with the id of an authenticated user. But this seems to be a problem with Apache or with Linux? -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding a restricted python interpreter
Paul Rubin schrieb: Best solution would probably be to create a thread for each request that can operate only with the id of an authenticated user. But this seems to be a problem with Apache or with Linux? Threads wouldn't do it--you'd need separate processes. For example, multiple threads in the same process can access each other's file descriptors. You are probably talking about Unix-like systems. I googled for that and found that on Windows threads inherit the security context of their parent processes but can impersonate as another user after being created. So it seems to be an OS issue. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: SuSE 9.1: updating to python-2.4
Torsten Mohr schrieb: along with my distribution SuSE 9.1 came python 2.3.3. I'd like to update to 2.4 now, is this an easy thing to do or will lots of installed modules refuse to work then? Is there an easy way to find out what i need to update? I uninstalled 2.3.3 and compiled/installed 2.4 from source. Now there is a problem: each time I change my system, SuSE tries to reinstall 2.3.3 because of dependencies. I tried to mark SuSE-Python as tabu (taboo?) but this it isn't stored. Not sure if it is my fault or SuSE's. I'm too lazy to track it down. Perhaps you can do a regular upgrade via FTP. I didn't try that. -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: reference or pointer to some object?
Torsten Mohr schrieb: i'd like to pass a reference or a pointer to an object to a function. The function should then change the object and the changes should be visible in the calling function. [..] is something like this possible in python? Yes, wrap it in a container, e.g. a list or an object. Change the containers content in the called function. The keyword "global" does NOT fit this purpose to my understanding as it only makes the variables of the UPPERMOST level visible, not the ones of ONE calling level above. There are three namespaces in python, sorted according to priority: - local variables of the current scope (function or method), highest priority, show with locals() - global variables of the containing module, show with globals() - builtin builtin variables, show with __builtins__.__dict__ Since Python 2.1 the local namespace can be nested e.g. if a function is defined inside a function. Example: >>> def fo(u): ... def fi(v): ... v2 = 2*v ... print locals() ... return v2 ... u2 = fi(u) ... print locals() ... return u2 ... >>> fo(4) {'v2': 8, 'v': 4} <-- inner local namespace {'fi': , 'u': 4, 'u2': 8} <-- outer local namespace 8 -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: a new Perl/Python a day
Charlton Wilbur schrieb: "XL" == Xah Lee <[EMAIL PROTECTED]> writes: XL> i'll cross post to comp.lang.perl.misc and comp.lang.python. XL> If you spot mistakes, feel free to correct or discourse here. Error #1: crossposting to those two groups. (Error #2 is implying that you're a Perl expert, but someone else already pointed that out.) Xah Lee is the guy who used to fight Unixism some time ago thereby producing an extremly long and useless thread in this group. Now he's fighting Perl :) Please stop answering him if you don't want to waste your time. -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: MoinMoin and Mediawiki?
Alexander Schremmer schrieb: Having a DBMS backend is good in your opinion? It has some severe disadvantages like not easy to scale (you would need to setup DBMS replication), two potential points of failure, more complex setup, bigger memory requirements, etc. So nobody should use DBMS backends, right? Except those poor guys who need transactions, consistency rules, indexes, a standard query language, ... ;) What do you mean with scaling? If you multiply CPU and RAM by 8, good DBMS deliver nearly eightfold performance. If you distribute a DBMS on an 8 computer cluster, the DBMS will scale. If you distribute a DBMS on 8 arbitrary unrelated computers, you have 8 DBMSs which need to synchronize their data by replication. Do applications with file based persistence scale better? Since files need no setup beyond creation, every setup is complex compared to files ;) See e.g. the setup of an PostgreSQL DBMS: ./configure gmake su gmake install adduser postgres mkdir /usr/local/pgsql/data chown postgres /usr/local/pgsql/data su - postgres /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data >logfile 2>&1 & /usr/local/pgsql/bin/createdb test /usr/local/pgsql/bin/psql test The first four lines are the same for every source based distribution, only 8 lines are PostgreSQL specific. I don't think this is too complex. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: [perl-python] 20050112 while statement
[EMAIL PROTECTED] schrieb: "Xah Lee" <[EMAIL PROTECTED]> writes: [...] (As a matter of interest, is this sequence of posts intended to demonstrate ignorance of both languages, or just one?) :) This sequence of posts is intended to stir up a debate just for the sake of a debate. It's a time sink. It's up to you wether you want to post to this thread or do something useful. :) -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Refactoring; arbitrary expression in lists
Steven Bethard schrieb: BJörn Lindqvist wrote: [...] I believe this can be nicelier written as: if "Makefile" in basename: +1 for "nicelier" as VOTW (Vocabulation of the week) =) Me too, because nicelier is nicer than more nicely. :) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: (objects as) mutable dictionary keys
I have summarized the discussion about the usability of lists (and and other mutable types) as dictionary keys and put it into the Python wiki.URL: http://www.python.org/moin/DictionaryKeys. This summary might be used as a reference should the 'mutable dictionary keys' issue come up again in c.l.py. -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: python and macros (again) [Was: python3: 'where' keyword]
Craig Ringer schrieb: And then we have iteration (generator expressions, list comprehensions, for loops, ...?) over (sequences, iterators, generators) Just sequences and iterators. Generators are functions which return iterators. Sequences and iterators provide two ways to build containers. My use cases: finite, can be defined by enumeration: use sequence infinite, must be defined algorithmically: use iterator generator: neat way to produce an iterator, can also be viewed as a persistent function call (better than static local variables). Once defined, sequences and iterators have nearly the same interface. To have list comprehensions but no equivalent for iterators would be strange. I happen to be extremely fond of the flexibility this provides, but one obvious way to do it there is not. Development of the language, backward compatibility and obviousness are diverging goals. You can't satisfy them all at the same time. And goals provide a direction but are rarely reached. :) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: why are some types immutable?
Torsten Mohr schrieb: reading the documentation (and also from a hint from this NG) i know now that there are some types that are not mutable. But why is it this way? Immutable types (e.g. strings, tuples) allow for code optimization in some situations and can be used as dictionary keys. For the latter reason see: http://www.python.org/moin/DictionaryKeys -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: (objects as) mutable dictionary keys
Antoon Pardon schrieb: Dictionary lookup with mutable types like lists is a source of unpleasant surprises for the programmer and therefore impossible in Python. It is not impossible in Python. It may be discouraged but it is not impossible since I have already done so. Wouldn't this raise a TypeError? Or did you wrap them with an object? -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: rotor replacement
Paul Rubin schrieb: Wasn't there a default 40-bit version that was ok (weak), but you had to declare yourself US resident to download 128-bit support? That was years ago. The regulations changed since then, so they all have 128 bits now. Perhaps the NSA has found a way to handle 128bit in the meantime. But this is unlikely because there is no export regulation to ban 512bit as far as I know :) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: building Python: up arrow broken on SuSE Linux 8.2
Erik Johnson schrieb: I am trying to upgrade my Python installation. After downloading sources and building Python 2.3.4, I am unable to use the command history editing feature in the interactive interpreter (where the up-arrow would previously give you the last command line to edit, it now just prints "^[[A".) Do you have the GNU readline library installed and within Python's reach (lib in LD_LIBRARY_PATH or in /etc/ld.so.conf with subsequent call of ldconfig)? -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: "pickle" vs. f.write()
Johan Kohler schrieb: class person: name ="" age = 0 friends=[] comment="""""" me = person() Otherwise, what is the best "Python" way to write and read this data structure? import pickle class person: name ="" age = 0 friends=[] comment="""""" me = person() # store pf = file('/tmp/pickletest', 'w') pickle.dump(me, pf) pf.close() # load pf = file('/tmp/pickletest', 'r') me2 = pickle.load(pf) pf.close() This is sequential access. If you want to have random access, look for shelve. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: python without OO
Davor schrieb: so initially I was hoping this is all what Python is about, but when I started looking into it it has a huge amount of additional (mainly OO) stuff which makes it in my view quite bloated now. So you think f.write('Hello world') is bloated and file_write(f,'Hello world') is not? This is the minimum amount of OO you will see when using Python. But I guess you will use OO in the long run to *avoid* bloated code: --snip--- print "*** Davor's evolution towards an OO programmer ***" print '\n*** Step 1: OO is evil, have to use atomic variables:' name1 = 'Smith' age1 = 35 sex1 = 'male' name2 = 'Miller' age2 = 33 sex2 = 'female' print name1, age1, sex1, name2, age2, sex2 print '\n*** Step 2: This is messy, put stuff in lists:' p1 = ['Smith', 35, 'male'] p2 = ['Miller', 33, 'female'] for e in p1: print e for e in p2: print e print '\n*** Step 3: Wait ..., p[2] is age, or was it sex? Better take a dict:' p1 = dict(name = 'Smith', age = 35, sex = 'male') p2 = dict(name = 'Miller', age = 33, sex = 'female') for e in p1.keys(): print '%s: %s' % (e, p1[e]) for e in p2.keys(): print '%s: %s' % (e, p2[e]) print '\n*** Step 4: Have to create person dicts, invoice dicts, ...better use dict templates:' class printable: def __str__(self): '''magic method called by print, str() ..''' ps = '' for e in self.__dict__.keys(): ps += '%s: %s\n' % (e, str(self.__dict__[e])) return ps class person(printable): def __init__(self, name, age, sex): self.name = name self.age = age self.sex = sex class invoice(printable): def __init__(self, name, product, price): self.name = name self.product = product self.price = price per = person(name = 'Smith', age = 35, sex = 'male') inv = invoice(name = 'Smith', product = 'bike', price = 300.0) print per print inv --snip--- Either your program is small. Then you can do it alone. Or you will reach step 4. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Help With Python
Judi Keplar schrieb: I am currently taking a course to learn Python and was looking for some help. I need to write a Python statement to print a comma- separated repetition of the word, "Spam", written 511 times ("Spam, Spam, … Spam"). Can anybody help me get started? I am completely new to programming! Online: - http://www.python.org/moin/BeginnersGuide (Beginner, Advanced) - http://www.freenetpages.co.uk/hp/alan.gauld/ (Beginner) - http://docs.python.org/tut/tut.html (Beginner) - http://diveintopython.org/ (Advanced) Books (Look for most recent editions): - Mark Lutz, Learning Python (Beginner) - Alex Martelli, Python in a Nutshell (Beginner, Advanced) - Frederik Lundh, Python Standard Library (Beginner, Advanced) - Alex Martelli, Python Cookbook (Beginner, Advanced) - Mark Pilgrim Dive Into Python (Advanced) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: python without OO
Terry Reedy schrieb: But if the class method syntax were manditory, there would be class and/or class hierarchy bloat due to the unlimited number of possible functions-of-a-float and large number of actual such functions that have been written. You are right. I'm not an OO purist, I just wanted to convince Davor, that anti-OO purism can be harmful too. It's good for programmers to have a choice. Your Four Steps to Python Object Oriented Programming - vars, lists, dicts, and finally classes is great. I'm glad you like it :) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: python without OO
Davor schrieb: I browsed docs a bit today, and they also confirm what I have believed - that OO is totally secondary in Python. OO is not secondary in Python. It's secondary for you :) And Python leaves the choice to you. In fact, object/classes/metaclasses are nothing but *dictionaries with identity* in python. Eliminating "nothing but" makes this a true statement :) Love this approach. In fact, you can very easily implement your own *OO model* completely separate of Python's OO model... Now I actually strongly believe that Python's author has introduced the whole OO model just to attract and make happy OO population... I believe that your belief is wrong :) Guido van Rossum has introduced OO to Python because it's a useful concept. and you can definitely be more productive using Python's structured programming than Java/C++ OO programming :-)... and Python is probably the best example why we should have skipped OO all together.. Sigh. Proceed as you like but be aware that dogmatism - OO as well as anti-OO is always a poor guide. OO wasn't invented as a marketing buzz but to support programming styles that emerged in non-OO languages to control the increasing complexity of programs. so you get a nice program with separate data structures and functions that operate on these data structures, with modules as containers for both (again ideally separated). Very simple to do and maintain no matter what OO preachers tell you... The bad thing about OO preachers is not OO but preaching. And you are preaching, too ;) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: python without OO
[EMAIL PROTECTED] schrieb: Davor is right: even if you do not want to use it, the stuff is *there* and somebody in your team will. So definitely there is an audience of programmers that just do not have an use for all the sophistication and actually are penalized by it. No, because Python does not enforce using advanced concepts. You can write programs that are as simple as in 1991. A group of developers always has to find some kind of common style with a chance that some are penalized. This can happen with every language. There is not much than can be done at the Python level. But I would see with interest a Python spinoff geared towards simplicity. I think this would be useless because advanced concepts exist for a reason. A simplified spin-off would aquire advanced concepts over time and would just become a clone of Python. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Next step after pychecker
Jacek Generowicz schrieb: You also gain not having to clutter your code with all the type declarations. And you gain not having to decide what types you will use too early on in development. But it can be useful to restrict type variety in certain situations e.g. prime number calculation :) And it would probably also be useful to check violations of restrictions before running the program in normal mode. This must not necessarily mean 'int this, float that'. E.g. the following would be nice: a := some_type_value # "type fixing" assignment a = other_type_value # error: a is restricted to some_type a := yet_another_type_value # OK, another fixed type is set del a # release type restriction; a can be recreated in normal # dynamic mode The type fixing assignment could be used for optimization and for checking the program with pychecker. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: A tool for Python - request for some advice
TPJ schrieb: > First I have to admit that my English isn't good enough. I'm still > studying and sometimes I just can't express what I want to express. No excuses, please! Keep in mind that your English is much better than the Polish of most of us. And just in case you were fishing for compliments: Your English IS good enough. ;) -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Python API to manipulate CAB files.
Isaac Rodriguez schrieb: > Does anyone know of a Python API to manipulate CAB files? If there is a Windows API you can probybly call it from Python using Mark Hammond's Win32 extensions. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Daten Kinderheilkunde
Peter Maas schrieb: > vielen Dank für die Zusendung der Daten. Es handelt sich allerdings > nicht um jpeg-Dateien, wie die Erweiterung nahelegt. Wir konnten sie > nur mit dem PictureViewer auf einem Apple anzeigen. Sie werden unter > MacOS als Adobe-Photoshop-Dokument angezeigt. Sorry, my fault. Please disregard this :) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Daten Kinderheilkunde
Sehr geehrter Herr Wurm, vielen Dank für die Zusendung der Daten. Es handelt sich allerdings nicht um jpeg-Dateien, wie die Erweiterung nahelegt. Wir konnten sie nur mit dem PictureViewer auf einem Apple anzeigen. Sie werden unter MacOS als Adobe-Photoshop-Dokument angezeigt. Können wir die Dateien als jpegs bekommen oder sollen wir sie selbst umwandeln? Mit freundlichen Gruessen, Peter Maas -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Boss wants me to program
Brian schrieb: > Microsoft Visual Basic (.NET) would be your best bet for this type of > software development. It allows you to create GUI apps that can work > with a variety of database options, such as Access or MS SQL Server. Maybe you're right with .net, but I'd go for C# when doing .net. Basic is the ugliest and most mind corrupting language I've come across. And the OP has a C/C++ background. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: When someone from Britain speaks, Americans hear a "British accent"...
muldoon schrieb: >Now, what forum would you recommend? Any help would be appreciated. alt.culture.us.* -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Dr. Dobb's Python-URL! - weekly Python news and links (Jun 29)
Simon Brunning schrieb: > Sibylle Koczian needs to sort part of a list. His first attempt made > the natural mistake - sorting a *copy* of part of the list: I think it was _her_ first attempt. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Will Guido's "Python Regrets" ever get implemented/fixed?
George Sakkis schrieb: > Given that the latest 2.x python will be 2.9 Why not 2.13 or 2.4711? Version strings are sequences of arbitrary integers separated by dots and not decimal numbers, or are they? -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Opinions on KYLIX 3 (Delphi 4 Linux)
Jeff Epler schrieb: > I honestly don't know why anyone would spend money for a development > environment, no matter how fancy. I don't know why anyone would develop > software in a language that doesn't have at least one open > implementation. FreePascal is OSS. I recently developed a mixed Delphi/FreePascal application. FreePascal doesn't have a GUI Builder like Delphi but is very complete and mature. > It's a great way to get screwed when Borland goes under or decides > they only want to sell a new, incompatible product. What do you do with > your existing product when that happens? Re-train on a new platform, > and re-write from scratch? Port it to FreePascal :) -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: API class creation
kman3048 schrieb: > Now, I need to create a Class and fill it with Methods and Variables. > There are means to create (and attache) methods and variables. > However, I have not found how to create a Class within a Module. Or do import aModule c = aClassGenerator() setattr(aModule,'c',c) ci = aModule.c() -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Library vs Framework (was Dr. Dobb's Python-URL!)
Simon Brunning schrieb: > On 8/15/05, Rocco Moretti <[EMAIL PROTECTED]> wrote: > >>Which lead me to the question - what's the difference between a library >>and a framework? > > > If you call its code, it's a library. If it calls yours, it's a framework. IOW Apache with modpython is a framework for web apps because it calls your Python handlers. According to Andy Smith the Apache/ modpython combo sucks because it takes away the freedom to call a HTTP library and write your own HTTP server ;) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Obfuscator for Python Code
codecraig schrieb: > Is there any obfuscator out there that obfuscates the python code (byte > code i guess)??? http://www.lysator.liu.se/~ast rand/projects/pyobfuscate/ -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Obfuscator for Python Code
Peter Maas schrieb: > codecraig schrieb: > >> Is there any obfuscator out there that obfuscates the python code (byte >> code i guess)??? > > http://www.lysator.liu.se/~ast rand/projects/pyobfuscate/ Delete space: http://www.lysator.liu.se/~astrand/projects/pyobfuscate/ -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Testing for presence of arguments
Madhusudan Singh schrieb: > Dan Sommers wrote: [...] >>class _SemiPrivateClass: >>pass >> >>def f(required_argument=_SemiPrivateClass): >>if required_argument == _SemiPrivateClass: >>print "required_argument was probably not present" >>else: >>print "required_argument was present" [...] > Thanks for the suggestion, but seems needlessly complicated for > something very simple. What is "very simple"? The problem or the solution? :) If you examine this suggestion more closely you will note that it is more or less the same as Benji York's one except Benji used a built-in class. If you are interested in getting help on usenet you should abstain from devaluating efforts to give you a useful reply. "Thanks for the suggestion" or even no answer would have been sufficient. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: variable hell
Nx schrieb: > Hi > > I am unpacking a list into variables, for some reason they need to be > unpacked into variable names like a0,a1,a2upto aN whatever is > in the list. > > How to create the variables dynamically ? > > I am looking for something like > pseudo code line follows : > > a%s = str(value) >>> suffix = 'var' >>> vars()['a%s' % suffix] = 45 >>> avar 45 -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: variable hell
Benji York schrieb: >> >>> suffix = 'var' >> >>> vars()['a%s' % suffix] = 45 >> >>> avar >> 45 > > > Quoting from http://docs.python.org/lib/built-in-funcs.html#l2h-76 about > the "vars" built in: > > The returned dictionary should not be modified: the effects on the > corresponding symbol table are undefined. I tried this once and it worked. This may be too naive, so thanks for the warning :) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Python doc problems example: gzip module
Xah Lee schrieb: > today i need to use Python to decompress gzip files. > > since i'm familiar with Python doc and have 10 years of computing > experience with 4 years in unix admin and perl, i have quickly located > the official doc: > > http://python.org/doc/2.4.1/lib/module-gzip.html > > but after a minute of scanning, please someone tell me what the fuck is > it talking about? > > Fuck the Python programing morons. > > Thanks. > > I just need to decompress files. Is it: > > import gzip; > gzip.GzipFile("/Users/xah/access_log.1.gz"); > > can someone put a example into that fucking doc so that people don't > have to wade thru whatever fuck it is trying to sound big? Here's the example: import gzip # read fucked fuckedfile = gzip.GzipFile('somefile.gz') content = fuckedfile.read() fuckedfile.close() # write unfucked unfuckedfile = file('somefile','w') unfuckedfile.write(content) unfuckedfile.close() Please feel free to insert this fucking example into the fucking docs. Have a nice ... eh fucking day :) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
.pth files in working directory
My goal is to have the top level of a directory tree in the Python path without touching anything outside the directory. I tried to create .pth files with the top level path in every subdirectory but this doesn't work despite working directory being part of the Python path. Creating the pth file in .../site-packages works but I prefer to have everything inside the directory tree so that removing the tree is sufficient for a complete uninstall. Any hints are appreciated, thanks. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
module not found in IIS virtual dir
I'm trying to call python scripts from IIS in the following tree: upgrade/ util/ __init__.py logonUser.py select/ selectFiles.py - select/ is referred from IIS as a virtual dir vselect. - upgrade/ is inserted into the Python path via .pth file in .../site-packages. - selectFiles.py has a line "from util import logonUser". If I run selectFiles.py from the command line everything is ok. But if I call it via IIS (http://localhost/vselect/selectFiles.py) there is an error "No module named util" due the fact that selectFiles.py still sees upgrade/ in the Python Path but upgrade/util/logonUser.py can no longer be found by selectfiles.py (os.path.exists returns false). This is strange because other modules, e.g. odbc.py are still importable. Hope you can help me. Thanks. -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: .pth files in working directory
Peter Hansen schrieb: > Not sure from the above description exactly what it is you want, I want a tree top/ install.py sub1/ __init__.py mod1.py sub2/ mod2.py where I can do "from sub1 import mod1" in mod2.py no matter what the absolute path of top is. To achieve this I start install.py once to retrieve the absolute dir of itself (= abspath of top/) and creates .pth files with its absolute dir in every subdirectory. > but > generally such non-standard sys.path and .pth manipulations are best > handled by a sitecustomize.py file, possibly which makes its own calls > to site.addsitedir() and such. Try "help(site)" for more. But sitecustomize.py changes the Python installation, doesn't it? This wouldn't be an advantage over putting a .pth file into .../site-packages. -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: module not found in IIS virtual dir
Peter Maas schrieb: > I'm trying to call python scripts from IIS in the following tree: [...] > If I run selectFiles.py from the command line everything is ok. But > if I call it via IIS (http://localhost/vselect/selectFiles.py) there > is an error "No module named util" [...] Forget it. It was an ACL issue. Silly mistake. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: .pth files in working directory
Michael Ekstrand schrieb: > If top/ is the working directory for your Python interpreter, the > problem is solved automatically. Python puts the current working > directory in the default search path. So, if you run IIS sets the the site path as working directory. So I would probably have to change wd at the beginnig of every module. Each module would read the top location from a .pth file in its directory. Yes that's possible. Thanks for your help. -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: .pth files in working directory
Peter Hansen schrieb: > Peter Maas wrote: >> But sitecustomize.py changes the Python installation, doesn't it? >> This wouldn't be an advantage over putting a .pth file into >> .../site-packages. > > > You can have a local sitecustomize.py in the current directory, which > wouldn't change the Python installation. Would that help? I think this is what I need. Thanks, Peter. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Bicycle Repair Man usability
Sybren Stuvel schrieb: > I use BRM if I need to rename a function or variable, and that's about > it. I do the rest by hand faster than I can figure out how to use > additional software. Sounds like "I can walk from Aachen to Cologne faster than figure out how to drive a car" ;) I don't know BRM nor any other refactoring tool but for a thorough decision one would have to know the ratio time(learningTool)/time(doingByHand) to calculate the break even point in terms of number(doingByHand). -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Python versus Perl ?
[EMAIL PROTECTED] schrieb: His survey of programming languages in "The Art of Unix Programming", available at http://www.catb.org/~esr/writings/taoup/html/languageschapter.html , is interesting (and biased). Raymond evaluates C, C++, Shell, Perl, Tcl, Python, Java, and Emacs Lisp. One part of this survey strikes me: esr> In fact it's generally thought to be the least efficient and esr> slowest of the major scripting languages, a price it [Python] esr> pays for runtime type polymorphism. If I assume Perl, Python, Ruby, Tcl and PHP to be major scripting languages some benchmarks (http://dada.perl.it/shootout and http://shootout.alioth.debian.org) show that Python is probably the fastest among these (Perl is 25% faster at regex matching). -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: An Ode To My Two Loves
Jorgen Grahn schrieb: It's something that worries me frequently -- I feel guilty when I introduce Python into ("force Python upon") an organization. Because I hate having /other/ people's favorite toy languages forced down /my/ throat ... The solution is a multi language glue layer. Software interfaces are defined in a language independent way so that they can be used by many languages.I wonder why COM is so dominant on Windows and most Unixish systems don't use CORBA (with GNOME as an exception). Microsoft's .net takes this one step further by defining a multi language implementation layer. I hope these ideas will become more influential in Unix like systems as well just to stop this resource wasting source code issue. -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python as capable as Perl for sysadmin work?
Jeff Epler schrieb: There's another little-known fact about Python: No string is permitted to end with a backslash! Sure you meant string literals. But that is wrong, too: >>> a = '\\' >>> print a \ A Python string mustn't end with an *odd* number of backslashes. Other- wise a literal using backslash escapes like 'don\'t do that' couldn't be parsed. Now, this may not bother Unix sysadmins, but the honest truth is that you'll be administrating Windows systems, too, anywhere you work! This is no problem, thanks to os.path.join() ;) Well, if you ever have to threaten Python, just keep in mind that '... or die' just plain won't work. You have to suggest that it 'try ... except', which is really offensive. If I want to beg my computer to run programs, I know where to find Intercal with its "PLEASE" and "DO PLEASE" constructions. Sysadmin work with Intercal? Go ahead! ;) But what's wrong with a protecting try .. except block vs. "... or die" for every command to be protected? -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python as capable as Perl for sysadmin work?
Jeff Epler schrieb: Unlike Perl, Python implements only a *finite turning machine* model of computation. An easy way to see this limitation is in the following code: >>> 1.0 / 10.0 0.10001 In an infinite Turning machine, there would be an unbounded number of zeros before the second 1, giving the exact result, not a numeric approximation. Boy, you are cheating us Wake up, this isn't April 1st! :))) -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: hard_decoding
Tamas Hegedus schrieb: Do you have a convinient, easy way to remove special charachters from u'strings'? Replacing: ÀÁÂÃÄÅ => A èéêë=> e etc. 'L0xe1szl0xf3' => Laszlo or something like that: 'L\xc3\xa1szl\xc3\xb3' => Laszlo >>> ord(u'ë') 235 >>> ord(u'e') 101 >>> cmap = {235:101} >>> u'hello'.translate(cmap) u'hello' >>> u'hëllo'.translate(cmap) u'hello' The inconvenient part is to generate cmap. I suggest you write a helper class genmap for this: >>> g = genmap() >>> g.add(u'ÀÁÂÃÄÅ', u'A') >>> g.add(u'èéêë', u'e') >>> 'László'.translate(g.cmap()) Laszlo -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: sre is broken in SuSE 9.2
Serge Orlov schrieb: Denis S. Otkidach wrote: To summarize the discussion: either it's a bug in glibc or there is an option to specify modern POSIX locale. POSIX locale consist of characters from the portable character set, unicode is certainly portable. What about the environment variable LANG? I have SuSE 9.1 and LANG = de_DE.UTF-8. Your example is running well on my computer. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: PyINI : Cross-Platform INI parser
SeSe schrieb: I started a opensource project PyINI for corss-platform *.ini parsing at http://sourceforge.net/projects/pyini/ I have released a simple alpha version, which can read *.ini, with some extended features such as "key=value1,value2,value3". I also made a c++ binding to PyINI with elmer toolkit. I suggest that you have a look at Tim Daneliuk's tconfpy serving a similar purpose. Perhaps you can join forces. I'd like to see a configuration tool that for Python programmers is as easy as config.py, i.e. you you have config object and can write/read it to/from some storage, e.g. - .ini files - Java config files - xml files - LDAP server - win32 registry - ... It would be nice to make this not a Python only thing but accessible by other languages like Perl, Ruby, Java, C/C++ ... I think that a new config utility is worth the effort if it has the potential to put an end to roll-your-own config formats and parsers. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: For American numbers
Dave Brueck schrieb: Multiple definitions aside, "kilo" and "mega" are far too entrenched - even if I could manage to say "kibibyte" with a straight face, I'd get nothing but blank stares in return. This kibi-mebi thing will probably fail because very few can manage to say "kibibyte" with a straight face :) -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
replacing ASP/VBScript with Python
I have inherited an extremely messy ASP/VBScript application which is a pain for me to support. Now the customer is thinking about a redesign. I'd like to rewrite the whole thing in Python but the app has to meet some conditions like - IIS frontend - MSSQL db server - Win32 authentication - No 'ugly' URLs like http://server/cgi-bin/frontend.cgi?main.py - Performance: intranet with ~ 1000 users My personal preferences: - I'd rather do this in plain Python than using e.g. Zope because I fear the additional complexity of handling Zope and make it seam- lessly work with IIS. - I'd like to do session handling in Python because ASP's session object is quite limited and some of the ASP app's mess is caused by trying to use it for compound data type storage. OTOH I could pickle Python objects to a string and store that in an ASP session. Thanks for any help. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: replacing ASP/VBScript with Python
Peter Maas schrieb: I have inherited an extremely messy ASP/VBScript application which is a pain for me to support. Now the customer is thinking about a redesign. I'd like to rewrite the whole thing in Python but the app has to meet some conditions like [...] Just noticed that this posting doesn't contain any questions. Here they are: Any comments? Has anybody done something comparable successfully and give some advice? Thanks in advance. :) -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: replacing ASP/VBScript with Python
Diez B. Roggisch schrieb: You did not really give much information of what your application does - e.g. for a CMS, I'd strongly recommend a zope based solution. Other apps might be better written in other frameworks. It's a procurement app. Users (employees) can search in a product list and generate orders to the company's internal or external suppliers. The orders are stored in a database and emails are generated to the addresses of the buyer and the suppliers. There is no direct interface to an erp app (like SAP). -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: replacing ASP/VBScript with Python
Peter Maas schrieb: I have inherited an extremely messy ASP/VBScript application which is a pain for me to support. Now the customer is thinking about a redesign. I'd like to rewrite the whole thing in Python but the app has to meet some conditions like - IIS frontend - MSSQL db server - Win32 authentication - No 'ugly' URLs like http://server/cgi-bin/frontend.cgi?main.py - Performance: intranet with ~ 1000 users In the meantime I have searched the internet and found plenty of options: - plain cgi with fastcgi and mod_rewrite for IIS to transform the URL - quixote cgi with fastcgi and mod_rewrite - Webware + wkcgi - Python ASP (registering Python with Pywin32 as ASP language) - mxODBC + SQL ODBC driver - pyADO + SQL MDAC driver I'm now confident that it is doable and keen on finding out. The usual question: what is the one and best way to do it? ;) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: replacing ASP/VBScript with Python
Robert Brewer schrieb: I'm now confident that it is doable and keen on finding out. The usual question: what is the one and best way to do it? ;) Python ASP (pywin32), but put as little code as possible into the ASP--make it just a stub to call the real Python app. That app will be running persistently in the background, which should obviate most of the need for session support. That's been my experience, anyway. Sounds reasonable. How do ASP-Python and IIS work together? Is the Python- Interpreter loaded each time a Python-ASP is called? Here's an example (from http://www.aminus.org/rbre/cation/html/admin/ASP.html): <[EMAIL PROTECTED]> <% from cation.html.uiasp import UserInterfaceASP from cation import catapp ui = UserInterfaceASP(catapp) ui.request(Request, Response) %> That's interesting, thanks for the URL and your advice. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler
Michael Hoffman schrieb: Ilias Lazaridis wrote: But don't act like the volunteers who develop Python owe you a version of Python that runs out of the box on MinGW. They don't, anymore than you owe *me* a version of Python that runs out of the box on MinGW. Please, leave him alone. When he posted here first his tone made me suspicious and I did some searching. Replies like yours are exactly what he wants. He is here to fight and to waste your time. But if you enjoy this ... go ahead ;) I don't so this will be my only post in this thread. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: [EVALUATION] - E02 - ULTIMATE RECIPE TO RESOLVE ALL ISSUES
Ilias Lazaridis schrieb: I'm a newcomer to python: Sorry, I'm breaking my promise to post only once to this thread. But I've found the ultimate recipe to resolve all issues of this and other similar threads: Please read http://nobelprize.org/medicine/educational/pavlov/ and then do something useful :) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: [EVALUATION] - E02 - ULTIMATE RECIPE TO RESOLVE ALL ISSUES
Terry Reedy schrieb: "Peter Maas" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] http://nobelprize.org/medicine/educational/pavlov/ and then do something useful :) Thanks. I showed this to my daughter, who enjoyed the game, and explained your point re Pavlov posting, and about Pavlov advertising, etc. Fine that at least one person benefitted from my post :) I came across this when I browsed through the Lazaridis thread which was - if for nothing else - good for some laughs. But at the same time I felt uncomfortable to see how many bright Pythoneers cared to give well thought, helpful and friendly answers to somebody who was acting unpolite and kind of stupid, even mechanical. This newsgroup is used to be helpful to newbies and Lazaridis was ringing the newbie bell. Perhaps we will soon see a triumphant publication with the title "Ilias Lazaridis - the ELIZA of the 21st century. A milestone towards the perfect Turing test" ;) -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: - E02 - Support for MinGW Open Source Compiler
Fredrik Lundh schrieb: +00: googled for the mingw home page +00: found the mingw download page +02: finally figured out what to download +03: noticed that my usual SF site only offered 1K/s; aborted download +07: finished downloading the mingw kit from another SF site +17: finished installing +18: added \mingw\bin to the path +18: typed "python setup.py install --compiler=mingw32" +18: got a linker error; googled for help +19: copied python24.dll to \mingw\lib +20: finished building the sample library (cElementTree); all tests pass Impressive. How did you record the minutes? ;) I'd like to know wether this is a single observation or true for most if not all your MinGW builds? I used Borland's C++ Compiler (free and commercial) and had frequently to tweak .def files and the source to make it work. I also had to transform the python dll with COFF2OMF because the library interfaces of python.dll and the Borland binaries were different. If your MinGW experience described above is typical then I'll get a stop watch and give it a try ;) -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: list of all type names
Klaus Neuner schrieb: Python has one feature that I really hate: There are certain special names like 'file' and 'dict' with a predefined meaning. Yet, it is allowed to redefine these special names as in This is not a specific Python feature: If you include a header file in C that redefines fopen(), wou will probably also run into problems. dict = [1:'bla'] I would avoid the use of generic names for variables but rather use dict1 or aDict etc. If you want to avoid a name collision without the use of naming conventions you could rename __builtins__: bi = __builtins__ del __builtins__ Then you can define what you like but you will have to reference dict, list etc. as bi.dict, bi.list, ... For a fast check simply type e.g. dict in the interactive Interpreter. If you get a NameError it is not built-in. :) -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Creating module skeleton from unit tests
Edvard Majakari schrieb: Greetings, fellow Pythonistas! I'm about to create three modules. As an avid TDD fan I'd like to create typical 'use-cases' for each of these modules. One of them is rather large, and I wondered if it would be easy enough to create a code skeleton out of unit test module. I think this is too difficult, because there are many ways to write code (even skeletons) for a use case. An easier approach would be to write the skeleton manually, embed the test cases in the doc strings and generate the test code from the doc strings. If I remember correctly IBM has published something to generate unit tests from code. Python has a doctest module to support testing derived from doc strings. This can be combined with unit tests. > The problem can be solved more easily if you design the module skeleton first, then the tests and then the logic for the skeleton - you would be creating tests before the code, but many people > wouldn't regard it as TDD then. You shouldn't care if your approach works for you. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Debugging Python Scripts inside other processes
A. Klingenstein schrieb: I embedded Python in a Windows C++ program. Now I want to debug my embedded scripts which of course won't run in any IDE process. Commercial IDEs like WingIDE can attach to external processes by importing a module in the scripts. Is there a debugger capable of this which is Free or Open Source? What I need are the following things: - runs in Windows - single stepping - variable watches - breakpoints Does your Windows C++ program have a working stdin/stdout/stderr, i.e. kind of a console? Then you could insert import pdb pdb.set_trace() at a position in your embedded scripts where you want debugging to start. If your C++ program doesn't have a console then perhaps you can provide one with a Win32 call? Just guessing here. -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Python becoming less Lisp-like
Carl Banks schrieb: In Python, classes aren't some magical land where the usual rules don't hold (as they are in many other languages). That's why "self." is used on class variables, for instance. A class is nothing more than a scope that uses a smittering of magic to turn it into a type. scope -> dictionary -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Python becoming less Lisp-like
Fernando schrieb: The real problem with Python is that it has been very successful as a scripting language in the static-typing/C/C++ world. Those programmers, instead of adapting their evil ways to Python, and realizing the advantages of a dynamic language, are influencing Python's design and forcing it into the static-typing mold. Examples? Python is going the C++ way: piling feature upon feature, adding bells and whistles while ignoring or damaging its core design. What is core design? What are bells and whistles? I find it surprising that you talk about adding bells and whistles, whereas the URL you are referring to is about removing features. The new 'perlified' syntax for decorators, the new static type bonds and the weird decision to kill lambda instead of fixing it are good examples that show that Python is going the wrong way. I don't think that the introduction of '@' for decorators justifies the term perlification. If special characters are avoided at all costs Python could become too verbose like Java which is often critized for that in c.l.py. What used to be a cool language will soon be an interpreted C/C++ without any redeeming value. A real pity... What do you mean with cool? Which parts of Python are C/C++ish? Which features leave Python "without any redeeming value"? This phrase is close to trolling because is vague, emotional and unspecific. The fear of the anti-static fanatics is unfounded. Guido has made clear that he is thinking of a pychecker-like mechanism for validating programs at compile time. There's nothing wrong with defining interfaces and conditions and being able to check them before actually running the program. -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Python becoming less Lisp-like
Kay Schluehr schrieb: Some people refused properties in Python for exactly this reason. Defining somewhat like: def _get_X(self): return self._X def _set_X(self,X): self._X = X X = property(_get_X, _set_X ) in a Java-style fashion is indeed awfull and clumsy and that people dismiss such boilerplate code is understandable. This is original Delphi-Style, btw. But why is this boilerplate code? You define a property, and tell how it is read and written. How does your preferred code look like? -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple account program
wes weston schrieb: >Why have transactions not associated with accounts? > All transactions are related to an account; have > a self.TransActList in Account. >You have "amount" in both Withdrawl and Deposit > both derived from Transaction. If Transactions always > have an amount, why not put amount in the transactions > class? That's a good idea. I don't know if Igorati is just doing an exercise or has the ambition to create a usable application. In the latter case it would be a good idea to learn the basics of double accounting (DA). In DA each transaction is associated with 2 accounts. DA tries to avoid signed numbers, but uses the terms debit and credit instead. debit and credit aren't simply synonyms for minus and plus because there are two types of accounts: assets and liabilities. Liabilities have a minus sign built in. For me this is crazy and I used to confuse things until I found three rules to memorize this: 1. Positive flow of money is always recorded on the debit side. 2. Assets account balances are computed without sign change. 3. Liability account balances are computed with sign change. In matrix form: debit credit assets accont+ - liabil account - + Example: You empty your piggybank to pay your debts: Amount is recorded on the debit side of debts and on the credit side of piggybank (rule 1). Both balances are lower, because credit is negative for assets (rule 2) and debit is negative for liabilities (rule 3). So the easiest way to handle this programmatically is to have two lists, accounts and transactions. Each transaction generates a new entry in the list of transactions: translist.append(trans(credit_account, debit_account, amount)) where amount is always positive. The account class has a balance method: class account: def balance(self, translist): bal = 0 for e in translist: if self == e.debit_account: bal += e.amount if self == e.credit_account: bal -= e.amount if self.acctype == "liability": bal = -bal return bal -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Building web graphics with Python
Steven Feil schrieb: I am wondering if there is a light weight Python library for producing web graphics on-the-fly. There is a C-language library called gd that can be used in a CGI program to produce gif images. The Library can be used to produce graphics images that are dynamically generated. I was wondering if there is something similar for Python. You can create a Python wrapper for gd with SWIG or Pyrex. PIL (Python Imging Library) and Piddle are native Python solutions. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Protecting Python source
RCS schrieb: I am looking for methods of deploying applications with end users so that the python code is tamper proof. What are my options ? An interesting question is, what makes your source code so innovative as to mandate this tamper proof thing? I can think of 3 reasons to prevent tampering: - You need money and want to sell your software on a "per seat" basis. - You don't want customers to fiddle with your code and then innocently call for support and demand "bug fixes" for free. - Your customer demands closed source because the code contains trade secrets. Protecting source has nothing to do with innovation. It's about making money. -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Protecting Python source
Craig Ringer schrieb: On Mon, 2004-11-29 at 18:04, Peter Maas wrote: I can think of 3 reasons to prevent tampering: [...] My understanding is that that's never guaranteed safe, no? Or are restrictions against reverse engineering now commonly enforcable? It's not guaranteed but if protection works in 99.9% of all instal- lations it makes sense, at least if you are not producing highly visible software like Windows. Reverse engineering may be possible but in most cases it is a huge effort. Think of the samba project which builds Windows server software by analyzing network packets and this is probably easier than to analyze machine code. If the "reverse engineering" argument boils down to "protecting source doesn't make sense" then why does Microsoft try so hard to protect its sources? -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Protecting Python source
Grant Edwards schrieb: On 2004-11-29, Peter Maas <[EMAIL PROTECTED]> wrote: If the "reverse engineering" argument boils down to "protecting source doesn't make sense" then why does Microsoft try so hard to protect its sources? To avoid embarassment. :) This cannot be the whole truth otherwise they wouldn't release embarrasing binaries. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
installing wxPython on Linux and Windows
Recently I replaced Win2k with Linux on my desktop computer. Using mostly multi-platform software I thought this would be easy. It was not as easy as expected getting wxPython to work. There seemed to be no SuSE RPM so I installed from source. Here are my steps (gtk 2.4 was already installed): - Built wxWidgets (.configure --enable-unicode) - Built wxPython (python setup.py install) error: "you should use wx-config program for compilation" - Tried wx-config with various options - Examined (huge) error output more closely: There was a message "Usage: wx-config [options]" right at the beginning - Debugged setup.py: message was caused by wx-config option unicode=no - Debugged config.py: wx-config option unicode=no was caused by UNICODE=0 - Set UNICODE=1, next build, error: compiler couldn't find stc.h - Set BUILD_STC = 0 and some other BUILD_s as well - I worked! started demo.py, splash screen started up and - error in demo's Main.py 'DemoCodeEditor' object has no attribute 'editor' - Ah, STC is for StyledTextControl! set BUILD_STC = 1 again but how can I get styledTextControl? - Downloaded/built scintilla, but where's the slot for scintilla.a? - Realized that I had to build STC (wxWidgets' contribs) separately. - Built wxPython, start demo.py - it worked FINALLY! Took me with all tries and dead ends approx. 8 hours. Same task on Win2k: download wxPython-setup.exe, double-click, done. Took me approx. 1 minute. This strikes me. Why are some tasks so hard on Linux and so easy on Windows? After all wxPython/Win and wxPython/Lin are made by the same developers. My guess: the software deployment infrastructure on Linux needs to be improved. Disclaimer: I don't want to blame anyone here. wxPython is a fine piece of software otherwise I wouldn't have tried so hard to get it working. -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 3000 and "Python Regrets"
Dave Benjamin schrieb: LOL! Better yet: import __past__ del __past__.__mistakes__ Boy, what a load off! Merry Christmas in advance, from __future__ import NewYear A Happy New Year to everybody! ;) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: installing wxPython on Linux and Windows
Diez B. Roggisch schrieb: Same task on Win2k: download wxPython-setup.exe, double-click, done. Took me approx. 1 minute. This strikes me. Why are some tasks so hard on Linux and so easy on Windows? After all wxPython/Win and wxPython/Lin are made by the same developers. My guess: the software deployment infrastructure on Linux needs to be improved. On debian, it apt-get install wxPython2.5.3 I have heard praises of Debian's install system but Debian is quite conservative with latest versions. There are some packages (e.g. Python, PostgreSQL, Subversion) where I'd like to have the latest versions. I don't want to be too tightly bound to the update cycles of the Linux distribution. All the points are of course only an explanation, no excuse - there _could_ be better installers. As I showed, in parts that's already available, e.g. for debian which handles dependencies usually much better and is easier to use for online updates. I think we have to wait until consistent dependency checking and so on are established - maybe LSB helps us there. If there would be a common specification how to query and change configuration data of the system and applications this would be really helpful. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: os.path.islink()
Egor Bolonev schrieb: far file manager said 'C:\Documents and Settings\ÐÐÐÑ\My Documents\Scripts\Antiloop\' is link how to detect ntfs links? There are no ntfs links. What appears as a link on GUI level is nothing but a plain file with special content, so that os.path.islink() tells the truth. Windows "links" are a special Windows feature (shortcuts) and must be detected via Win32 api calls or by searching for content characteristics of shortcuts. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: os.path.islink()
JanC schrieb: There are no ntfs links. You're wrong, NTFS supports symlinks for directories and hard links for files: <http://www.sysinternals.com/ntw2k/source/misc.shtml#junction> <http://shell-shocked.org/article.php?id=284> Thanks for the update and my apologies to Egor. I was using Win2k for two years and never saw a link, neither at system nor at application locations. How nasty of Microsoft to add this feature so silently :) -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Suggestion for "syntax error": ++i, --i
Christian Ergh schrieb: Ah, ok, i misunderstood you. Well, to mark it as a syntax error sounds good, and at the Moment I would not know a case where this conflicts with a implementation. target = 'a=' sign = '-' operand = '-2' exec(target+sign+operand) -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
objects as mutable dictionary keys
There was a huge and sometimes heated debate about tuples, lists and dictionaries recently, and the mainstream opinion was that dictionary keys must not be mutable, so lists are not allowed as dictionary keys. BUT: objects are allowed as dictionary keys, aren't they? See the interpreter session below: class x(object): ... pass ... >>> x1 = x() >>> x1.prop = 'a' >>> d = {} >>> d[x1] = 'x1' >>> for i in d.iteritems(): ... if i[0].prop == 'a': ... print i ... (<__main__.x object at 0x011AC330>, 'x1') >>> x1.prop = 'b' >>> for i in d.iteritems(): ... if i[0].prop == 'b': ... print i ... (<__main__.x object at 0x011AC330>, 'x1') This strikes me because if one can do this with instances of user defined classes why not with lists? Trying to use lists as dict keys yields "TypeError: list objects are unhashable". So why are list objects unhashable and user defined objects hashable? For user defined objects hash(x1) = id(x1), why not do the same with lists? I think it's because of the existence of list literals. If you would use id() as a hash function for lists how should d[[1,2,3]] be stored? For instances of user defined classes there is no literal and accordingly no problem to use id() as a hash function and instances as dictionary keys. Is that correct? -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: objects as mutable dictionary keys
Andrew Koenig schrieb: This strikes me because if one can do this with instances of user defined classes why not with lists? Trying to use lists as dict keys yields "TypeError: list objects are unhashable". So why are list objects unhashable and user defined objects hashable? For user defined objects hash(x1) = id(x1), why not do the same with lists? If d is a dict and t1 and t2 are tuples, and t1 == t2, then d[t1] and d[t2] are the same element. If lists used the id as the hash, this property would not hold for lists. This leads to the question: Why does (t1 == t2 => d[t1] identical to d[t2]) hold for user defined objects and not for lists? My answer: because the cmp function looks at id() for user defined objects and at list content for lists. Why does the cmp function _have_ to look at lists contents? My answer: because of the existence of list literals. Can you give me an example of a program for which you consider such behavior to be useful? I'm not interested in using lists as dict keys. I was just searching for an explanation why user defined objects can be used as dict keys contrary to lists. -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: objects as mutable dictionary keys
Steven Bethard schrieb: If lists were hashable, new programmers to Python would almost certainly make mistakes like: py> d = {[1, 2, 3]: 'abc'} > The coder here almost certainly *doesn't* want that list to be compared > by id. The only way to get a binding for that list would be using the > dict's keys or __iter__ methods. That's what I meant when I said that for lists id() doesn't make sense as hash because of the list literals. For user defined objects id() can be used as hash because there are no literals for user defined objects. -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: objects as mutable dictionary keys
John Roth schrieb: No. The basic answer is that it's up to the object whether it will allow itself to be used as a dictionary key. In other words, if the designer of an object thinks it makes sense for instances to be dictionary keys, then he can supply a __hash__() method. If he doesn't, then he doesn't supply such a method, and it won't work. Except for classic objects which can be used as dictionary keys without having __hash__(). -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: objects as mutable dictionary keys
Peter Maas schrieb: There was a huge and sometimes heated debate about tuples, lists and dictionaries recently, and the mainstream opinion was that dictionary keys must not be mutable, so lists are not allowed as dictionary keys. Warning, long posting (~ 100 lines) The existence of lists and tuples and the impossibility to use lists as dictionary keys is a constant source of irritation for Python newcomers. Recent threads in c.l.py have revealed that even programmers like me using Python for some years now often don't have a clear picture. To put an end to this misery I tried to learn from the recent discussions and to explain to myself what's going on. My problem was that I didn't know exactly how a dictionary and a dictionary lookup works: A dictionary maps key values to data values. Sketch of a dictionary lookup(value = dict[key]): def lookup(dict, key): '''dictionary lookup is done in three steps: 1. A hash value of the key is computed using a hash function. Hash functions map a large set L to a (usually) smaller set S. A hash function must satisfy: (*) for all e1, e2 in L: h(e1) != h(e2) => e1 != e2 A hash function should satisfy as well as possible: for all e1, e2 in L: h(e1) == h(e2) => e1 == e2 Violation of the latter condition means a hash collision, i.e. two or more elements of L have the same hash value. This should be highly unlikely for good hash functions. If not, hash lookup becomes as slow as sequential lookup. 2. The hash value addresses a location in dict.data which is supposed to be an array of bins. A bin contains a collision list of (key,value) pairs. 3. The collision list addressed by the hash value is searched sequentially until a pair is found with pair[0] == key. The return value of the lookup is then pair[1]. Equality (==) is defined by the function cmp(). The return value for equality is 0, for inequality some other value. ''' h = hash(key) # step 1 cl = dict.data[h] # step 2 for pair in cl:# step 3 if cmp(key, pair[0]) == 0: return pair[1] else: raise KeyError, "Key %s not found." % key Thus a data type must be a valid input for hash() and cmp() to be usable as a dictionary key. hash() and cmp() must satisfy the condition (*) in lookup.__doc__ for this data type. Is a list a suitable candidate for a dictionary key? hash(list) = id(list) and cmp(list1, list2) comparing id(list1) with id(list2) would satisfy condition (*). But this definition completely ignores list contents, causing big surprises for programmers: - Different lists with the same content would be mapped to different dictionary values. - Dictionary lookup with list literals would be impossible. To avoid these surprises dictionary lookup would have to use list contents instead of list id. Consider the (hypothetical, not working) code: >>> d = dict() >>> li = [1,2,3] >>> d[li] = "123" >>> d[[1,2,3]] "123" Now assume li is changed (e.g. li[2] = 4). There are two options to handle this, let the dictionary ignore changes >>> d[li] KeyError: [1,2,4] not found in dictionary. (even worse: a previously existing [1,2,4] map is returned). or let the dictionary follow changes >>> d[[1,2,3]] MovedError: Please address future lookups to [1,2,4] :) Both are pretty unsatisfactory. Conclusion: dictionary lookup with mutable types like lists is a source of unpleasant surprises for the programmer and therefore impossible in Python. This is the point where tuples come in. They have nearly the same interface as lists but cannot be changed once they have been created thereby avoiding the problems discussed for lists. Thus tuples can be used as dictionary keys. What about instances of user defined classes? User defined classes can be anything the programmer likes but yet their instances are usable as dictionary keys because there is a default: hash(object) = id(object) and cmp(object1, object2) compares id(object1) with id(object2). The same setting that has been discussed above for lists and has been found unsatisfactory. What is different here? 1. It is a default setting which can be adapted to each class by defining/ overriding the methods __hash__ and __cmp__. 2. For objects identity is more important than for lists. That's it. Please correct me if I'm wrong. If not, a poor programmer's soul has found peace eventually :) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting the word to conventional programmers
Peter Hansen schrieb: Cameron Laird wrote: *DevSource* profiles "The State of the Scripting Universe" in http://www.devsource.com/article2/0,1759,1778141,00.asp >. Which, sadly, doesn't seem to work with Firefox here, though IE shows it fine. :-( Mozilla 1.7.3 shows it fine, too. FF bug or config issue? -- ------- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming Language for Systems Administrator
Ville Vainio schrieb: If you don't need to edit already existing system scripts, you don't really need to know bash scripting. For debugging purposes, it's easy to see what commands the script executes to perform a task. This is only true for trivial bash scripts. I have seen bash scripts which were quite hard to read especially for beginners. -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python appropriate for web applications?
Unknown User schrieb: I am a Python programmer and I'm thinking about learning PHP, which is similar to C++ wrong (quite different from Python). true I want to start writing web applications. Do you think if I learn > PHP I'll develop faster? Nobody but you can anawer this question. You'll have to try. Does PHP have more features? PHP has a rich library which probably outperforms any Python alternative in terms of features. But this doesn't necessarily mean that you will develop faster in PHP. The problem with Python is that you have to make a choice among many solutions (roughly ordered by inreasing complexity): - plain cgi - Quixote - modpython - CherryPy - Spice - Webware - Twisted - ZOPE ... Have a look at http://www.python.org/topics/web/ How about the speed of execution? There is no simple answer. Both languages use C functions which are executed at CPU speed. But with interpreted code Python seems to be approximately 3-4 times faster than PHP (http://dada.perl.it/shootout/). What are the pros and cons? http://www.allsites.com/Top.Computers.Programming.Languages.Comparison_and_Review.html -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: goto statement
Maxim Kasimov schrieb: but what if i just can't to do this becouse i'm working thrue ssh, and have to use only installed editors (such as vi) - at first line of block enter: ma (mark line as 'a') - go to last line of block - enter :'a,.s/^/###/ (insert 3 comment chars at begin of line, starting from line marked as 'a' to current line) :) -- --- Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0 E-mail 'cGV0ZXIubWFhc0BtcGx1c3IuZGU=\n'.decode('base64') --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Still Loving Python
Mike Meyer schrieb: > I agree. I've tried a number of different gui builders. I find it much > faster to type something like: > > ui.add_button("New", self.new) > ui.add_button("Open", self.open) > ui.add_button("Save", self.save) > ui.add_button("Save As", self.save_as) > > Than have to drag four menu buttons from a pallette, then open the > properties of each one to edit the text of the button and the callback > entry (or whatever dance they need so you can enter the required > text). If you design a moderately complex UI a designer will be faster. It's not the speed of typing vs. dragging that matters. You see the result instantly and don't have to start your program, look, type code, start again and so on. A GUI builder is more pleasant to work with, at least with a good one like Delphi or Qt designer. It's not a good idea to do everything in code. I find it tiresome to create menus and toolbars by writing code. It's not as bad as creating an image by typing addpixel(x,y,color) a million times but it comes close. Creating visual resources visually is the direct way, creating them in code is a detour. Code is too lengthy and too versatile for such a job. -- Peter Maas, Aachen, Germany -- http://mail.python.org/mailman/listinfo/python-list
Re: Python obfuscation
yepp schrieb: > Once you got the model of free and open source software you can't but shake > your head at obfuscating people treating their users as enemies. Sorry but this is naive nonsense. Open source is a good model but it can't be applied everywhere. Look at the following example: There is a company who is developing and marketing a single application. It is a simulation software for industrial processes which embodies an enormous amount of knowledge accumulated by the hard work of many individuals since about twenty years, algorithmic, process, implementation, market knowlegde. This application is of great value to the customers because it helps them save lots of money and improve the quality of their products. No wonder that they have (and are willing) to pay a considerable price for it. If the company would decide to go open source it would be dead very soon because it wouldn't no longer have a competitive advantage. Most customers wouldn't see the necessity to pay high prices, the competition would use the source code in their own products, the earnings would fall rapidly and there wouldn't be enough money availabe to pay highly skilled developpers, engineers and scientists for continued development. In certain sense suppliers and customers ARE enemies because they have different interests. The customer will pay a price only if it is neccessary to get the product. If he can get it legally for nothing he won't pay anything or at least not enough. So please: continue praising OSS (as I do) but don't make ideological claims that it fits everywhere. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: Python obfuscation
Chris Mellon schrieb: >>There is a company who is developing and marketing a single application. >>It is a simulation software for industrial processes which embodies an >>enormous amount of knowledge accumulated by the hard work of many >>individuals since about twenty years, algorithmic, process, implementation, >>market knowlegde. This application is of great value to the customers >>because it helps them save lots of money and improve the quality of their >>products. No wonder that they have (and are willing) to pay a considerable >>price for it. >> > > > You just described UNIX, which has been all but replaced by open > source projects, and the general state of the operating system market > a few decades ago. No, I didn't describe UNIX. UNIX and OSs in general are software which is needed by everybody who is using a computer. You have many developers all over the world willing to contribute. But the software I mentioned is a highly specialized field with a (compared to OS users) a tiny number of customers and a degree of complexity at least the same as an OS. So I think that an OSS model wouldn't work here. Also using UNIX as an example is qustionable here because of its special history. UNIX was to a large extent developed in academic environments and later closed sourced by AT&T at a time when much OS specific knowledge was available in universities. >>If the company would decide to go open source it would be dead very soon >>because it wouldn't no longer have a competitive advantage. Most customers >>wouldn't see the necessity to pay high prices, the competition would use >>the source code in their own products, the earnings would fall rapidly and >>there wouldn't be enough money availabe to pay highly skilled developpers, >>engineers and scientists for continued development. >> >>In certain sense suppliers and customers ARE enemies because they have >>different interests. The customer will pay a price only if it is neccessary >>to get the product. If he can get it legally for nothing he won't pay anything >>or at least not enough. >> >>So please: continue praising OSS (as I do) but don't make ideological claims >>that it fits everywhere. > You're looking at the wrong things here. What you're describing is > actually a potentially very successfull open source project Successful for whom? > - many > companies, single source, highly technical, high price. An open source > project could easily succeed in this area. Of course, it would not be > in the interest of the current monopoly supplier to open source thier > product. The supplier doesn't have a monopoly. He has competition but the supplier started first, has always been the pacemaker and has therefore an advance. His revenues are based on this advance. If somebody would suggest him to go open source - what would be the advantage for him? Doing business is a game, games are about winning and it isn't realistic to tell a player to commit suicide. > But a third party that started such a project could quite > possibly succeed. There are several 3rd parties all with closed source :) If an OSS 3rd party would enter the game it would have to answer the question how to fund the development. To succeed the OSS player would have to catch up to its closed source competitors. This is anything but easy - there is a lot of knowlegde (a crucial part of it not available for the public) to be worked out. The developers have to earn money, who pays them? I think a lot of people believe OSS isn't about money. This is wrong. Either OSS developers are working in their spare time for their own pleasure. This puts some limits on their projects. Or they are working all the day on OSS projects. Then they have to be paid, e.g. by academic institutions (tax payer) or by companies like IBM and Novell who are funding OSS because they have appropriate business models. There's nothing wrong about this. But to pretend that OSS miraculously solves the money problem for consumers _and_ producers is wrong IMO. There are conditions for OSS for to succeed. It is worthwile to get to know these conditions. To claim that there are no conditions at all and OSS is successful by itself is certainly not true. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie with some doubts.
Claudio Grondi schrieb: >> Im newbie to Python (I found it three weeks ago) , in fact Im newbie to >> programming. I'm being reading and training with the language, but I >> still wondering about what Classes are used to. Could you please give >> me some examples?? [...] > I don't know any really good examples which were able to demonstrate > what Classes are good for and I am in programming already for decades. Then you have in all those decades for sure never seen a GUI program done with the Win32 API (not OO, ugly, hard to grasp) and a Delphi equivalent (OO, elegant, easy). > There is actually no real need for usage of Classes. This is your opinion, not a fact as your wording suggests. If the OP is asking for examples it doesn't make sense to answer "Hey, I don't know any examples". > The notion, that they could be useful comes eventually with longer > programming experience and/or with growing size of the code library. I don't think so. OO is modeled after human reasoning. Look e.g. at phrases like Bob calls a friend, Bob learns math. What is better: Bob.call(friend) or human_call(Bob, friend), Bob.learn(math) or human_learn(Bob, math)? On the other hand there are cases where the emphasis is on the verb, e.g. compute the sine of alpha: sin(alpha) is perfect, no need to code alpha.sin(). Therefore I like hybrid languages like python giving the programmer the freedom to choose an appropriate model. > If you can avoid to learn about them, at least at the beginning, > take the chance - it will save you much trouble and help to get > things done. Excuse me, but to present your personal experience as a law of nature is not very helpful for a newbie seeking for advice not for propaganda. It is plain wrong to claim that procedural programming is kind of natural and OOP is rocket science. > I for myself try to avoid classes where I can, especially > inheritance, because I consider the latter in most cases evil. There are terrible OO libraries out there but this is not a genuine feature of OOP. Bad code can be written in lots of ways. > There are sure many others who can't imagin to program > without classes, so don't conclude that there is a > contradiction here - it's just the question of taste It's not a question of taste it's a question of the kind of problem to solve. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the ascii code of Chinese characters?
Gerhard Fiedler wrote: > Well, ASCII can represent the Unicode numerically -- if that is what the OP > wants. No. ASCII characters range is 0..127 while Unicode characters range is at least 0..65535. > For example, "U+81EC" (all ASCII) is one possible -- not very > readable though -- representation of a Hanzi character (see > http://www.cojak.org/index.php?function=code_lookup&term=81EC). U+81EC means a Unicode character which is represented by the number 0x81EC. There are some encodings defined which map Unicode sequences to byte sequences: UTF-8 maps Unicode strings to sequences of bytes in the range 0..255, UTF-7 maps Unicode strings to sequences of bytes in the range 0..127. You *could* read the latter as ASCII sequences but this is not correct. How to do it in Python? Let chinesePhrase be a Unicode string with Chinese content. Then chinesePhrase_7bit = chinesePhrase.encode('utf-7') will produce a sequences of bytes in the range 0..127 representing chinesePhrase and *looking like* a (meaningless) ASCII sequence. chinesePhrase_16bit = chinesePhrase.encode('utf-16be') will produce a sequence with Unicode numbers packed in a byte string in big endian order. This is probably closest to what the OP wants. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: What do you want in a new web framework?
Alex Martelli wrote: > Indeed, it has been truthfully observed that Python's the only language > with more web frameworks than keywords. > > I have already suggested to the BDFL that he can remedy this situation > in Py3k: all he has to do, of course, is to add a LOT more keywords. Here is another remedy: he adds one of the frameworks to the standard library :) Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
n-body problem at shootout.alioth.debian.org
I have noticed that in the language shootout at shootout.alioth.debian.org the Python program for the n-body problem is about 50% slower than the Perl program. This is an unusual big difference. I tried to make the Python program faster but without success. Has anybody an explanation for the difference? It's pure math so I expected Perl and Python to have about the same speed. Peter Maas, Aachen -- http://mail.python.org/mailman/listinfo/python-list
Re: n-body problem at shootout.alioth.debian.org
John J. Lee wrote: > Replacing ** with multiplication in advance() cut it down to 0.78 > times the original running time for me. That brings it along side > PHP, one place below Perl (I didn't bother to upload the edited script). I tried this also but got only 90%. Strange. -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list
Re: n-body problem at shootout.alioth.debian.org
Matteo wrote: > Of course, numpy is not a standard package (though there is a proposal > to add a standard 'array' package to python, based of numpy/numeric), > but if you want to do any numerics with python, you shouldn't be > without it. I know that nbody.py could be speeded up by psyco and numpy but I was curious why plain Python was slower than plain Perl. Thanks for your hints, guys! -- Regards/Gruesse, Peter Maas, Aachen E-mail 'cGV0ZXIubWFhc0B1dGlsb2cuZGU=\n'.decode('base64') -- http://mail.python.org/mailman/listinfo/python-list