Re: [Tutor] print() invalid syntax error

2014-12-23 Thread Adam Jensen
On Tue, 23 Dec 2014 18:27:10 + stuart kurutac wrote: > finish = (int(input("Finish: ")) The parenthesis aren't balanced. I would have written it as: finish = int(input("Finish: ")) but something like this should also work: finish = (int(input("Finish: "))) ___

Re: [Tutor] My Query - How to implement multi threading with remote execution capability in python to achieve parallel processing

2014-12-23 Thread Adam Jensen
This thread is hilarious. Thanks for the chuckle. http://www.ignyte.ms/whitepapers/LayersOf%20HumanValuesInStrategy.pdf http://www.principiadiscordia.com/downloads/04%20Prometheus%20Rising.pdf On Mon, 22 Dec 2014 11:27:01 + Vishwas Pathak wrote: > I am working building on developing an au

Re: [Tutor] Learning to program, not code.

2014-12-21 Thread Adam Jensen
On Sun, 21 Dec 2014 21:15:43 +1100 Ben Finney wrote: > Use a distributed version control system > (Mercurial is good and is written in Python) I'm beginning to really appreciate [fossil](http://fossil-scm.org/). Re: "Learning to program, not code". Is that like learning to think rather than

Re: [Tutor] lottery problem (Was Re: (no subject))

2014-12-19 Thread Adam Jensen
On Fri, 19 Dec 2014 10:32:15 +0100 Peter Otten <__pete...@web.de> wrote: > Basically > > from random import randint, seed > > is equivalent to > > import random > randint = random.randint > seed = random.seed > del random > > From that you can deduce that the whole random module is loaded int

Re: [Tutor] lottery problem (Was Re: (no subject))

2014-12-18 Thread Adam Jensen
On Thu, 18 Dec 2014 20:27:03 -0500 Adam Jensen wrote: > And to build the 'lines' list (although, this is getting rather ugly): > > >>> lines = [[random.randint(x,x+6) for x in range(1,50,7)] for i in range(7)] Oops, in the context of the original program this might

Re: [Tutor] lottery problem (Was Re: (no subject))

2014-12-18 Thread Adam Jensen
On Fri, 19 Dec 2014 00:55:49 + Alan Gauld wrote: > You could have used a list instead of all the > individual variables > > line[0] = ... > line[1] = ... > > But then you could get clever and use a loop: > > while lines != 0: > start = 1 > period = 7 > for lineNum in range(7):

Re: [Tutor] Need help!

2014-12-13 Thread Adam Jensen
On Fri, 12 Dec 2014 07:46:05 -0500 Jagannath Ramanan wrote: > My name is jag. I need little bit of help understanding something. I have a > vncserver running at the background in redhat. My client is lubuntu where > im using python. > > For some reason the communication is only possible between

Re: [Tutor] Memory management in Python

2014-12-09 Thread Adam Jensen
On Wed, 26 Nov 2014 14:08:53 + Raúl Cumplido wrote: > This web is quite useful to visualize what is happening: > http://www.pythontutor.com/visualize.html#mode=edit > Very nifty web app, thanks for the link! ___ Tutor maillist - Tutor@python.org

Re: [Tutor] Dividing a float derived from a string

2014-11-21 Thread Adam Jensen
> -Original Message- > From: Tutor [mailto:tutor-bounces+hanzer=riseup@python.org] On > Behalf Of Alan Gauld > Sent: Thursday, November 20, 2014 7:24 PM > But that's considered bad practice, it's better to put the valid errors only in > the except line like this: > > try: > print

Re: [Tutor] Dividing a float derived from a string

2014-11-20 Thread Adam Jensen
On Thu, 20 Nov 2014 21:20:27 + Stephanie Morrow wrote: > Hi there, > > I have been posed with the following challenge: > > "Create a script that will ask for a number. Check if their input is a > legitimate number. If it is, multiply it by 12 and print out the result." > > I was able to do

Re: [Tutor] Data chart

2014-11-20 Thread Adam Jensen
import fileinput def parseLine(a): x = a.split('/') b = x[1].split(':') c = b[0].split('.') y = c[0] z = int(b[2]) return x[0], y, z print('{:>4}{:>10}{:>8}{:>8}'.format('','canofica','lnvd','msd')) data = [0, 0, 0] prevDate = "None" for line in fileinput.input():

Re: [Tutor] Dividing a float derived from a string

2014-11-20 Thread Adam Jensen
#!/usr/bin/env python3.4 good = False s = input('Enter a number: ') a = s.split('.') n = len(a) if n <= 2: for y in a: if y.isdigit(): good = True else: good = False exit else: good = False if good: num = float(s) print(num * 12) e

Re: [Tutor] subprocess.Popen basics

2014-10-28 Thread Adam Jensen
On 10/28/2014 04:27 PM, Todd wrote: > Centos has SELinux enabled by default. I dont know if SELinux is > causing your problem, but it is always worth looking at. > > SELinux can keep a process from accessing files or executing another > process. > > Try temporarily disabling SELinux by runnin

Re: [Tutor] subprocess.Popen basics

2014-10-28 Thread Adam Jensen
On 10/28/2014 02:32 PM, Alan Gauld wrote: > I tried -1 and 1 on my Lubuntu and it still works fine. > Definitely weird, it begins to look like a CentOS build issue > but what is CentOS doing different to Lubuntu/Suse/OpenBSD etc? > > From memory CentOS is basically a free version of Red Hat > Ent

Re: [Tutor] subprocess.Popen basics

2014-10-28 Thread Adam Jensen
Update: On 10/27/2014 09:50 PM, Adam Jensen wrote: > What's weird is that I have two different python3.4 installations on > this CentOS-6.5 machine and both have the same behavior (script hangs > until Ctrl+C). > > I built this one (/opt/bin/python3.4) from source

Re: [Tutor] subprocess.Popen basics

2014-10-27 Thread Adam Jensen
On 10/27/2014 09:31 PM, Alan Gauld wrote: > On 27/10/14 20:26, Adam Jensen wrote: > >> That's a bit bizarre. I too have the execution bit set for both the >> python script and the shell script but the same (no joy) behavior occurs >> on both: > >> $ ./subpr

Re: [Tutor] subprocess.Popen basics

2014-10-27 Thread Adam Jensen
On 10/27/2014 03:40 PM, David Abbott wrote: >> It hangs at the print statement and, from the sound of the fans in the >> computer, I suspect it spirals off into an infinite loop somewhere / >> somehow. Does anyone have any ideas about what it is that I might be >> misunderstanding? > > Works here.

Re: [Tutor] subprocess.Popen basics

2014-10-27 Thread Adam Jensen
On 10/27/2014 07:12 PM, Alan Gauld wrote: > On 27/10/14 18:24, Adam Jensen wrote: >> It hangs at the print statement and, from the sound of the fans in the >> computer, I suspect it spirals off into an infinite loop somewhere > > It works fine on my Lubuntu 14 with Python3.4.

Re: [Tutor] subprocess.Popen basics

2014-10-27 Thread Adam Jensen
On 10/27/2014 03:40 PM, David Abbott wrote: >> It hangs at the print statement and, from the sound of the fans in the >> computer, I suspect it spirals off into an infinite loop somewhere / >> somehow. Does anyone have any ideas about what it is that I might be >> misunderstanding? > > Works here

[Tutor] subprocess.Popen basics

2014-10-27 Thread Adam Jensen
Hi, I'm exploring Popen today and I seem to be having some trouble deciphering the [documentation][1]. [1]: docs.python.org/3/library/subprocess.html#popen-constructor In this example (below), I expect to start a shell script as a separate process, send a line of text through a pipe (to the shell

Re: [Tutor] Standard Library Performance (3.4.1)

2014-10-24 Thread Adam Jensen
On 10/24/2014 08:01 AM, Stefan Behnel wrote: > Alan Gauld schrieb am 24.10.2014 um 13:03: >> Not all library modules are C based however so it doesn't >> always apply. But they are usually optimised and thoroughly >> debugged so it is still worth using them rather than building >> your own. > > I

[Tutor] Standard Library Performance (3.4.1)

2014-10-24 Thread Adam Jensen
I'm tinkering this evening and I've noticed that math.factorial() is much faster than my plain python implementations. import math def factorial(n): temp = 1 for k in range(0,n): temp = temp * (n - k) return(temp) def fac(n): r

Re: [Tutor] A question about using stdin/out/err vs named files

2014-10-19 Thread Adam Jensen
On 10/18/2014 02:36 PM, George R Goffe wrote: > Hi, > > When you run a python program, it appears that stdin, stdout, and stderr are > opened automatically. > > I've been trying to find out how you tell if there's data in stdin (like when > you pipe data to a python program) rather > than in a