Re: Which way is best to execute a Python script in Excel?

2012-07-07 Thread Thomas Jollans
On 07/07/2012 11:05 AM, Maurizio Spadaccino wrote: > Thanks again Emile, I'll try out some examples. I found this one: > http://showmedo.com/videotutorials/video?name=2190050&fromSeriesID=219 > quite enlightning. > One last doubt is: say the python code gets used by more Excel Users > (different

Re: PyEval_SetProfile usage ?

2012-07-07 Thread Thomas Jollans
On 07/06/2012 11:40 PM, Salman Malik wrote: > Hi All, > > I have used the Python's C-API to call some Python code in my c code and > now I want to know how much time does my Python part of the program > takes. I came across the PyEval_SetProfile API and am not sure how to > use it. Do I need to wr

Re: Socket code not executing properly in a thread (Windows)

2012-07-07 Thread Thomas Jollans
d processes in sequence. (This sounds to me like an application better implemented thread-less, using select() or some method of asynchronous I/O. Just a shame that Python makes neither at all pleasant and leaves threads as the nicest option) Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Socket code not executing properly in a thread (Windows)

2012-07-08 Thread Thomas Jollans
On 07/08/2012 11:03 AM, Andrew D'Angelo wrote: > Also, running the sned to socket code inside the main loop would not work, > as the main loop pauses until it recieves data from the socket (an IRC > message), which is why I didn't put the SMS code in the main loop in the > first place. http://

Re: What's wrong with this code?

2012-07-24 Thread Thomas Rachel
uld only modify these objects (not possible as ints are immutable), you would notice the changes here and there. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: the meaning of r`.......`

2012-07-24 Thread Thomas Rachel
t all of them on your keyboard. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: What's wrong with this code?

2012-07-24 Thread Thomas Rachel
But even those don't do that under all circumstances. Think about __setitem__, __setattr__, __set__, __delitem__, __delattr__, __delete__. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Error

2012-07-29 Thread Thomas Jollans
On 07/29/2012 02:30 PM, subhabangal...@gmail.com wrote: > Thanks for the answer. But my list does not contain another list that is the > issue. Intriguing. Thinking what to do. What does your list contain? Can you reproduce the issue in a few self-contained lines of code that you can show us, th

newbie: write content in a file (server-side)

2012-07-29 Thread Thomas Kaufmann
Hi, I send from a client file content to my server (as bytes). So far so good. The server receives this content complete. Ok. Then I want to write this content to a new file. It works too. But in the new file are only the first part of the whole content. What's the problem. o-o T

Re: newbie: write content in a file (server-side)

2012-07-30 Thread Thomas Kaufmann
Am Sonntag, 29. Juli 2012 17:16:11 UTC+2 schrieb Peter Otten: > Thomas Kaufmann wrote: > > > > > I send from a client file content to my server (as bytes). So far so good. > > > The server receives this content complete. Ok. Then I want to write this > > >

Re: newbie: write content in a file (server-side)

2012-07-30 Thread Thomas Kaufmann
Am Sonntag, 29. Juli 2012 16:16:01 UTC+2 schrieb Thomas Kaufmann: > Hi, > > > > I send from a client file content to my server (as bytes). So far so good. > > The server receives this content complete. Ok. Then I want to write this > content to a new file. It works

Re: On-topic: alternate Python implementations

2012-08-04 Thread Thomas Rachel
are Python and Cython. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Unexpected behavior using contextmanager on a class method

2012-08-07 Thread Thomas Draper
I want to use with..as in a "reversible circuit generator". However, it seems that @contextmanager changes the expected nature of the class. I tried to distill the problem down to a simple example. import contextlib class SymList: def __init__(self, L=[]): self.L = L @contextli

Python and OSX 10.8

2012-08-09 Thread David Thomas
Im looking to upgrade my Mac to 10.8 and I'm worried if Python and IDLE may not run on it. When I try to run this command in Terminal: python -m idlelib.idle I can not launch IDLE which comes bundled on Mac. On Lion it's been fine but I've tried it on my friend's copy of Mountain Lion and it wil

Re: suggesting a launcher wrapper script for portable python

2012-08-12 Thread Thomas Jollans
ripts to write the launchers. I.e. use JScript or VBScript to do exactly the same thing. I don't know much about Windows shortcut (*.lnk) files; if they can contain relative paths, you could just create shortcuts that launch portable python with the script. Thomas -- http://mail.python.o

