Re: multithreading

2012-04-07 Thread Bryan
Kiuhnm wrote: > My question is this: can I use 'threading' without interfering with the > program which will import my module? Yes. The things to avoid are described at the bottom of: http://docs.python.org/library/threading.html On platforms without threads, 'import threading' will fail. There's

Re: Python Gotcha's?

2012-04-07 Thread Chris Angelico
On Sun, Apr 8, 2012 at 2:19 PM, Chris Angelico wrote: > Agreed. Putting an expression first feels weird; in every high level > language I know of, the word "if" is followed by the condition, and > then by what to do if true, and then what to do if false - not true, > then condition, then false. C

Re: Python Gotcha's?

2012-04-07 Thread Chris Angelico
On Sun, Apr 8, 2012 at 2:01 PM, John Nagle wrote: > 4.  The syntax for expression-IF is just weird. Agreed. Putting an expression first feels weird; in every high level language I know of, the word "if" is followed by the condition, and then by what to do if true, and then what to do if false - n

Re: Python Gotcha's?

2012-04-07 Thread John Nagle
On 4/4/2012 3:34 PM, Miki Tebeka wrote: Greetings, I'm going to give a "Python Gotcha's" talk at work. If you have an interesting/common "Gotcha" (warts/dark corners ...) please share. (Note that I want over http://wiki.python.org/moin/PythonWarts already). Thanks, -- Miki A few Python "got

Re: Python Gotcha's?

2012-04-07 Thread Chris Angelico
On Sun, Apr 8, 2012 at 1:47 PM, Tim Roberts wrote: > No, but there certainly is a justification for expecting JAVASCRIPT Object > Notation (which is, after all, what JSON stands for) to follow Javascript's > syntax rules.  And Javascript happens to follow the same quoting rules as > Python. > > No

Re: Python Gotcha's?

2012-04-07 Thread Tim Roberts
Roy Smith wrote: > >There's absolutely no reason why JSON should follow Python syntax rules. No, but there certainly is a justification for expecting JAVASCRIPT Object Notation (which is, after all, what JSON stands for) to follow Javascript's syntax rules. And Javascript happens to follow the

Re: PEP 274

2012-04-07 Thread Alec Taylor
I have it in 2.7.3 On Sun, Apr 8, 2012 at 2:35 AM, Terry Reedy wrote: > On 4/7/2012 7:20 AM, Rodrick Brown wrote: >> >> This proposal was suggested in 2001 and is only now being >> implemented. Why the extended delay? > > > It was implemented in revised form 3 years ago in 3.0. > > -- > Terry Jan

Re: Multiprocessing & Logging

2012-04-07 Thread Vinay Sajip
Thibaut gmail.com> writes: > This is exactly what I wanted, it seems perfect. However I still have a > question, from what I understood, > I have to configure logging AFTER creating the process, to avoid > children process to inherits the logging config. > > Unless there is a way to "clean" lo

Re: Pass a list of variables to a procedure

2012-04-07 Thread Keith Burns
Thank you, Chris! Sent from my iPhone On Apr 7, 2012, at 3:24 PM, Chris Rebert wrote: > On Sat, Apr 7, 2012 at 2:15 PM, KRB wrote: >> Hi there, >> >> I would like to be able to pass a list of variables to a procedure, and have >> the output assigned to them. > > You cannot pass a variable its

Re: Why does this hang sometimes?

2012-04-07 Thread Jason Friedman
> I am just playing around with threading and subprocess and found that > the following program will hang up and never terminate every now and > again. > > import threading > import subprocess > import time > > def targ(): >    p = subprocess.Popen(["/bin/sleep", "2"]) >    while p.poll() is None:

Re: Pass a list of variables to a procedure

2012-04-07 Thread Nobody
On Sat, 07 Apr 2012 14:15:09 -0700, KRB wrote: > I would like to be able to pass a list of variables to a procedure, and > have the output assigned to them. Use a dictionary or an object. If the variables are globals (i.e. attributes of the current module), you can pass the result of globals() i

