Re: Crazy what-if idea for function/method calling syntax

2011-07-17 Thread Thomas Jollans
On 07/18/2011 12:54 AM, ΤΖΩΤΖΙΟΥ wrote: > Jumping in: > > What if a construct > >xx(*args1, **kwargs1)yy(*args2, **kwargs2) > > was interpreted as > > xxyy(*(args1+args2), **(kwargs1+kwargs2)) > > (Note: with **(kwargs1+kwargs2) I mean “put keyword arguments in the > order given”, since

Re: planet.python.org blog registration

2011-07-18 Thread Thomas Jollans
On 07/18/2011 03:04 PM, Markus Schmidberger wrote: > Hello, > > whom I have to contact to get a blog aggregated in planet.python.org? > > Thanks > Markus > I quote planet.python.org (below the list of names) > To request addition or removal: > e-mail planet at python.org (note, responses can t

Re: Partial Function Application -- Advantages over normal function?

2011-07-18 Thread Thomas Jollans
On 19/07/11 00:33, Thomas 'PointedEars' Lahn wrote: > Thomas 'PointedEars' Lahn wrote: > >> Dave Angel wrote: >>> On 01/-10/-28163 02:59 PM, Terry Reedy wrote: >>>> def makeadder(y) >>>> def _add(x): return x+y >>>

Re: os.path.isdir do not work for Foder named '2011-07-03'

2011-07-18 Thread Thomas Jollans
lashes. The "correct" solution in many cases is to not assume any particular path separator at all, and use os.path.join when dealing with paths. This will work even on systems that do not accept forward slashes as path separators. (does Python still support any of those?) > (3) Use another operating system. *wink* This, of course, is the only truly tenable solution. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Partial Function Application -- Advantages over normal function?

2011-07-19 Thread Thomas Jollans
On 19/07/11 18:49, Ian Kelly wrote: > On Tue, Jul 19, 2011 at 12:22 AM, Thomas Jollans wrote: >>> Supplemental: The above can be simplified to >>> >>> def makeadder(y): return lambda x: x + y >>> >> >> In turn: >> >> makeadder = lambd

Re: a little parsing challenge ☺

2011-07-19 Thread Thomas Jollans
On 19/07/11 18:54, Xah Lee wrote: > On Sunday, July 17, 2011 2:48:42 AM UTC-7, Raymond Hettinger wrote: >> On Jul 17, 12:47 am, Xah Lee wrote: >>> i hope you'll participate. Just post solution here. Thanks. >> >> http://pastebin.com/7hU20NNL > > just installed py3. > there seems to be a bug. > in

Re: a little parsing challenge ☺

2011-07-19 Thread Thomas Jollans
On 19/07/11 19:49, Xah Lee wrote: > On Jul 17, 8:31 am, Thomas Jollans wrote: >> >> I thought I'd have some fun with multi-processing: >> >> https://gist.github.com/1087682 > > hi Thomas. I ran the program, all cpu went max (i have a quad), but > afte

Re: a little parsing challenge ☺

2011-07-19 Thread Thomas Jollans
Oh, by the way: On 19/07/11 19:49, Xah Lee wrote: > I ran the program, all cpu went max Mission accomplished. -- http://mail.python.org/mailman/listinfo/python-list

Re: I am fed up with Python GUI toolkits...

2011-07-20 Thread Thomas Jollans
On 20/07/11 04:12, sturlamolden wrote: > 3. Unpythonic memory management: Python references to deleted C++ > objects (PyQt). Manual dialog destruction (wxPython). Parent-child > ownership might be smart in C++, but in Python we have a garbage > collector. I wonder - what do you think of GTK+? I've

Re: Pythonic way with more than one max possible

2011-07-20 Thread Thomas Jollans
On 20/07/11 06:19, Steven D'Aprano wrote: > On Wed, 20 Jul 2011 01:17 pm CM wrote: > >> I have three items in a dict, like this: >> >> the_dict = {'a':1, 'b':2, 'c':3} >> >> but the vals could be anything. I want to configure something else >> based on the "winner" of such a dict, with these rule

Re: I am fed up with Python GUI toolkits...

2011-07-20 Thread Thomas Jollans
On 20/07/11 15:47, sturlamolden wrote: > On 20 Jul, 11:59, Thomas Jollans wrote: > >> I wonder - what do you think of GTK+? > > PyGTK with GLADE is the easier to use, but a bit awkward looking on > Windows and Mac. (Not to mention the number of dependencies that must > b

Re: Convert '165.0' to int

2011-07-21 Thread Thomas Jollans
On 21/07/11 11:31, Frank Millman wrote: > Hi all > > I want to convert '165.0' to an integer. Well, it's not an integer. What does your data look like? How do you wish to convert it to int? Do they all represent decimal numbers? If so, how do you want to round them? What if you get '165.xyz' as i

Re: a little parsing challenge ☺

2011-07-21 Thread Thomas Jollans
On 21/07/11 14:29, Xah Lee wrote: > On Jul 19, 11:14 am, Thomas Jollans wrote: >> I thought I'd have some fun with multi-processing: > > Nice joke. ☺ > >> Here's a sane version: >> >> https://gist.github.com/1087682/2240a0834463d490c29ed0f794ad1512

Re: PEP 8 and extraneous whitespace

2011-07-21 Thread Thomas Jollans
On 21/07/11 19:51, Andrew Berg wrote: > Looks nice all lined up, but it violates PEP 8 because of those extra > spaces, which is only because extra spaces look bad in one-line > assignments that have nothing to do with lists/tuples or dictionaries. > This is one of those times not to follow PEP 8 t

Re: // about building python //

2011-07-21 Thread Thomas Jollans
27;re using Windows, you'll need Visual Studio 2008. The free Express Edition of Visual C++ will do. As for modules: you (should) know which modules your application uses. A trial-and-error approach should get you to a bare minimum quickly. (You know, remove everything you don't know is needed

Re: Question about timeit

2011-07-22 Thread Thomas Rachel
quot;shell" removes the "" in the first case, but not the '' in the second case. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 8 and extraneous whitespace

2011-07-22 Thread Thomas Rachel
Am 22.07.2011 00:45 schrieb Terry Reedy: Whether or not they are intended, the rationale is that lining up does not work with proportional fonts. Who on earth would use proportional fonts in programming?! -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP 8 and extraneous whitespace

2011-07-22 Thread Thomas Jollans
On 22/07/11 10:11, Thomas Rachel wrote: > Am 22.07.2011 00:45 schrieb Terry Reedy: > >> Whether or not they are intended, the rationale is that lining up does >> not work with proportional fonts. > > Who on earth would use proportional fonts in programming?! Why not?

Re: [PyWart 1001] Inconsistencies between zipfile and tarfile APIs

2011-07-22 Thread Thomas Jollans
On 22/07/11 05:46, rantingrick wrote: > PS: I will be posting more warts very soon. This stdlib is a gawd > awful mess! Please don't. Not here. There's a wonderful bug tracker at python.org. Use that. That's where this kind of thing belongs. And, please, be concise. What's the point of shouting

Re: WindowsError: exception: access violation

2011-07-22 Thread Thomas Jollans
> On Fri, Jul 22, 2011 at 7:47 AM, Benjamin Kaplan wrote: > Are you using a Cygwin build of Python? Trying to mix Cygwin with > normal Windows programs doesn't usually work very well. On 22/07/11 06:41, Sathish S wrote: > Benjamin thanks for replying. i'm not using the python that comes wi

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread Thomas Jollans
On 22/07/11 13:12, caccolangrifata wrote: > I'm very very new with python, and I have some experience with java > programming, so probably you guys will notice. > Anyway this is my question: > I'd like to use class scope vars in method parameter, something like > that > > class foo(object): > >

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread Thomas Jollans
On 22/07/11 13:32, Karim wrote: > > I think you did a typo > > it is > > def foo2(self, len = self._myvar): >while i< len: > dosomething > That, of course, won't work: the default argument (in this case: "self._myvar") is looked up when the function is created, and stored with th

Re: Question about timeit

2011-07-22 Thread Thomas Jollans
On 22/07/11 14:30, Frank Millman wrote: > This is what I get after modifying timeit.py as follows - > > if args is None: > args = sys.argv[1:] > + print(args) > > C:\>python -m timeit int(float('165.0')) > ["int(float('165.0'))"] > 10 loops, best of 3: 3.43 usec per loop >

Re: compiling qt app extensions with distutils

2011-07-22 Thread Thomas Jollans
On 22/07/11 15:43, strattonbrazil wrote: > I'd like to extend my C++ Qt applicaition using distutils. Looking > over the tutorial docs (http://docs.python.org/extending/ > building.html#building), it seems fairly intuitive for simple > examples, but I'm already using a rather complex qmake/Makefil

Re: compiling qt app extensions with distutils

2011-07-22 Thread Thomas Jollans
spend too > much time trying to figure out out to create a Qt extension-- > especially since it looks like few others have actually done it. Is > there a way to build a simple python module from my existing > makefile? Or should I just stick with embedding for now using the &

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread Thomas Jollans
On 22/07/11 20:38, rantingrick wrote: > On Jul 22, 10:43 am, "bruno.desthuilli...@gmail.com" > wrote: >> >> class names should start with an uppercase letter: > > WRONG! Class identifiers should use the capwords convention > All CamelCase names start with an uppercase letter. You "WRONG!" is wr

Re: Use self.vars in class.method(parameters, self.vars)

2011-07-22 Thread Thomas Jollans
>> 2/ the argument name ('len') will shadow the builtin 'len' function >> within this function's scope. >> >>> self.__myvar = len > > I have experience in java programming so using function calling > without () is foolish for me XD, but that a great suggestion No function is being

Re: run a script getting 4 arguments from another script

2011-07-22 Thread Thomas Jollans
s a plain directory into a package that Python recognises. What you actually have is this: ./ SpO2Sweep.loop.py (That won't work) Since Python treats periods specially, and names in Python cannot contain periods (the special meaning of '.' trumps), you can never import a file with that name. - Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: compiling qt app extensions with distutils

2011-07-22 Thread Thomas Jollans
On 22/07/11 21:37, strattonbrazil wrote: >> Okay, your terminology was confused: you want to extend Python, not your >> application. > > Sorry, after I sent that e-mail, I realized I had already mixed up the > terms, where I should have written "embedding". > >> First of all, you don't technicall

Re: Strings show as brackets with a 'u'.

2011-07-23 Thread Thomas Jollans
On 24/07/11 02:52, Dan Stromberg wrote: > > It's probably a list containing a single unicode string. > > You can pull the first element from the list with n[0]. > > To print a unicode string in 2.x without the u stuff: > > print u'174'.encode('ISO-8859-1') just >>> print u'174' will do. Encod

Re: How to catch an memory error in Windows?

2011-07-25 Thread Thomas Jollans
he Python part? Also, "no memory left" is not necessarily an error, it's simply a fact of life. How to catch it depends on how you're (here, "you" means the external process) allocating the memory - The POSIX C malloc function will return NULL and set errno to ENOMEM,

Re: PEP 8 and extraneous whitespace

2011-07-25 Thread Thomas Jollans
In the end, it really doesn't matter. This is probably why I enjoyed writing this message so much. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Trying to learn about metaclasses

2011-07-26 Thread Thomas Jollans
On 26/07/11 04:44, Victor Khangulov wrote: > Hi Steven, > > I too am just learning about metaclasses in Python and I found the > example you posted to be excellent. > > I played around with it and noticed that the issue seems to be the > double-underscore in front of the fields (cls.__fields = {}

Re: problem in compiling C API in mingw

2011-07-26 Thread Thomas Jollans
On 27/07/11 01:53, llwa...@gmail.com wrote: > > $ python setup.py build --compiler=mingw32 > running build > running build_ext > building 'example' extension > D:\Programs\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall "-Ic:\Program Files > (x8 > 6)\Python\include" "-Ic:\Program Files (x86)\Python\

Re: @PyNoobs: The Fundamental Five Built-in Functions, and Beyond!

2011-07-26 Thread Thomas Jollans
Beyond! On 27/07/11 02:01, rantingrick wrote: > -- > 1. help() > -- > -- > 2. dir() > -- Pro tip: the "I

Re: Only Bytecode, No .py Files

2011-07-27 Thread Thomas Rachel
) stat64("/lib/bash/4.1/i686", 0xbfe0c4d0) = -1 ENOENT (No such file or directory) open("/lib/bash/4.1/sse2/libreadline.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/lib/bash/4.1/sse2", 0xbfe0c4d0) = -1 ENOENT (No such file or directory) open("/lib/bash/4.1/libreadline.so.6", O_RDONLY) = -1 ENOENT (No such file or directory) stat64("/lib/bash/4.1", 0xbfe0c4d0) = -1 ENOENT (No such file or directory) open("/etc/ld.so.cache", O_RDONLY) = 3 So can it really be such a huge problem? Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Only Bytecode, No .py Files

2011-07-27 Thread Thomas Rachel
d test for the existence of optional files by trying to open them. This may be what Bash is doing. ACK. That is exactly what I wanted to show. (With the difference that this is probably nt the bash, but the linux loader trying to link a .so, but for the problem, it doesn't make any difference.) Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I access IDLE in Win7

2011-07-27 Thread Thomas Jollans
or the error, see if there is file /users/wayne/idlerc/recent-files.lst And if there is, delete it. Or even delete the whole folder «idlerc». IDLE should be able to cope with it not being there at all: it wouldn't be there the first time IDLE is started by a user. - Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: PyWart: PEP8: A cauldron of inconsistencies.

2011-07-27 Thread Thomas Jollans
On 28/07/11 00:34, rantingrick wrote: > I believe the current Python style guide is inconsistent. The author > again allowed hie emotion to get in the way of logic. If you think that logic can be the foundation of a style [guide], then you have a very curious idea of what "logic" means. > [ snip

Re: How do I access IDLE in Win7

2011-07-28 Thread Thomas Jollans
On 2011-07-28 13:56, W. eWatson wrote: On 7/27/2011 9:46 PM, Dennis Lee Bieber wrote: {and that was captured by a in the command window, "select all", another to capture, then move to the newreader and to paste} I'm quite willing to do this in the command window, but I know of no way to co

Re: Is it bad practise to write __all__ like that

2011-07-28 Thread Thomas Rachel
(): pass @__all__ def db(): pass @__all__ def input(): pass @__all__ def output(): pass @__all__ def tcl(): pass HTH, Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: multilanguage application - step by step

2011-07-28 Thread Thomas Jollans
I used gettext in xmm2tray. You can have a look at the code as an example: http://code.jollybox.de/hg/xmms2tray/file/04443c59a7a1/src/xmms2tray/__init__.py On 2011-07-28 12:12, Peter Irbizon wrote: I tried this: # -*- coding: utf-8 -*- import gettext gettext.bindtextdomain('multilanguage', 'E:\f

Re: gettext localize strings with variables

2011-07-28 Thread Thomas Jollans
On 28/07/11 15:33, miamia wrote: > Hello, > I have > variable OUHH and > print _('This is %(OUHH)s a translatable string.' % locals()) > > how can I translate this ? Get the translation first, insert values second. _('This string contains a variable: {0}. Amazing').format(OUHH) Depending on wha

Re: Is it bad practise to write __all__ like that

2011-07-28 Thread Thomas Rachel
h the more readable @export def func(): pass Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: multilanguage application - step by step

2011-07-29 Thread Thomas Jollans
On 29/07/11 11:18, Peter Irbizon wrote: > Hello Thomas, > > > The usual way of using gettext is to use the system locale to determine > > the right language. Of course, you can have different translations and > > install() them (I expect), but you'll have to re-load

Re: Only Bytecode, No .py Files

2011-07-29 Thread Thomas Rachel
s not a good idea for an "audit tool" to report all failing open() calls and that the OP's "problem" is none, at least not one related to Python. No more, no less. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: change gtk STOCK_SAVE label text on the fly

2011-07-29 Thread Thomas Jollans
On 29/07/11 13:02, Peter Irbizon wrote: > Hello, > > how could I change STOCK_SAVE label text? I would like to have "Save > it!" instead of "Save" > And other question related to this is how can I change translation of > STOCK_SAVE on the fly? I think I need to set locale for pygtk...but > don't

Re: regex question

2011-07-29 Thread Thomas Jollans
is that match assumes that the start of the regex coincides with the start of the string (and this is documented in the library docs IIRC). re.match(exp, s) is equivalent to re.search('^'+exp, s). (if not exp.startswith('^')) Apparently, findall() returns the content of the first group if there is one. I didn't check this, but I assume it is documented. - Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: How object's setattr differs from inherited?

2011-07-29 Thread Thomas Rachel
7;__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__'] What are the differences? ['__dict__', '__module__', '__weakref__'] As the attributes are stored in __dict__, I would suppose that it is __dict__ which makes the difference. object() has no such and therefore there is no place to save an attribute. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: How object's setattr differs from inherited?

2011-07-29 Thread Thomas Jollans
lt, Jul 11 2011, 12:37:49) [GCC 4.6.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> >>> class Foo: ... __slots__ = ['a', 'b'] ... >>> f = Foo() >>> f.a = 1 >>> f.b = 1 >>> f.c = 2 Traceback (most recent call last): File "", line 1, in AttributeError: 'Foo' object has no attribute 'c' >>> - Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: What is xrange?

2011-07-29 Thread Thomas Jollans
ist-like indices, the iterator protocol, and probably a few other things that you will find in the stdlib docs. Generators also support the iterator protocol, but that's about as far as the similarity goes (in general) - Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: regex question

2011-07-29 Thread Thomas Jollans
On 29/07/11 19:52, Rustom Mody wrote: > MRAB wrote: > > findall returns a list of tuples (what the groups captured) if there > is more than 1 group, > > or a list of strings (what the group captured) if there is 1 group, > or a list of > > strings (what the regex matched) if there are no groups. >

Re: change gtk STOCK_SAVE label text on the fly

2011-07-29 Thread Thomas Jollans
On 30/07/11 00:29, Peter Irbizon wrote: >> (Don't feel you need to answer this: Do you really think you need > on-the-fly language switching? It's "cool", but how many users are going > to want to use that?) > yes, you're right. anyway it's cool feature and I hoped it's easy to do > it in python /

Re: Windows: setting title of console window

2011-07-30 Thread Thomas Jollans
On 30/07/11 20:39, Ethan Furman wrote: > How it works: since the sys.argv object does yet exist, I create an > object and assign it to sys.argv; then, when Python assigns the actual > argv to sys.argv, my object is tossed, and the __del__ method is called; > the __del__ method is then able to acces

Re: Notifications when process is killed

2011-08-01 Thread Thomas Jollans
P (for when the controlling terminal is lost, which usually causes a process to quit) I'm assuming you're using a UNIX-like system - Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: where the function has problem? n = 900 is OK , but n = 1000 is ERROR

2011-08-01 Thread Thomas Rachel
eep. If you "pre-calculate" the stuff before, calling fibo(n/2) before the line with 'print "Fibo(" + str(n) + ") = " + str(fibo(n))', it succeeds. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: python reading file memory cost

2011-08-01 Thread Thomas Jollans
) records in memory? With generators, Python has excellent support for working with streams of data like this. (and it would save you a lot of RAM) - Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: test systems

2011-08-01 Thread Thomas Jollans
Linux/RHEL/other RHEL rebuild), Ubuntu LTS release and, perhaps: (3) bleeding edge - Arch / Gentoo You may also want to consider non-current releases. If I had to chose three, it might be Ubuntu 11.04, Debian 6, and CentOS 5. - Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Notifications when process is killed

2011-08-02 Thread Thomas Rachel
Am 02.08.2011 09:30 schrieb AndDM: The function works for SIGHUP and SIGINT, but it doesn't work for SIGTERM. I've tried with simple killall and with -15 option. Have you some ideas? SIGTERM cannot be caught - it kills the process the hard way. HTH, Thomas -- http://mail.python.o

Re: range() vs xrange() Python2|3 issues for performance

2011-08-02 Thread Thomas Rachel
cline that. The behaviour, though, seems to be the same, but range3 (as I call it now) has some more methods than xrange, like the rich comparison ones. Indexing works with all of them. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Hardlink sub-directories and files

2011-08-02 Thread Thomas Jollans
to mkdir everything. However, there is an easier way: subprocess.Popen(['cp','-Rl','target','link']) This is assuming that you're only supporting Unices with a working cp program, but as you're using hard links, that's quite a safe bet, I should think. - Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: python reading file memory cost

2011-08-02 Thread Thomas Jollans
On 02/08/11 13:00, 张彤 wrote: > Thanks Peter! Your explanation is great! > And one more question: > Why it is still keeping the memory even when I del the large array in > interactive python mode? This is an optimisation of the way the Python interpreter allocates memory: it holds on to memory it's

Re: Notifications when process is killed

2011-08-02 Thread Thomas Rachel
Am 02.08.2011 10:26 schrieb Thomas Rachel: Am 02.08.2011 09:30 schrieb AndDM: The function works for SIGHUP and SIGINT, but it doesn't work for SIGTERM. I've tried with simple killall and with -15 option. Have you some ideas? SIGTERM cannot be caught - it kills the process th

Re: Early binding as an option

2011-08-02 Thread Thomas Jollans
n to make sense, or even which names are looked up at all. I think this effect can only, and best, be achieved in Python by binding relevant globals as locals in the module, and documenting which these are for the benefit of users who might want to change builtins, and would have to do it before imp

Re: Early binding as an option

2011-08-02 Thread Thomas Jollans
On 02/08/11 19:42, Chris Angelico wrote: > On Tue, Aug 2, 2011 at 6:18 PM, Thomas Jollans wrote: >> I suppose it would be possible to introduce a kind of "constant >> globals" namespace that a JIT compiler could then use to optimise, but >> how much would this help?

Re: how to sort a hash list without generating a new object?

2011-08-02 Thread Thomas Jollans
On 02/08/11 20:02, smith jack wrote: > the source code is as follows > > x={} > x['a'] = 11 > x['c'] = 19 > x['b'] = 13 > print x > > tmp = sorted(x.items(), key = lambda x:x[0])# increase order by > default, if i want to have a descending order, what should i do? > # after sorted is called,

Re: Hardlink sub-directories and files

2011-08-03 Thread Thomas Jollans
On 03/08/11 03:59, Dan Stromberg wrote: > > On Tue, Aug 2, 2011 at 3:13 AM, Thomas Jollans <mailto:t...@jollybox.de>> wrote: > > On 02/08/11 11:32, loial wrote: > > I am trying to hardlink all files in a directory structure using > > os.link. >

Re: Early binding as an option

2011-08-03 Thread Thomas Jollans
smart enough, so a good Python JIT could be as well. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: with statement and context managers

2011-08-03 Thread Thomas Rachel
aid, take threading.Lock as an example: they can be acquire()d and release()d as often as you want, and these actions happen in __enter__() and __exit__(), respectively. HTH, Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Hardlink sub-directories and files

2011-08-03 Thread Thomas Jollans
On 03/08/11 16:22, Grant Edwards wrote: > On 2011-08-03, Kushal Kumaran wrote: >> I suppose it is a good thing systems don't allow that now. > > It wouldn't be a problem, except there are some important places in > Unix where it is assume that filesystems are trees. Hard linking > directories ca

Re: Snippet: The leanest Popen wrapper

2011-08-03 Thread Thomas Jollans
On 03/08/11 17:29, Phlip wrote: > Groupies: > > This is either a code snippet, if you like it, or a request for a > critique, if you don't. > > I want to call a command and then treat the communication with that > command as an object. And I want to do it as application-specifically > as possible

Re: Equality check

2011-08-03 Thread Thomas Jollans
On 03/08/11 18:22, Abhishek Jain wrote: > How to check equality of two nos. in python > > http://docs.python.org/py3k/reference/expressions.html#not-in http://docs.python.org/py3k/tutorial/index.html -- http://mail.python.org/mailman/listinfo/python-list

Re: Hardlink sub-directories and files

2011-08-03 Thread Thomas Jollans
On 03/08/11 18:29, Dan Stromberg wrote: > > On Wed, Aug 3, 2011 at 2:47 AM, Thomas Jollans <mailto:t...@jollybox.de>> wrote: > > Is it more portable? I don't actually have cpio installed on this > system. > > > Interesting. Of course, it'

Re: Hardlink sub-directories and files

2011-08-03 Thread Thomas Jollans
On 03/08/11 23:25, Dan Stromberg wrote: > > On Wed, Aug 3, 2011 at 11:49 AM, Thomas Jollans <mailto:t...@jollybox.de>> wrote: > > > > Interesting. Of course, it's probably readily available to you. What > > *ix are you seeing that doesn't i

Re: Snippet: The leanest Popen wrapper

2011-08-04 Thread Thomas Rachel
ke this. As you generally cannot know what ugly things the user of your program does, it is better to avoid the additional shell layer. So generally agree to what you say, but it is not the proper shell escaping one should worry about (it is so simple that one cannot call it "worry"), but the type of shell one talks with. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Snippet: The leanest Popen wrapper

2011-08-04 Thread Thomas Rachel
ine = sp.stdout.readline # if you want so: line = lambda: sp.stdout.readline().rstrip() - which # might lose information as well... print 'lines' print line() print line() print line() print 'all' print list(line.s()) print list(iter(line, '')) Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Snippet: The leanest Popen wrapper

2011-08-04 Thread Thomas Rachel
hings are harmless when included in ''s. $ echo '`rm -rf .`' '$RANDOM' `rm -rf .` $RANDOM Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: ImportError: No module named PyQt4.QtGui

2011-08-04 Thread Thomas Jollans
On 04/08/11 11:39, 守株待兔 wrote: > i have installed such things: > > sudo apt-get install libqt4-dev > sudo apt-get install g++ automake > sudo apt-get install qt4-dev-tools qt4-designer qt4-doc > sudo apt-get install libqt4-opengl-dev > sudo apt-get install libqt4-sql-mysql libqt4-sql-odbc libqt4-

Re: PIL question. having exactly same font on multiple platforms

2011-08-04 Thread Thomas Jollans
aracters at known coordinates - or a load of small bitmaps) Why do you need the images to be identical to the pixel anyway? Surely, if it's about comparing the text, you would just compare the strings? And if it's only for displaying the text, then why bother with details like that as long as it looks good? - Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Observations on the three pillars of Python execution

2011-08-05 Thread Thomas Jollans
On 05/08/11 09:20, Eric Snow wrote: > Object available during code object execution: > (M) no > (C) no > (F) no (F) yes. cf. recursion. -- http://mail.python.org/mailman/listinfo/python-list

Re: Embedded python console and FILE* in python 3.2

2011-08-08 Thread Thomas Jollans
;1/0" the result should be > > Traceback (most recent call last): > File "", line 1, in > ZeroDivisionError: division by zero > > > Thank you, > > F.L. > > I assume you could simply use PyFile_FromFd? The more elegant solution might be to create custom Python file-like objects for std{in,out,err} that communicate directly with your application. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Embedded python console and FILE* in python 3.2

2011-08-08 Thread Thomas Jollans
On 08/08/11 19:14, F L wrote: >> Is the `code` module (http://docs.python.org/library/code.html) an > insufficiently exact copy of an interpreter for you? > > The problem isn't really to emulate the behavior of the interpreter as > to obtain the result of the execution as a string in c++. > The c

Re: Embedded python console and FILE* in python 3.2

2011-08-08 Thread Thomas Jollans
On 08/08/11 19:44, Thomas Jollans wrote: > If you use the same workflow as you do currently, it won't: > > 1. Feed input to your custom stdin object, which will buffer the code. > 2. Call PyRun_IteractiveOne - it will read from your object, which will >return the buffe

Re: Restricted attribute writing

2011-08-10 Thread Thomas Jollans
the option of not checking vigorously at all at that point: If the value is invalid, it will raise an exception later, when it is used. Depending on what you're doing, this might be all the checking you need. If you're going to serialise the data, or if you want to use the property sett

Re: subprocess.Popen and thread module

2011-08-10 Thread Thomas Rachel
part) and then wait(). Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: allow line break at operators

2011-08-12 Thread Thomas Rachel
6", meaning "no READ without DATA"... same as "READ Y". Thomas, it was a long time ago... -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess.Popen question

2011-08-16 Thread Thomas Rachel
Am 16.08.2011 09:03 schrieb Danny Wong (dannwong): Hi All, I'm executing a command which I want to capture the standard/stderr output into a file (which I have with the code below), but I also want the standard output to go into a variable so I can process the information for the next com

Re: Replacement for the shelve module?

2011-08-19 Thread Thomas Jollans
ydbm in Python2; this is what shelve uses), or simple the file system: one file per serialised object. Looking at your use case, however, I think what you really should use is a SQL database. SQLite is part of Python and will do the job nicely. Just use a single table with three columns: symbol, date, value. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: PUT with proxy-support

2011-08-25 Thread Thomas Jollans
hat you tried, what actually happened, including any error messages in full, and what you wanted to happen. Thomas > I managed to do this via command line curl: > > $ curl http:/xyz.com/testing/shashwat/test.txt > <http://xyz.com/testing/shashwat/test.txt> -T test.txt -H &

Re: Catch and name an exception in Python 2.5 +

2011-08-26 Thread Thomas Jollans
> I'm pretty sure there isn't, but I thought I'd ask just in case. It's not elegant, and I haven't actually tested this, but this should work: try: ... except (ValueError, KeyError): error = sys.exc_info()[2] -- Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Catch and name an exception in Python 2.5 +

2011-08-27 Thread Thomas Jollans
On 27/08/11 05:45, Steven D'Aprano wrote: > Thomas Jollans wrote: > >> On 26/08/11 21:56, Steven D'Aprano wrote: > >>> Is there any way to catch an exception and bind it to a name which will >>> work across all Python versions from 2.5 onwards? >>

Re: Why do closures do this?

2011-08-28 Thread Thomas Jollans
n what has since happened in the parent function. That may not be as common, but it is a perfectly plausible situation, and the hack required to support that behaviour in a Python that acts as you had expected it to, a surrogate namespace using a class, list, or dict, is infinitely more cryptic and ugly than the default-parametre hack. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: killing a script

2011-08-29 Thread Thomas Jollans
On 2011-08-29 05:08, Russ P. wrote: Yes, but if I am not mistaken, that will require me to put a line or two after each os.system call. That's almost like whack-a-mole at the code level rather than the Control-C level. OK, not a huge deal for one script, but I was hoping for something simpler.

Re: Help parsing a text file

2011-08-29 Thread Thomas Jollans
might be "start/end record", "field data", etc. That way, you could separate the code that keeps track of the current record, and how the data fits together to make an object structure, and the parsing code, that knows how to convert a line of data into something meaningful. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: fun with nested loops

2011-09-01 Thread Thomas Rachel
or which immediately runs the given functions, after adding the needed exception classes. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Detecting Ctrl-Alt-Del in Windows

2011-09-02 Thread Thomas Jollans
ugh the individual window manager. As m'colleague Nobody mentions, there's also the SysRq feature, but that always goes straight to the kernel and is, like Ctrl+Alt+Delete on Windows, impossible to handle in userspace code. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Hello, and request for help with 'dynamic grids'

2011-09-05 Thread Thomas Jollans
hat similar to MS Access) - and they can be scripted using Python. Depending on what you're doing, and what you're planning to do in the future (re learning investment), that might be worth looking into. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: One line command line filter

2011-09-05 Thread Thomas Jollans
On 05/09/11 22:38, Jon Redgrave wrote: > It seems unreasonably hard to write simple one-line unix command line > filters in python: > > eg: ls | python -c " print x.upper()" > > to get at sys.stdin or similar needs an import, which makes a > subsequent for-loop illegal. > python -c "import sys;

Re: Floating point multiplication in python

2011-09-06 Thread Thomas Rachel
Am 06.09.2011 07:57 schrieb xyz: hi all: As we know , 1.1 * 1.1 is 1.21 . But in python ,I got following : 1.1 * 1.1 1.2102 why python get wrong result? Who can tell me where's the 0.0002 from? 1.1 does not fit in a binary floating point number. It is approximate

Re: Portable locale usage

2011-09-06 Thread Thomas Jollans
e status of locale.locale_alias (official documentation > does not mention it)? I don't know, but I'd assume it's not considered part of the public API, and you that shouldn't assume that it'll exist in future versions of Python. Thomas -- http://mail.python.org/mailman/listinfo/python-list

<    1   2   3   4   5   6   7   8   9   10   >