Re: Java NIO server and Python asyncore client

2013-02-05 Thread dieter
foobarome...@gmail.com writes: > Can someone help answer this? > http://stackoverflow.com/questions/14698020/java-nio-server-and-python-asyncore-client > > Blocking python client works, asyncore doesn't work. I fear you must tell us which Python version you are using. Your call to "dispatcher.cre

Re: Opinion on best practice...

2013-02-05 Thread rusi
On Feb 6, 6:55 am, Steven D'Aprano wrote: > I would not hesitate to use Python, or some other high-level language like > Ruby, over bash for anything non-trivial that I cared about. It might not > be as terse and compact as a well-written bash script, but that's a *good* > thing, and a poorly-wri

Re: Issue with my code

2013-02-05 Thread rusi
> Pythons 2.7 and later have dictionary comprehensions. So you can do > this: > > >>> {item: s.count(item) for item in set(s)} > > {'a': 1, 'b': 1, '1': 2, '3': 1, '2': 2, '4': 1} > > Which gives counts for all letters. To filter out the digit-counts > only: > > >>> digits="0123456789" > >>> {item:

Re: Issue with my code

2013-02-05 Thread rusi
On Feb 5, 11:38 pm, maiden129 wrote: > Hi, > > I'm trying to create this program that counts the occurrences of each digit > in a string which the user have to enter. > > Here is my code: > > s=input("Enter a string, eg(4856w23874): ") > s=list(s) > > checkS=['0','1','2','3','4','5','6','7','8','

Re: Opinion on best practice...

2013-02-05 Thread Chris Angelico
On Wed, Feb 6, 2013 at 12:55 PM, Steven D'Aprano wrote: > Chris Angelico wrote: > >> Python is not an "excellent option". It's a bad fit for shell >> scripting, it just happens to be way better than a weak shell. Having >> grown up on command.com, I found OS/2's cmd.exe to be a massive >> improvem

Re: Opinion on best practice...

2013-02-05 Thread Michael Torrie
On 02/05/2013 08:32 PM, Nobody wrote: > A shell script is only the better option if (almost) the *only* thing the > script needs to do is to execute commands. > > The moment you start trying to "process" data, it's time to put up with > the verbosity of subprocess.Popen() so that you can use a wel

Re: best way to share an instance of a class among modules?

2013-02-05 Thread Terry Reedy
On 2/5/2013 11:40 PM, CM wrote: I have recently moved all my SQLite3 database-related functions into a class, DatabaseAccess, that lives in a "utilities" module. When the application loads, the namespace of the instance of the class is populated with two different cursors for two different datab

best way to share an instance of a class among modules?

2013-02-05 Thread CM
I have recently moved all my SQLite3 database-related functions into a class, DatabaseAccess, that lives in a "utilities" module. When the application loads, the namespace of the instance of the class is populated with two different cursors for two different databases the whole application needs t

Re: Opinion on best practice...

2013-02-05 Thread Nobody
On Tue, 05 Feb 2013 21:01:56 +, Walter Hurry wrote: > Hooray for common sense! Python is great, but it's silly to use Python > (unless there is good reason) when a simple shell script will do the job. A shell script is only the better option if (almost) the *only* thing the script needs to d

Re: Opinion on best practice...

2013-02-05 Thread Dan Stromberg
On Feb 5, 2013 6:00 PM, "Steven D'Aprano" < steve+comp.lang.pyt...@pearwood.info> wrote: > > Chris Angelico wrote: > > > Python is not an "excellent option". It's a bad fit for shell > > scripting, it just happens to be way better than a weak shell. Having > > grown up on command.com, I found OS/2'

Re: Opinion on best practice...

2013-02-05 Thread Steven D'Aprano
Chris Angelico wrote: > Python is not an "excellent option". It's a bad fit for shell > scripting, it just happens to be way better than a weak shell. Having > grown up on command.com, I found OS/2's cmd.exe to be a massive > improvement, and Windows's cmd.exe to be rather less impressive... but >

About a value error called 'ValueError: A value in x_new is below the interpolation range'

2013-02-05 Thread Isaac Won
Dear all, I am trying to calculate correlation coefficients between one time series data and other time series. However,there are some missing values. So, I interploated each time series with 1d interpolation in scipy and got correlation coefficients between them. This code works well for some

Re: Issue with my code

2013-02-05 Thread Terry Reedy
On 2/5/2013 1:38 PM, maiden129 wrote: Hi, I'm trying to create this program that counts the occurrences > of each digit in a string which the user have to enter. Here is my code: s=input("Enter a string, eg(4856w23874): ") s=list(s) Unnecessary conversion. checkS=['0','1','2','3','4','5'

Re: Opinion on best practice...

2013-02-05 Thread Ian Kelly
On Tue, Feb 5, 2013 at 3:59 PM, Grant Edwards wrote: > On 2013-02-05, Neil Cerutti wrote: >> On 2013-02-05, Walter Hurry wrote: Sorry, I'm a Linux guy. I have no clue what that means. >>> >>> Hooray for common sense! Python is great, but it's silly to use >>> Python (unless there is good r

How to improve writing code in python?

2013-02-05 Thread Banh
Hi, I have a problem with learning Python. My code is really bad and I can't solve many problems. I really want to improve it. Do you know any website which helps me to learn python effectively (for beginners)? This is my first programming language and I am studying about manipulating the images

Re: Hitting send by mistake -- a solution

2013-02-05 Thread Terry Reedy
On 2/5/2013 3:22 PM, TIm Chase wrote: On Tue, 05 Feb 2013 14:41:21 -0500, Terry Reedy wrote: [comment about a double post] > He must have hit the send button too early by mistake. I used to do that occasionally. The reason is that the default position of [send] was on the left, under [File] a

Re: Opinion on best practice...

2013-02-05 Thread Chris Angelico
On Wed, Feb 6, 2013 at 10:00 AM, Grant Edwards wrote: > On 2013-02-05, Ethan Furman wrote: >> On 02/05/2013 01:39 PM, Neil Cerutti wrote: >>> Python is an excellent option for writing shell scripts, >>> particularly if your shell is cmd.exe. >> >> I believe having your shell be cmd.exe qualifies

Re: Opinion on best practice...

2013-02-05 Thread Grant Edwards
On 2013-02-05, Ethan Furman wrote: > On 02/05/2013 01:39 PM, Neil Cerutti wrote: >> On 2013-02-05, Walter Hurry wrote: Sorry, I'm a Linux guy. I have no clue what that means. >>> >>> Hooray for common sense! Python is great, but it's silly to use >>> Python (unless there is good reason) whe

Re: Opinion on best practice...

2013-02-05 Thread Grant Edwards
On 2013-02-05, Neil Cerutti wrote: > On 2013-02-05, Walter Hurry wrote: >>> Sorry, I'm a Linux guy. I have no clue what that means. >> >> Hooray for common sense! Python is great, but it's silly to use >> Python (unless there is good reason) when a simple shell script >> will do the job. > > Pyt

Re: ftp - delete multiple files of same type

2013-02-05 Thread chris . annin
> > > im trying to delete all text files from an ftp directory. is there a way to > > delete multiple files of the same extension? > > > > > > I came up with the following code below which works but I have to append > > the string because ftp.nlst returns: > > > > > > "-rwx-- 1 user gro

Re: Issue with my code

2013-02-05 Thread darnold
On Feb 5, 4:05 pm, marduk wrote: > > Although that implementation also scans the string 10 times (s.count()), > which may not be as efficient (although it is happening in C, so perhaps > not). > > A better solution involves only scanning the string once. agreed. i was specifically showing how to

Re: Opinion on best practice...

2013-02-05 Thread Ethan Furman
On 02/05/2013 01:39 PM, Neil Cerutti wrote: On 2013-02-05, Walter Hurry wrote: Sorry, I'm a Linux guy. I have no clue what that means. Hooray for common sense! Python is great, but it's silly to use Python (unless there is good reason) when a simple shell script will do the job. Python is

Re: Issue with my code

2013-02-05 Thread marduk
On Tue, Feb 5, 2013, at 04:37 PM, darnold wrote: > On Feb 5, 2:19 pm, maiden129 wrote: > > How to reverse the two loops? > > > > s=input("Enter a string, eg(4856w23874): ") > > checkS=['0','1','2','3','4','5','6','7','8','9'] > > for digit in checkS: > t = s.count(digit) > if t == 0:

Re: Detecting a click on the turtle screen when the turtle isn't doing anything?

2013-02-05 Thread Dave Angel
On 02/05/2013 02:58 PM, Adam Funk wrote: On 2013-02-05, woo...@gmail.com wrote: Globals are confusing IMHO. Code becomes cleaner and easier to write and read when you become familiar with classes. If I have to write a class just to create one instance of it & call the main()

Re: Issue with my code

2013-02-05 Thread darnold
On Feb 5, 2:19 pm, maiden129 wrote: > How to reverse the two loops? > s=input("Enter a string, eg(4856w23874): ") checkS=['0','1','2','3','4','5','6','7','8','9'] for digit in checkS: t = s.count(digit) if t == 0: pass elif t == 1: print(digit,"occurs 1 time.") e

Re: Opinion on best practice...

2013-02-05 Thread Neil Cerutti
On 2013-02-05, Walter Hurry wrote: >> Sorry, I'm a Linux guy. I have no clue what that means. > > Hooray for common sense! Python is great, but it's silly to use > Python (unless there is good reason) when a simple shell script > will do the job. Python is an excellent option for writing shell s

Re: Hitting send by mistake -- a solution

2013-02-05 Thread Ian Kelly
On Tue, Feb 5, 2013 at 12:41 PM, Terry Reedy wrote: > [comment about a double post] >> He must have hit the send button too early by mistake. > > I used to do that occasionally. The reason is that the default position of > [send] was on the left, under [File] and [Edit], and sometimes I did not >

Re: Opinion on best practice...

2013-02-05 Thread Walter Hurry
On Tue, 05 Feb 2013 13:22:02 +, Grant Edwards wrote: > On 2013-02-05, Anthony Correia wrote: > >> I need to pick up a language that would cover the Linux platform. > > Well, you haven't really described what it is you're trying to do, but > it looks to me like bash and the usual set of shel

Re: Hitting send by mistake -- a solution

2013-02-05 Thread TIm Chase
On Tue, 05 Feb 2013 14:41:21 -0500, Terry Reedy wrote: > [comment about a double post] > > He must have hit the send button too early by mistake. > > I used to do that occasionally. The reason is that the default > position of [send] was on the left, under [File] and [Edit], and > sometimes I did

Re: Issue with my code

2013-02-05 Thread maiden129
How to reverse the two loops? On Tuesday, February 5, 2013 2:43:47 PM UTC-5, Dave Angel wrote: > On 02/05/2013 02:20 PM, maiden129 wrote: > > > On Tuesday, February 5, 2013 1:56:55 PM UTC-5, marduk wrote: > > >> On Tue, Feb 5, 2013, at 01:38 PM, maiden129 wrote: > > >> > > > > > > > > when

Re: Detecting a click on the turtle screen when the turtle isn't doing anything?

2013-02-05 Thread Adam Funk
On 2013-02-05, Adam Funk wrote: > I'm trying to get a program to do some plotting with turtle graphics, > then wait for the user to click on the graphics window, then do some > more plotting, &c. So far I have the following, which doesn't work: > > #v+ > waiting = False > > def clicked(x, y): >

Re: Detecting a click on the turtle screen when the turtle isn't doing anything?

2013-02-05 Thread Adam Funk
On 2013-02-05, woo...@gmail.com wrote: > Note that the code you posted does not call onclick(). It does, actually, but I accidentally snipped it when C&Ping code into my original post. Sorry! > Globals are > confusing IMHO. Code becomes cleaner and easier to write and read > when you becom

Re: Run time Error

2013-02-05 Thread inshu chauhan
On Tue, Feb 5, 2013 at 3:10 PM, Roy Smith wrote: > In article , > inshu chauhan wrote: > > > Hello all, > > > > I am trying to run a small code of mine but I am getting a run time > error. > > What is actually meant by run time error ? it is saying to contact > > programme administrator somethi

Re: Issue with my code

2013-02-05 Thread Dave Angel
On 02/05/2013 02:20 PM, maiden129 wrote: On Tuesday, February 5, 2013 1:56:55 PM UTC-5, marduk wrote: On Tue, Feb 5, 2013, at 01:38 PM, maiden129 wrote: when I removed "s.remove(i), it starts to repeat the number of occurrences too many times like this: 2 occurs 3 times. 2 occurs 3 times.

Hitting send by mistake -- a solution

2013-02-05 Thread Terry Reedy
[comment about a double post] > He must have hit the send button too early by mistake. I used to do that occasionally. The reason is that the default position of [send] was on the left, under [File] and [Edit], and sometimes I did not move the mouse up enough before clicking. With Thunderbird,

Re: real-time monitoring of propriety system: embedding python in C or embedding C in python?

2013-02-05 Thread Terry Reedy
On 2/5/2013 10:23 AM, Duncan Booth wrote: Bas wrote: A) Implement the main program in C. In a loop, get a chunk of data using direct call of C functions, convert data to python variables and call an embedded python interpreter that runs one iteration of the user's algorithm. When the script fi

Re: puzzled by name binding in local function

2013-02-05 Thread Terry Reedy
Code examples are Python 3 On 2/5/2013 10:18 AM, Ulrich Eckhardt wrote: Below you will find example code distilled from a set of unit tests, usable with Python 2 or 3. I'm using a loop over a list of parameters to generate tests with different permutations of parameters. Instead of calling util

Re: Issue with my code

2013-02-05 Thread maiden129
On Tuesday, February 5, 2013 1:56:55 PM UTC-5, marduk wrote: > On Tue, Feb 5, 2013, at 01:38 PM, maiden129 wrote: > > > Hi, > > > > > > I'm trying to create this program that counts the occurrences of each > > > digit in a string which the user have to enter. > > > > > > Here is my code: >

Re: Issue with my code

2013-02-05 Thread MRAB
On 2013-02-05 18:38, maiden129 wrote: Hi, I'm trying to create this program that counts the occurrences of each digit in a string which the user have to enter. Here is my code: s=input("Enter a string, eg(4856w23874): ") s=list(s) checkS=['0','1','2','3','4','5','6','7','8','9'] for i in s:

Re: Issue with my code

2013-02-05 Thread marduk
On Tue, Feb 5, 2013, at 01:38 PM, maiden129 wrote: > Hi, > > I'm trying to create this program that counts the occurrences of each > digit in a string which the user have to enter. > > Here is my code: > > s=input("Enter a string, eg(4856w23874): ") > s=list(s) > > checkS=['0','1','2','3','4'

Re: Issue with my code

2013-02-05 Thread maiden129
Also I’m using Python 3.2.3. On Tuesday, February 5, 2013 1:38:55 PM UTC-5, maiden129 wrote: > Hi, > > > > I'm trying to create this program that counts the occurrences of each digit > in a string which the user have to enter. > > > > Here is my code: > > > > s=input("Enter a string, eg

Re: ftp - delete multiple files of same type

2013-02-05 Thread MRAB
On 2013-02-05 17:29, chris.an...@gmail.com wrote: im trying to delete all text files from an ftp directory. is there a way to delete multiple files of the same extension? I came up with the following code below which works but I have to append the string because ftp.nlst returns: "-rwx--

Issue with my code

2013-02-05 Thread maiden129
Hi, I'm trying to create this program that counts the occurrences of each digit in a string which the user have to enter. Here is my code: s=input("Enter a string, eg(4856w23874): ") s=list(s) checkS=['0','1','2','3','4','5','6','7','8','9'] for i in s: if i in checkS: t=s.count(i

Re: ftp - delete multiple files of same type

2013-02-05 Thread Dave Angel
On 02/05/2013 12:29 PM, chris.an...@gmail.com wrote: im trying to delete all text files from an ftp directory. is there a way to delete multiple files of the same extension? I came up with the following code below which works but I have to append the string because ftp.nlst returns: "-rwx

Re: real-time monitoring of propriety system: embedding python in C or embedding C in python?

2013-02-05 Thread Stefan Behnel
Bas, 05.02.2013 16:10: > at work, we are thinking to replace some legacy application, which is a > home-grown scripting language for monitoring and controlling a large > experiment. It is able to read live data from sensors, do some simple > logic and calculations, send commands to other subsystems

Re: Best Practice Question

2013-02-05 Thread Dave Angel
On 02/05/2013 11:53 AM, Joel Goldstick wrote: On Tue, Feb 5, 2013 at 11:40 AM, Anthony Correia wrote: On Tuesday, February 5, 2013 10:17:54 AM UTC-5, pytho...@tim.thechases.comwrote: On Tue, 5 Feb 2013 15:32:32 +0100 (CET), Jean-Michel Pichavant wrote: By the way, did someone ever notice tha

Re: Detecting a click on the turtle screen when the turtle isn't doing anything?

2013-02-05 Thread woooee
> waiting = False > > > > def clicked(x, y): > > global waiting > > print('clicked at %f %f' % (x,y)) > > waiting = False > > return > > > > def wait_for_click(s): > > global waiting > > waiting = True > > s.listen() > > while waiting: > > time

Re: puzzled by name binding in local function

2013-02-05 Thread Dave Angel
On 02/05/2013 10:18 AM, Ulrich Eckhardt wrote: Hello Pythonistas! Below you will find example code distilled from a set of unit tests, usable with Python 2 or 3. I'm using a loop over a list of parameters to generate tests with different permutations of parameters. Instead of calling util() with

ftp - delete multiple files of same type

2013-02-05 Thread chris . annin
im trying to delete all text files from an ftp directory. is there a way to delete multiple files of the same extension? I came up with the following code below which works but I have to append the string because ftp.nlst returns: "-rwx-- 1 user group 0 Feb 04 15:57 New Text Document.txt"

Re: Best Practice Question

2013-02-05 Thread Joel Goldstick
On Tue, Feb 5, 2013 at 11:40 AM, Anthony Correia wrote: > On Tuesday, February 5, 2013 10:17:54 AM UTC-5, > pytho...@tim.thechases.comwrote: > > On Tue, 5 Feb 2013 15:32:32 +0100 (CET), Jean-Michel Pichavant wrote: > > > > > By the way, did someone ever notice that r'\' fails ? I'm sure > > > > >

Re: Best Practice Question

2013-02-05 Thread Anthony Correia
On Tuesday, February 5, 2013 10:17:54 AM UTC-5, pytho...@tim.thechases.com wrote: > On Tue, 5 Feb 2013 15:32:32 +0100 (CET), Jean-Michel Pichavant wrote: > > > By the way, did someone ever notice that r'\' fails ? I'm sure > > > there's a reason for that... (python 2.5) Anyone knows ? > > > >

Re: Best Practice Question

2013-02-05 Thread python . list
On Tue, 5 Feb 2013 15:32:32 +0100 (CET), Jean-Michel Pichavant wrote: > By the way, did someone ever notice that r'\' fails ? I'm sure > there's a reason for that... (python 2.5) Anyone knows ? > > r'\' > SyntaxError: EOL while scanning single-quoted string I hit this all the time with Vim's path

puzzled by name binding in local function

2013-02-05 Thread Ulrich Eckhardt
Hello Pythonistas! Below you will find example code distilled from a set of unit tests, usable with Python 2 or 3. I'm using a loop over a list of parameters to generate tests with different permutations of parameters. Instead of calling util() with values 0-4 as I would expect, each call uses

Re: real-time monitoring of propriety system: embedding python in C or embedding C in python?

2013-02-05 Thread rusi
On Feb 5, 8:10 pm, Bas wrote: > Since all the functions I have to interface with (read and write of live > data, sending > commands, ...) are implemented in C, the solution will require writing both C > and python. Standard embedding/extending is ok when the interface is 'thin' ie the number of

Re: real-time monitoring of propriety system: embedding python in C or embedding C in python?

2013-02-05 Thread Duncan Booth
Bas wrote: > A) Implement the main program in C. In a loop, get a chunk of data > using direct call of C functions, convert data to python variables and > call an embedded python interpreter that runs one iteration of the > user's algorithm. When the script finishes, you read some variables > fro