Re: Pass a list of variables to a procedure

2012-04-07 Thread Chris Rebert
On Sat, Apr 7, 2012 at 2:15 PM, KRB wrote: > Hi there, > > I would like to be able to pass a list of variables to a procedure, and have > the output assigned to them. You cannot pass a variable itself to a function; you can only pass a variable's value. Which is to say that Python doesn't use pa

Pass a list of variables to a procedure

2012-04-07 Thread KRB
Hi there, I would like to be able to pass a list of variables to a procedure, and have the output assigned to them. For instance: x=0 y=0 z=0 vars =[x,y,z] parameters=[1,2,3] for i in range(1,len(vars)): *** somefunction that takes the parameter "1", does a computation and assigns the output

Re: multithreading

2012-04-07 Thread Adam Skutt
On Apr 7, 5:06 pm, Kiuhnm wrote: > On 4/7/2012 22:09, Bryan wrote:>> For instance, let's say I want to make this > code thread-safe: > > >> ---> > >> myDict = {} > > >> def f(name, val): > >>       if name not in myDict: > >>           myDict[name] = val > >>       return myDict[name] > >> <--- >

Re: multithreading

2012-04-07 Thread Kiuhnm
On 4/7/2012 22:09, Bryan wrote: For instance, let's say I want to make this code thread-safe: ---> myDict = {} def f(name, val): if name not in myDict: myDict[name] = val return myDict[name] <--- First, don't re-code Python's built-ins. The example is a job for dict.setd

Re: Distribute app without source?

2012-04-07 Thread Bill Felton
On Apr 7, 2012, at 1:22 PM, Terry Reedy wrote: > On 4/7/2012 9:07 AM, Bill Felton wrote: >> Thanks in advance for any insights! >> >> My partner and I have developed an application primarily > > intended for internal use within our company. However, we face the > > need to expose the app to ce

Re: multithreading

2012-04-07 Thread Bryan
Kiuhnm wrote: > I'm about to write my first module and I don't know how I should handle > multithreading/-processing. > I'm not doing multi-threading inside my module. I'm just trying to make > it thread-safe so that users *can* do multi-threading. There are a couple conventions to follow. Trying

ordering with duck typing in 3.1

2012-04-07 Thread Jon Clements
Any reason you can't derive from int instead of object? You may also want to check out functions.total_ordering on 2.7+ -- http://mail.python.org/mailman/listinfo/python-list

documentation for asyncmongo?

2012-04-07 Thread Laszlo Nagy
Is there any kind of API documentation for asyncmongo? On GITHub they say "asyncmongo syntax strives to be similar to pymongo .". However, many basic things do not work or they are not similar. http://api.mongodb.org/python/2.1

Re: Distribute app without source?

2012-04-07 Thread Terry Reedy
On 4/7/2012 9:07 AM, Bill Felton wrote: Thanks in advance for any insights! My partner and I have developed an application primarily > intended for internal use within our company. However, we face the > need to expose the app to certain non-employees. We would like to do so without exposing

Re: Python Script Works Locally But Not Remotely with SSH

2012-04-07 Thread Andrew Berg
On 4/7/2012 11:59 AM, goldtech wrote: I thought if I SSH > even from a Linux to a Windows machine whatever I say on the SSH > client command line would be the same as me doing a command on the > "DOS" command-line in Windows. I incorrectly thought SSH is just a > tunnel for text... It gives you wh

Re: Python Script Works Locally But Not Remotely with SSH

2012-04-07 Thread goldtech
Thank you for the help. I guess I didn't understand what's really going on. I thought if I SSH even from a Linux to a Windows machine whatever I say on the SSH client command line would be the same as me doing a command on the "DOS" command-line in Windows. I incorrectly thought SSH is just a tunn

Re: PEP 274

