ANN: unicode 0.4.9

unicode is a simple python command line utility that displays properties for a given unicode character, or searches unicode database for a given name. It was written with Linux in mind, but should work almost everywhere (including MS Windows and ...

Posted On: Saturday 10th of November 2012 02:21:13 AM Total Views:  387
View Complete with Replies

Related Messages:

error using all()/numpy [TypeError: cannot perform reduce withflexible type]   (291 Views)
all, I'm pretty new to Python, but use it a lot lately. I'm getting a crazy error trying to do operations on a string list after importing numpy. Minimal example: [start Python] Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> a=['1','2','3'] >>> all(a) True >>> from numpy import * >>> all(a) Traceback (most recent call last): File "", line 1, in File "C:\Python25\lib\site-packages\numpy\core\", line 982, in all return _wrapit(a, 'all', axis, out) File "C:\Python25\lib\site-packages\numpy\core\", line 37, in _wrapit result = getattr(asarray(obj),method)(*args, **kwds) TypeError: cannot perform reduce with flexible type [end of example] It seems that Python calls numpy's "all" instead of the standard one, is that right If so, how can I call the standard "all" after the numpy import ["import numpy" is not a deable option, I use a lot of math in my progs] Is there another way around this error Marc
Re: [Python-Dev] annoying dictionary problem, non-existing keys   (214 Views)
bvidinli schrieb: > I posted to so many lists because, > > this issue is related to all lists, > this is an idea for python, > this is related to development of python... > > why are you so much defensive > > i think ideas all important for development of python, software.... > i am sory anyway.... hope will be helpful. You could take the answers from the people (including core developers) as sign that it is *not* related to all lists. Crossposting is generally frowned upon and should be avoided. If you post here & people think that it is a python devel issue, they will indicate that. Diez
Cannot understand the detailedly the following code   (218 Views)
At the url there is some code by Guido Van Rossum for computing paths through a graph - I have pasted it below for reference - Let's write a simple function to determine a path between two nodes. It takes a graph and the start and end nodes as arguments. It will return a list of nodes (including the start and end nodes) comprising the path. When no path can be found, it returns None. The same node will not occur more than once on the path returned (i.e. it won't contain cycles). The algorithm uses an important technique called backtracking: it tries each possibility in turn until it finds a solution. def find_path(graph, start, end, path=[]): path = path + [start] if start == end: return path if not graph.has_key(start): return None for node in graph[start]: if node not in path: newpath = find_path(graph, node, end, path) if newpath: return newpath return None *** He then says------------------------ It is simple to change this function to return a list of all paths (without cycles) instead of the first path it finds: def find_all_paths(graph, start, end, path=[]): path = path + [start] if start == end: return [path] if not graph.has_key(start): return [] paths = [] for node in graph[start]: if node not in path: newpaths = find_all_paths(graph, node, end, path) for newpath in newpaths: paths.append(newpath) return paths *** I couldn't understand how it was simple to change the function find paths to find all paths. How would you think about writing this second function recursively. Especially the part about if start==end: return [path]. I feel you would give square brackets around path here after first writing the inductive part ... for node in graph[start] .... and then by trial and error put square brackets around path in the Basis part. Can someone please explain how to write this code.
Cannot build Python 2.4 SRPM on x64 platform   (254 Views)
For those on several python lists, I appologize in advance for cross-posting, but I'm really not sure which list is best to ask for assistance with this. Currently, I am trying to build the python2.4 SRPM from on a RHEL4 x64 platform, but the build is failing with a very non-descript error message. ..... + cd /var/tmp/python2.4-2.4-root/usr/bin + mv -f pydoc pydoc2.4 + cd /var/tmp/python2.4-2.4-root/usr/bin + mv -f idle idle2.4 + echo '#!/bin/bash' + echo 'exec /usr/bin/python2.4 /usr/lib64/python2.4/idlelib/' + chmod 755 /var/tmp/python2.4-2.4-root/usr/bin/idle2.4 + cp -a Tools /var/tmp/python2.4-2.4-root/usr/lib64/python2.4 + rm -f mainpkg.files + find /var/tmp/python2.4-2.4-root/usr/lib64/python2.4/lib-dynload -type f + sed 's|^/var/tmp/python2.4-2.4-root|/|' + grep -v -e '$' error: Bad exit status from /var/tmp/rpm-tmp.55639 (%install) RPM build errors: user jafo does not exist - using root group jafo does not exist - using root user jafo does not exist - using root group jafo does not exist - using root Bad exit status from /var/tmp/rpm-tmp.55639 (%install) If I try to run /var/tmp/rpm-tmp.55639 manually from the prompt manually after the rpmbuild fails, it runs properly to completion. If I try to comment out that last line (find /var/tmp/python2.4-2.4-root/usr/lib64/python2.4/lib-dynload -type f | sed 's|^/var/tmp/python2.4-2.4-root|/|' | grep -v -e '$' ) that seems to be causing the script to fail, rpmbuild finishes, but with several error msgs, complaining about missing files in the lib64 directories: + rm -f /tmp/python-rpm-files.4859 + /usr/lib/rpm/brp-compress + /usr/lib/rpm/brp-strip + /usr/lib/rpm/brp-strip-static-archive + /usr/lib/rpm/brp-strip-comment-note Processing files: python2.4-2.4-1pydotorg error: File not found by glob: /var/tmp/python2.4-2.4-root/usr/lib64/python2.4/*.txt error: File not found by glob: /var/tmp/python2.4-2.4-root/usr/lib64/python2.4/*.py* error: File not found: /var/tmp/python2.4-2.4-root/usr/lib64/python2.4/pdb.doc error: File not found: /var/tmp/python2.4-2.4-root/usr/lib64/python2.4/profile.doc error: File not found: /var/tmp/python2.4-2.4-root/usr/lib64/python2.4/curses error: File not found: /var/tmp/python2.4-2.4-root/usr/lib64/python2.4/distutils error: File not found: /var/tmp/python2.4-2.4-root/usr/lib64/python2.4/encodings error: File not found: /var/tmp/python2.4-2.4-root/usr/lib64/python2.4/plat-linux2 error: File not found: /var/tmp/python2.4-2.4-root/usr/lib64/python2.4/site-packages error: File not found: /var/tmp/python2.4-2.4-root/usr/lib64/python2.4/test error: File not found: /var/tmp/python2.4-2.4-root/usr/lib64/python2.4/xml error: File not found: /var/tmp/python2.4-2.4-root/usr/lib64/python2.4/email error: File not found: /var/tmp/python2.4-2.4-root/usr/lib64/python2.4/compiler error: File not found: /var/tmp/python2.4-2.4-root/usr/lib64/python2.4/bsddb error: File not found: /var/tmp/python2.4-2.4-root/usr/lib64/python2.4/hotshot error: File not found: /var/tmp/python2.4-2.4-root/usr/lib64/python2.4/logging error: File not found: /var/tmp/python2.4-2.4-root/usr/lib64/python2.4/lib-old Executing(%doc): /bin/sh -e /var/tmp/rpm-tmp.95118 + umask 022 + cd /usr/src/redhat/BUILD + cd Python-2.4 + DOCDIR=/var/tmp/python2.4-2.4-root/usr/share/doc/python2.4-2.4 + export DOCDIR + rm -rf /var/tmp/python2.4-2.4-root/usr/share/doc/python2.4-2.4 + /bin/mkdir -p /var/tmp/python2.4-2.4-root/usr/share/doc/python2.4-2.4 + cp -pr Misc/README Misc/cheatsheet Misc/Porting /var/tmp/python2.4-2.4-root/usr/share/doc/python2.4-2.4 + cp -pr LICENSE Misc/ACKS Misc/HISTORY Misc/NEWS /var/tmp/python2.4-2.4-root/usr/share/doc/python2.4-2.4 + exit 0 Processing files: python2.4-devel-2.4-1pydotorg error: File not found: /var/tmp/python2.4-2.4-root/usr/lib64/python2.4/config Processing files: python2.4-tools-2.4-1pydotorg Requires(rpmlib): rpmlib(CompressedFileNames)
ftplib question (cannot open data connection)   (236 Views)
Hi , I'm using a simple program that uploads a file on a remote ftp server. This is an example (not the whole program): def store(self,hostname,username,password,destdir,srcpath): self.ftp = ftplib.FTP(hostname) self.ftp.login(username,password) self.ftp.set_pasv(False) self.ftp.cwd(destdir) fobj = file(srcpath,"rb") destname = os.path.split(srcpath)[1] self.ftp.storbinary("STOR "+destname,fobj) The ftp server cannot use passive connections, and I can do nothing about that. Here is the problem: I can connect to this ftp server from my home computer, which is behind a NAT firewall. I can also connect to it from another computer, but I'm not able to upload any file. I tried to debug with a simple "ftp -v -d" command line program and apparently the problem is with the "EPRT" command: ftp> ls ---> EPRT |1||55749| 200 Port command successful. ---> LIST 425 Cannot open data connection. ftp> Well, the port number given by EPRT is bad - it is a closed port on this computer. I can open a small port range for this, but I would not like to open all ports and disable the firewall completely. Here are my questions: 1. How can I instruct ftplib to use specific ports for incoming connections (For example, ports between 55000 and 56000). 2. How it is possible that the same program works from another computer that is behind a NAT firewall
C/C++ on UNIX Developer required in Woodmead, Johannesburg   (205 Views)
We seek the following sort of experience / skill for developer resources (if u do not qualify - we offer a handsome referral fee if you refer someone that is succesfully placed:-) . C Programming 5 years C++ Programming 2 years SQL Programming 2 years Software Design 2 years Software Engineering Process 3 years GUI Development 1 year Unix/Linux environment 2 years Scientific/Mathematical Programming 2 years These skills all need to be current. The candidate should demonstrate an ability to work resourcefully and independently, whilst delivering in the framework of a team. The candidate must also demonstrate a willingness and dee to program hands-on in C and C++ code. He/she must have personally developed significant amounts of program code, demonstrating and requiring modular design and the use of a source code repository for version control. The candidate must communicate well, and be comfortable discussing design issues with both the team and the customer. His / her present role should require this of him/her. The candidate must be able to describe the software development lifecycle and identify his/her personal points of interaction in that cycle. These points must be Functional Requirements Specification, Software Design, Programming and Unit Testing. The following skills would be an advantage: Object oriented design UML and the use of design tools like Rational Rose Development tools (GDB, DBX, WxWidets/Qt/GTK, Makefiles etc.)
Re: PyQt, Cannot send events to objects owned by a different thread?   (335 Views)
On Sun Nov 25 15:22:24 CET 2007, Alexander Tuchacek wrote: > i try to adress an qt object > > self.statusbar.showMessage("rtt %s...." % (n.rtt)) > > in an callback function, comming from a shared lib importet by ctypes, on > osx this works wonderfull > > when i run the same code on linux (ubuntu gutsy), i get this core dump, ok, > i understand that the problem is, that i cant speak to the qt thread, but > why does it work on osx Maybe the implementation of the library is different on OS X. You need to give us more enough information to work with. > shall i recompile python pyqt or sip without threads > > could somebody give me a hint what to do best how can i call a qt object in > an c-lib callback You can either construct some sort of event handling mechanism or use signals and slots. Personally, I'd use signals and slots for this, if possible. The idea would be to set up a connection between your callback code and the status bar's showMessage() slot. Then you would only have to emit that signal to update the status bar. David
urllib: cannot open webpage which requires authentication   (279 Views)
I tried using urllib.urlopen to open a personalized webpage ( but it doesn't work: print urllib.urlopen( Instead of returning, it returns a page asking me to log in. So then I tried urllib.urlencode: data = urllib.urlencode({'action': ' login', 'login': , 'passwd': }) print urllib.urlopen(, data).read() However, this doesn't work either. Is there a way to do this
Cannot formulate regex   (224 Views)
I'd like to filter spam from a certain company. Here are examples of strings found in their spam: Mega Dik Mega D1k MegaDik Mega. Dik M eg ad ik M E _G_A_D_ IK M_E_G. ADI. K I figured that this regex would match all but the second example, yet it matches none: |[^a-z]m[^a-z]e[^a-z]g[^a-z]a[^a-z]d[^a-z]i[^a-z]k[^a-z]|i What would be the regex that matches "megadik" regardless of whatever characters are sprinkled throughout
cannot create my own dict   (236 Views)
all, This morning I tried to create my own read-only dictionary, and failed miserably. I don't understand why, can somebody enlighten me Below is a brute-force experiment that cannot deal with "x in obj", plz read the explanation below the code: -------------------------------- class myowndict(object): def __init__(self, mydict): self.mydict = mydict # Below is produced with # print '\n'.join([' self.%s = self.mydict.%s' % (v,v) # for v in dir(dict)]) # commented-out functions done by hand # #self.__class__ = self.mydict.__class__ self.__cmp__ = self.mydict.__cmp__ self.__contains__ = self.mydict.__contains__ self.__delattr__ = self.mydict.__delattr__ self.__delitem__ = self.mydict.__delitem__ #self.__doc__ = self.mydict.__doc__ self.__eq__ = self.mydict.__eq__ self.__ge__ = self.mydict.__ge__ self.__getattribute__ = self.mydict.__getattribute__ self.__getitem__ = self.mydict.__getitem__ self.__gt__ = self.mydict.__gt__ self.__hash__ = self.mydict.__hash__ #self.__init__ = self.mydict.__init__ self.__iter__ = self.mydict.__iter__ self.__le__ = self.mydict.__le__ self.__len__ = self.mydict.__len__ self.__lt__ = self.mydict.__lt__ self.__ne__ = self.mydict.__ne__ #self.__new__ = self.mydict.__new__ self.__reduce__ = self.mydict.__reduce__ self.__reduce_ex__ = self.mydict.__reduce_ex__ self.__repr__ = self.mydict.__repr__ self.__setattr__ = self.mydict.__setattr__ self.__setitem__ = self.mydict.__setitem__ self.__str__ = self.mydict.__str__ self.clear = self.mydict.clear self.copy = self.mydict.copy self.fromkeys = self.mydict.fromkeys self.get = self.mydict.get self.has_key = self.mydict.has_key self.items = self.mydict.items self.iteritems = self.mydict.iteritems self.iterkeys = self.mydict.iterkeys self.itervalues = self.mydict.itervalues self.keys = self.mydict.keys self.pop = self.mydict.pop self.popitem = self.mydict.popitem self.setdefault = self.mydict.setdefault self.update = self.mydict.update self.values = self.mydict.values # end of __init__ if __name__ == '__main__': fd = myowndict({1:10}) print 1 in fd # FAILS! (with "TypeError: iterable argument required") -------------------------------- I wanted to make my own dictionary. However, a simple element test failed (after implementing various __*__ functions), and I cannot figure out why. The above code is a brute force attempt, where I forward all methods (except __class__, __doc__, __init__, and __new__) to my local 'mydict' object. IT STILL FAILS. So if copying all methods of a native dictionary is not enough, what should I do to make my class work as a dictionary WITHOUT deriving from dict (which will obviously work). Sincerely, Albert
Py3K: Ensuring future compatibility between function annotation basedtools   (217 Views)
There could be future compatibility issues between libraries using the new function annotation scheme: PEP 3107 -- Function Annotations See also: Let's assume two hypotetic libraries: mashaller: provides JSON marshalling support typechecker: provides runtime type checking Let's write a simple function that uses both libraries: from marshaller import marshall, JSON from typechecker import check, Str @marshall @check def splitter(s:Str) -> JSON: return s.split(',') The function get a singe string and returns JSON encoded list of it's comma separated parts. Both libraries can be used together without problems as long as all arguments and the return value are annotated by at most one annotator object. However, there could be frequent use cases, when multiple annotations for a single argument or return value is required: @marshall @check def splitter(sJSON, Str)) -> JSON: return s.split(',') The above function does the same as the first one, but accepts a JSON encoded string. This solution works only if both libraries can cooperatively handle composite annotator objects and do not complain about unknown ones. (Note, that the order of processing depends on the order of the decorators, not on the order of the annotators.) Let me suggest the following recommendation for tool developers: If you encounter a tuple as the annotator, then iterate it and process only the known ones while silently skipping all others. Keep all existing annotators if you include new ones. Create a tuple if you find an existing annotator and need to include a second one. Extend existing tuples by replacing them with new ones including new annotator(s). (Possibly lists or dictionaries in place of tuples I don't think so. Ideas) This way all annotation based tools will be compatible and should work seamlessly without imposing any unnecessary constraint. Anybody with a better solution Any comments Greetings, Viktor
ann: Python at the IET   (213 Views)
If you're in London around 6.30pm this Thursday evening, July 5th 2007, you might want to drop in on The Institution of Engineering and Technology [1] on the Embankment near Waterloo Bridge [2] for "A Light byte of Python" [3]. Michael Grazebrook, Pete Ryland and I are flying the Python flag for the benefit of technologists who have not yet had the pleasure. Michael will be using ctypes to control a USB-interfaced sensor kit; Pete will be demoing user interfaces; I'll be using BeautifulSoup and sqlite3 to populate a database from a web page and (time permitting) using csv and ReportLab to push it back out again. We're presenting the thing as a bring-a-laptop workshop, and it would be great if we had experienced Pythoneers along to help afterwards (in addition to ourselves). The take-up's been quite high for the event and there's tea & coffee beforehand and sandwiches afterwards. Tim Golden [1] [2] [3]
contextlib.closing annoyance   (173 Views)
it looks like contextlib.closing fails to be idempotent, i.e. wrapping closing() around another closing() doesn't work. This is annoying because the idea of closing() is to let you use legacy file-like objects as targets of the "with" statement, e.g. with closing( as zf: ... but what happens if the gzip library gets updated the dumb way to support the enter and exit methods so you don't need the explicit closing call any more The dumb way of course is to just call closing() inside the library. It seems to me that closing(closing(f)) ought to do the same thing as closing(f). Let me know if I'm overlooking something. I'm thinking of submitting an RFE.
"assert" annoyance   (176 Views)
So I have some assert statements in my code to verify the absence of some "impossible" conditions. They were useful in debugging and of course I left them in place for "real" runs of the program. Umpteen hours into a run, an assertion failed, and of course since failure was "impossible", I didn't catch the exception so the whole program crashed. I don't know what I'd have done with the exception anyway, since it would have had to be caught at an outer scope where the data I cared about was no longer around, or else I'd have had to predict in advance what I needed to examine and pass that as a an arg to the assert statement. What I really want is for any assertion failure, anywhere in the program, to trap to the debugger WITHOUT blowing out of the scope where the failure happened, so I can examine the local frame. That just seems natural, but I don't see an obvious way to do it. Am I missing something I guess I could replace all the assertions with function calls that launch pdb, but why bother having an assert statement , Paul Rubin writes: > So I have some assert statements in my code to verify the absence of > some "impossible" conditions. They were useful in debugging and of > course I left them in place for "real" runs of the program. Umpteen > hours into a run, an assertion failed, and of course since failure > was "impossible", I didn't catch the exception so the whole program > crashed. This is exactly the sort of check which is best done as unit tests. The program has no 'assert' cruft in it, and the tests can be as comprehensive as needed without having any impact on the actual running program. -- \ Legionnaire: "We have their leader captive!" Cr: "Is he | `\ bound" Legionnaire: "Of his health I know not, ." -- The | _o__) Goon Show, _The Histories Of Pliny The Elder_ | Ben Finney
Re: string formatter %x and a class instance with __int__ cannothandle long   (236 Views)
En Thu, 21 Jun 2007 05:36:42 -0300, Kenji Noguchi escribi: > I confirmed that "%08x" % int(y) works. And yes, I'm hoping so. > It actually works that way if the v is less than or equal to 0x7ffffffff. > >> It is a bug, at least for me, and I have half of a patch addressing it. >> As a workaround, convert explicitely to long before formatting. > > I'm interested in your patch. What's the other half still missing As you have seen, PyString_Format doesn't handle well objects that can be converted to long but are not longs themselves; I've modified that function, but PyUnicode_Format has a similar problem, that's "the other half". Maybe this weekend I'll clean those things and submit the patch. -- Gabriel Genellina
ANN: pytoken 1.0 - native 86 machine code scanner generator   (194 Views)
I am pleased to announce the 1.0 version of pytoken. It is available here: What is pytoken Pytoken is a scanner generator. Given an input specification - a bunch of regular expressions - pytoken will generate x86 machine code that recognizes those regular expressions. Pytoken will be most useful for programmers that want to parse complex text files. Pytoken has separate objects for scanners and buffers. Here is a simple example: import pytoken lexer_obj = pytoken.lexer() lexer_obj.add_pattern("a", 1) lexer_obj.add_pattern("b", 2) lexer_obj.compile_to_machine_code() buf = pytoken.lexer_state() buf.set_input("ab") tok = lexer_obj.get_token(buf) assert tok == 1 tok = lexer_obj.get_token(buf) assert tok == 2 Pytoken has been written in a portable fashion - it is designed to support multiple CPU types, even though only the x86 (32 bit) is supported now. -Ram
Cannot Read MySQLdb docs within Python interpreter   (216 Views)
I'm gettting a traceback when I attempt to read the MySQLdb docs after installation on Mac OS X 10.5.2: BEGIN TRACEBACK: >>> help( "MySQLdb" ) Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/2.5/lib/ python2.5/", ...
Re: annoying dictionary problem, non-existing keys   (188 Views)
bvidinli wrote: > i use dictionaries to hold some config data, such as: > > conf={'key1':'value1','key2':'value2'} and so on... > > when i try to process conf, i have to code every time like: if > conf.has_key('key1'): if conf['key1']<>'': other ...
Re: [Python-Dev] annoying dictionary problem, non-existing keys   (212 Views)
On Thu, Apr 24, 2008 at 11:13:25AM +0300, bvidinli wrote: > if conf.has_key('key1'): > if conf['key1']<>'': > other commands.... > > this is very annoying. > in php, i was able to code only like: > if conf['key1']=='someth' > > ...
Release: vizann-2.0 Tkinter Neural Net Demo Program   (181 Views)
Release Name: vizann-2.0 This freeware program may be downloaded from . *Notes:* This is a program to graphically demonstrate the operational details of two types of ANN (Artificial Neural Network) when used to implement the XOR function. The ...