Re: [Tutor] Desperately need help to uninstall python from my mac

2016-06-03 Thread Alan Gauld via Tutor
On 03/06/16 17:18, Christian Carbone via Tutor wrote: > As the subject line indicates, I really need help uninstalling python on my > mac.. You almost certainly don;t want to to do that! Your Mac will stop working properly, it uses Python. That's why its installed by default on Macs. > The

Re: [Tutor] Command statement work well on interactive mode, which running as pf file it throws error object has no attribute '__getitem__'

2016-06-09 Thread Alan Gauld via Tutor
On 09/06/16 08:33, Joseph John wrote: > Now when I create a *.py file with all the above steps and run it, I am > getting error > Traceback (most recent call last): > File "./ReadingDataFrom1X.py", line 10, in > c = sheet['A1'] > TypeError: 'Worksheet' object has no attribute

Re: [Tutor] Python Setup Help

2016-06-08 Thread Alan Gauld via Tutor
On 08/06/16 03:24, Vincent Trost via Tutor wrote: > Hi, > I'm looking for help on the proper installation of Python and the Text > editor, Atom. OK, Lets break those into two separate activities. Start with Python. > we downloaded Enthought Canopy and used that for some scientific Python work.

Re: [Tutor] Command statement work well on interactive mode, which running as pf file it throws error object has no attribute '__getitem__'

2016-06-10 Thread Alan Gauld via Tutor
On 09/06/16 10:03, Joseph John wrote: > itsupport@Server-A:~$ cat ReadingDataFrom1X.py > #!/usr/bin/python > import openpyxl > wb = openpyxl.load_workbook('1XDataUserMDN.xlsx') > wb.get_sheet_names() > sheet= wb.get_sheet_by_name('SQL Results') > sheet.title > print sheet.title > print

[Tutor] Fwd: Re: Loop in pre-defined blocks

2016-06-10 Thread Alan Gauld via Tutor
Forwarding to tutor list. Always use Reply All when responding to list mail. > Sorry, to be a little bit more descriptive. I'd like to loop from 1 to 35 > but within this loop there are divisions which I need to prefix that > particular division number. > My output would look like this:

Re: [Tutor] Loop in pre-defined blocks

2016-06-10 Thread Alan Gauld via Tutor
On 10/06/16 23:43, Jignesh Sutar wrote: > Is there a better way to code the below than to specify blocks as I have. > Ideally I'd like to specify blocks simply as *blocks=(12,20,35)* > > blocks=[(1,12), (13,20), (25,35)] > for i,j in enumerate(blocks): > for x in

Re: [Tutor] Practice Exercises for Beginner ?

2016-06-03 Thread Alan Gauld via Tutor
On 02/06/16 21:43, Andrei Colta wrote: > Hi, > > Anyone can recommend practical work on learning python.. seems reading and > reading does not helping. Other have recommended starting a project and that's always the best way. But if you are really stuck for ideas try the Python Challenge. It's

Re: [Tutor] Cmd line not correctly interpreted

2016-06-04 Thread Alan Gauld via Tutor
On 04/06/16 02:01, Alan Outhier wrote: > I'm working on a Python script to call "sox" to convert ;ogg files to .mp3s. 1outname=fname+".mp3" 2fname=ReSpace(fname) # substitute " " with "\ " 3outname=ReSpace(outname) 4cmdline="sox " + fname + " " +outname 5print cmdline 6

Re: [Tutor] Logging exceptions, but getting stderr output instead

2016-05-25 Thread Alan Gauld via Tutor
On 25/05/16 19:11, Alex Hall wrote: > As a quick aside, is there an easy way to halt script execution for some > exceptions? Right now, catching them means that execution continues, but I > sometimes want to log the problem and then abort the script, as the error > means it shouldn't continue.

Re: [Tutor] Loop in pre-defined blocks

2016-06-13 Thread Alan Gauld via Tutor
On 13/06/16 08:46, Ek Esawi wrote: > Here is a beginner code that might work for you. Best of luck. EK > > b=[12, 20, 35] > > for i in range(len(b)): > if i==0: > c=0 > else: > c=b[i-1] > for j in range(c, b[i]): > print(i+1,j+1) The problem here

Re: [Tutor] Hello everybody

2016-06-13 Thread Alan Gauld via Tutor
On 13/06/16 20:55, Влад wrote: >Hi. I've just begin with Python? I'm 34. Is it late or what? If it is - I >will cut it out. What you think guys? No you are just a young whippersnapper. I've had students use my tutorial in their 70s (and in their pre-teens too) But is this also your start

Re: [Tutor] Python ODBC driver for Oracle 9

2016-06-13 Thread Alan Gauld via Tutor
On 13/06/16 11:47, Joseph John wrote: > I am trying to connect Python to Oracle 9 DB, checked for python ODBC > driver for oracle. Please be clear. Are you looking for an ODBC driver that will work with Oracle 9? Or are you looking for a Python DBAPI driver for Oracle 9? Those are two different

