On 21.10.18 08:13, boB Stepp wrote:
Use case: I want to allow a user of my Solitaire Scorekeeper program
to be able to give any name he wants to each game of solitaire he
wishes to record. My thought for permanent storage of each game's
parameters is to use a dictionary to map the user-chosen g
On 05/07/2018 04:15 PM, Alan Gauld via Tutor wrote:
On 7 May 2018, at 15:08, ruiyan wrote:
I want to log to the remote supercomputer automatically, upload and download
files
If it supports ftp then there is an ftp module.
There are also http and ssh modules, depending on the complexity o
On 04/19/2018 10:45 AM, Niharika Jakhar wrote:
Hi
I want to store a file from BioGRID database (tab separated file, big data)
into a data structure(I prefer lists, please let me know if another would
be better) and I am trying to print the objects.
Here’s my code:
class BioGRIDReader:
def __
On 06.02.2018 10:53, Alan Gauld via Tutor wrote:
You would have needed something like
fraction = Fraction(input('>'))
Assuming Fraction has a string based constructor which
I don't think it does. I really don't think Fraction
helps you here.
Oh, most certainly it has - though it may accept m
On 08/02/2017 04:57 PM, Steven D'Aprano wrote:
On Wed, Aug 02, 2017 at 10:48:39PM +1000, Ben Finney wrote:
Thomas Güttler writes:
Maybe I am doing something wrong. I was proud because I did use
“console_scripts” entry points.
Did someone lead you to believe it was wrong? Setuptools console
On 07/31/2017 02:53 PM, Chris Warrick wrote:
On 31 July 2017 at 14:45, Wolfgang Maier
wrote:
On 07/31/2017 03:31 AM, Mats Wichmann wrote:
since this all opinions :), I don't think idle is worth bothering with.
for editor that can do ide like things, consider atom (free, get a bun
On 07/31/2017 03:31 AM, Mats Wichmann wrote:
since this all opinions :), I don't think idle is worth bothering with. for
editor that can do ide like things, consider atom (free, get a bunch of
plugins) or sublime text (not free). for a full ide, pycharm is great
(community edition free). for a
On 03/16/2017 10:38 AM, Wolfgang Maier wrote:
In addition, I'd agree with Alan that the advantage of using numpy
functionality in this function seems quite questionable. You'd probably
get pretty much the same performance with just:
def sum2(N):
return sum(2*(1+3**(i-1)) for i in
On 03/16/2017 10:12 AM, Alan Gauld via Tutor wrote:
On 16/03/17 05:11, Aaliyah Ebrahim wrote:
def sum2(N):
b = np.arange(1,N+1,1)
mylist = [ ]
for i in b:
terms = 2*(1+3**(i-1))
a = mylist.append[terms]
return np.sum(mylist)
terms = 2*(1+3**(i-1))> 9
On 28.10.2016 04:49, Jim Byrnes wrote:
On 10/27/2016 08:09 PM, Danny Yoo wrote:
On Thu, Oct 27, 2016 at 5:40 PM, Jim Byrnes
wrote:
Is comp.lang.python available on gmane?
I've googled and found references to it being on gmane but I can't
find it
there. I'd like to use gmane because Comcast do
On 26.10.2016 19:44, Alex Kleider wrote:
I've got three files as follows:
keeping just the relevant lines
...
2:
#!/bin/bash
#
# file: call.sh
# Demonstrates running a local python script on another host
# with command line arguments specified locally.
ssh -p22 alex@10.10.10.10 python3 -u
On 25.10.2016 10:09, niraj pandey wrote:
Try this.
my_string = '0,1,2,3'
my_lst=my_string.split(",")
leng = len(my_lst)
b=sum(my_lst)
avg=float(b/leng)
print avg
better try things yourself before suggesting them to others:
>>> my_string = '0,1,2,3'
>>> my_lst=my_string.split(",")
>>> leng =
On 25.10.2016 10:10, Ben Finney wrote:
Bryon Adams writes:
I'm very new to python so please forgive what may be a beginner
question.
Welcome! You are in the right place for asking beginner Python questions
:-)
I'm thinking there should be a way to do this without the for loop I
used, b
On 20.09.2016 17:48, Gabriele Brambilla wrote:
Hi,
I have this script
import numpy as np
import random as rnd
from math import *
import matplotlib.pyplot as plt
folder = '../NOBACKUP/heavi3/'
pre = '10'
dat = '.dat'
snshot = '4189'
d = 0.02
d2 = d/2.0
tot = 156
half = 78
points = 3375000
On 29.06.2016 04:16, Alex Kleider wrote:
On 2016-06-28 11:46, David Rock wrote:
Here’s my take on a lot of this (it’s similar to what’s been said
already, so this is more of a general philosophy of distros).
Very interesting reading for which I thank you.
I'd be interested in knowing if you'
On 29.06.2016 01:16, boB Stepp wrote:
On Mon, Jun 27, 2016 at 10:48 PM, Steven D'Aprano wrote:
What about running Win7 in a virtual machine?
What type of performance hit will I take when running CPU intensive
processes? I don't yet have any real experiences with running virtual
machines. If
On 28.06.2016 18:58, Steven D'Aprano wrote:
On Tue, Jun 28, 2016 at 07:58:22AM -0700, Alex Kleider wrote:
On 2016-06-27 20:48, Steven D'Aprano wrote:
Also Debian. Not Ubuntu.
Can you elaborate why you specifically exclude Ubuntu?
I've been bitten by an Ubuntu install where half of the GU
On 09.03.2016 04:41, syed zaidi wrote:
Well, I know about it but I want to perform the task using python 2.7 since
the tool I'm trying to develop is in 2.7. For some reason I want to do it
without biopython please help. ..
Fair enough. Parsing the fasta and the other (was it gff?) input is
On 13.10.2015 15:43, David Aldrich wrote:
>
I have one more question, which regards style. Suppose my 'send' method is in
its own module: TxControl, along with the custom exceptions:
TxControl.py:
class MessageTimeoutError(Exception): pass
class UndefinedMessageTypeError(Exception): pass
def
On 16.04.2015 19:24, Jim Mooney wrote:
Understood about the quondam inexactness of floating point bit
representation. I was just wondering why the different implementation of
representing it when using Fraction(float) as opposed to using
Fraction(string(float)). In terms of user presentation, t
On 04/16/2015 07:03 AM, Jim Mooney wrote:
Why does Fraction interpret a number and string so differently? They come
out the same, but it seems rather odd
from fractions import Fraction
Fraction(1.64)
Fraction(738590337613, 4503599627370496)
Fraction("1.64")
Fraction(41, 25)
41/25
1.64
On 04/01/2015 11:04 AM, Alan Gauld wrote:
On 01/04/15 05:50, Jim Mooney wrote:
s = [1,2,3,4,5,6,7,8]
list(zip(*[iter(s)]*2))
[(1, 2), (3, 4), (5, 6), (7, 8)]
Personally I'd have used slicing in this example:
zip(s[::2],s[1::2])
With an emphasis on *in this example*.
The idiom you are cit
On 09.03.2015 18:50, David Heiser wrote:
On 3/9/2015 9:50 AM, Alan Gauld wrote:
Somebody posted a question asking how to fond out if a file
exists. The message was in the queue and I thought I'd approved
it but it hasn't shown up yet. Sorry to the OP if I've messed up.
The answer is that you
On 10/10/2014 05:57 AM, boB Stepp wrote:
I am hoping to save other people the grief I just worked through. I
wanted to run both Python 2 and 3 on my windows PC, and, after
googling this topic found that with Python 3.3 or later one could
easily do both. So I merrily installed Python 3.4.2 first a
On 09/10/2014 11:20 AM, jarod...@libero.it wrote:
If I follow the exmple I have this type of error:
File "./RNA_prova.py", line 73, in run
for line in p1.stdout():
TypeError: 'NoneType' object is not callable
You have at least two errors in your script below:
This time you're not piping
On 09/09/2014 11:45 AM, Peter Otten wrote:
jarod...@libero.it wrote:
I want to use subprocess for run some programs But I need to be sure the
program end before continue with the other:
subprocess.call("ls")
cmd1 = i
p1 = subprocess.Popen(cmd1,shell=True,stdout=subprocess.PIPE)
while True:
if
On 24.07.2014 14:37, Chris “Kwpolska” Warrick wrote:
It’s recommended to switch to the [[ syntax anyways, some people
consider [ deprecated. Also, [ is actually /bin/[ while [[ lives in
your shell (and is therefore faster).
About the equals sign, == is the preferred syntax, and = is also
consi
On 24.07.2014 14:19, Chris “Kwpolska” Warrick wrote:
python test.py
if [ $? = 0 ]; then
python second.py
fi
as your shell script.
The [ ] and = should be doubled.
?? why that ?
Double brackets can do more:
http://stackoverflow.com/questions/2188199/how-to-use-double-or-single-br
On 24.07.2014 14:09, Chris “Kwpolska” Warrick wrote:
On Thu, Jul 24, 2014 at 2:01 PM, Wolfgang Maier
wrote:
Try something like this (assuming bash):
python test.py
if [ $? = 0 ]; then
python second.py
fi
as your shell script.
The [ ] and = should be doubled.
?? why that ?
But all
On 24.07.2014 13:35, jitendra gupta wrote:
Hi All
My shell script is not throwing any error when I am having some error
in Python code.
test.py ~~
def main():
print "Test"
#some case error need to be thrown
raise Exception("Here is error")
if __name__ == "__main__"
On 07/23/2014 11:28 AM, Wolfgang Maier wrote:
breakpoints = [your_list_of breakpoints]
large_value_buffer = []
int_list_iter = iter(int_list) # see comment below
for breakpoint in breakpoints:
sublist = large_value_buffer
for value in int_list_iter:
if value < breakpo
On 07/23/2014 03:36 AM, LN A-go-go wrote:
>
> with your help. I have been working the last few days, I am sorry to
> say, unsuccessfully, to calculate the mean (that's easy), split the data
> into sub-groups or secondary means - which are the break values between
> 4 classes. Create data-sets wi
On 07/23/2014 03:36 AM, LN A-go-go wrote:
Hi again and thank-you Wolfgang and company. I wish I could give you
snickers bars or something! I was able to get through the road_blocks
with your help. I have been working the last few days, I am sorry to
say, unsuccessfully, to calculate the mean (
On 21.07.2014 01:48, LN A-go-go wrote:> Dear Gurus,
> Thank-you thank-you, one more time, thank-you.
> I am over that hurdle and have the other: converting the list of
> characters that was just created by the split - into integers so I can
> manipulate them. I was trying to convert to a string,
On 20.07.2014 22:37, Marc Tompkins wrote:
First of all, I would take advantage of the "with" construction, like so:
with open('C:/Python27/egund919/Program1/BOJ_B.txt','r') as infile:
#do stuff with infile
When the block of code inside of the "with" section finishes, Python
will take care
On 20.07.2014 17:40, LN A-go-go wrote:
>>> filename = "C:/Python27/egund919/Program1/BOJ.txt"
>>> myfile = open(filename,"r")
>>> newfile = "C:/Python27/egund919/Program1/BOJ_B.txt"
>>> mynewfile = open(newfile,"w")
>>> while True:
line = myfile.readline()
print line
mynewfile.write(l
On 16.07.2014 13:49, Jose Amoreira wrote:
Hello
I wrote a function that, given a list of numbers, finds clusters of
values by proximity and returns a reduced list containing the centers of
these clusters. However, I find it rather unclear. I would appreciate
any comments on how pythonic my functi
On 16.07.2014 10:04, jarod...@libero.it wrote:
Hi there!!!
I have a file with this data
['uc002uvo.3 ', 'uc001mae.1']
['uc010dya.2 ', 'uc001kko.2']
['uc003ejx.2 ', 'uc010yfr.1']
['uc001bhk.2 ', 'uc003eib.2']
['uc001znc.2 ', 'uc001efn.2']
['uc002ycq.2 ', 'uc001vnh.2']
['uc001odf.1 ', 'uc002mwd.2'
On 12.07.2014 14:20, Dave Angel wrote:
I don't remember my high school German enough to remember if the ß
character is an example, but in various languages there are
characters that exist only in uppercase, and whose lowercase
equivalent is multiple letters. Or vice versa. And characters
On 12.07.2014 14:19, Steven D'Aprano wrote:
On Sat, Jul 12, 2014 at 11:27:17AM +0100, Alan Gauld wrote:
On 12/07/14 10:28, Steven D'Aprano wrote:
If you're using Python 3.3 or higher, it is better to use
message.casefold rather than lower. For English, there's no real
difference:
...
but it ca
plz provide info :(
State the problem you are trying to solve and your program's expected
output.
Include any error messages you are getting - the full
text not a summary.
It's also helpful if you state the Python and OS version you are using.
___
T
On 09.07.2014 08:16, Alan Gauld wrote:
On 09/07/14 06:58, Alan Gauld wrote:
list1 = [1, 8, 15]
list2 = [2, 9, 16]
list3 = [[3, 4, 5, 6], [10, 11, 12, 13], [17, 18, 19, 20]]
list4 = [7, 14, 21]
I'm thinking something like
result = []
for L in (list1,list2,list3):
if isinstance(L,list)
On 25.06.2014 00:55, Alex Kleider wrote:
I was surprised that the use of dictionaries was suggested, especially
since we were told there were many many files.
The OP was talking about several thousands of files, which is, of
course, too many for manual processing, but is far from an impressi
On 04.06.2014 12:29, jarod...@libero.it wrote:
Dear all thanks for your suggestion!!!
In [4]: with open("prova.csv") as p:
for i in p:
lines =i.rstrip("\n").split("\t")
line = (lines[0],lines[1])
...: diz.setdefault(line,set()).add(lines[2])
...:
In [5]: d
On 03.06.2014 21:56, Wolfgang Maier wrote:
- the tricky part is what to do with keys that are encountered for the
first time and, thus, don't have a set associated with them yet.
Here, dict.setdefault() will help you
(https://docs.python.org/2.7/library/stdtypes.html?highlight=setde
On 03.06.2014 18:24, jarod...@libero.it wrote:
HI there!!!
I have afile like this:
file.txt
programssample gene
program1sample1 TP53
program1sample1 TP53
program1sample2 PRNP
program1sample2 ATF3
program2sample1 TP53
program2sample1 PRNP
p
Adam Gold gmx.com> writes:
>
> I start with the following which can be used to encrypt a single file
> (assume I have the indentations correct in the actual code, I can't seem
> to modify the wrapping with my email client):
>
> phrase = '12345'
> cipher = 'AES256'
> gpg = gnupg.GPG(gnupghome='
On 31.05.2014 11:23, Sasi - wrote:
Hi, i tried to make a code to execute the functions that i described
below. However i got a break outside the loop error and i have tried to
tab and all that but i still get the same error for line 23. I'm using
python 2.7
Hi,
as a general rule, copy paste the
On 28.05.2014 21:16, jarod...@libero.it wrote:
Dear all!
I have two example files:
tmp.csv:
namevalue root
mark34 yes
tmp2.csv
namevalue root
I want to print a different text if I have more than one row and if I have
only one row. My code is this:
with open("tmp.csv") as p
On 21.05.2014 12:32, 1 2 wrote:
Hi there,
As shown in the codes below, I want to end the loop until the s is no
greater than -5 but I found there is no "do... loop until..." like C so
what should I do? I will write it in C's style
s,n = 0,1
do:
import math
s=s+(math.log((n+1)/(n+2))
On 17.05.2014 15:26, Alan Gauld wrote:
On 17/05/14 08:01, ani wrote:
So I thought it would be cool to read a sequence at three different
frames,
A sequence of what?
And whats a frame in this context?
...I've come across a conundrum: how to make a list of lists.
outerlist = []
innerlist = [
Peter Otten <__peter__ web.de> writes:
> Look at this line:
>
> > if __name__ == " __main__":
>
do so very closely :)
Wolfgang
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/li
Rafael Knuth gmail.com> writes:
>
> Hej there,
>
> > I use any() and all() frequently. For example, suppose you have a
> > function that takes a list of numbers, and they are all supposed to be
> > positive.
> >
> > def calculate_values(numbers):
> > if all(number > 0 for number in numbers)
Steven D'Aprano pearwood.info> writes:
>
> On Tue, Dec 10, 2013 at 10:39:34AM +0100, Rafael Knuth wrote:
>
> > def DigSum (integer):
> > s = 0
> > while integer != 0:
> > integer, remainder = divmod(integer, 10)
> > s += remainder
> > print(s)
>
> A thought comes to
Asokan Pichai talentsprint.com> writes:
>
> If you liked it, I will give you one that uses one less variable
>
> def digitSum(n):
> dsum = 0
> while n > 0:
> dsum += n % 10
>
> n /= 10
> return dsum
>
> Stupid of me not to have mentioned that this Pyt
spir gmail.com> writes:
>
> On 12/09/2013 02:29 PM, Wolfgang Maier wrote:
> > spir gmail.com> writes:
> >
> >>
> >> Tu sum it up (aha!): you algorithm is the right and only one
> >
> > No, it's not the only one. It's certai
spir gmail.com> writes:
>
> Tu sum it up (aha!): you algorithm is the right and only one
No, it's not the only one. It's certainly the most obvious one, but there is
also the pure numbers approach pointed out by me and Alan.
___
Tutor maillist -
Rafael Knuth gmail.com> writes:
>
> Hej there,
>
> I wrote a program that converts an integer into a digit sum:
>
> def DigitSum(YourNumber):
> DigitList = []
> YourNumber = str(YourNumber)
> for i in YourNumber:
> DigitList.append(int(i))
> print(sum(DigitList))
>
> D
Alan Gauld btinternet.com> writes:
>
> On 04/12/13 10:22, Wolfgang Maier wrote:
>
> >
> > # instead of senateInfo[lastName] = state,
> > # which builds a simple state dictionary
> > if lastName in senateInfo:
> >
Byron Ruffin g.austincc.edu> writes:
>
>
>
>
>
> I realize the code snippet was bad. It was meant to be pseudo code. I
was on my phone and far from pc. Anyway
> I tried this: already_seen = set()
> for name in last_names:
> if name in already_seen:
> print("Already seen",
Alan Gauld btinternet.com> writes:
>
> On 02/12/13 11:03, Wolfgang Maier wrote:
>
> > ... and since you want to be able to resolve ambiguous last names based on
> > first names, you will have to store not just the states, but also the first
> > names.
> >
Oscar Benjamin gmail.com> writes:
>
> On 2 December 2013 02:25, Byron Ruffin g.austincc.edu>
wrote:
> >
> > The following program works and does what I want except for one last problem
> > I need to handle. The program reads a txt file of senators and their
> > associated states and when I in
richard kappler gmail.com> writes:
>
>
> Now I'm completely lost. While opening the serial port outside the
function sounds like a good idea, I'm thinking that might not work unless I
am mistaken. The sensorRead function once it's called would then basically
own the serial port barring other tr
Hi again,
think I spotted the problem now:
you’re setting up your connection everytime you enter the function (with the
serial.Serial call), but I guess you’re calling that function repeatedly to
retrieve lines. That’s wrong and means you could loose data that was sent
while you weren’t listening.
richard kappler gmail.com> writes:
>
> I have a script that reads sensor values gathered by an Arduino board from
serial as a dictionary, said values to later be used in the AI for Nav &
Control. Here's the script:
> #!/usr/bin/python
>
>
> def sensorRead():
> import serial
> from time
richard kappler gmail.com> writes:
>
> I'm using psutil to generate some somatic data with the following script:
>
> import psutil as ps
>
> cpu = ps.cpu_percent()
> mem = ps.virtual_memory()
> disk = ps.disk_usage('/')
>
> All works well, but except for cpu I am struggling to learn how to st
Arijit Ukil tcs.com> writes:
>
> I have following random number generation
> function
> def
> rand_int ():
> rand_num = int(math.ceil
> (random.random()*1000))
> return
> rand_num
> I like to make the value of rand_num
> (return of rand_int) static/ unchanged after first call even if it
Alan Gauld btinternet.com> writes:
>
> On 21/06/13 07:21, Arijit Ukil wrote:
> > I have following random number generation function
> >
> > def*rand_int* ():
> > rand_num = int(math.ceil (random.random()*1000))
> > returnrand_num
> >
> > I like to make the value of rand_num (return of rand_
Dave Angel davea.name> writes:
>
> > str_num = '1234567890'
> > n = 5
> >
> > strings = [str_num[i:i+5] for i in range(0, len(str_num)) if
> > len(str_num[i:i+5])==5]
>
> If you changed the range() size, you could eliminate the extra if test.
> After all, the only ones that'll be short are t
On 24 May 2013 12:01, Rafael Knuth gmail.com> wrote:
> Hello,
>
> I am writing a program in Python 3.3.0 which flips a coin 10 x times and
> then counts the number of heads and tails. It obviously does something else
> than I intended, and I am wondering what I did wrong:
>
> import random
>
> pri
70 matches
Mail list logo