Re: Is Python portable/Can I install it on an USB Stick?
On 14 Jul 2010 19:28:58 GMT tommyb...@hotmail.com (Thomas Tundor) wrote: Is Python portable? Yes. Can I install it on an USB Stick? Yes. Or is Python installing (at least on WinXP) services or register some DLLs or write something into Registry? Well, the installer is writing something into the registry, although it is not neccessary to run Python. regards, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: Naming Conventions, Where's the Convention Waldo?
On Sun, 11 Jul 2010 00:26:36 -0700 (PDT) rantingrick rantingr...@gmail.com wrote: Another source of asininity seems to be the naming conventions of the Python language proper! True/False start with an upper case and i applaud this. However str, list, tuple, int, float --need i go on...?-- start with lowercase. Achtually, these are type names with their own constructor. The name of the type of True and False is bool and, bool() returns a bool-object. regards, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: If Scheme is so good why MIT drops it?
On Sun, 19 Jul 2009 15:09:28 -0400 Roy Smith r...@panix.com wrote: In article 1cethsrrw8h6k$.9ty7j7u7zovn@40tude.net, Frank Buss f...@frank-buss.de wrote: there is one free unique implementation on the 3 major platforms Linux, Windows and MacOS X Most people would still consider Solaris to be a major platform. Depends on who you ask. On the desktop it doesn't matter at all (fortunately, since everytime I work on Solaris I'm entering a world of pain which is just slowly getting better with OpenSolaris), on the server it (and other propietary Unices) is losing ground compared to the free Unices. But ok, let's say 3 major platforms: Unix, Windows and Mac OS X. Mac OS X is formally a Unix but everything with GUI is non-Unix'y so it can be considered a separate platform. regards, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: Advantages of Python (for web/desktop apps)?
On 28 Jun 2009 11:45:06 -0700 a...@pythoncraft.com (Aahz) wrote: Perhaps I was unclear: I already knew what LMGTFY stands for, and I think that using a site that requires JavaScript is anti-social. Maybe they could just redirect to Google if JS wasn't detected. regards, Marek -- http://mail.python.org/mailman/listinfo/python-list
[issue5567] Operators in operator module don't work with keyword arguments
New submission from Marek Kubica ma...@xivilization.net: When calling operators from the ``operator``-module, they refuse to accept keyword arguments: operator.add(a=1, b=2) TypeError: add() takes no keyword arguments Operators with keyword arguments are important when one wants to create partial functions with non-positional arguments. Take for example ``operator.mod`` where the order of the arguments matters: This works: map(lambda x: x % 2, range(5)) This does not work, since ``operator.mod`` does not support keyword arguments: map(functools.partial(operator.mod, b=2), range(5)) So there are two solutions: define one's own add(), mod(), contains() etc. but then the ``operator`` module is rather useless or make them accept keyword arguments. With ``partial`` in the Stdlib this solution would be a whole lot nicer. -- components: Library (Lib) messages: 84181 nosy: leonidas severity: normal status: open title: Operators in operator module don't work with keyword arguments type: feature request ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5567 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5567] Operators in operator module don't work with keyword arguments
Marek Kubica ma...@xivilization.net added the comment: Well, some Schemes have an CURRYR variant which creates partial functions with positional arguments from the right but the current solution with partial accepting keywords is way more flexible since I can pre-set any arguments I like in such a function in any order. Doing so by using keyword arguments looks cleaner than by using the position of the argument. Compare ``partial(operator.mod, (2, 2))`` with ``partial(operator.mod, divisor=2)`` and at least to me, it is clearer what is happening in the second case. Even ``partial(operator.mod, b=2)`` looks simpler, albeit the name ``b`` is not particularly descriptive. The names ``a`` and ``b`` as used in many operators are indeed not very useful but renaming them wouldn't be a problem since nobody currently depends on ``a`` or ``b`` in their code; just in the order. That said, ``a`` and ``b`` are not so bad actually, because I couldn't think of better names for ``a`` and ``b`` in ``operator.contains(a, b)``. The nice thing now is, that partial can indeed replace many lambdas so not allowing partial to use operator seems just a random restriction. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5567 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: calling an external program and capturing the output
On Sun, 18 Jan 2009 09:36:59 -0800 (PST) Xah Lee xah...@gmail.com wrote: See: • Making System Calls in Perl and Python http://xahlee.org/perl-python/system_calls.html You can safely drop the Raw-Strings as they are only needed on Windows when constuction paths and programs with hardcoded paths are rare. regards, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: Where Find Activestate Python 2.5?
On Sun, 11 Jan 2009 16:29:16 -0800 W. eWatson notval...@sbcglobal.net wrote: Using that gets me to http://www.activestate.com/activepython/, the big download 2.6 button again. Nowhere did I get your url. An interesting maze. Tried that Other Systems and Versions just below that Download Now button? regards, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: Why not Ruby?
On Thu, 01 Jan 2009 13:13:19 -0800, Fuzzyman wrote: Care to save me the effort of looking it up and tell me what Data.Map does that Python's dict doesn't? I guess if it is functional then every mutation must copy and return a new data structure? (Which will be much more efficient in Haskell than in Python - Haskell can share most of the underlying data whereas Python would have to create a new dict every time. At least it only stores references.) Who says that it must create a whole new one? I could imagine that with a bit weakref code and some thought an immutable dictionary that shares data would be possible in Python too. regards, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: What is site-packages?
On Sun, 28 Dec 2008 04:06:36 -0800, Hussein B wrote: You mean like MoinMoin, Django or Pylons for example? Yes. Or lxml, BeautifulSoup, psycopg2 and basically anything that is available on PyPI. regards, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: pyparsing: match empty line
Hi, First of all a big thank you for your excellent library and of course also for your extensive and enlightening answer! 1) Well done in resetting the default whitespace characters, since you are doing some parsing that is dependent on the presence of line ends. When you do this, it is useful to define an expression for end of line so that you can reference it where you explicitly expect to find line ends: EOL = LineEnd().suppress() Ok, I didn't think about this. But as my program is not only a parser but a long-running process and setDefaultWhitespace modifies a global variable I don't feel too comfortable with it. I could set the whitespace on every element, but that is as you surely agree quite ugly. Do you accept patches? I'm thinking about some kind of factory-class which would automatically set the whitespaces: factory = TokenFactory(' \t\r') word = Factory.Word(alphas) That way, one wouldn't need to set a grobal value which might interfere with other pyparsers running in the same process. parser = OneOrMore(watchname ^ pagebreak ^ leaveempty ^ EOL) This will now permit the second test to pass. Right. Seems that working with whitespace requires a bit better understanding than I had. 3) Your definition of pagebreak looks okay now, but I don't understand why your test containing 2 blank lines is only supposed to generate a single PAGEBREAK. No, it should be one PAGEBREAK per blank line, now it works as expected. 4) leaveempty probably needs this parse action to be attached to it: leaveempty = Literal('EMPTY').setParseAction(replaceWith('EMPTY')) I added this in the meantime. replaceWith is really a handy helper. parser = OneOrMore(watchname | pagebreak | leaveempty | EOL) '|' operators generate MatchFirst expressions. MatchFirst will do short-circuit evaluation - the first expression that matches will be the one chosen as the matching alternative. Okay, adjusted it. If you have more pyparsing questions, you can also post them on the pyparsing wiki - the Discussion tab on the wiki Home page has become a running support forum - and there is also a Help/Discussion mailing list. Which of these two would you prefer? Thanks again, it works now just as I imagined! regards, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: pyparsing: match empty line
On Wed, 03 Sep 2008 06:12:47 -0700, Paul McGuire wrote: On Sep 3, 4:26 am, Marek Kubica [EMAIL PROTECTED] wrote: I could set the whitespace on every element, but that is as you surely agree quite ugly. Do you accept patches? I'm thinking about some kind of factory-class which would automatically set the whitespaces: factory = TokenFactory(' \t\r') word = Factory.Word(alphas) That way, one wouldn't need to set a grobal value which might interfere with other pyparsers running in the same process. I tried to prototype up your TokenFactory class, but once I got as far as implementing __getattribute__ to return the corresponding pyparsing class, I couldn't see how to grab the object generated for that class, and modify its whitespace values. I have had the same problem, until I remembered that I can fake __init__ using a function closure. I have imported pyparsing.py into a hg repository with a patchstack, here is my first patch: diff -r 12e2bbff259e pyparsing.py --- a/pyparsing.py Wed Sep 03 09:40:09 2008 + +++ b/pyparsing.py Wed Sep 03 14:08:15 2008 + @@ -1400,9 +1400,38 @@ def __req__(self,other): return self == other +class TokenFinder(type): +Collects all classes that are derived from Token +token_classes = dict() +def __init__(cls, name, bases, dict): +# save the class +TokenFinder.token_classes[cls.__name__] = cls + +class WhitespaceTokenFactory(object): +def __init__(self, whitespace): +self._whitespace = whitespace + +def __getattr__(self, name): +Get an attribute of this class +# check whether there is such a Token +if name in TokenFinder.token_classes: +token = TokenFinder.token_classes[name] +# construct a closure which fakes the constructor +def _callable(*args, **kwargs): +obj = token(*args, **kwargs) +# set the whitespace on the token +obj.setWhitespaceChars(self._whitespace) +return obj +# return the function which returns an instance of the Token +return _callable +else: +raise AttributeError('%s' object has no attribute '%s' % ( +WhitespaceTokenFactory.__name__, name)) class Token(ParserElement): Abstract ParserElement subclass, for defining atomic matching patterns. +__metaclass__ = TokenFinder + def __init__( self ): I used metaclasses for getting all Token-subclasses so new classes that are created are automatically accessible via the factory, without any additional registration. Oh and yes, more patches will follow. I'm currently editing the second patch, but I better mail it directly to you as it is not really interesting for this list. regards, Marek -- http://mail.python.org/mailman/listinfo/python-list
pyparsing: match empty line
Hi, I am trying to get this stuff working, but I still fail. I have a format which consists of three elements: \d{4}M?-\d (4 numbers, optional M, dash, another number) EMPTY (the EMPTY token) [Empty line] (the PAGEBREAK token. The line may contain whitespaces, but nothing else) While the ``watchname`` and ``leaveempty`` were trivial, I cannot get ``pagebreak`` to work properly. #!/usr/bin/env python # -*- coding: UTF-8 -*- from pyparsing import (Word, Literal, Optional, Group, OneOrMore, Regex, Combine, ParserElement, nums, LineStart, LineEnd, White, replaceWith) ParserElement.setDefaultWhitespaceChars(' \t\r') watchseries = Word(nums, exact=4) watchrev = Word(nums, exact=1) watchname = Combine(watchseries + Optional('M') + '-' + watchrev) leaveempty = Literal('EMPTY') def breaks(s, loc, tokens): print repr(tokens[0]) #return ['PAGEBREAK' for token in tokens[0]] return ['PAGEBREAK'] #pagebreak = Regex('^\s*$').setParseAction(breaks) pagebreak = LineStart() + LineEnd().setParseAction(replaceWith ('PAGEBREAK')) parser = OneOrMore(watchname ^ pagebreak ^ leaveempty) tests = [ 2134M-2, 3245-3 3456M-5, 3256-4 4563-4, 4562M-6 EMPTY 3246-5 ] for test in tests: print parser.parseString(test) The output should be: ['2134M-2'] ['3245-3', '3456M-5'] ['3256-4', 'PAGEBREAK' '4563-4'] ['4562M-6', 'EMPTY', '3246-5'] Thanks in advance! regards, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: Confused: looking for a simple XML parser
Hi, On Fri, 15 Aug 2008 17:21:56 -0700, Rex wrote: What tool should I use? For easy stuff ElementTree (bundled with Python 2.5 but also available to older versions), for more complex stuff lxml (which extends the ET API, so the learning curve is incremental). regards, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: Python's doc problems: sort
On Tue, 29 Apr 2008 19:48:39 -0700, [EMAIL PROTECTED] wrote: Python priests: go fuck yourselfs. In case you have something useful to add, grap the documentation sources of Python 2.6 (they were converted from LaTeX to reST now) and send a patch to the documentation maintainers. Lamenting about the Python documentation is no help to anyone if one is not willing to improve it. regards, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: Django Vs Rails
Hello! On 7 Sep 2005 20:56:28 -0700 flamesrock wrote: On the other, Rails seems to have a brighter future, Why that? Django is not yet released and everybody is talking about it. Like it happened with RoR. How difficult would it be to learn Ruby+Rails, assuming that someone is already skilled with Python? Learning Ruby: quite trivial, as Ruby is like Python, but sometimes there a Ruby-way and a non-Ruby-way (codeblocks and stuff like this) and to write nice Ruby programs you better write in the Ruby-way. Is it worth it? Well, I've learned it, because it was easy but I haven't yet found a really significant difference that makes Ruby much better than Python. You can write some things in an very elegant way, but sometimes the Python solution is more readable. But the docs are sometimes.. say: very compact ;). As Ruby is not that hard to learn you could give it a try - maybe you'll like it, maybe not. RoR is not the only framework, some folks prefer Nitro. greets, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: Dabo in 30 seconds?
Hello! On Sun, 31 Jul 2005 17:38:44 -0700 James Stroud wrote: On Sunday 31 July 2005 05:14 pm, Robert Kern wrote: You can't blame Dabo for this one. Your wxPython install is broken. Yes, but my Tkinter install works just fine. But you chose wx: dabo.ui.loadUI(wx) Why can't I compile my linux kernel? I know, my gcc is broken, but my Python runs fine? SCNR. greets, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: The state of OO wrappers on top of wxPython (was Re: Wheel-reinvention with Python)
On Sat, 30 Jul 2005 14:13:14 -0700 Cliff Wells wrote: But how stable is GTK on systems such as Windows and OS/X? That has been what has kept me from using it. Most GTK apps I've used on Windows (including the venerable GIMP) are nowhere near as stable as their Linux counterparts (although this may not be entirely the fault of GTK). Also, GTK on OS/X requires Fink, which is a pretty hefty requirement to place on an end user. I cannot speak for Mac OS X, but I like GTK on Windows, it's better than Tkinter :D GTK unter Windows has been discussed not so long ago: http://groups.google.de/group/comp.lang.python/browse_frm/thread/308b08adce4b9794/7ca38c3d89933ce9?tvc=1#7ca38c3d89933ce9 If you already tried GIMP on Windows, better try Inkscape on Windows.. that piece of GTK software is really good. greets, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: Wheel-reinvention with Python
Hello! On Sun, 31 Jul 2005 13:46:55 +0200 Torsten Bronger wrote: Be that as it may, some Google postings suggest that it works at least with wxPython. Yes, it does. I hadn't done this a long time, but it is possible. In fact, afaik there are less problems with py2exe and wxPython than with PyGTK (writing the setup.py was easier). greets, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: Wheel-reinvention with Python
On 31 Jul 2005 16:38:45 -0700 Paul Rubin wrote: I can put up a Tk gui in about 5 lines of code from a stock Python distro without having to install anything additional. How do I do that with wxPython? It is very easy under Debian Sarge to do it. Well after installing python-tk which needs python2.3-tk which needs blt, tcl8.4, tk8.4 and likes to have tix8.1. So, for a Tkinter programm you just need to install at least five packages for a GUI toolkit which may be great for you if you like to study the history of computing. :D Not that wxPython, PyGTK, PyQt have no dependencies ;) Bug you still can't forget the dependency on Tcl/Tk. greets, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK or wxPython (not a flame war) on Windows
Hi! On Sun, 24 Jul 2005 22:16:01 +0200 Torsten Bronger wrote: I'm very suprised. wxPython is still that buggy? I read reports from 2000 about such observations, but they tried wxPython in a non-standard way, and the project has had 5 years to become more stable after all. Well, I don't know version 2.6.x but I had some trouble with 2.4. I was trying to mass-hide buttons, which was possible with .detach() or .hide() (or was it .show(False)?). This was explained in the documentation, but in the release I had, was a bug somewhere and the widgets had no .detach() function. Robin Dunn said it will be fixed in the next release.. but that release came months later. But I know that the release cycles had got a lot faster in the meantime. Besides, wxPython prepares for being included into the standard distribution. To replace Tkinter? No problem with that :) Oh, I see, there seems to be a more pythonic wrapper for wx: wax.. http://www.zephyrfalcon.org/labs/wax.html greets, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK or wxPython (not a flame war) on Windows
Hello! AFAIK PyGTK doesn't look native on Win as well, but I don't care. It does have a nearly-native look and feel: http://gtk-wimp.sourceforge.net/screenshots/ And yes, the theme adjusts itself to Windows XP themes, so GTK+ apps look nearly like any other Windows Program. The native look and feel is not as good as the look and feel of wx but still really _much_ better than older versions of GTK. This is done by a theme engine.. you can find it in the gladewin32 package. greets, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK or wxPython (not a flame war) on Windows
Hi! Am Sun, 24 Jul 2005 19:47:30 +0200 schrieb Torsten Bronger: Is PyGTK more Pythonic by the way? I had a look at wxPython yesterday and didn't like that it has been brought into the Python world nearly unchanged. You can see its non-Python origin clearly. How does PyGTK feel in this respect? Well.. I'd say, PyGTK is still quite like GTK in C. There are some nice features like iterators in treeviews but some things are IMHO unneccesary difficult and much more elegant in wx. I have started GUIs in Python with wx, but after a short time I was annoyed how many things were buggy. I don't know why, but I fell from one bug to the other while programming one application. Then, I tried GTK on Windows, because I know GTK+ 2 a bit liked it. First I was very impressed, the documentation (Tutorial + Reference + FAQ) was after wxPy 2.4.x _very_ impressive and things which were difficult in wxPy were easy in PyGTK. But after some time I realized some other things were complicated in PyGTK. You see, there is no non-plus-ultra GUI library and my best advice is to test it yourself to see which one fits your needs best. I hope a Qt4 compatible PyQt will be released soon, I'm curious about the new Qt4, which is free for GPL-only software on Windows. greets, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: Detecting computers on network
Hello! On Fri, 22 Jul 2005 10:32:04 -0600 Sandeep Arya wrote: Sybren.. Does nmap is available on every systems? I tried on my linux fc4 machine in user previleage. it was not working. Does this just belongs to superuser... I'm not Sybren, but I think I'm able to respond. nmap is only available if it is installed on the system, on Debian you would need to install the package nmap first. It is not really a good idea hoping nmap to be installed. You can use nmap as a normal user, but some advanced scanning options are reserved for superuser. greets, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: Friend wants to learn python
Hello, On 23 Jul 2005 10:24:02 -0700 Pietro Campesato wrote: Maybe diveintopython.org can help I consider diveintopython a little bit to hard for the beginner. I really like this book, it's excellent, great thanks to Mike Pilgrim for providing us the book. I pointed a friend to Python Programming for the Absolute Beginner by Premier Press. He liked it, although I don't know how much Python he had learned yet. Just my 1/50 of a bigger coin in your currency ;) greets, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: How to run python script in background after i logout
Hello! On 24 Jul 2005 12:59:04 -0700 Steve M wrote: Another is that when I use putty.exe from Windows for my ssh client, I can't get scroll-back buffers to work correctly with screen. (Screen is really powerful with its own scrollback buffers and screendumps and stuff but I don't have time to get into all that or even learn it sometimes. I wish I were more a master of it since its such a great program.) I use Crtl+A+Esc and go into the screen scrollback buffer, where I can navigate with the arrow keys. After typing Esc a second time, I get back to my program. greets, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGTK or wxPython (not a flame war) on Windows
Hello! How well does PyGTK run on Windows (98, 2K, XP)? How stable is it? Will I be able to make an executable (using Py2Exe) of an application that uses PyGTK? I _do_ like PyGTK on Windows. It works without problems. You can find a ready to use py2exe script on http://www.pythonwiki.de/PyGtk. You could also bundle the runtime DLLs with your py2exe'd application, but I have never done this. You could try doing this like described here: http://aspn.activestate.com/ASPN/Mail/Message/py2exe-users/2476686 (use the setup.py script from the wiki and start at (2) in the mail). HTH. greets, Marek PS: Yes, I admit it is harder than py2exe + wxPython but I still like PyGTK. -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python like VB?
Hi! People coming from VB background probably also appreciate the ability to draw the UI in pointclick style: http://gazpacho.sicem.biz/ http://wxglade.sourceforge.net/ Unfortunately these seem to still be a tad rough around the edges... wxGlade is a port of Glade (which is designed for GTK+) to wx. But Glade is still the best and can be used very well with PyGTK (I prefer using PyGTK on Windows than wxPython). http://glade.gnome.org greets, Marek -- http://mail.python.org/mailman/listinfo/python-list
SimpleXMLServer meets inetd
Hi! I was thinking about connecting SimpleXMLRPCServer with inetd.. but I haven't been able to replace the socket by sys.stdin and sys.stdout. Maybe socket.fromfd(sys.stdin.fileno()) could help me, but I can't get it to work, I always get connection refused. Any ideas? greets, Marek -- http://mail.python.org/mailman/listinfo/python-list
Re: [ANN] WConio 1.5 Binary Installer for Python 2.4
Am Sat, 05 Mar 2005 20:33:22 -0600 schrieb Chris Gonnerman: http://newcenturycomputers.net/projects/wconio.html I've done this before: http://www.pythonwiki.de/PythonErweiterungen/WindowsBinaries greets, Marek -- http://mail.python.org/mailman/listinfo/python-list