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
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
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
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
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
- 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
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
> - 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
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
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
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
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
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,
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
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
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
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?
>>
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
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' %
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
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
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
- 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
[...]
> 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
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
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
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
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
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
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
On Tuesday, February 5, 2013 10:17:54 AM UTC-5, [email protected]
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 ?
>
> >
>
On Tue, Feb 5, 2013 at 11:40 AM, Anthony Correia wrote:
> On Tuesday, February 5, 2013 10:17:54 AM UTC-5,
> [email protected]:
> > 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
> >
> > >
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"
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
> 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
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, [email protected]:
On Tue, 5 Feb 2013 15:32:32 +0100 (CET), Jean-Michel Pichavant wrote:
By the way, did someone ever notice tha
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
On 02/05/2013 12:29 PM, [email protected] 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
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
On 2013-02-05 17:29, [email protected] 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--
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
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'
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:
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:
>
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
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
[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,
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.
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
On 2013-02-05, [email protected] 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
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):
>
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
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
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
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
>
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
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
On 02/05/2013 02:58 PM, Adam Funk wrote:
On 2013-02-05, [email protected] 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()
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:
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
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
>
> > 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
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
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
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
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
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
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
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'
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
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
>
On Feb 5, 2013 6:00 PM, "Steven D'Aprano" <
[email protected]> 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'
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
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
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
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
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
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','
> 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:
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
[email protected] 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
81 matches
Mail list logo