real-time monitoring of propriety system: embedding python in C or embedding C in python?

2013-02-05 Thread Bas
Hi Group, at work, we are thinking to replace some legacy application, which is a home-grown scripting language for monitoring and controlling a large experiment. It is able to read live data from sensors, do some simple logic and calculations, send commands to other subsystems and finally gene

Re: ERROR:root:code for hash md5 was not found

2013-02-05 Thread bidzina_kapanadze
On Wednesday, January 11, 2012 12:28:52 PM UTC+1, Laurent Claessens wrote: > Le 11/01/2012 12:19, mike a �crit : > > > Hi, > > > > > > We are running are running Python program on Redhat 5.5. > > > > > > When executing our program we get the following error ( see below). > > > > > > Any id

Re: Best Practice Question

2013-02-05 Thread Albert Hopkins
[...] > By the way, did someone ever notice that r'\' fails ? I'm sure there's a > reason for that... (python 2.5) Anyone knows ? > > r'\' > SyntaxError: EOL while scanning single-quoted string > > "Even in a raw string, string quotes can be escaped with a backslash, but the backslash remains in

Re: Best Practice Question

2013-02-05 Thread Jean-Michel Pichavant
- Original Message - > On 02/04/2013 11:23 PM, Anthony Correia wrote: > > Just started learning Python. I just wrote a simple copy files > > script. I use Powershell now as my main scripting language but I > > wanted to extend into the linux platform as well. Is this the > > best way to