Re: [Tutor] Correct use of model-view-controller design pattern

2016-05-30 Thread Alan Gauld via Tutor
On 29/05/16 05:33, boB Stepp wrote: As promised I'm back so will try to answer these... > Some other questions: > > 1) If I were to add code to filter user inputs, which file is the > logical place to place such code? My current impression is that it > should go in the controller, but I could

Re: [Tutor] Correct use of model-view-controller design pattern

2016-05-31 Thread Alan Gauld via Tutor
On 31/05/16 02:25, boB Stepp wrote: > This "views register with models" and "registered views" terminology > is unfamiliar to me. Googling suggests registered views is referring > to a dynamically generated presentation, perhaps in the sense of a db No, this is different. Try googling

Re: [Tutor] Correct use of model-view-controller design pattern

2016-05-31 Thread Alan Gauld via Tutor
On 31/05/16 02:16, boB Stepp wrote: > I perhaps see a general principle developing here: Before passing > data elsewhere, the data should be validated and in a form suitable > for where it is being sent. Correct. > By "business service" are you intending this to mean a totally > different

Re: [Tutor] Help with 'if' statement and the concept of None

2016-05-31 Thread Alan Gauld via Tutor
On 31/05/16 16:16, marat murad via Tutor wrote: > program whose code I have pasted below. The author introduced a new way of > coding the Boolean NOT operator with the 'if' statement I have highlighted > the relevant area,apparently this if statement actually means if money != > 0,which I

Re: [Tutor] Python OLS help

2016-05-31 Thread Alan Gauld via Tutor
On 31/05/16 16:30, Vadim Katsemba wrote: > Hello there, I am having trouble running the Ordinary Least Squares (OLS) > regression on Spyder. I had no idea what Spyder was but a Google search says its an IDE somewhat akin to matlab or IPython... It also has a discussion group:

Re: [Tutor] Tkinter and threading

2016-06-02 Thread Alan Gauld via Tutor
On 02/06/16 14:40, Marco Soldavini wrote: > What if I want to run another loop beside the graphical interface in > the same python script? You need to do it in a separate thread. Keep the Tkinter loop on your main thread and use it to trigger actions. > For example a state machine with a var

Re: [Tutor] Semantic Error: Trying to access elements of list and append to empty list with for loop

2016-06-02 Thread Alan Gauld via Tutor
On 02/06/16 18:05, Olaoluwa Thomas wrote: > lst = list() > for line in fhand: > words = line.split() words is now a list of words a test that a portion of my code was working) > lst.append(words) So you append that list to lst and get a list of lists. Try using + instead: lst +=

Re: [Tutor] Newcomer with organizational questions

2016-05-26 Thread Alan Gauld via Tutor
On 26/05/16 23:34, Max Jegers wrote: > that I wrote a reply with a thank you and a follow-up question, only to > discover that I don’t see a way to send it. A mailing list works by email, so you reply as you would to any email. If you use Reply it goes to the person who sent the email. If you

Re: [Tutor] Study Tips

2016-06-01 Thread Alan Gauld via Tutor
On 01/06/16 20:06, Anindya Mookerjea wrote: > Hi experts, > > I am going to start learning Python and have got no coding > experience/knowledge whatsoever . So Python would be my first programming > language Start with one of the tutorials on the non-programmers page of python.org

Re: [Tutor] OrderedDict?

2016-06-01 Thread Alan Gauld via Tutor
On 01/06/16 16:36, Alex Hall wrote: > I'm trying to find the OrderedDict documentation. I found one page, but it > wasn't very clear on how to actually make an OrderedDict. Plus, an empty > constructor in Python's interpreter returns an error that the class doesn't > exist It's in the

[Tutor] Use of None (was: Re: Tutor Digest, Vol 147, Issue 52)

2016-06-01 Thread Alan Gauld via Tutor
On 01/06/16 12:43, marat murad via Tutor wrote: > Thanks for your replies,I think I understand it much better now. I Also I > wanted to know what the 'None' does in the second program. Please make the subject something meaningful and delete all the excess messages. we have all seen them already

Re: [Tutor] Learning Regular Expressions

2016-05-30 Thread Alan Gauld via Tutor
On 30/05/16 18:21, dirkjso...@gmail.com wrote: > I moved my notes that contained any '\'s to a different python file. > However, if we run it, we get the error I was having. Here's the > script: Runs fine for me. Can you run it using the python command line interpreter rather than IDLE? Do you

Re: [Tutor] Study Tips

2016-05-30 Thread Alan Gauld via Tutor
On 30/05/16 06:45, Steve Lett wrote: > Out of a long list of books that I have collected ( python, Blender, etc ) > I have decided to start on Introducing Python (hard copy 2nd Ed, ebook 3rd > ed) by Bill Lubanovic. Before that I was going to start with Python > Programming for the Absolute

