Re: Initial nose experience

2012-07-16 Thread Philipp Hagemeister
On 07/15/2012 08:58 PM, Roy Smith wrote: >> What motivated you to migrate from unittest to nose? > Mostly I was just looking for a better way to run our existing tests. > We've got a bunch of tests written in standard unittest, but no good way > to start at the top of the tree and run them all w

unittest: Improve discoverability of discover (Was: Initial nose experience)

2012-07-16 Thread Philipp Hagemeister
On 07/16/2012 01:47 PM, Peter Otten wrote: > http://docs.python.org/library/unittest#test-discovery That's precisely it. Can we improve the discoverability of the discover option, for example by making it the default action, or including a message "use discover to find test files automatically" if

Re: unittest: Improve discoverability of discover (Was: Initial nose experience)

2012-07-16 Thread Philipp Hagemeister
On 07/16/2012 02:37 PM, Philipp Hagemeister wrote: > Can we improve the discoverability of the discover > option, for example by making it the default action, or including a > message "use discover to find test files automatically" if there are no > arguments? Oops, alr

Re: dict: keys() and values() order guaranteed to be same?

2012-07-23 Thread Philipp Hagemeister
On 07/23/2012 01:23 PM, Henrik Faber wrote: > With an arbitrary dictionaty d, are d.keys() and d.values() > guaraneed to be in the same order? Yes. From the documentation[1]: If items(), keys(), values(), iteritems(), iterkeys(), and itervalues() are called with no intervening modifications to th

Re: from future import pass_function

2012-07-25 Thread Philipp Hagemeister
Unlike the print statement, pass has no overboarding complexity (like >>, printing tuples, etc.) - it just serves as a marker (and practicality beats purity). And you don't ever want to use pass as a value (say, for map() or the right side of an assignment). In fact, if pass were a function, users

Re: catch UnicodeDecodeError

2012-07-25 Thread Philipp Hagemeister
Hi Jaroslav, you can catch a UnicodeDecodeError just like any other exception. Can you provide a full example program that shows your problem? This works fine on my system: import sys open('tmp', 'wb').write(b'\xff\xff') try: buf = open('tmp', 'rb').read() buf.decode('utf-8') except Uni

Re: catch UnicodeDecodeError

2012-07-26 Thread Philipp Hagemeister
On 07/26/2012 01:15 PM, Stefan Behnel wrote: >> exits with a UnicodeDecodeError. > ... that tells you the exact code line where the error occurred. Which property of a UnicodeDecodeError does include that information? On cPython 2.7 and 3.2, I see only start and end, both of which refer to the nu

Re: catch UnicodeDecodeError

2012-07-26 Thread Philipp Hagemeister
On 07/26/2012 02:24 PM, Stefan Behnel wrote: > Read again: "*code* line". The OP was apparently failing to see that > the error did not originate in the source code lines that he had > wrapped with a try-except statement but somewhere else, thus leading to the misguided impression that the exceptio

Re: Linux shell to python