Re: Run time Error

2013-02-05 Thread Roy Smith
In article , inshu chauhan wrote: > Hello all, > > I am trying to run a small code of mine but I am getting a run time error. > What is actually meant by run time error ? it is saying to contact > programme administrator something. Why one would get this error ? and how > to remove it ? Start

Re: Run time Error

2013-02-05 Thread Chris Angelico
On Wed, Feb 6, 2013 at 1:05 AM, inshu chauhan wrote: > Hello all, > > I am trying to run a small code of mine but I am getting a run time error. > What is actually meant by run time error ? it is saying to contact programme > administrator something. Why one would get this error ? and how to remov

Run time Error

2013-02-05 Thread inshu chauhan
Hello all, I am trying to run a small code of mine but I am getting a run time error. What is actually meant by run time error ? it is saying to contact programme administrator something. Why one would get this error ? and how to remove it ? -- http://mail.python.org/mailman/listinfo/python-list

Detecting a click on the turtle screen when the turtle isn't doing anything?

2013-02-05 Thread Adam Funk
I'm trying to get a program to do some plotting with turtle graphics, then wait for the user to click on the graphics window, then do some more plotting, &c. So far I have the following, which doesn't work: #v+ waiting = False def clicked(x, y): global waiting print('clicked at %f %f' %