Re: [Tutor] Correct use of model-view-controller design pattern

2016-05-29 Thread Alan Gauld via Tutor
On 29/05/16 05:33, boB Stepp wrote: > I am currently mulling over some information Alan passed along a while > back on using the model-view-controller design pattern (Would > 'architectural pattern' be a better choice of phrase?). Either is appropriate. Design Pattern is more usual, largely

Re: [Tutor] Converting a sequence of dictionaries to a single dictionary

2016-06-22 Thread Alan Gauld via Tutor
On 22/06/16 01:41, Ek Esawi wrote: > I am trying to read a csv file via DictReader and produce a single > dictionary without fieldnames; that is, I just want a single dictionary > that contains tests as keys and grades as values as shown below in my > sample file. OK, As you've discovered that's

Re: [Tutor] capture output from a subprocess while it is being produced

2016-06-14 Thread Alan Gauld via Tutor
On 14/06/16 21:03, Albert-Jan Roskam wrote: > from subprocess import Popen, PIPE > from threading import Thread > from collections import deque > import sys > import time > import os.path > > > def process(dq): > """Run a commandline program, with lots of output""" > cwd =

Re: [Tutor] rock paper scissor lizard spock help

2016-06-14 Thread Alan Gauld via Tutor
On 14/06/16 11:18, Katelyn O'Malley wrote: > Hi I am just getting into python and I am trying to create a rock paper > scissor lizard spock game for 3 people and I cannot figure out the scoring The scoring of any ganme is the bit that makes it unique, so we would need to know the scoring rules to

Re: [Tutor] Correct use of model-view-controller design pattern

2016-06-19 Thread Alan Gauld via Tutor
On 19/06/16 05:18, boB Stepp wrote: > code, I am left scratching my head. My main issue is what am I aiming > at for a final CLI display of a circle? This is not such a simple > thing! First, what are the units for a circle's radius in a CLI? If > it is 1 radius unit = 1 character, then your

Re: [Tutor] Fwd: Turtle

2016-06-19 Thread Alan Gauld via Tutor
On 19/06/16 04:46, Hershel Millman wrote: >> In pycharm, when I enter the following, it replies with the following error >> message: >> >> from turtle import * >> Change that to import turtle and it should work. >> def drawSquare(size=100): >>turtle.pendown() >>turtle.forward(size)

Re: [Tutor] help with comparing list of tuples in python 2

2016-06-17 Thread Alan Gauld via Tutor
On 17/06/16 20:18, Lulu J wrote: > I have a list of dictionaries. Each dictionary has a word and its position > in the text the positions are in the form of a tuple. > Here is an example: > [ > {'position': (5, 4), 'term': u'happy',}, > {'position': (5, 5), 'term': u'something'} > ] > > for

Re: [Tutor] Why are expressions not allowed as parameters in function definition statements?

2016-06-18 Thread Alan Gauld via Tutor
On 18/06/16 20:04, boB Stepp wrote: > py3: def d(row, col/2, radius=5): > File "", line 1 > def d(row, col/2, radius=5): > ^ > SyntaxError: invalid syntax > > And this surprised me. It seems that only identifiers are allowed as > parameters in a function definition

Re: [Tutor] : Turtle

2016-06-23 Thread Alan Gauld via Tutor
On 23/06/16 01:52, Hershel Millman wrote: > I found the turtle module on my computer. > import turtle print(turtle.__file__) > /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/turtle.py That's the right turtle module do not rename it. >>> I entered "import

Re: [Tutor] Py 2.4.4: Inheriting from ftplib.FTP()

2016-06-16 Thread Alan Gauld via Tutor
On 16/06/16 16:38, boB Stepp wrote: > class FTPFiles(FTP, object): > """FTP files to Windows server location(s).""" OK, First comment. You describe this as an action(verb) rather than a noun. Classes should represent nouns (objects) not actions. FTP represents a protocol connection with

Re: [Tutor] turtle on linux

2016-06-24 Thread Alan Gauld via Tutor
On 24/06/16 09:02, Hershel Millman wrote: > I tried to import Tkinter and I got this message: > > Traceback (most recent call last): > File "", line 1, in > ImportError: No module named Tkinter > > > And since I am running Linux, you may be under the false impression that I > know what I am

Re: [Tutor] turtle on linux

2016-06-24 Thread Alan Gauld via Tutor
On 24/06/16 09:02, Hershel Millman wrote: > mean by "package manager", so if you could enlighten me, that would be > immensely appreciated. I meant to add that on Fedora the package manager seems to be called PackageKit... There are also command line tools (yum, DNF and rpm) but I'm guessing

Re: [Tutor] Fwd: Fwd: : Turtle