2012-04-07 Thread Terry Reedy
On 4/7/2012 7:20 AM, Rodrick Brown wrote: This proposal was suggested in 2001 and is only now being implemented. Why the extended delay? It was implemented in revised form 3 years ago in 3.0. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: 'string_escape' in python 3

2012-04-07 Thread Ian Kelly
On Sat, Apr 7, 2012 at 8:30 AM, Nicholas Cole wrote: > On Sat, Apr 7, 2012 at 12:10 AM, Ian Kelly wrote: > import codecs > codecs.getdecoder('unicode_escape')(s)[0] >> 'Hello: this is a test' >> >> Cheers, >> Ian > > Thanks, Ian.  I had assumed that if a unicode string didn't have a > .de

Re: Multiprocessing & Logging

2012-04-07 Thread Vinay Sajip
Thibaut gmail.com> writes: > This is exactly what I wanted, it seems perfect. However I still have a > question, from what I understood, > I have to configure logging AFTER creating the process, to avoid > children process to inherits the logging config. > > Unless there is a way to "clean" lo

Let's have hex

2012-04-07 Thread cotpi
A hexual game: http://cotpi.com/letushavehex/1/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiprocessing & Logging

2012-04-07 Thread Thibaut
Le 07/04/2012 16:47, Vinay Sajip a écrit : Thibaut gmail.com> writes: Ok, I understand what happenned. In fact, configuring the logging before forking works fine. Subprocess inherits the configuration, as I thought. The problem was that I didn't passed any handler to the QueueListener constr

Re: Multiprocessing & Logging

2012-04-07 Thread Vinay Sajip
Thibaut gmail.com> writes: > Ok, I understand what happenned. In fact, configuring the logging before > forking works fine. Subprocess inherits the configuration, as I thought. > > The problem was that I didn't passed any handler to the QueueListener > constructor. The when the listener reciev

Re: ordering with duck typing in 3.1

2012-04-07 Thread mwilson
Thomas Rachel wrote: > Am 07.04.2012 14:23 schrieb andrew cooke: > >> class IntVar(object): >> >> def __init__(self, value=None): >> if value is not None: value = int(value) >> self.value = value >> >> def setter(self): >> def wrapper(stream_in, thunk): >>

Re: ordering with duck typing in 3.1

2012-04-07 Thread John O'Hagan
On Sat, 7 Apr 2012 05:23:25 -0700 (PDT) andrew cooke wrote: > > hi, > > please, what am i doing wrong here? the docs say > http://docs.python.org/release/3.1.3/library/stdtypes.html#comparisons "in > general, __lt__() and __eq__() are sufficient, if you want the conventional > meanings of the

multithreading

2012-04-07 Thread Kiuhnm
I'm about to write my first module and I don't know how I should handle multithreading/-processing. I'm not doing multi-threading inside my module. I'm just trying to make it thread-safe so that users *can* do multi-threading. For instance, let's say I want to make this code thread-safe: --->

Re: ordering with duck typing in 3.1

2012-04-07 Thread Rob Williscroft
andrew cooke wrote in news:33019705.1873.1333801405463.JavaMail.geo-discussion-forums@ynmm9 in gmane.comp.python.general: > > hi, > > please, what am i doing wrong here? the docs say > http://docs.python.org/release/3.1.3/library/stdtypes.html#comparisons > "in general, __lt__() and __eq__() a

how i loved lisp cons and UML and Agile and Design Patterns and Pythonic and KISS and YMMV and stopped worrying

2012-04-07 Thread Xah Lee
OMG, how i loved lisp cons and macros and UML and Agile eXtreme Programing and Design Patterns and Anti-Patterns and Pythonic and KISS and YMMV and stopped worrying. 〈World Multiconference on Systemics, Cybernetics and Informatics???〉 http://xahlee.org/comp/WMSCI.html highly advanced plain text f

Re: 'string_escape' in python 3