Re: [GENERAL] DEFERRABLE NOT NULL constraint

2013-02-05 Thread Chris Angelico
On Wed, Feb 6, 2013 at 12:31 AM, Bèrto ëd Sèra wrote: > Hi Chris, > >> Why do that as a trigger, then? Why not simply call a procedure that >> generates the value and inserts it? > > Because this must be unknown to whoever makes the call and I'm not > supposed to expose any detail of what's going

Re: Opinion on best practice...

2013-02-05 Thread Grant Edwards
On 2013-02-05, Anthony Correia wrote: > I need to pick up a language that would cover the Linux platform. Well, you haven't really described what it is you're trying to do, but it looks to me like bash and the usual set of shell utilities (e.g. find) is what you need rather than Python. > I u

Re: Opinion on best practice...

2013-02-05 Thread Grant Edwards
On 2013-02-05, Terry Reedy wrote: > On 2/4/2013 11:14 PM, Anthony Correia wrote: >> I need to pick up a language that would cover the Linux platform. I use >> Powershell for a scripting language on the Windows side of things. Very >> simple copy files script. Is this the best way to do it? >>

Re: Opinion on best practice...

2013-02-05 Thread Ulrich Eckhardt
Am 05.02.2013 11:35, schrieb Peter Otten: Ulrich Eckhardt wrote: [...] use os.path.walk(), because that doesn't first build a list and then iterate over the list but iterates over the single elements directly. [...] Not true. os.walk() uses os.listdir() internally. Oh. 8| Thanks for proofr