2016-06-24 Thread Alan Gauld via Tutor
On 24/06/16 08:51, Hershel Millman wrote: > Python didn't come installed on my Mac, my dad had to install it. Nope, it definitely would have been on there because MacOS uses it. So you definitely have two versions of python installed and it looks like one of them (probably the default) is v2.5

Re: [Tutor] Py 2.4.4: Inheriting from ftplib.FTP()

2016-06-17 Thread Alan Gauld via Tutor
On 17/06/16 16:41, boB Stepp wrote: >> Inheritance is a powerful tool but it carries lots of potential for >> problems too,... > > I looked up LSP last night. I can see how I can easily get burned > even on something seemingly simple. One example, which I imagine is > often used, is of a

Re: [Tutor] Fwd: : Turtle

2016-06-23 Thread Alan Gauld via Tutor
On 23/06/16 22:13, Hershel Millman wrote: > What I typed was: > > import turtle > turtle.pendown() > > (And pendown was highlighted in pycharm, indicating that it was not a valid > command.) Don't use pycharm. We need to eliminate as many variables as possible. Start python in a Terminal and

Re: [Tutor] Best way to use excepthook here?

2016-06-23 Thread Alan Gauld via Tutor
On 23/06/16 22:08, Alex Hall wrote: > setup I'm going to try first is one file per job, with utils.py and a > couple others shared between them all. > ... > Now, Python is running two scripts which each have their excepthook set to > something different. What happens when both try to log an

Re: [Tutor] Hi

2016-06-23 Thread Alan Gauld via Tutor
On 23/06/16 19:00, Bharath Swaminathan wrote: > Can I run my python code in multiple processors? I have a dual core... Your OS may run your python code on multiple processors but it's not something you can easily control in Python. Remember that your computer probably has hundreds of processes

Re: [Tutor] Opening EOS-5 HDF file - help!

2016-06-23 Thread Alan Gauld via Tutor
On 23/06/16 15:02, Lennartson, Elizabeth M wrote: > I am trying to open a HDF file in python. I downloaded python 2.7.8 through > miniconda2. Given how many other modules you are loading I'd suggest installing a full anaconda distribution which has everything included as standard. > I also

Re: [Tutor] Fwd: Fwd: : Turtle

2016-06-24 Thread Alan Gauld via Tutor
On 24/06/16 03:02, Hershel Millman wrote: > It tells me: > Trace back (most recent call last): > File "", line 1, in > NameError: name 'turtle' is not defined As I recall, the default install of Python on a Mac does not include Tkinter. Turtle uses Tkinter so I suspect turtle is not

Re: [Tutor] turtle on linux

2016-06-24 Thread Alan Gauld via Tutor
On 24/06/16 01:21, Hershel Millman wrote: > This is from my terminal on Fedora 24: > > [hmillman@localhost ~]$ python > Python 2.7.10 (default, Sep 24 2015, 17:50:09) > [GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux2 > Type "help", "copyright", "credits" or "license" for more information.

Re: [Tutor] Help

2016-06-28 Thread Alan Gauld via Tutor
On 28/06/16 06:54, Aaron Johnson wrote: > I have a program that is telling my i need your digital snake, but i dont > want a snake. Help I'm not sure what you expect us to do based on the information you've given. Can you be more specific? What OS are you running? On what platform (phone,

Re: [Tutor] OT: Recommendations for a Linux distribution to dual-boot with Win7-64 bit

2016-06-28 Thread Alan Gauld via Tutor
On 28/06/16 03:52, boB Stepp wrote: Steven has already repolied and my immediate responbse was almost word for word what he said, sop I'll start again and you can consider this an addendum to Steve's message :-) > 1) I am not ready at this time to take on the challenge of *really* > getting

Re: [Tutor] Coding help 1D diffusion equation

2016-06-26 Thread Alan Gauld via Tutor
On 26/06/16 13:16, Severin Langberg wrote: > I have a problem with solving the 1D diffusion equation for Gaussian > initial using odeint. Anyone care to help? You need to realize that most folks on this list have no idea what that means. You need to provide a bit more detail. What is the 1D

Re: [Tutor] For-else... Any other handy constructs hiding in Python?

2016-06-24 Thread Alan Gauld via Tutor
On 24/06/16 14:07, Alex Hall wrote: > but I never knew for-else was available. for-else is useful although I don't like else for it, I would have preferred something like for-also as being more meaningful. > Are there other constructs that I may have missed Probably. :-) Are you aware of

Re: [Tutor] Most efficient way to read large csv files with properly converted mixed data types.

2016-06-25 Thread Alan Gauld via Tutor
On 25/06/16 08:04, Ek Esawi wrote: > genfromtxt or (2) looping through each line in the file and split, strip, > and assign data type to each entry. > > I am wondering if there is a better and more efficient alternative, > especially to method 2 without using numpy or pandas. The csv module