2012-04-07 Thread Nicholas Cole
On Sat, Apr 7, 2012 at 12:10 AM, Ian Kelly wrote: import codecs codecs.getdecoder('unicode_escape')(s)[0] > 'Hello: this is a test' > > Cheers, > Ian Thanks, Ian. I had assumed that if a unicode string didn't have a .decode method, then I couldn't use a decoder on it, so it hadn't occu

Re: Distribute app without source?

2012-04-07 Thread Andrew Berg
On 4/7/2012 8:07 AM, Bill Felton wrote: > We are using Python 3.2 and tkinter. It appears, and limited testing bears > out, that py2app, and presumably py2exe, are not options given lack of 3.x > support. cx_Freeze supports Python 3.2. It works fine for my purposes, but I have not done any serio

Re: ordering with duck typing in 3.1

2012-04-07 Thread Thomas Rachel
Am 07.04.2012 14:23 schrieb andrew cooke: class IntVar(object): def __init__(self, value=None): if value is not None: value = int(value) self.value = value def setter(self): def wrapper(stream_in, thunk): self.value = thunk() retur

Distribute app without source?

2012-04-07 Thread Bill Felton
Thanks in advance for any insights! My partner and I have developed an application primarily intended for internal use within our company. However, we face the need to expose the app to certain non-employees. We would like to do so without exposing our source code. Our targets include users of

Re: Multiprocessing & Logging

2012-04-07 Thread Thibaut
Le 07/04/2012 11:22, Thibaut DIRLIK a écrit : Hi, I'm currently writing a multiprocess applications with Python 3.2 and multiprocessing module. My subprocesses will use a QueueHandler to log messages (by sending them to the main process, which uses a QueueListener). However, if logging is alr

ordering with duck typing in 3.1

2012-04-07 Thread andrew cooke
hi, please, what am i doing wrong here? the docs say http://docs.python.org/release/3.1.3/library/stdtypes.html#comparisons "in general, __lt__() and __eq__() are sufficient, if you want the conventional meanings of the comparison operators" but i am seeing > assert 2 < three E T

Re: PEP 274

2012-04-07 Thread Rodrick Brown
This proposal was suggested in 2001 and is only now being implemented. Why the extended delay? Sent from my iPhone On Apr 7, 2012, at 3:32 AM, Alec Taylor wrote: > Has been withdrawn... and implemented > > http://www.python.org/dev/peps/pep-0274/ > -- > http://mail.python.org/mailman/listin

Re: escaping/encoding/formatting in python

2012-04-07 Thread Chris Angelico
On Sat, Apr 7, 2012 at 3:36 PM, Nobody wrote: > The delimiter can be chosen either by analysing the string > or by choosing something a string at random and relying upon a collision > being statistically improbable. The same techniques being available to MIME multi-part encoders, and for the same

Re: Python Training

2012-04-07 Thread Mohan kumar
On Apr 7, 2:21 pm, Mohan kumar wrote: > Hi, > We are an IT Training company located in Bangalore, Chennai and > Coimbatore. We provide Python training with Placement Assistance. For > more details, email to mo...@cgonsoft.com We also provide Online Training. -- http://mail.python.org/mailman/lis

Python Training

2012-04-07 Thread Mohan kumar
Hi, We are an IT Training company located in Bangalore, Chennai and Coimbatore. We provide Python training with Placement Assistance. For more details, email to mo...@cgonsoft.com -- http://mail.python.org/mailman/listinfo/python-list

Multiprocessing & Logging

2012-04-07 Thread Thibaut DIRLIK
Hi, I'm currently writing a multiprocess applications with Python 3.2 and multiprocessing module. My subprocesses will use a QueueHandler to log messages (by sending them to the main process, which uses a QueueListener). However, if logging is already configured when I create the subprocesses, the

Re: Learning new APIs/classes (beginner question)

2012-04-07 Thread Martin Jones
On Apr 7, 1:52 am, Steven D'Aprano wrote: > Sounds like this library is documented the same way most third party > libraries are: as an afterthought, by somebody who is so familiar with > the software that he cannot imagine why anyone might actually need > documentation. > > I feel your pain. >