Re: Decimal 0**0

2013-02-05 Thread Stefan Krah
Steven D'Aprano wrote: > Does anyone have an explanation why Decimal 0**0 behaves so differently from > float 0**0? > > Tested in both Python 2.7 and 3.3, float 0**0 returns 1, as I would expect: The behavior follows the specification: http://speleotrove.com/decimal/daops.html#refpower Why ex

Decimal 0**0

2013-02-05 Thread Steven D'Aprano
Does anyone have an explanation why Decimal 0**0 behaves so differently from float 0**0? Tested in both Python 2.7 and 3.3, float 0**0 returns 1, as I would expect: py> 0.0**0.0 # floats return 1 1.0 With Decimals, if InvalidOperation is trapped it raised: py> from decimal import getcontext,

Re: LBYL vs EAFP

2013-02-05 Thread Chris Angelico
On Tue, Feb 5, 2013 at 11:04 PM, Steven D'Aprano wrote: > py> isinstance(NAN, Number) > True Does that line of code count as nerd humour? ChrisA -- http://mail.python.org/mailman/listinfo/python-list

Re: LBYL vs EAFP

2013-02-05 Thread Steven D'Aprano
Pete Forman wrote: > Steven D'Aprano writes: >>> I want to check that a value is a number. [...] >> I'm leaning towards an isinstance check [...] > BTW what if the value is Not-a-Number? ;-) Nothing different, and hopefully exactly what the caller expects. As far as Python is concerned, NANs are