Dynamically determine base classes on instantiation

2012-08-15 Thread Thomas Bach
def do_something(self): # do something on self._obj pass Which seems ugly. Is there a way to provide the functions of `list' and `dict' in Foo's look-up path without having to write all the stubs myself? Regards, Thomas Bach. -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamically determine base classes on instantiation

2012-08-16 Thread Thomas Bach
e on the logical level. > Instead, Foo should implement only the shared operations, and everything > else should be delegated to _obj. > > If you inherit from builtins, you cannot use automatic delegation on the > magic "double-underscore" (dunder) methods like __eq__, __len__,

Re: Dynamically determine base classes on instantiation

2012-08-16 Thread Thomas Bach
On Thu, Aug 16, 2012 at 05:10:43PM +0200, Hans Mulder wrote: > On 16/08/12 14:52:30, Thomas Bach wrote: > > > > So, my question (as far as I can see it, please correct me if I am > > wrong) is less of the "How do I achieve this?"-kind, but more of the > > &q

Re: Dynamically determine base classes on instantiation

2012-08-16 Thread Richard Thomas
have __new__ make these Foo* classes dynamically when it encounters a new type of argument. Chard. On Thursday, 16 August 2012 18:54:12 UTC+2, Thomas Bach wrote: > On Thu, Aug 16, 2012 at 05:10:43PM +0200, Hans Mulder wrote: > > > On 16/08/12 14:52:30, Thomas Bach wrote: > > &g

Re: Dynamically determine base classes on instantiation

2012-08-16 Thread Richard Thomas
> a is a Foo > b is a Foo > therefore a and b are the same type What you mean here is "a and b share a common base class". -- http://mail.python.org/mailman/listinfo/python-list

Re: Dynamically determine base classes on instantiation

2012-08-16 Thread Thomas Bach
On Thu, Aug 16, 2012 at 12:29:21PM -0400, Dennis Lee Bieber wrote: > On Thu, 16 Aug 2012 14:52:30 +0200, Thomas Bach > declaimed the following in > gmane.comp.python.general: > > Of course, since the parse result (at least from my recent > experiment) is a Python s

Re: Dynamically determine base classes on instantiation

2012-08-16 Thread Thomas Bach
On Thu, Aug 16, 2012 at 10:03:51AM -0700, Richard Thomas wrote: > class Foo(object): > def __new__(cls, arg): > if isinstance(arg, list): > cls = FooList > elif isinstance(arg, dict): > cls = FooDict > return object.__new__

Re: Dynamically determine base classes on instantiation

2012-08-17 Thread Richard Thomas
On Thursday, 16 August 2012 19:49:43 UTC+2, Steven D'Aprano wrote: > On Thu, 16 Aug 2012 10:03:51 -0700, Richard Thomas wrote: > > > > > class Foo(object): > > > def __new__(cls, arg): > > > if isinstance(arg, list): > > >

Re: Parsing ISO date/time strings - where did the parser go?

2012-09-06 Thread Thomas Jollans
On 09/06/2012 09:27 PM, John Nagle wrote: > In Python 2.7: > >I want to parse standard ISO date/time strings such as > > 2012-09-09T18:00:00-07:00 > > into Python "datetime" objects. The "datetime" object offers > an output method , datetimeobj.isoformat(), but not an input > parser.

Re: set and dict iteration

2012-09-08 Thread Thomas Rachel
not a direct cycle, but an indirect one. Or would that be detected via the list? Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Does os.getcwd() and os.curdir have the same effect ?

2012-09-09 Thread Thomas Jollans
On 09/09/2012 03:22 PM, iMath wrote: > Does os.getcwd() and os.curdir have the same effect ? > Python 3.2.3 (default, May 3 2012, 15:51:42) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.getcwd() '/home/tjol' >>> os.curdir '.' >>

Re: generators as decorators simple issue