Re: [Tutor] The game of nim in python

2016-04-22 Thread Alan Gauld via Tutor
On 22/04/16 13:45, Henderson, Kevin (GE Aviation, US) wrote: > Python to Jython. > > Can you help me with a Jython code for the Nim game? > There shouldn't be much difference between a Jython or Python implementation - unless you are building a GUI of course! > Removing 1-4 sticks out of 13,

Re: [Tutor] XML and ElementTree

2016-04-25 Thread Alan Gauld via Tutor
On 25/04/16 17:24, Marco Soldavini wrote: > I've a few questions about parsing XML. I wrote some code that works > but I want to know which are the most intelligent data structures to > parse data to Answer: The ones that suit what you want to do with it. But you haven't told us what you plan on

Re: [Tutor] vpython help

2016-04-29 Thread Alan Gauld via Tutor
On 29/04/16 00:27, Craig, Daniel Joseph wrote: > I am writing a program where I have a ball with a position and velocity > reach a wall in 3D space. Well done, but vpython is a bit off topic for this list which deals with the core python language and libraries. I notice there is a vpython user

Re: [Tutor] XML and ElementTree

2016-04-26 Thread Alan Gauld via Tutor
Forwarding to tutor list. Please always use "Reply All" or "Reply List" when responding to the tutor list. On 26/04/16 09:24, Marco Soldavini wrote: > On Tue, Apr 26, 2016 at 2:05 AM, Alan Gauld via Tutor <tutor@python.org> > wrote: >> On 25/04/16 17:24,

Re: [Tutor] def __init__(self):

2016-04-26 Thread Alan Gauld via Tutor
On 26/04/16 08:01, Santanu Jena wrote: > Hi, > > Pls let me why > " > def __init__(self): > > " > declaration required, what's the use of this one.Pls explain me in > details. It is used to initialise object instances. For example if you define a class Rectangle that has a length and width and

Re: [Tutor] python equivalents for perl list operators?

2016-04-23 Thread Alan Gauld via Tutor
On 23/04/16 01:15, Malcolm Herbert wrote: > @raw = (2, 1, 4, 3); > @grepped = grep { $_ >= 3 } @raw; # (4, 3) grepped = [item for item in raw if item >= 3] > @mapped = map { $_ + 1 } @raw; # (3, 2, 5, 4) mapped = [item +1 for item in raw] or mapped = map(lambda x: x+1, raw) > @sorted

Re: [Tutor] Sorting a list in ascending order [RESOLVED]

2016-04-29 Thread Alan Gauld via Tutor
On 30/04/16 00:05, Ken G. wrote: > been able to change over to Python3. I am not together sure if Python3 > is now more stable to use and more commonly use. It is definitely stable and most libraries are now converted (although a few remain v2 only). Availability of libraries is now the only

Re: [Tutor] Extracting bits from an array

2016-04-29 Thread Alan Gauld via Tutor
On 29/04/16 20:47, Anish Kumar wrote: >> Is the number of bits fixed to four? If so you can shift the bits to the >> right: >> > y = [v>>2 for v in x] > > Right shifting is well defined in Python? Yes, Python has good support for all the common bitwise operations, including the shift

Re: [Tutor] Sorting a list in ascending order [RESOLVED]

2016-04-29 Thread Alan Gauld via Tutor
On 29/04/16 23:58, Ken G. wrote: >> print ''.join(list1) #making it again as a single string >> > > Thanks, Meena, that is great! I changed your last line to: > > print "".join(list1) and it came out as below: > > 0511414453 > > Another quotation mark was needed. No it wasn't.

Re: [Tutor] Issue with Code

2016-04-30 Thread Alan Gauld via Tutor
On 30/04/16 16:30, Olaoluwa Thomas wrote: > I've attached the scripts in question (created via Notepad++). attachments often get stripped by the mail system as a security risk. Since your code is very short just post it in the mail message as plain text. > The problem with this script is that

Re: [Tutor] Fwd: Issue with Code

2016-04-30 Thread Alan Gauld via Tutor
On 30/04/16 22:32, Olaoluwa Thomas wrote: > I sent this forwarded email earlier but hadn't subscribed to the mailing > list so I guess that's why I didn't get a response. When you first subscribe all messages are moderated so there is a delay. Plus remember that email is pretty much the lowest

Re: [Tutor] Issue with Code