2012-07-30 Thread Philipp Hagemeister
On 07/30/2012 09:05 AM, Vikas Kumar Choudhary wrote: > `lspci | grep Q | grep "$isp_str1" | grep "$isp_str2" | cut -c1-7' The rough Python equivalent would be import subprocess [ l.partition(' ')[0] # or l[:7], if you want to copy it verbatim for l in subprocess.check_output(['lspci']).sp

Re: Linux shell to python

2012-07-30 Thread Philipp Hagemeister
On 07/30/2012 01:31 PM, Jürgen A. Erhard wrote: > On Mon, Jul 30, 2012 at 12:35:38PM +0200, Philipp Hagemeister wrote: >> import subprocess >> [ l.partition(' ')[0] # or l[:7], if you want to copy it verbatim >> for l in subprocess.check_output(['lspci&

Re: consistent input() for Python 2 and 3

2012-08-02 Thread Philipp Hagemeister
On 08/02/2012 11:49 AM, Ulrich Eckhardt wrote: > try: > # redirect input() to raw_input() like Python 3 > input = raw_input > except NameError: > # no raw input, probably running Python 3 already > pass > What do you think? Any better alternatives? That's the generic so

Re: Error help

2012-08-02 Thread Philipp Hagemeister
Let's go thorugh this program: On 08/02/2012 12:58 PM, danielashi...@googlemail.com wrote: > import cPickle, pickle you probably want to transparently fall back to pickle if cPickle is not available. > print 'WELLCOME TO THE LIBET CLOCK EXPERIMENT DATA ANALYSIST' > file=raw_input('\nPLEASE ENTER

Re: Blue Screen Python

2012-10-09 Thread Philipp Hagemeister
On 10/09/2012 09:37 AM, mikcec82 wrote: > In my script I open and close an html (in a FOR cycle); could be this the > problem? Unless you're running your Python script as a kernel driver (and you can't do that accidentally), there is no way that your user-space program should cause a bluescreen. T

Re: what’s the difference between socket.send() and socket.sendall() ?

2013-01-08 Thread Philipp Hagemeister
socket.socket.send is a low-level method and basically just the C/syscall method send(3) / send(2). It can send less bytes than you requested. socket.socket.sendall is a high-level Python-only method that sends the entire buffer you pass or throws an exception. It does that by calling send until e

Re: Any Advice Would Be Greatly Appreciated

2012-02-29 Thread Philipp Hagemeister
If you're looking for skilled developers, the best way to find them is probably to search their current work. http://careers.stackoverflow.com/ and the more experimental http://githire.com/ are two excellent developer-friendly solutions for that. - Philipp On 03/01/2012 12:08 AM, Greg Harezlak w

Re: multiprocessing: excepthook not getting called

2012-06-13 Thread Philipp Hagemeister
multiprocessing just mimicks the threading module here, see http://bugs.python.org/issue1230540 . Why do you need excepthook in the first place? You can perfectly simulate it by wrapping the root method (target in your example) in a try .. catch: import multiprocessing import sys def printErrors

Re: multiprocessing: excepthook not getting called

2012-06-13 Thread Philipp Hagemeister
On 06/13/2012 11:00 AM, Dave Cook wrote: > Originally, I was trying to send formatted > tracebacks back to the main process on a queue. You can still do that: import multiprocessing import sys def queueErrors(q): def decorator(func): def wrapped(*args, **kwargs): try:

Re: Download all youtube favorites with youtube-dl script

2013-09-26 Thread Philipp Hagemeister
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Hi Bill, the best way to ask for features or file bugs on youtube-dl is asking us at http://github.com/rg3/youtube-dl/issues . Luckily, I this list from time to time ;) Simply use youtube-dl --username u...@gmail.com --password secret :ytfav Best

Re: From Python on Solaris to Python on LINUX

2011-09-15 Thread Philipp Hagemeister
> What are the traps to be avoided? Assuming you're not using any OS features (scan the code for "/dev" and "/proc"), the transition from Solaris to Linux will be seamless. Your main problem will be the transition from the archaic Python 2.3 to a modern one. Luckily, all 2.x Pythons should be bac

Re: Code Review

2011-09-17 Thread Philipp Hagemeister
Instead of comments, you can often use docstrings (http://www.python.org/dev/peps/pep-0257/ ): This is hard to read due to the indentation, and cannot be accessed programmatically: #Update the GUI def update_gui(self, new_word): Instead, use this: def update_gui(self, new_word):

Re: python-based downloader (youtube-dl) missing critical feature ...

2011-11-04 Thread Philipp Hagemeister
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 As already said, you should file your request at https://github.com/rg3/youtube-dl/issue , not here. A few things to note: * Not all sites necessarily send the Content-Length header. * RTMP URLs would have to be treated differently * Sending a Rang

Re: youtube-dl: way to deal with the size cap issue + new errors + issues ...

2011-11-21 Thread Philipp Hagemeister
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 As a general rule, feel free to contact youtube-dl developers and users at https://github.com/rg3/youtube-dl/issues/ . youtube-dl is just one application, which happens to be written in Python. l...@mail.python.org wrote: > I did find my way (throu

codecs in a chroot / without fs access

2012-01-09 Thread Philipp Hagemeister
I want to forbid my application to access the filesystem. The easiest way seems to be chrooting and droping privileges. However, surprisingly, python loads the codecs from the filesystem on-demand, which makes my program crash: >>> import os >>> os.getuid() 0 >>> os.chroot('/tmp') >>> ''.decode('r

Re: any chance for contracts and invariants in Python?

2013-02-14 Thread Philipp Hagemeister
I don't know anything about the status of this PEP or why it hasn't been implemented, but here's what strikes me as obviously complex: Doesn't one need to traverse the entire class hierarchy on every function call? So if I have class A: def foo(self): return 1 class B(A): "inv: True" d

Re: pypi changelog api

2013-02-21 Thread Philipp Hagemeister
Hi Gregg, to get a smaller response, you can simply pass in a timestamp, like this: >>> client = xmlrpclib.ServerProxy('http://pypi.python.org/pypi') >>> import time >>> client.changelog(int(time.time() - 600)) [['vs.bootstrap.plonetheme', '1.0.1', 1361451748, 'update description, classifiers'],

Re: pypi changelog api

2013-02-21 Thread Philipp Hagemeister
; > On Thu, Feb 21, 2013 at 5:33 AM, Philipp Hagemeister wrote: > >> Hi Gregg, >> >> to get a smaller response, you can simply pass in a timestamp, like this: >> >>>>> client = xmlrpclib.ServerProxy('http://pypi.python.org/pypi') >>>&g

Re: pypi changelog api

2013-02-21 Thread Philipp Hagemeister
On 02/21/2013 02:58 PM, Michael Herman wrote: > Oh - and I haven't tried this site, but you may be able to set something up > on there to email when the changelog is updated. > > http://www.changedetection.com/ They just query the whole page - I could do that myself, easily. But the problem is tha

Re: ** Please Rank These Learning Sources **

2013-02-21 Thread Philipp Hagemeister
> http://learnpythonthehardway.org/book/ I have never used that myself, but I have seeen plenty of stackoverflow and student questions about it. In short, it's horrible. The book mostly consists of basic Python programs, and beginners often fail to grasp even the most basic structures demonstrated

Re: Issues a longer xpath expression

2013-02-22 Thread Philipp Hagemeister
Hi anonymous, your code is working perfectly right. It's just that the only time that you find anything matching //div[@class="col f-cb"] is this one: 名称 视频下载 课程简介 And obviously, there's no in there, so the xpath won't match. Cheers, Philipp On 02/22/2013 02:24 AM, python wrote

Convert IPv6 address to binary representation on 2.x/Windows

2009-03-04 Thread Philipp Hagemeister
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 socket.inet_pton which does exactly what I want is not available on 2.x on Windows. Strangely, the documentation of socket.inet_aton (IPv4 only) reads: "inet_aton() does not support IPv6, and getnameinfo() should be used instead for IPv4/v6 dual sta

Re: Convert IPv6 address to binary representation on 2.x/Windows

2009-03-04 Thread Philipp Hagemeister
rite it. But then, why should I need ipaddr? netaddr[3] has the function I'm looking for Addr('::1').packed(), but it's way over the top for this purpose; an assembler implementation would be more readable. Kind regards, Philipp Hagemeister [1] http://bugs.python.org/issue5379 [

Re: how to convert from network to host byte order

2009-03-05 Thread Philipp Hagemeister
; out = struct.pack('=H', struct.unpack('!H', inp)[0]) >>> out '\x00\x04' For more information, look for "Size and alignment" in http://docs.python.org/library/struct.html. Regards, Philipp Hagemeister -BEGIN PGP SIGNATURE- Version

Re: Binary IP address representation

2009-04-22 Thread Philipp Hagemeister
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Hi Dave, I've solved this now using ipaddr. ipaddr will be in the stdlib as soon as its developers realize there are actually not one, but two proposals to fix the remaining issues waiting for their input. Anyway, since ipaddr:r68, you can do the f

.pth in current directory: Why doesn't it work as the documentation says?

2009-05-18 Thread Philipp Hagemeister
Where is the fault in my reasoning here? 1) According to http://docs.python.org/dev/install/, "The most convenient way is to add a path configuration file to a directory that’s already on Python’s path, (...). 2) Path configuration files have an extension of .pth, (...)" 1&2 => 3) A file test.pt

Re: .pth in current directory: Why doesn't it work as the documentation says?

2009-05-18 Thread Philipp Hagemeister
David Lyon wrote: > (...) >> 1&2 => 3) A file test.pth with the content "/example/" should result in >> sys.path containing "/example/". > > No. Python, once finding the .pth will process it. Yes, but that processing will add /example/ to sys.path, right? >> 4) "" (the current directory) is the

Re: .pth in current directory: Why doesn't it work as the documentation says?

2009-05-18 Thread Philipp Hagemeister
David Lyon wrote: > On Mon, 18 May 2009 14:34:33 +0200, Philipp Hagemeister > wrote: >> Yes, but that processing will add /example/ to sys.path, right? > > It actually works the other way around. The directories listed in > sys.path are scanned for .pth files. No, they ar

Re: issue: Permissions in odfpy

2009-05-19 Thread Philipp Hagemeister
Hi Shruti, your message is kind of hard to read. Please note the following: · Do not put useless junk("issue") in title. · Multiple exclamation marks convey a sure sign of a diseased mind, especially syntactically interesting constructions such as "??.." · You didn't purchase your keyboard in Aug

Re: identifying live hosts on a network

2009-05-20 Thread Philipp Hagemeister
We acknowledge your problems with a network script idenifying live hosts on your network. Seriously, you have to tell us a little bit more so that we can help you. How about you actually post the script, and actually post the trouble (What exactly do you expect? What exactly do you see? What other

Python3: hex() on arbitrary classes

2009-09-01 Thread Philipp Hagemeister
e object to int before constructing the hex string? Regards, Philipp Hagemeister signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Python3: hex() on arbitrary classes

2009-09-01 Thread Philipp Hagemeister
Mark Dickinson wrote: > (...) If you want to be > able to interpret instances of X as integers in the various Python > contexts that expect integers (e.g., hex(), but also things like list > indexing), you should implement the __index__ method: Thanks. Somehow forgot this magic method and deleted i