2012-09-11 Thread Thomas Rachel
Am 12.09.2012 04:28 schrieb j.m.dagenh...@gmail.com: I'm trying to call SetName on an object to prevent me from ever having to call it explictly again on that object. Best explained by example. def setname(cls): '''this is the proposed generator to call SetName on the object''' try:

Re: how to get os.py to use an ./ntpath.py instead of Lib/ntpath.py

2012-09-11 Thread Thomas Rachel
effective as long as you are in the relevant code part and is reverted as soon as you leave it. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Decorators not worth the effort

2012-09-15 Thread Thomas Rachel
nc(*a, **k), func(*a, **k) can be used with @twice def f(x): print (x); return x very nicely. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: using text file to get ip address from hostname

2012-09-17 Thread Thomas Rachel
s you a list of parameter tuples for connecting. So which way you go above, you should change the respective lines to for line in ...: hostname = line.strip() for target in socket.getaddrinfo(hostname, 0, socket.AF_UNSPEC, socket.SOCK_STREAM): print("IP address fo

Re: Decorators not worth the effort

2012-09-18 Thread Thomas Rachel
Am 15.09.2012 16:18 schrieb 8 Dihedral: The concept of decorators is just a mapping from a function ... or class ... > to another function ... or any other object ... > with the same name in python. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: User defined lexical scoping... can I do this?

2012-09-18 Thread Thomas Jollans
On 09/18/2012 10:10 PM, porkfried wrote: > I want to define a 'with' command that makes entries > in dictionary available within the local scope, and > stores new local variables into that dictionary. The > original scope should be restored on exit, and called > functions should not see anything s

Re: User defined lexical scoping... can I do this?

2012-09-18 Thread Thomas Jollans
On 09/18/2012 10:50 PM, weissman.m...@gmail.com wrote: > Well there's wired stuff like this: > > In [1]: locals()["x"] = 5 > > In [2]: print x > 5 > No, there isn't. Modifying the dictionary returned by locals() has no effect. >>> def f (): ... locals()["x"] = 1 ... return x ... >>> f

Re: 'indent'ing Python in windows bat

2012-09-19 Thread Thomas Rachel
can be used this way: bat cmds python -m thismodule cmd1 a b other bat cmds python -m thismodule cmd2 ... HTH, Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Using dict as object

2012-09-19 Thread Thomas Rachel
ect() d.a = 1 print d['a'] # This results in d.__dict__['a'] = 1. # As d.__dict__ is d, this is equivalent to d['a'] = 1. # Now the other way: d['b'] = 42 print d.b # here as well: d.b reads d.__dict__['b'], which is essentially d['b']. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: How to apply the user's HTML environment in a Python programme?

2012-09-22 Thread Thomas Jollans
ascriptissexy.com/how-to-learn-javascript-properly/ http://pyjs.org/ may be worth a look too. -- Thomas PS: Most of your messages appear to be both To: and Cc: this list. Please stop sending each message twice, it's rather distracting. -- http://mail.python.org/mailman/listinfo/python-list

Re: which a is used?

2012-09-24 Thread Thomas Rachel
): self.a = 20 print self.a a = a(1) a.f() a.g() Yes - this is a different situation. Here, the "self" referred to is the same in all cases (the "a" from top level), and so self.a can be used consistently as well. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: which a is used?

2012-09-24 Thread Thomas Rachel
smell. Where did he so? Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: python file API

2012-09-24 Thread Thomas Rachel
lse: self.seek(o, 1) # yes, it is Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: python file API

2012-09-24 Thread Thomas Rachel
only sets bit 7, OUTTGL = 0x10 toggles it and OUTCLR = 0x10 clears it. If this behaviour is documented properly enough, it is quite OK, IMHO. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: which a is used?

2012-09-24 Thread Thomas Rachel
they refer to. If you was really insulted, you should answer to these insults in their thread and not in a different one. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: For Counter Variable

2012-09-24 Thread Thomas Rachel
e, I skipped my re-written version and used the built-in. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: python file API

2012-09-25 Thread Thomas Rachel
work with any device where 0x10 (0001 binary) modifies bit SEVEN. 0x40, OTOH, would fit my mental impression of bit 7. Of course. My fault. It can as well be a bit mask, with OUTTGL = 0x11 toggling bit 4 and bit 0. Very handy sometimes. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: python file API

2012-09-25 Thread Thomas Rachel
eplace the tell/seek API, and -0 on adding a second, redundant API. ACK. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: data attributes override method attributes?

2012-09-25 Thread Thomas Rachel
>>> t.b trying to get value - return None >>> t.a=12 >>> t.b=12 value 12 ignored. >>> t.a 12 >>> t.b trying to get value - return None >>> del t.a >>> del t.b delete called and ignored >>> t.a > >>> t.b trying to get value - return None Thomas -- http://mail.python.org/mailman/listinfo/python-list

Slicing iterables in sub-generators without loosing elements

2012-09-29 Thread Thomas Bach
s itertools.takewhile consumes the first entry not fulfilling the pred. I currently have the intuition that the problem is not solvable without using e.g. a global to pass something back to iter_in_blocks from block_iter. Any other suggestions? Regards, Thomas Bach. -- http://mail.python.org/mailman/listinfo/python-list

Re: Slicing iterables in sub-generators without loosing elements

2012-09-29 Thread Thomas Bach
On Sat, Sep 29, 2012 at 09:26:00AM -0700, Paul Rubin wrote: > Thomas Bach writes: > > itertools.groupby(data, lambda (x,y) : x) > > is basically what you want. True! Thanks, Thomas Bach -- http://mail.python.org/mailman/listinfo/python-list

Re: unit testing class hierarchies

2012-10-02 Thread Thomas Bach
stD2? To me it sounds like test_base() is actually no test. Hence, I would rather give it a catchy name like _build_base_cls(). If a method name does not start with 'test' it is not considered a test to run automatically. Does this help? Regards, Thomas Bach. -- http://mail.python.org/mailman/listinfo/python-list

Re: fastest data structure for retrieving objects identified by (x, y) tuple?

2012-10-04 Thread Thomas Rachel
es printed will depend on how sparse the matrices are, but for the same above (approximately half full), I wouldn't consider 1000 of 576 "half full"... Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Unpaking Tuple

2012-10-08 Thread Thomas Bach
t;>> head ['foo', 'bar'] >>> tail >>> I don't get it! Could someone help me, please? Why is head not 'foo' and tail not 'bar'? Regards, Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: How to use "while" within the command in -c option of python?

2012-10-13 Thread Thomas Bach
a simple statement separated by a semicolon.”, right? Regards, Thomas Bach. -- http://mail.python.org/mailman/listinfo/python-list

Re: overriding equals operation

2012-10-16 Thread Thomas Rachel
mmunication is for informational purposes only. It is not intended to be, nor should it be construed or used as, financial, legal, tax or investment advice or an offer to sell, or a solicitation of any offer to buy, an interest in any fund advised by Ada Investment Management LP, the Investment a

Re: Python does not take up available physical memory

2012-10-19 Thread Thomas Rachel
, the free space in virtual memory is not necessarily contiguous. So even if you have 1.5G free, you might not be able to read 1.5G at once, but you might succeed in reading 3*0.5G. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: while expression feature proposal

2012-10-25 Thread Thomas Rachel
None for j in i1) # and now, break on None: i3 = iter(lambda: next(i2), None) would do the job. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: while expression feature proposal

2012-10-25 Thread Thomas Rachel
(line, *rr): for r in rr: m = r.match(line) if m: yield r; return for r in matching(line, *actions.keys()): actions[r]() break else: raise NoActionMatched() # or something like that Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: while expression feature proposal

2012-10-25 Thread Thomas Rachel
such as def maybe_do_that(): if moon == full: with something as val: yield val for val in maybe_do_that(): bla but I would consider this as an abuse of the generator concept. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: while expression feature proposal

2012-10-25 Thread Thomas Rachel
Am 25.10.2012 09:21 schrieb Thomas Rachel: I think # iterate ad inf., because partial never returns None: i1 = iter(partial(randrange, n), None) # take the next value, make it None for breaking: i2 = (j if j in selected else None for j in i1) # and now, break on None: i3 = iter(lambda: next(i2

Re: while expression feature proposal

2012-10-25 Thread Thomas Rachel
ase of calls to send(), throw() and close(), things become considerably more difficult. As will be seen later, the necessary code is very complicated, and it is tricky to handle all the corner cases correctly. Ok, thanks. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: while expression feature proposal

2012-10-25 Thread Thomas Rachel
. The same as in if regex.search(string) as match: process it But with def if_true(expr): if expr: yield expr you can do for match in if_true(regex.search(string)): process it But the proposed if ... as ...: statment woulkd be more beautiful by far. Thomas -- http://mail.python.org/mai

Re: while expression feature proposal

2012-10-25 Thread Thomas Rachel
Am 25.10.2012 18:36 schrieb Ian Kelly: On Thu, Oct 25, 2012 at 1:21 AM, Thomas Rachel wrote: j = next(j for j in iter(partial(randrange, n), None) if j not in selected) This generator never ends. If it meets a non-matching value, it just skips it and goes on. next() only returns one value

Re: a.index(float('nan')) fails

2012-10-27 Thread Thomas Rachel
n, what about sqrt(x)**2 or arcsin(sin(x))? Did that always return the original x? Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: better way for ' '.join(args) + '\n'?

2012-10-27 Thread Thomas Rachel
'\'''\'''. Ugly, but works. return " ".join([ "'"+st.replace("'","'\\''")+"'" for st in strs ]) so I can use shellquote('program name', 'argu"ment 1', '$arg 2', "even args containing a ' are ok") For Windows, you'll have to modify this somehow. HTH, Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Immutability and Python

2012-11-07 Thread Thomas Rachel
and why? That's why I generally prefer mutable objects, but it can depend. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Obnoxious postings from Google Groups

2012-11-09 Thread Thomas Rachel
it, it can be run wherever desired. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Printing characters outside of the ASCII range

2012-11-11 Thread Thomas Rachel
So do print(repr(chr(254))) or, for byte strings, print(bytes([254])). Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Help building a dictionary of lists

2012-11-13 Thread Thomas Bach
', 'Test 2', 'Test 3']) Also have a look at ``collections.defaultdict``. Regards, Thomas. -- http://mail.python.org/mailman/listinfo/python-list

Re: stackoverflow quote on Python

2012-11-13 Thread Thomas Rachel
Am 13.11.2012 14:21 schrieb wxjmfa...@gmail.com: * strings are now proper text strings (Unicode), not byte strings; Let me laugh. Do so. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: how to simulate tar filename substitution across piped subprocess.Popen() calls?

2012-11-13 Thread Thomas Rachel
hing second_process, it might be useful to firstprocess.stdout.close(). If you fail to do so, your process is a second reader which might break things apart. At least, I once hat issues with it; I currently cannot recapitulate what these were nor how they could arise; maybe there was just the open file descriptor which annoyed me. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: how to simulate tar filename substitution across piped subprocess.Popen() calls?

2012-11-13 Thread Thomas Rachel
% (mydir, mydir)) , then it will only break if there are single quotes in the file name. And if you do mydir_q = mydir.replace("'", "'\\''") and use mydir_q, you should be safe... Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Python garbage collector/memory manager behaving strangely

2012-11-15 Thread Thomas Rachel
xt_line # keepsep: only if we have something. if (not keepsep) or data: yield data you can iterate over everything you want without needing too much memory. Using a larger "buffering" might improve speed a little bit. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: editing conf file

2012-11-16 Thread Thomas Bach
7;, 'option').split(',') ] if you use a comma as a separator. Have a look at YAML if this is not enough for you, as I think lists are supported there. Haven't had a look myself though, yet. Regards, Thomas Bach. -- http://mail.python.org/mailman/listinfo/python-list

Re: Web Frameworks Excessive Complexity

2012-11-22 Thread Thomas Bach
-packages/zope 2044.virtualenvs/pyramid/lib/python2.7/site-packages/chameleon 6312.virtualenvs/pyramid/lib/python2.7/site-packages/pyramid I think 22 MB are OK given the functionality Pyramid has to offer. Just my 2 cents, Thomas. -- http://mail.python.org/mailman/listinfo/python-list

Re: method that can be called from a class and also from an instance

2012-11-22 Thread Thomas Bach
classmethod) explicitly says so: It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()). The instance is ignored except for its class. I think the way to go is via the descriptor protocol[1] as suggested by Peter. Regards, Thomas. Footnotes: [1] http://docs.p

Re: Managing multiple packages

2012-11-22 Thread Thomas Bach
I have not come up with a good solution for tox, yet. Hope this helps, Thomas. -- http://mail.python.org/mailman/listinfo/python-list

Re: Re: Managing multiple packages

2012-11-27 Thread Thomas Bach
rifying. Regards, Thomas. Footnotes: [1] http://ziade.org/2010/03/03/the-fate-of-distutils-pycon-summit-packaging-sprint-detailed-report/ -- http://mail.python.org/mailman/listinfo/python-list

Re: os.popen and the subprocess module

2012-11-29 Thread Thomas Rachel
ver you like). Third step: Getting the status, terminating the process. And if you have read the whole output, you do status = sp.wait() in order not to have a zombie process in your process table and to obtain the process status. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Compare list entry from csv files

2012-11-29 Thread Thomas Bach
part or in a function on its own. Also have a look at the with statement you can use it in several places of your code. There are several other improvements you can make: + instead of having the file-names hard coded try to use argparse to get them from the command-line, + let functions stand at their own and use less globals, + try to avoid the use of the type of the data structure in the name (e.g. names is IMHO a better name then namelist), + add tests. Regards, Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: List problem

2012-12-02 Thread Thomas Bach
On Sun, Dec 02, 2012 at 04:16:01PM +0100, Lutz Horn wrote: > > len([x for x in l if x[1] == 'VBD']) > Another way is sum(1 for x in l if x[1] == 'VBD') which saves the list creation. Regards, Thomas. -- http://mail.python.org/mailman/listinfo/python-list

Re: CSV out of range

2012-12-04 Thread Thomas Bach
o ignore the > empty arrays using if statement, but it does the same. Please provide a small, runable example with the actual code you tried that raises the exception and the complete trace back. Regards, Thomas Bach. -- http://mail.python.org/mailman/listinfo/python-list

Re: scope, function, mutable

2012-12-04 Thread Thomas Bach
confuses you further… Well, tell me that my autodidact methodology did not work out at all and ask again. ;) Regards, Thomas. -- http://mail.python.org/mailman/listinfo/python-list

How to check if Pexpect child already exist?

2012-12-04 Thread Thomas Elsgaard
Hi List I am wondering, how can i check if child already exist before i spawn ? child.isalive() cannot be done on child before it has been spawned. --- import pexpect child=pexpect.spawn('ssh mysurface@192.168.1.105') child.sendline('test') --- Thomas -- http://mai

Re: Confused compare function :)

2012-12-06 Thread Thomas Rachel
do_stuff() might raise a KeyError, which should not go undetected. Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: forking and avoiding zombies!

2012-12-11 Thread Thomas Rachel
27;error.log') resp. os.path.join(os.getcwd(), 'out.log') Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with unittest2

2012-12-13 Thread Thomas Bach
ending on the arguments type. If you want to make sure that something is of a certain type use assertIsInstance! Hope this helps, Thomas Bach. -- http://mail.python.org/mailman/listinfo/python-list

Install python with custom tk-tcl installation

2012-12-17 Thread Derek Thomas
Hello, I seem to have a problem because it seems Tkinter assumes relative paths for TCL_LIBRARY and TK_LIBRARY. I am working with the homebrew group to get python27 to install nicely with a custom installation of tk and tcl (https://github.com/mxcl/homebrew/pull/16626). However, this breaks

Re: I need help with graphs in python (2.7.3.1)

2012-12-18 Thread Thomas Bach
h a solution. Hope this helps, Thomas Bach. Footnotes: [1] http://docs.python.org/2/library/configparser.html [2] http://docs.python.org/2/library/csv.html [3] http://docs.python.org/2/library/collections.html#collections.Counter [4] http://matplotlib.org/gallery.html -- http://mail.pyt

Re: counting how often the same word appears in a txt file...But my code only prints the last line entry in the txt file

2012-12-19 Thread Thomas Bach
else: > dict[word] = 1 When you got the indentation and names right, you can restate this as import collections counter = collections.Counter(words) in Python 2.7 or as import collections counter = collections.defaultdict(int) for word in words: counter[word] += 1 in Python 2.6 Re

Re: Pattern-match & Replace - help required

2012-12-19 Thread Thomas Bach
am', 'spam, ham, spam') 'egg, spam, ham, spam, tomato' If the pattern you want to match is more complicated, have a look at the re module! Regards, Thomas. -- http://mail.python.org/mailman/listinfo/python-list

Re: Py 3.3, unicode / upper()

2012-12-19 Thread Thomas Bach
l question is why? Because there is no definition for upper-case 'ß'. 'SS' is used as the common replacement in this case. I think it's pretty smart! :) Regards, Thomas. -- http://mail.python.org/mailman/listinfo/python-list

Re: [newbie] plotting pairs of data

2012-12-19 Thread Thomas Bach
but also the how is the matter of your question something like xs = [ float(x) for x, _ in map(str.split, l) ] ys = [ float(y) for _, y in map(str.split, l) ] should do the trick. Regards, Thomas Bach. -- http://mail.python.org/mailman/listinfo/python-list

Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread Thomas Bach
hing_with(data) > HomeDatastore.py > def QuerySqlite(): > #doing something here.. > # returning Data Have you read the Python tutorial by the way? Regards, Thomas. -- http://mail.python.org/mailman/listinfo/python-list

Re: Custom alphabetical sort

2012-12-24 Thread Thomas Bach
;, 'R', > 's', 'S', 't', 'T', 'u', 'U', 'ü', 'Ü', 'ú', 'Ú', 'û', 'Û', 'ù', 'Ù', 'v', > 'V', 'w', 'W', 'x', 'X', 'y', 'Y', 'z', 'Z') > One option is to use sorted's key parameter with an appropriate mapping in a dictionary: >>> cs = (' ', '.', '\'', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', >>> '9', 'a', 'A', 'ä', 'Ä', 'á', 'Á', 'â', 'Â', 'à', 'À', 'å', 'Å', 'b', 'B', >>> 'c', 'C', 'ç', 'Ç', 'd', 'D', 'e', 'E', 'ë', 'Ë', 'é', 'É', 'ê', 'Ê', 'è', >>> 'È', 'f', 'F', 'g', 'G', 'h', 'H', 'i', 'I', 'ï', 'Ï', 'í', 'Í', 'î', 'Î', >>> 'ì', 'Ì', 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'ñ', 'N', 'Ñ', 'o', >>> 'O', 'ö', 'Ö', 'ó', 'Ó', 'ô', 'Ô', 'ò', 'Ò', 'ø', 'Ø', 'p', 'P', 'q', 'Q', >>> 'r', 'R', 's', 'S', 't', 'T', 'u', 'U', 'ü', 'Ü', 'ú', 'Ú', 'û', 'Û', 'ù', >>> 'Ù', 'v', 'V', 'w', 'W', 'x', 'X', 'y', 'Y', 'z', 'Z') >>> d = { k: v for v, k in enumerate(cs) } >>> import random >>> ''.join(sorted(random.sample(cs, 20), key=d.get)) '5aAàÀåBCçËÉíÎLÖøquùx' Regards, Thomas. -- http://mail.python.org/mailman/listinfo/python-list

Twisted 12.3.0 released

2012-12-26 Thread Thomas Hervé
oad it now from: http://pypi.python.org/packages/source/T/Twisted/Twisted-12.3.0.tar.bz2 or http://pypi.python.org/packages/2.7/T/Twisted/Twisted-12.3.0.win32-py2.7.msi Thanks to the supporters of Twisted via the Software Freedom Conservancy and to the many contributors for this release.

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

2013-01-07 Thread Thomas Rachel
. See http://docs.python.org/2/library/socket.html#socket.socket.sendall | [...] Unlike send(), this method continues to send data from string | until either all data has been sent or an error occurs. HTH, Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: How to modify this script?

2013-01-08 Thread Thomas Rachel
item + ' ' with if len(columns) >= 3: output += '' else: output += '' output += item + ' ' (untested as well; keep the indentation in mind!) Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: How to modify this script?

2013-01-08 Thread Thomas Rachel
out and columns = line.split("\t"); if len(columns) == 1: output += ('' % max_columns) + line + '\n' continue with this feature. HTH, Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: please i need explanation

2013-01-11 Thread Thomas Rachel
n in each step. As the loop should contain a 'n -= 1', n decreases by 1 every step, turning it into f = n * (n-1) * (n-2) * ... * 2 and then, as n is not >= 2 any longer, stops the loop, returning f. HTH, Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Dependency management in Python?

2013-01-12 Thread Thomas Bach
onment. As a side note: some versions of distribute, pip and virtualenv do interact rather poorly on Python 3. Upgrading via easy_install: $ easy_install -U distribute $ easy_install -U pip usually solves these issues. Have fun! Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: average time calculation??

2013-01-12 Thread Thomas Boell
On Thu, 10 Jan 2013 09:50:37 -0800 (PST) pmec wrote: > Hi there guys i've got a script that's suppose to find the average of two > times as strings. The times are in minutes:seconds:milliseconds > i'm doing ok in printing the right minutes and seconds my problem is with the > milliseconds. > >

Re: i can't understand decorator

2013-01-15 Thread Thomas Rachel
efore myfunc() called. myfunc() called. after myfunc() called. before myfunc() called. myfunc() called. after myfunc() called. Because the function calls are wrapped and not repeated. Thomas -- http://mail.python.org/mailman/listinfo/python-list

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