2016-04-30 Thread Alan Gauld via Tutor
On 01/05/16 01:16, Alan Gauld via Tutor wrote: > I can't see anything obviously wrong in your code I was too busy focusing on the calculations that I didn't check the 'if' test closely enough. You need to convert your values from strings before comparing them. hours = float(raw_input ('How m

Re: [Tutor] Is there a library which has this object?

2016-04-30 Thread Alan Gauld via Tutor
On 30/04/16 08:48, Yeh wrote: > start = input("please input the value of start: ") > end = input("please input the value of end: ") > dur = input("please input the value of dur: ") > array = np.linspace(float(start),float(end),1000) > dur = float(dur)/len(array) > for i in array: >

Re: [Tutor] (no subject)

2016-04-29 Thread Alan Gauld via Tutor
On 29/04/16 14:10, Павел Лопатин wrote: > Hello, > I downloaded Python 3.4.3 from python.org, installed it, > but when I tried to run it on my notebook a message appeared The error is about IDLE rather than about Python so its probably worth checking whether python itself runs first. Open a CMD

Re: [Tutor] Is there a library which has this object?

2016-04-28 Thread Alan Gauld via Tutor
On 28/04/16 19:08, Yeh wrote: > I just solved my first question by using numpy, as below: You need to post in plain text otherwise the mail system mangles your code, as you can see. > import timeimport numpy as np > start = input("please input the value of start: ")end = input("please input >

Re: [Tutor] Detect the folder of a file

2016-04-28 Thread Alan Gauld via Tutor
On 28/04/16 11:11, Steven D'Aprano wrote: > You know, some day I must learn why people use virtual environments. Me too :-) My co-author included a section in one of her chapters of our recent book, and I duly played with them while reviewing that chapter. But at the end I just deleted it all

Re: [Tutor] Is there a library which has this object?

2016-04-28 Thread Alan Gauld via Tutor
On 28/04/16 14:53, Yeh wrote: > Hi, > Is there a library which can return some numbers continuously? You probably want to look at the itertools module. There you can find among others the count() generator function. Others of possible interest include cycle() and repeat() -- Alan G Author of

Re: [Tutor] Using a dictionary to map functions

2016-04-26 Thread Alan Gauld via Tutor
On 26/04/16 05:30, Colby Christensen wrote: > import re > from store_point import store_point > > try: > infile = open(raw_input("Enter input file name; name.txt:"),'r') > except: > print "Invalid filename" > exit() > > templist = [] > pt_table = {} > cmd_table = {5:"store_point",

Re: [Tutor] FTP file transfer stops, no error given

2016-05-19 Thread Alan Gauld via Tutor
On 19/05/16 19:01, Craig Jackson wrote: > Adding the parentheses worked. So sorry for taking your time. I'm new > to Python and not at all a programmer. Thanks for your help. No trouble, that's what the list is here for. Just remember next time to post the code that fails rather than the code

Re: [Tutor] Getting started in testing

2016-05-19 Thread Alan Gauld via Tutor
On 19/05/16 20:34, Terry Carroll wrote: > Is anyone aware of any good tutorials on testing one's Python code? I'm not a big fan of video tutorials but I recently had to teach myself Junit testing (and mockito) in Java and I found that Youtube videos really helped. I know there are similar videos

Re: [Tutor] genfromtxt and dtype to convert data to correct format

2016-05-19 Thread Alan Gauld via Tutor
On 19/05/16 01:31, Ek Esawi wrote: > Thanks Alan! > > Taking the strtime off did not work either and printed dattime.dattime(very > long date format). But isn't that just the representation of a datetime object (which is what strptime produces)? In other words it's an object not a string. Can

Re: [Tutor] genfromtxt and dtype to convert data to correct format

2016-05-18 Thread Alan Gauld via Tutor
On 17/05/16 18:11, Ek Esawi wrote: > output comes out in the correct format (the desired output as shown below). > I used converters to covert time and date values, but all came out in > string format (output below). What makes you think they are strings? I would expect to see quote signs if

[Tutor] Fwd: Re: I've subscribed to your service, no confirmation yet. I'm looking for a tutor and I need help with some code.

2016-05-24 Thread Alan Gauld via Tutor
and just type; telnet 10.45.34.80 and I'll be able to get to my controller??? Thank you for helping me :) ...you cannot direct the wind but you can adjust your sails... *Angelia Spencer (Angie)* *From:* Alan Gauld

[Tutor] Fwd: Re: I've subscribed to your service, no confirmation yet. I'm looking for a tutor and I need help with some code.

2016-05-24 Thread Alan Gauld via Tutor
Forwarding to the list. Please use reply-all to respond to list messages. Also please use plain text as HTML messages often result in code listings being corrupted, especially the spacing, which is very important in Python. Forwarded Message > I just opened the python IDLE

Re: [Tutor] genfromtxt and dtype to convert data to correct format

2016-05-18 Thread Alan Gauld via Tutor
On 18/05/16 14:14, Ek Esawi wrote: > OPS! Sorry, I made a mistake on the posting. My output is in a string > format as shown below. I want the 1st and 8th integers, the 3rd string > which is OK as, the 2nd date and the rest time. You will need to convert the integers manually I suspect with

Re: [Tutor] SQLite

2016-05-19 Thread Alan Gauld via Tutor
On 19/05/16 10:03, Crusier wrote: > c.execute('''CREATE TABLE stocks > (code text)''') > > # Insert a row of data > List = ['1', '2', '3', '4', '5', '6', '7', > '8', '9', '00010', '00011', '00012'] > > c.executemany('INSERT INTO stocks VALUES

Re: [Tutor] genfromtxt and dtype to convert data to correct format

2016-05-19 Thread Alan Gauld via Tutor
On 19/05/16 12:51, Ek Esawi wrote: > Thanks again! > > I tried a combination of the suggestions and still not getting what i want. > > Here are the original code, file, and output. > > CODE > > mport csv; import numpy as np; from datetime import datetime, date, time > > CF = lambda date:

Re: [Tutor] FTP file transfer stops, no error given

2016-05-19 Thread Alan Gauld via Tutor
On 19/05/16 15:11, Craig Jackson wrote: > ftp. In a nutshell the problem is that if the two objectives are > combined into one Python script, ftp stops uploading in the middle of > the file, but if the same code is split into two files, web page > creation in one script and ftp in another, and

Re: [Tutor] Python 3: string to decimal conversion

2016-05-22 Thread Alan Gauld via Tutor
On 22/05/16 14:19, US wrote: >>with open(file) as csvfile: >>records = csv.reader(csvfile, quoting=csv.QUOTE_NONE) > [...] >>for row in records: > [...] >>try: >>expenses[ts.Date(row[0]).month] += > decimal.Decimal(row[4]) >>

Re: [Tutor] which is best python 2 or python3

2016-05-23 Thread Alan Gauld via Tutor
On 23/05/16 08:54, Palanikumar Gopalakrishnan wrote: > Hi buddies, > I read one article on internet which is said python 2 > and python3 is totally different in programming. > As a beginner which i prefer for my learning, python 2 or python3 ? Nowadays the only real

Re: [Tutor] Python 3: string to decimal conversion

2016-05-23 Thread Alan Gauld via Tutor
On 23/05/16 02:45, US wrote: > I tried the float() function instead of decimal.Decimal and got an > error message: could not convert string to float: '($75.59)'. The problem is that the functions don;t recognize the parens as a negative sign. You will need to convert them yourself. I suggest you

Re: [Tutor] What these Python user-defined functions do?

2016-05-21 Thread Alan Gauld via Tutor
On 21/05/16 02:21, Max Jegers wrote: > class View: > def __init__(self): > self.handle = None > > def order(self, n): > return hostviewOrder(handle, self.handle, n) > > def put(self, fieldName, value, verify=1): > if verify == True: >

Re: [Tutor] postgreSQL + psycopg2

2016-05-10 Thread Alan Gauld via Tutor
On 10/05/16 08:33, nitin chandra wrote: > here is the result. > > 1 > ('Supervisor',) > > 1 > Vinayak > Salunke > 1 > > Now I need to remove the braces and quotes .. :) No you don't. Those are just part of the string representation that Python uses when printing a string inside a tuple. If

Re: [Tutor] Adding to a dict through a for loop confusion.

2016-05-17 Thread Alan Gauld via Tutor
On 17/05/16 09:28, Chris Kavanagh wrote: > # Example #1 > cart_items = ['1','2','3','4','5'] > > cart = {} > > for item in cart_items: > cart['item'] = item 'item' is a literal string. It never changes. So you keep overwriting the dict entry so that at the end of the loop the dict contains

Re: [Tutor] Adding to a dict through a for loop confusion.

2016-05-17 Thread Alan Gauld via Tutor
On 17/05/16 23:56, Chris Kavanagh wrote: > So, by putting quotes around a dict key, like so dict["key"] or in my case > cart["item"] this makes the dict have ONE key. The loop assigns the > cart_items to this ONE key until the end of the loop, and I'm left with > {'item': 5}. . . > > Where as if

Re: [Tutor] Curses Module

2016-05-16 Thread Alan Gauld via Tutor
On 15/05/16 22:45, Rosen, Brian - 2016 wrote: >...In my current assignment, I would like to import the curses module > into either Python 2.7 or Python 3.4. However, > whenever I attempt to import it, there is an Import Error Curses is only available in the standard library on Unix-like

Re: [Tutor] sqlite

2016-05-13 Thread Alan Gauld via Tutor
On 13/05/16 21:25, Neil D. Cerutti wrote: > From your tutorial: > > query = '''INSERT INTO Address > (First,Last,House,Street,District,Town,PostCode,Phone) > Values ("%s","%s","%s","%s","%s","%s","%s","%s")''' %\ > (first, last, house, street,

Re: [Tutor] pytsk

2016-04-29 Thread Alan Gauld via Tutor
On 29/04/16 14:15, Tees, Peter (EthosEnergy) wrote: > Now I want to put what I've learned to good use, based on the > articles by David Cowen at the Hacking Exposed blog > and in particular his series "Automating DFIR - How to series > on programming libtsk with Python" > Can anyone point me to

Re: [Tutor] sqlite

2016-05-03 Thread Alan Gauld via Tutor
On 03/05/16 10:09, Crusier wrote: > I am just wondering if there is any good reference which I can learn how to > program SQLITE using Python > > I can not find any book is correlated to Sqlite using Python. You can try my tutorial below. http://www.alan-g.me.uk/tutor/tutdbms.htm If you want

Re: [Tutor] META: Moderation and subscription to the tutor list

2016-05-01 Thread Alan Gauld via Tutor
On 01/05/16 06:35, c...@zip.com.au wrote: > There seems to me a subjectly large number of very short threads with a > question from someone, a couple of responses from list members, and no > further > reply. > > To me this argues that either newcomers are not subscribed and probably do > not

Re: [Tutor] simple regex question

2016-05-01 Thread Alan Gauld via Tutor
On 01/05/16 20:04, bruce wrote: > Hey all.. > > Yeah, the sample I'm dealing with is html.. I'm doing some "complex" > extraction, and i'm modifying the text to make it easier/more robust.. > > So, in this case, the ability to generate the line is what's needed > for the test.. > But as Peter

Re: [Tutor] Issue with Code [SOLVED]

2016-05-01 Thread Alan Gauld via Tutor
On 01/05/16 05:20, Olaoluwa Thomas wrote: > Thank you so much, Alan. That fixed it (See Script 2[SOLVED] below). > > For the purpose of record-keeping, I'm pasting the entire code of all > scripts below as I should have done from the very beginning. > thanks :-) > P.S. How were you able to

Re: [Tutor] Issues converting a script to a functioin (or something)

2016-05-01 Thread Alan Gauld via Tutor
On 01/05/16 12:55, Olaoluwa Thomas wrote: > It computes total pay based on two inputs, no. of hours and hourly rate. While you do specify two inputs you immediately throw them away and ask the user to provide the information. In general it is good practice to separate calculation from

Re: [Tutor] simple regex question

2016-05-01 Thread Alan Gauld via Tutor
On 01/05/16 17:49, bruce wrote: > Hi. I have a chunk of text code, which has multiple lines. > s=''' > id='CourseId10795788|ACCT2081|002_005_006' style="font-weight:bold;" > onclick='ShowSeats(this);return false;' alt="Click for Class Availability" > title="Click for Class

Re: [Tutor] Issues converting a script to a functioin (or something) [SOLVED]

2016-05-01 Thread Alan Gauld via Tutor
On 01/05/16 14:38, Olaoluwa Thomas wrote: > Thanks for your feedback. Please do not hesitate to provide more as I shall > email you personally in the future. Please don't do that. a) Bob is a busy man who volunteers his time here, but may have other things to do too. b) The list is here so

Re: [Tutor] META: Moderation and subscription to the tutor list

2016-05-01 Thread Alan Gauld via Tutor
On 01/05/16 05:18, Steven D'Aprano wrote: > What's your policy here on the tutor list? I don't really have a policy. The list policy, set by my predecessors, is to allow anyone to send mail and encourage them to subscribe. All unsubscribed mail goes to moderation (and there is not very much of

Re: [Tutor] META: Moderation and subscription to the tutor list

2016-05-01 Thread Alan Gauld via Tutor
On 01/05/16 07:23, boB Stepp wrote: > I am in agreement with this as well. I have often wondered if > newcomers are subscribed or not Most are. Several who are not, subscribe very soon after - presumably in response to the intro message. > as after subscription one receives a > very helpful

Re: [Tutor] META: Moderation and subscription to the tutor list

2016-05-01 Thread Alan Gauld via Tutor
On 01/05/16 10:06, Alan Gauld via Tutor wrote: > Quite a lot of people use the digest service, especially lurkers. > (A quick scan of the members lists suggests around 35-40% > of all members use digest). I'd be reluctant to remove a > service that is so widely used. I've jus

Re: [Tutor] Dictionary Question

2016-05-02 Thread Alan Gauld via Tutor
On 02/05/16 22:55, isaac tetteh wrote: > > For some reason i cant find reply all . But try this > for key, value in mydic.items(): > If A==value: >Print key or as a function: def findKey(dct, val): for k,v in dct.items(): if v == val: return k mydic = {"A:

[Tutor] Digest format changed to MIME

2016-05-05 Thread Alan Gauld via Tutor
As mentioned earlier I've changed the digest format to MIME. If anyone has problems receiving that please let me know offline and we'll try to resolve it. Hopefully this will allow digest users to reply to individual messages and avoid the frequent resending of entire digests. It may even fix

  1   2   3   4   5   6   7   8   9   10   >