Re: Two questions about logging
Matthew Pounsett wrote: [snip] Second, I'm trying to get a handle on how libraries are meant to integrate with the applications that use them. The naming advice in the advanced tutorial is to use __name__ to name loggers, and to allow log messages to pass back up to the using application's logger for processing, but these two pieces of advice seem contradictory.. since log messages only pass back up to the root if the loggers are named hierarchically. [snip] So, given this state of affairs, how is a library author to use loggers, given that he or she can't know how authors who use the library will name their logger objects? In the above example, what would the author of bar.py do to hook up bar's logger with foo's, without knowing in advance what foo's logger will be named? Thanks very much for any suggestions, or pointers to documentation that I've missed. All loggers share at least one parent : the root logger. In the standard way of using the loggers, the root logger is *the* logger responsible of processing logs. Considering that extlib is an external library from anApp, and intlib an internal library to the anApp application: People may expect logs that way: anApp.extlib : INFO : a log message anApp.intlib : INFO : another message However, what will happen is : extlib : INFO : message from the external lib anApp.intlib : INFO : message from the internal lib As you mentioned in your post, there is no way to 'attach' an external lib to your application since the external lib knows nothing about the application, but there is no need to attach it actually. JM -- http://mail.python.org/mailman/listinfo/python-list
Re: how to install lxml in window xp?
Am 12.01.2012 06:08, schrieb Brian Curtin: > On Wed, Jan 11, 2012 at 23:01, Tamer Higazi wrote: >> Use Linux! >> Specially Gentoo Linux! > > Not a useful answer. then take windows 7 instead of something that is no more supported by the vendor itself. I am running Python 64Bit on my Windows machine and almost every library could have been installed my sides with the MSSDK and the Visual C++ 2008 Express Edition compiler in the background, that tasks are invoked automatically by easy_install. So, instead of making yourself continuously headache for an outdated OS I advise taking a low performance OS like, let us say, xubunutu that has a light environment instead of gnome3 or kde4 for a WindowsXP designed CPU. Tamer -- http://mail.python.org/mailman/listinfo/python-list
stable object serialization to text file
Hello All, I'm developing an app which stores the data in file system database. The data in my case consists of large python objects, mostly dicts, containing texts and numbers. The easiest way to dump and load them would be pickle, but I have a problem with it: I want to keep the data in version control, and I would like to use it as efficiently as possible. Is it possible to force pickle to store the otherwise unordered (e.g. dictionary) data in a kind of ordered way, so that if I dump a large dict, then change 1 tiny thing in it and dump again, the diff of the former and the new file will be minimal? If pickle is not the best choice for me, can you suggest anything else? (If there isn't any solution for it so far, I will write the module of course, but first I'd like to look around and make sure it hasn't been created yet.) Thanks, Mate -- http://mail.python.org/mailman/listinfo/python-list
Re: stable object serialization to text file
Máté Koch wrote: > I'm developing an app which stores the data in file system database. The > data in my case consists of large python objects, mostly dicts, containing > texts and numbers. The easiest way to dump and load them would be pickle, > but I have a problem with it: I want to keep the data in version control, > and I would like to use it as efficiently as possible. Is it possible to > force pickle to store the otherwise unordered (e.g. dictionary) data in a > kind of ordered way, so that if I dump a large dict, then change 1 tiny > thing in it and dump again, the diff of the former and the new file will > be minimal? > > If pickle is not the best choice for me, can you suggest anything else? > (If there isn't any solution for it so far, I will write the module of > course, but first I'd like to look around and make sure it hasn't been > created yet.) Have you considered json? http://docs.python.org/library/json.html The encoder features a sort_keys flag which might help. -- http://mail.python.org/mailman/listinfo/python-list
Re: stable object serialization to text file
That's probably the easiest way as I don't store any binary data just strings and numbers. Thanks! On Jan 12, 2012, at 1:24 PM, Peter Otten wrote: > Máté Koch wrote: > >> I'm developing an app which stores the data in file system database. The >> data in my case consists of large python objects, mostly dicts, containing >> texts and numbers. The easiest way to dump and load them would be pickle, >> but I have a problem with it: I want to keep the data in version control, >> and I would like to use it as efficiently as possible. Is it possible to >> force pickle to store the otherwise unordered (e.g. dictionary) data in a >> kind of ordered way, so that if I dump a large dict, then change 1 tiny >> thing in it and dump again, the diff of the former and the new file will >> be minimal? >> >> If pickle is not the best choice for me, can you suggest anything else? >> (If there isn't any solution for it so far, I will write the module of >> course, but first I'd like to look around and make sure it hasn't been >> created yet.) > > Have you considered json? > > http://docs.python.org/library/json.html > > The encoder features a sort_keys flag which might help. > > -- > http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Python lib for creating Database tables
On Wed, Jan 11, 2012 at 4:38 PM, Emeka wrote: > Hello All, > > I just made something pretty simple that I intend to use while creating > database tables. It is still in the basic form, and much needs to be added. > However, I use introspection to make it a bit easier and less work on the > user. > > I would want my code to be reviewed by this great group. I look forward to > your feedback and comments. > https://github.com/janus/cheeta Having done a LOT of work with SQL Alchemy, I would definitely encourage you to just bite the bullet and get on board with it now. I routinely do very challenging things with it, and it has yet to be a roadblock. The learning curve can be somewhat steep but it is absolutely worth it. Nathan -- http://mail.python.org/mailman/listinfo/python-list
Is there a way to merge two XML files via Python?
This is more a theory exercise and something I'm trying to figure out, and this is NOT a homework assignment... I'm trying to make a tool I use at work more efficient :) So this is at test tool that generates an XML file as it's output that is eventually used by a web service to display test results and system information. The problem is that the testing is broken down into to different runs: Functional and Automated where the Functional tests are all manual, then the automated tests are run separately, usually overnight. Each of those test runs generates essentially an identical XML file. What I want to learn is a way to merge them. In abstract terms, the idea is essentially to diff the two files creating a patch and then use that patch to merge the two files into a single XML file. SO what I was hoping I could get pointers on from those of you who are experienced in using Python with XML is what python libraries or means are there for working with XML files specifically, and how easy or difficult would this be? I'm also doing research on my own in my spare time on this, but I also wanted to ask here to get the opinion of developers who are more experienced in working with XML than I am. Thanks Jeff -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to merge two XML files via Python?
J, 12.01.2012 17:04: > This is more a theory exercise and something I'm trying to figure out, > and this is NOT a homework assignment... > > I'm trying to make a tool I use at work more efficient :) > > So this is at test tool that generates an XML file as it's output that > is eventually used by a web service to display test results and system > information. > > The problem is that the testing is broken down into to different runs: > Functional and Automated where the Functional tests are all manual, > then the automated tests are run separately, usually overnight. > > Each of those test runs generates essentially an identical XML file. > What I want to learn is a way to merge them. Ok - how large are these files? (i.e., do they easily fit into memory?) > In abstract terms, the idea is essentially to diff the two files > creating a patch and then use that patch to merge the two files into a > single XML file. I wouldn't go through patch. If they fit into memory, just load both, merge one into the other eliminating duplicates, and save that. Or rather, load just one and process the other one incrementally using ElementTree's iterparse(). > SO what I was hoping I could get pointers on from those of you who are > experienced in using Python with XML is what python libraries or means > are there for working with XML files specifically, and how easy or > difficult would this be? Depends on how easy it is to recognise duplicates in your specific data format. Once you've managed to do that, the rest is trivial. > I'm also doing research on my own in my spare time on this, but I also > wanted to ask here to get the opinion of developers who are more > experienced in working with XML than I am. I recommend looking at the stdlib xml.etree.ElementTree module or the external lxml package (which contains the ElementTree compatible lxml.etree module). The latter will (likely) make things easier due to full XPath support and some other goodies, but ElementTree is also quite quick and easy to use by itself. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Re: Is there a way to merge two XML files via Python?
On 01/12/2012 11:39 AM, Stefan Behnel wrote: J, 12.01.2012 17:04: This is more a theory exercise and something I'm trying to figure out, and this is NOT a homework assignment... I'm trying to make a tool I use at work more efficient :) So this is at test tool that generates an XML file as it's output that is eventually used by a web service to display test results and system information. The problem is that the testing is broken down into to different runs: Functional and Automated where the Functional tests are all manual, then the automated tests are run separately, usually overnight. Each of those test runs generates essentially an identical XML file. What I want to learn is a way to merge them. Ok - how large are these files? (i.e., do they easily fit into memory?) In abstract terms, the idea is essentially to diff the two files creating a patch and then use that patch to merge the two files into a single XML file. I wouldn't go through patch. If they fit into memory, just load both, merge one into the other eliminating duplicates, and save that. Or rather, load just one and process the other one incrementally using ElementTree's iterparse(). SO what I was hoping I could get pointers on from those of you who are experienced in using Python with XML is what python libraries or means are there for working with XML files specifically, and how easy or difficult would this be? Depends on how easy it is to recognise duplicates in your specific data format. Once you've managed to do that, the rest is trivial. I'm also doing research on my own in my spare time on this, but I also wanted to ask here to get the opinion of developers who are more experienced in working with XML than I am. I recommend looking at the stdlib xml.etree.ElementTree module or the external lxml package (which contains the ElementTree compatible lxml.etree module). The latter will (likely) make things easier due to full XPath support and some other goodies, but ElementTree is also quite quick and easy to use by itself. Stefan Question for jeff: Have you tried doing it by hand? Do you know when a duplicate should be ignored, when it should be replicated, when it should be represented by incrementing a count? xml is very flexible, but the final reader of your file may not be so flexible. (e.g. if it has to match a wsdl) If two runs differ only by some timing field, then you might need to sum those times, and produce an average in the final run. Or a max value, or both. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Wing IDE 4.1.3 released
Hi, Wingware has released version 4.1.3 of Wing IDE, an integrated development environment designed specifically for the Python programming language. Wing IDE is a cross-platform Python IDE that provides a professional code editor with vi, emacs, and other key bindings, auto-completion, call tips, refactoring, context-aware auto-editing, a powerful graphical debugger, version control, unit testing, search, and many other features. **Changes in Version 4.1.3** Highlights of this release include: * Added move-line-up and move-line-down line editing commands * Added Open From Project option to search only on the file name * Added goto-overridden-method command * Added copy-reference command to copy filename, line number(s), scope, and optionally the current or selected lines to the clipboard * Added experimental Eclipse style key binding * Several auto-editing improvements * 12 vi mode fixes * Avoid grouping snippets and arg entry into a single undo action * Speed up auto-completion and auto-editing * About 25 other bug fixes and minor improvements Complete change log: http://wingware.com/pub/wingide/4.1.3/CHANGELOG.txt **New Features in Version 4** Version 4 adds the following new major features: * Refactoring -- Rename/move symbols, extract to function/method, and introduce variable * Find Uses -- Find all points of use of a symbol * Auto-Editing -- Reduce typing burden by auto-entering expected code * Diff/Merge -- Graphical file and repository comparison and merge * Django Support -- Debug Django templates, run Django unit tests, and more * matplotlib Support -- Maintains live-updating plots in shell and debugger * Simplified Licensing -- Includes all OSes and adds Support+Upgrades subscriptions Details on licensing changes: http://wingware.com/news/2011-02-16 **About Wing IDE** Wing IDE is an integrated development environment designed specifically for the Python programming language. It provides powerful editing, testing, and debugging features that help reduce development and debugging time, cut down on coding errors, and make it easier to understand and navigate Python code. Wing IDE can be used to develop Python code for web, GUI, and embedded scripting applications. Wing IDE is available in three product levels: Wing IDE Professional is the full-featured Python IDE, Wing IDE Personal offers a reduced feature set at a low price, and Wing IDE 101 is a free simplified version designed for teaching beginning programming courses with Python. Version 4.0 of Wing IDE Professional includes the following major features: * Professional quality code editor with vi, emacs, and other keyboard personalities * Code intelligence for Python: Auto-completion, call tips, find uses, goto-definition, error indicators, refactoring, context-aware auto-editing, smart indent and rewrapping, and source navigation * Advanced multi-threaded debugger with graphical UI, command line interaction, conditional breakpoints, data value tooltips over code, watch tool, and externally launched and remote debugging * Powerful search and replace options including keyboard driven and graphical UIs, multi-file, wild card, and regular expression search and replace * Version control integration for Subversion, CVS, Bazaar, git, Mercurial, and Perforce * Integrated unit testing with unittest, nose, and doctest frameworks * Django support: Debugs Django templates, provides project setup tools, and runs Django unit tests * Many other features including project manager, bookmarks, code snippets, diff/merge tool, OS command integration, indentation manager, PyLint integration, and perspectives * Extremely configurable and may be extended with Python scripts * Extensive product documentation and How-Tos for Django, matplotlib, Plone, wxPython, PyQt, mod_wsgi, Autodesk Maya, and many other frameworks Please refer to http://wingware.com/wingide/features for a detailed listing of features by product level. System requirements are Windows 2000 or later, OS X 10.3.9 or later (requires X11 Server), or a recent Linux system (either 32 or 64 bit). Wing IDE supports Python versions 2.0.x through 3.2.x and Stackless Python. For more information, see the http://wingware.com/ **Downloads** Wing IDE Professional and Wing IDE Personal are commercial software and require a license to run. A free trial can be obtained directly from the product when launched. Wing IDE Pro -- Full-featured product: http://wingware.com/downloads/wingide/4.1 Wing IDE Personal -- A simplified IDE: http://wingware.com/downloads/wingide-personal/4.1 Wing IDE 101 -- For teaching with Python: http://wingware.com/downloads/wingide-101/4.1 **Purchasing and Upgrading** Wing 4.x requires an upgrade for Wing IDE 2.x and 3.x users at a cost of 1/2 the full product pricing. Upgrade a license: https://wingware.com/store/upgrade Purchase a new license: https://wingware.com/store/purchase Optional Support
Re: stable object serialization to text file
On 1/12/2012 7:24 AM, Peter Otten wrote: Máté Koch wrote: I'm developing an app which stores the data in file system database. The data in my case consists of large python objects, mostly dicts, containing texts and numbers. The easiest way to dump and load them would be pickle, but I have a problem with it: I want to keep the data in version control, and I would like to use it as efficiently as possible. Is it possible to force pickle to store the otherwise unordered (e.g. dictionary) data in a kind of ordered way, so that if I dump a large dict, then change 1 tiny thing in it and dump again, the diff of the former and the new file will be minimal? If pickle is not the best choice for me, can you suggest anything else? (If there isn't any solution for it so far, I will write the module of course, but first I'd like to look around and make sure it hasn't been created yet.) Have you considered json? http://docs.python.org/library/json.html The encoder features a sort_keys flag which might help. If that does not do it for you, consider that a dict is a two-column table, with arbitrary structures in each column. Convert to list with sorted(somedict.items()). This is basically what json should do. Then write to a text stream, one line per key,value pair. Whether you put the text into an os file in a directory (a hierachical database ;-) or a text field in another database is up to you. Either way, diffs are easy. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Symbolic expressions (or: partials and closures from the inside out)
Greetings,
I have been writing a lot of code lately that involves creating
symbolic expressions of one form or another, which are then fully
evaluated at a later time. Examples of this include Elementwise,
where I create expressions that act on every member of an iterable
(there is a much improved new version coming soon, by the way), and a
design by contract/validation lib I'm working on (which shall remain
nameless :D) that uses symbolic expressions in the *args of the
metaclass __new__ method to generate a constraint class which
validates input using __instancecheck__. I do most of this with
lambdas, a little hacking with closures and FunctionType(), and
chainable objects. I am very impressed that python is this flexible,
but there are some issues with the approach that I would like to
rectify, namely:
1. Because of the early binding behavior of most things in Python, if
I want to include isinstance(X, someclass) in a symbolic expression, I
have to wrap it in a lambda (or use .apply(), in the case of
Elementwise). This is not a huge deal for me, but it forces me to
create wrappers for lots of functions (e.g. isinstance_(X, someclass))
and/or have users wrap every such function they want to use in a
symbolic expression. Having to do this also bloats the code a lot;
the github version of Elementwise is over 3,000 LoC at this point
(including prodigious documentation, but still...).
2. Python expects that certain functions, such as int(), str(), etc,
will have a specific return type. While in general I agree with this,
it makes Elementwise somewhat inconsistent (and it will do the same to
anything else that wants to work with symbolic expressions).
I'm interested in fixing both issues. I believe both issues I've had
could be solved by having a robust "symbolic object". These objects
would basically usable like ordinary objects, however upon any
attribute access or other form of interaction, the object would
basically short circuit the calling function, and return a symbolic
object directly to the outer scope. The symbolic object would behave
like a generator function frozen at the point of attribute access, and
upon send()-ing (or whatever method), it would behave exactly as if
the values sent had been the ones passed in originally (ideally
without consuming the generator).
I have thought about ways to approximate this behavior python
currently, and while I could hack something together using inspect to
pull relevant info from the stack, then break out using a special
exception (potentially passing a generator with state as an exception
arg), this approach strikes me as VERY brittle, implementation
dependent, ugly and difficult to work with. Additionally, you would
need to catch the special exception somewhere in the stack, so this
trick wouldn't work on the first thing in an expression to be
evaluated.
As an aside, I'd like to solicit some feedback on the validation
syntax I've been working on. Currently, I have code that support
things like:
X = SymbolicObject()
const = Constraints(X * 2 + 1 >= 5, X % 2 != 0)
const2 = Constraints(X[-1] == "h")
const3 = Constraints(X[-1].upper() == "H")
>>> print isinstance(3, const)
True
>>> print isinstance(2, const)
False
>>> print isinstance(1, const)
False
>>> print isinstance("bleh", const2)
True
>> print isinstance("bleh", const3)
True
Callables are supported as well, so if you wanted to do something like:
Constraints(isinstance(X.attr, someclass), somefunc(X[-2].attr, args))
You could approximate that with:
Constraints(lambda x: isinstance(x.attr, someclass), lambda x:
somefunc(x[-2].attr, args))
As I mentioned in the first paragraph, Constraints is a metaclass, so
your validations are checked using __instancecheck__. I'm also
considering having __init__ generate mock objects (for certain
straight-forward cases, anyhow).
Thanks for your time,
Nathan
--
http://mail.python.org/mailman/listinfo/python-list
ANN: pysendfile 0.2.0 released
Hi folks, I'm pleased to announce the 0.2.0 release of pysendfile: http://code.google.com/p/pysendfile === About === This is a python interface to sendfile(2) system call available on most UNIX systems. sendfile(2) provides a "zero-copy" way of copying data from one file descriptor to another (a socket). The phrase "zero-copy" refers to the fact that all of the copying of data between the two descriptors is done entirely by the kernel, with no copying of data into userspace buffers, resuting in file transfers being from 2x to 3x faster. Basically, any application sending files over the network can take advantage of it. HTTP and FTP servers are a typical example. === Supported platforms === * Linux * Mac OSX * FreeBSD * Dragon Fly BSD * Sun OS * AIX (not properly tested) === Supported python versions === >From 2.5 to 3.3. === Links === * Home page: http://code.google.com/p/pysendfile * Source tarball: http://pysendfile.googlecode.com/files/pysendfile-0.2.0.tar.gz --- Giampaolo Rodola' http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ http://code.google.com/p/pysendfile/ -- http://mail.python.org/mailman/listinfo/python-list
Reading and writing to a file creates null characters
Hi,
I've got a file which I'd like to read, modify and write.
# file contents
a
b
c
d
My script reads the file contents into a list and rotates the list and
writes it back to the same file.
Problem is that the output contains null characters. I don't know
where they are coming from.
#!/usr/bin/env python
def rotate(l):
return l[1:] + [l[0]]
f = open("/tmp/.rrd", 'r+')
lines = [ line.strip() for line in f.readlines() ]
newlist = rotate(lines)
print newlist
f.truncate(0)
f.write("\n".join(newlist))
f.close()
# output
[root@Inferno html]# python rotate.py
['b', 'c', 'd', 'a']
[root@Inferno html]# python rotate.py
['c', 'd', 'a', '\x00\x00\x00\x00\x00\x00\x00\x00b']
[root@Inferno html]#
What's going on? Thanks for your help,
Dennis
--
http://mail.python.org/mailman/listinfo/python-list
Re: Reading and writing to a file creates null characters
In article <[email protected]>, Denhua wrote: > [omitted] > f.write("\n".join(newlist)) > f.close() > > # output > > [root@Inferno html]# python rotate.py > ['b', 'c', 'd', 'a'] > [root@Inferno html]# python rotate.py > ['c', 'd', 'a', '\x00\x00\x00\x00\x00\x00\x00\x00b'] > [root@Inferno html]# > > > What's going on? Thanks for your help, > Dennis Step 1 in debugging any problem -- try to isolate the smallest possible test case. In your example, can you figure out if the weirdness is happening in f.write(), or in what is being passed to f.write()? Try breaking it down into something like: > output = "\n".join(newlist) > print output > f.write(output) > f.close() Next, figure out if it happens whenever you write() to a file, or only if you write() after you do a truncate(). Once you can answer those questions, you'll have a much smaller problem to try and solve. -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading and writing to a file creates null characters
On 12/01/2012 22:26, Denhua wrote:
Hi,
I've got a file which I'd like to read, modify and write.
# file contents
a
b
c
d
My script reads the file contents into a list and rotates the list and
writes it back to the same file.
Problem is that the output contains null characters. I don't know
where they are coming from.
#!/usr/bin/env python
def rotate(l):
return l[1:] + [l[0]]
f = open("/tmp/.rrd", 'r+')
lines = [ line.strip() for line in f.readlines() ]
newlist = rotate(lines)
print newlist
f.truncate(0)
f.write("\n".join(newlist))
f.close()
# output
[root@Inferno html]# python rotate.py
['b', 'c', 'd', 'a']
[root@Inferno html]# python rotate.py
['c', 'd', 'a', '\x00\x00\x00\x00\x00\x00\x00\x00b']
[root@Inferno html]#
What's going on? Thanks for your help,
>
I think this is the relevant part of the documentation:
"""The current file position is not changed. Note that if a specified
size exceeds the file’s current size, the result is platform-dependent:
possibilities include that the file may remain unchanged, increase to
the specified size as if zero-filled, or increase to the specified size
with undefined new content.
"""
In other words, you also need to reset the file pointer to the start of
the file.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Two questions about logging
On 1/11/12 18:19 , Matthew Pounsett wrote:
Second, I'm trying to get a handle on how libraries are meant to
integrate with the applications that use them. The naming advice in
the advanced tutorial is to use __name__ to name loggers, and to allow
log messages to pass back up to the using application's logger for
processing, but these two pieces of advice seem contradictory.. since
log messages only pass back up to the root if the loggers are named
hierarchically.
Here's the confusion. Each log named __name__ is under the root logger.
If you want them all, then catch them all with the root logger.
In foo.py, change getLogger(__name__) to getLogger(''). Only the
included modules need __name__. Or use two - one logger for setting
handlers based on the root logger, and another based on __name__ for
logging from the top level.
--rich
--
http://mail.python.org/mailman/listinfo/python-list
Re: stable object serialization to text file
On 1/11/12 12:16 , Máté Koch wrote: Hello All, I'm developing an app which stores the data in file system database. The data in my case consists of large python objects, mostly dicts, containing texts and numbers. The easiest way to dump and load them would be pickle, but I have a problem with it: I want to keep the data in version control, and I would like to use it as efficiently as possible. Is it possible to force pickle to store the otherwise unordered (e.g. dictionary) data in a kind of ordered way, so that if I dump a large dict, then change 1 tiny thing in it and dump again, the diff of the former and the new file will be minimal? If pickle is not the best choice for me, can you suggest anything else? (If there isn't any solution for it so far, I will write the module of course, but first I'd like to look around and make sure it hasn't been created yet.) Json kinda sucks. Try yaml. If your data is simple enough, you can just write and read your own format. Sort it first and you're golden. You might also try sorted dicts. I don't know if those will come out of pickle any differently than regular dicts, but it's worth trying. You can also write your own serializer for any of the previously mentioned serializers. If you sort during serialization, then they'll be sorted in the disk file. --rich -- http://mail.python.org/mailman/listinfo/python-list
Re: how to install lxml in window xp?
Tamer Higazi wrote: > So, instead of making yourself continuously headache for an outdated OS > I advise [...] Please don't recommend people use another OS when they ask an explicit question about a particular OS. It just makes you come across as a zealot. Not everyone is working within an environment that they control. I'm aware of quite a few local government agencies that will be stuck on XP for quite some time, expecting any employee of such organisations to install whatever they want on their computers is laughable. -- http://mail.python.org/mailman/listinfo/python-list
Re: ERROR:root:code for hash md5 was not found
On Wed, 11 Jan 2012 22:13:16 -0800, mike wrote:
[...]
> esekilx5030 [7:09am] [roamFroBl/pysibelius/bin] -> python Python 2.7.2
> (default, Jun 16 2011, 15:05:49) [GCC 4.5.0] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
import sys
> print(sys.version)
> import hashlib
> print(hashlib.__file__)
> print(hashlib.md5)
> import _md5
> print(_md5.__file__) >>> 2.7.2 (default, Jun 16 2011, 15:05:49) [GCC
> 4.5.0]
ERROR:root:code for hash md5 was not found.
> Traceback (most recent call last):
> File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
> hashlib.py", line 139, in
> globals()[__func_name] = __get_hash(__func_name)
> File "/vobs/rnc/rrt/roam1/roamSs/roamFroBl/python/lib/python2.7/
> hashlib.py", line 91, in __get_builtin_constructor
> raise ValueError('unsupported hash type %s' % name)
It looks like pysibelius comes with its own Python installation, which is
*seriously* broken.
What is pysibelius? I can't find it on the web. Does it have anything to
do with Sibelius the music composition software?
It looks like the installation you are trying to use is missing modules.
You might need to consult the pysibelius forums or mailing lists, if they
have any, or the author, or possibly re-install it and see if the problem
goes away.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
How to remove ellipses from long paths in traceback?
Hi, Long paths in python traceback are contracted with ellipses. eg: TclError: couldn't load library "C:/Python26/tcl/tk8.5/../../bin/tk85.dll" Is there any way to see the full path? Surprisingly, search didn't reveal an answer to this question. Thanks Jason -- http://mail.python.org/mailman/listinfo/python-list
Re: ERROR:root:code for hash md5 was not found
On Jan 13, 1:34 pm, Steven D'Aprano wrote: > What is pysibelius? I can't find it on the web. Does it have anything to > do with Sibelius the music composition software? Yes, please provide more information about the pysibelius package, especially if this is the case. The few tenuous Python/Sibelius links I found didn't have anything on pysibelius, unfortunately. -- http://mail.python.org/mailman/listinfo/python-list
Zealotry [was Re: how to install lxml in window xp?]
On Thu, 12 Jan 2012 18:50:13 -0800, alex23 wrote: > Tamer Higazi wrote: >> So, instead of making yourself continuously headache for an outdated OS >> I advise [...] > > Please don't recommend people use another OS when they ask an explicit > question about a particular OS. It just makes you come across as a > zealot. Why is it that only Linux and Mac users are accused of being "zealots"? If I ask how to install (say) MYOB or Photoshop on Linux, and people tell me that I will have to use Windows if I want to easily run that software, I don't accuse them of being a zealot. I've had Quicken tell me that Quickbooks can only store its data files on a Windows file server. The fact that I've been successfully running it in a VM with the data files stored on a Samba file share without any problems proves them wrong, but if I accused Quicken technical support of being "zealots" I'd be considered a loon. Yet Windows users get away with calling others zealots all the time. > Not everyone is working within an environment that they control. I'm > aware of quite a few local government agencies that will be stuck on XP > for quite some time, expecting any employee of such organisations to > install whatever they want on their computers is laughable. That may be true, but the advice remains reasonable advice. If somebody asks you how to get from Iceland to Norway by car, it is perfectly reasonable to tell them that they will find it much easier to use a plane or boat. The existence of people who, for whatever reason, can't or won't use a plane or boat doesn't change the fact that using a car will be extremely difficult, if not impossible. Some Windows users are so used to being the centre of the computing universe that any time they hit a problem that is easier to solve on another OS, and people dare remind them of that fact, they get their nose out of joint. If your OS does everything you need it to do, great. I personally am happy running Windows Server 2000 for my needs, and don't need any Windows software that doesn't run on it. But my sympathies go out to those who are stuck (for whatever reason) on an OS (of any flavour) that doesn't do what they want. Just don't blame the messenger. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Zealotry [was Re: how to install lxml in window xp?]
On Jan 13, 3:02 pm, Steven D'Aprano wrote: > Why is it that only Linux and Mac users are accused of being "zealots"? Oh please. Don't tar me with the Windows brush. I'd have used the same term no matter what OS was being recommended. > If I ask how to install (say) MYOB or Photoshop on Linux, and people tell > me that I will have to use Windows if I want to easily run that software, > I don't accuse them of being a zealot. And if lxml didn't have Windows binaries, then maybe this would be the case. [snippety snippety to the rest of your straw men] > That may be true, but the advice remains reasonable advice. If somebody > asks you how to get from Iceland to Norway by car, it is perfectly > reasonable to tell them that they will find it much easier to use a plane > or boat. In what way is downloading pre-built binaries and then installing lxml on Windows like driving across the ocean? This is a new low in pedantry for you. > Some Windows users are so used to being the centre of the computing > universe that any time they hit a problem that is easier to solve on > another OS, and people dare remind them of that fact, they get their nose > out of joint. Because suggesting people ditch their environment whenever they hit a single bit of friction - whether it's one they've chosen or had forced upon them - is absolutely ridiculous. And believe me, _no_ user of Windows' Python would ever make the mistake of thinking they were the centre of _that_ world. Recommending another OS to a clearly phrased problem is the IT equivalent of the old joke about the doctor saying "well don't do that then". It doesn't do _anything_ to address the actual problem the person is trying to solve. -- http://mail.python.org/mailman/listinfo/python-list
Re: Zealotry [was Re: how to install lxml in window xp?]
On Jan 13, 3:02 pm, Steven D'Aprano wrote: > Why is it that only Linux and Mac users are accused of being "zealots"? Incidentally, in the post I replied to, Tamer was talking about Windows 7, so there's that too. Are you just riding out the Friday afternoon clock? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to remove ellipses from long paths in traceback?
On Thu, Jan 12, 2012 at 22:34, Jason Veldicott wrote: > Hi, > > Long paths in python traceback are contracted with ellipses. eg: > TclError: couldn't load library "C:/Python26/tcl/tk8.5/../../bin/tk85.dll" > > Is there any way to see the full path? > > Surprisingly, search didn't reveal an answer to this question. > > Thanks > > Jason Is this tcl/tk specific or have you seen it in other places? Either way, you may want to submit a report to http://bugs.python.org -- http://mail.python.org/mailman/listinfo/python-list
Re: Zealotry
Steven D'Aprano writes: > On Thu, 12 Jan 2012 18:50:13 -0800, alex23 wrote: > > > Tamer Higazi wrote: > >> So, instead of making yourself continuously headache for an > >> outdated OS I advise [...] > > > > Please don't recommend people use another OS when they ask an > > explicit question about a particular OS. It just makes you come > > across as a zealot. > > Why is it that only Linux and Mac users are accused of being > "zealots"? If I ask how to install (say) MYOB or Photoshop on Linux, > and people tell me that I will have to use Windows if I want to easily > run that software, I don't accuse them of being a zealot. Agreed. Giving a recommendation for a different OS is not zealotry. Even if it were expressed passionately (and I don't think this case qualifies), a recommendation of software on its merits is still not zealotry. When someone starts being extremely emotional, or even militant, it might be appropriate to break out the “zealot” label. Short of that, it's an attempt to slur someone enthusiastically giving advice. -- \ “I am amazed, O Wall, that you have not collapsed and fallen, | `\since you must bear the tedious stupidities of so many | _o__) scrawlers.” —anonymous graffiti, Pompeii, 79 CE | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: How to remove ellipses from long paths in traceback?
Am 13.01.2012 05:34, schrieb Jason Veldicott: > Hi, > > Long paths in python traceback are contracted with ellipses. eg: > TclError: couldn't load library "C:/Python26/tcl/tk8.5/../../bin/tk85.dll" > > Is there any way to see the full path? The dots don't look like an ellipses to me. An ellipses has three dots "...". It might be an unnormalized path. In paths two dots mean parent directory, so the path references C:/Python26/bin/tk85.dll. Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: Zealotry
On Fri, Jan 13, 2012 at 5:02 PM, Ben Finney wrote: > Giving a recommendation for a different OS is not zealotry. The line to zealotry is (probably) crossed when _every_ problem is met with "Install XYZ then". But that can still be correct. If you're currently using flat files and NetBEUI to manage your customer names and addresses across the internet, then every problem you have will be answered with "Migrate to a real database". Zealotry? Probably. Correct? Yes. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-ideas] Symbolic expressions (or: partials and closures from the inside out)
On Thu, Jan 12, 2012 at 3:03 PM, Terry Reedy wrote: > On 1/12/2012 3:45 PM, Nathan Rice wrote: > print isinstance(3, const) >> >> True > > > A Contraints instance defines a set. 'const' is the set 'odd_ge_3' > It would look better if you used standard syntax and do the inclusion check > in a __contains__ method. > 3 in odd_ge_3 > > True But what are types but abstract sets of values? Phrasing it as a typecheck is perfectly sensible from a type-theoretic standpoint. Also, the problem of representing `isinstance(X.attr, someclass)` [for non-Constraint someclass, e.g. str] in a Constraint would still remain, since there's no "__lcontains__" (thus precluding `X.attr in str`). >> so your validations are checked using __instancecheck__. > > But it is a fake check in that 3 is not really an instance of the class, > which has no instances. The same can be true for abstract base classes, which have been sufficiently accepted to warrant adding __instancecheck__() in the first place and also to be added to the std lib (witness the `abc` and `collections` modules). It may seem unfamiliar, but then again it was only made possible starting with v2.6, which is pretty recent. Cheers, Chris -- http://rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: [Python-ideas] Symbolic expressions (or: partials and closures from the inside out)
>> I have been writing a lot of code lately that involves creating
>> symbolic expressions of one form or another, which are then fully
>> evaluated at a later time. Examples of this include Elementwise,
>
>
> Python is designed for concrete, rather than symbolic computation. But the
> latter has been done.
Being able to create abstract expressions that are later realized is
super useful and neat. You can do this decently right now, but life
would be better if you didn't have to jump through so many hoops.
Having symbolic variables override *anything* would also make lambdas
obsolete and greatly increase the potential for lazy evaluation.
> 0: rewrite the text -- a bit awkward in Python.
>
> action = compile("read({this})".format(this=), 'xxx', 'eval')
Yeah, that is something I'd expect to see in Perl code :)
> 1. default args -- has to be done when the function is defined.
>
> def action(this = ): read(this)
>
> 2. closures (nested functions) -- also requires a planned-ahead definition.
>
> make_read(x):
> return lambda: read(x)
> action = make_read()
I use this extensively in Elementwise.
> 3. bound methods -- only works for classes with methods.
>
> Class Book:
> def read(self): pass
> action = Book().read
>
> 4. partial binding of function params -- generalizes bound methods; works
> for any function and argument.
>
> from functools import partial
> action = partial(read, )
>
>> if I want to include isinstance(X, someclass) in a symbolic expression,
>
>
> Consider using partial, which can totally bind all needed args *now* for
> *later* action.
The issue isn't so much that I *can't* do things as they are more
trouble than they should be, and it makes the end user interface for
the stuff I write less elegant.
For example, if I want to work with a symbolic object, but include a
function that is not well behaved, or if I was creating a constraint
on the result of a function applied to a symbolic object, I have to
know ahead of time everything I want to do, so I can wrap the whole
expression in a lambda. Once I wrap it, the nice generative chaining
property disappears and I'm stuck with a callable.
from functools import partial
t = partial(isinstance, 1, int)
t()
> True
f = partial(isinstance, 1, float)
f()
> False
>
>
>> I have to wrap it in a lambda
>
>
> Are you sure that partial will not work for you? Since partial is written in
> Python, you can grab and adjust the code to your needs. It amounts to adding
> default args after the fact by using a generic closure.
In some cases it would, in some cases it wouldn't. Since I basically
never do */** expansion on wrappers, lambdas tend to be my go-to more
often.
>> (or use .apply(), in the case of
>>
>> Elementwise). This is not a huge deal for me, but it forces me to
>> create wrappers for lots of functions (e.g. isinstance_(X, someclass))
>> and/or have users wrap every such function they want to use in a
>> symbolic expression. Having to do this also bloats the code a lot;
>> the github version of Elementwise is over 3,000 LoC at this point
>> (including prodigious documentation, but still...).
>>
>> 2. Python expects that certain functions, such as int(), str(), etc,
>> will have a specific return type. While in general I agree with this,
>
>
> People expect that class constructors produce an instance of the class. It
> is surprising when one does otherwise ;-). Builtin classes like int, bool,
> and str are classes just like ones you write.
type/str/int/etc as types is definitely semi-coherent, since the
language really treats them more like functions. They are treated
that way all over the docs as well.
>From the data model page:
"object.__str__(self)
Called by the str() built-in function and by the..."
"object.__nonzero__(self)
Called to implement truth value testing and the built-in operation bool()"
"object.__complex__(self)
object.__int__(self)
object.__long__(self)
object.__float__(self)
Called to implement the built-in functions complex(), int(), long(),
and float(). Should return a value of the appropriate type."
So clearly this is an area that needs some polish :)
>> X = SymbolicObject()
>>
>> const = Constraints(X * 2 + 1>= 5, X % 2 != 0)
>> const2 = Constraints(X[-1] == "h")
>> const3 = Constraints(X[-1].upper() == "H")
>
>
> Using a special class is a standard way to delay concrete execution.
Standard, and currently a pain in the butt, starting from the fact
that operators don't hook into __getattribute__ and getting
progressively worse from there.
> print isinstance(3, const)
>>
>> True
>
>
> A Contraints instance defines a set. 'const' is the set 'odd_ge_3'
> It would look better if you used standard syntax and do the inclusion check
> in a __contains__ method.
Used standard syntax? Can you elaborate please?
Also, a set is one of many things a Constraints instance could
logically be represented with, as well as a discontinuous interval, a
class in the colloquial sense, etc.
Re: Zealotry [was Re: how to install lxml in window xp?]
On Fri, Jan 13, 2012 at 5:47 AM, alex23 wrote: > On Jan 13, 3:02 pm, Steven D'Aprano [email protected]> wrote: >> Why is it that only Linux and Mac users are accused of being "zealots"? > > Incidentally, in the post I replied to, Tamer was talking about > Windows 7, so there's that too. I agree with what you posted. If there was a single bad thing I would point out to anyone about the Python community, it would be that there are a huge amount of "freetards" - people who believe that Linux is the only way, or that Linux is the best way. Protip: It's not the only way, and it's not always the best way. Use what works for you. If Windows works for you, great. Same applies to every OS. It's not then unreasonable to ask others for support for that OS - they may not have the ability to provide support, but it's always good to ask. If you have no choice in the matter, sucks to be you, but live with it. Worse things have happened than having to use Windows XP, as much as I *personally* dislike XP. Claiming that x OS is best, and that every other OS is rubbish is insane. Different operating systems do things differently, and are therefore suited for different tasks and for different people. Suggesting to someone that doing a task is easier on a different OS - "Yeah, I can't help you but I might I suggest you do Python development on Linux - these sort of problems are much easier to handle when you have a package manager system and Linux distros have awesome Python support" is fine and perfectly sensible - "USE LINUX OMFG!111!! YOU'RE SO LAME, WINDOZE SUCKS OMFG YOU N00B! I'M SO COOL USE MY HARDCORE GENTOO INSTALL THAT TOOK 36 HOURS AND SHAVED 2 SECONDS OFF MY BOOTUP TIME! LOOK AT THE SPINY COMPIZ CUBE! I DON'T KNOW WHAT I DID BEFORE I COULD MAKE MY DESKTOP CUBE-Y!", as in the post you referred to, is not. I see this kind of nonsense everywhere, but it tends to be in the Linux and Apple community more - I've no idea why, probably has something to do with being a minority. For reference, I am a Linux developer who uses Windows, Linux, *BSD and OS X, each in a place where it's suitable. tl;dr - Use what works for you. Suggest, don't preach. -- http://mail.python.org/mailman/listinfo/python-list
Re: Zealotry [was Re: how to install lxml in window xp?]
alex23, 13.01.2012 06:41: > On Jan 13, 3:02 pm, Steven D'Aprano wrote: >> Why is it that only Linux and Mac users are accused of being "zealots"? > > Oh please. Don't tar me with the Windows brush. I'd have used the same > term no matter what OS was being recommended. > >> If I ask how to install (say) MYOB or Photoshop on Linux, and people tell >> me that I will have to use Windows if I want to easily run that software, >> I don't accuse them of being a zealot. > > And if lxml didn't have Windows binaries, then maybe this would be the > case. [...] > In what way is downloading pre-built binaries and then installing lxml > on Windows like driving across the ocean? Note the two sides to this problem. On the one side, there is a Windows user who is unable to easy_install lxml because the latest binaries are not on PyPI. It's an obvious first reaction to blame the project for not putting them there. On the other side, there's the lxml project which can't currently produce binaries due to the lack of a proper maintainer who has a legal and properly configured copy of that commercial operating system installed. It's an obvious first reaction to blame the Windows user who is unable to configure his/her own system to properly build lxml there. Who's to blame here? Personally, I think that solving the problem on the second side is much closer to actually driving across the ocean, whereas the first side sounds more like it's recommending it. But I guess that's just because I *am* on the second side. Now, you are saying that this problem is easily solved by downloading binary packages from an unknown third-party source and installing them on your machine. I've already seen requests to upload those specific binaries to PyPI a couple of times. This appears to be a normal way of thinking specifically amongst many Windows users, simply because this system trains them to download opaque binary software packages from arbitrary external sources in order to install them manually and use them. Coming from a Linux angle, where signed and trusted software has been the normal case for more than a decade now, so much that an attempt to install unsigned or untrusted software actually leads to a clear warning, I cannot see this as a reasonable recommendation. It may well be that Christoph Gohlke is generally trustworthy enough to install the software he builds in a given user setting. However, presenting this as the ultimate solution to any software installation problems is clear zealotry in my eyes, because it ignores the fact that software from unknown third-party sources may simply not be a valid alternative in a given setting, e.g. on a company computer. As usual, it's not all that easy, but IMHO, recommending to use Linux isn't that much worse than recommending to install untrusted binary software. Stefan -- http://mail.python.org/mailman/listinfo/python-list