Re: autoflush on/off

2013-02-05 Thread Piet van Oostrum
Ulrich Eckhardt writes: > Am 05.02.2013 01:09, schrieb Jabba Laci: >> setting the sys.stdout back to the original value doesn't work. > [...] >> The problem is in __exit__ when sys.stdout is pointed to the old >> value. sys.stdout.write doesn't work from then on. Output: >> >> .close failed

Re: Best Practice Question

2013-02-05 Thread Dave Angel
On 02/04/2013 11:23 PM, Anthony Correia wrote: Just started learning Python. I just wrote a simple copy files script. I use Powershell now as my main scripting language but I wanted to extend into the linux platform as well. Is this the best way to do it? import os objdir = ("C:\\temp2

Re: Opinion on best practice...

2013-02-05 Thread rusi
> - Original Message - > > I need to pick up a language that would cover the Linux platform.  I > > use Powershell for a scripting language on the Windows side of > > things.  Very simple copy files script.  Is this the best way to do > > it? Have you seen/checked http://pash.sourceforge

Re: Opinion on best practice...

2013-02-05 Thread Peter Otten
Ulrich Eckhardt wrote: > separate variable but iterated over it directly. For large dirs, it > could also be better to use os.path.walk(), because that doesn't first > build a list and then iterate over the list but iterates over the single > elements directly. This avoids the memory allocation ov

Re: Opinion on best practice...

2013-02-05 Thread Jean-Michel Pichavant
- Original Message - > I need to pick up a language that would cover the Linux platform. I > use Powershell for a scripting language on the Windows side of > things. Very simple copy files script. Is this the best way to do > it? > > import os > > objdir = ("C:\\temp2") > colDi

Re: LBYL vs EAFP

2013-02-05 Thread Pete Forman
Steven D'Aprano writes: >> I want to check that a value is a number. [...] > I'm leaning towards an isinstance check Well that is the answer to your question, whether the value *is* a number. EAFP can answer the question whether the value *behaves* like a number, where the criterion depends on wh

Re: autoflush on/off

2013-02-05 Thread Ulrich Eckhardt
Am 05.02.2013 01:09, schrieb Jabba Laci: I like the context manager idea There is a helper library for constructing context managers, see http://docs.python.org/2/library/contextlib.html. That would have made your code even shorter. setting the sys.stdout back to the original value doesn

Re: Opinion on best practice...

2013-02-05 Thread Ulrich Eckhardt
Am 05.02.2013 05:14, schrieb Anthony Correia: I need to pick up a language that would cover the Linux platform. I use Powershell for a scripting language on the Windows side of things. Very simple copy files script. Is this the best way to do it? import os objdir = ("C:\\temp2") Dro

Java NIO server and Python asyncore client

2013-02-05 Thread foobarometer
Can someone help answer this? http://stackoverflow.com/questions/14698020/java-nio-server-and-python-asyncore-client Blocking python client works, asyncore doesn't work. Server.java: import java.net.InetAddress; import java.net.InetSocketAddress; import java.nio.channels.SelectionKey; import ja

Re: Opinion on best practice...

2013-02-05 Thread Terry Reedy
On 2/4/2013 11:14 PM, Anthony Correia wrote: I need to pick up a language that would cover the Linux platform. I use Powershell for a scripting language on the Windows side of things. Very simple copy files script. Is this the best way to do it? import os objdir = ("C:\\temp2") c