Re: [Tutor] Help with building bytearray arrays

2018-09-08 Thread Alan Gauld via Tutor
On 08/09/18 03:15, Chip Wachob wrote: > Admin, please remove my earlier messages. No can do, once the emails are sent by the server they are out there on the net, stored in people's mailboxes and in various internet archives. When using a mailing list always check before sending, there's no going

Re: [Tutor] Help with building bytearray arrays

2018-09-08 Thread Alan Gauld via Tutor
On 08/09/18 03:15, Chip Wachob wrote: > my function's main pieces are: It would probably be better to post the entire function, a partial code sample like this just gives us an inkling of what you are trying to do but not enough to be sure of where the errors lie. > def transfer_byte_array(): >

Re: [Tutor] Help with building bytearray arrays

2018-09-10 Thread Alan Gauld via Tutor
On 10/09/18 04:00, Chip Wachob wrote: > I presume that I need to instantiate an array of slice_size-sized bytearrays. Cameron has already addressed this and explained that you don't need to and if you did how to do it. I'd only add that you need to readjust your thinking when it comes to Python

Re: [Tutor] Help with building bytearray arrays

2018-09-10 Thread Alan Gauld via Tutor
On 10/09/18 19:15, Chip Wachob wrote: > So I see why my .join() isn't working. I'm not sure how to fix it though. I already showed you the sum() function. It can take a list of lists and add them together end_array = sum(results,[]) > My background is in C and other 'historical' languages, so

Re: [Tutor] IDLE

2018-09-11 Thread Alan Gauld via Tutor
On 11/09/18 19:57, Roger Lea Scherer wrote: > Can you direct me to where or how to update from Python 3.6.5 Shell, I > think it is also called IDLE 3.6.5, to Python 3.7 Shell? The Python shell and IDLE are really two different things. The shell is normally considered to mean the interactive inte

Re: [Tutor] Clean the Shell

2018-09-11 Thread Alan Gauld via Tutor
On 11/09/18 23:31, Denis Dzhindo wrote: > Hello! > May I know, how I can clean the Shell, I'm not sure what you mean by that, however, if you mean reset the IDLE shell back to square one there is a menu option to restart the shell. Shell->Restart Shell. If you mean the command line interpreter th

[Tutor] Fwd: How to roughly associate the values of two numpy arrays, or python lists if necessary

2018-09-19 Thread Alan Gauld via Tutor
Forwarded to list I have, I suspect, an elementary problem that I am too inexperienced to resolve. I have two numpy arrays, each representing the values of a specific property of a set of cells. Now, I want to associate the two values for each cell, that is fo

Re: [Tutor] Installing new modules

2018-09-29 Thread Alan Gauld via Tutor
On 28/09/18 20:03, Rahul Koparde wrote: > How to install twilio module in python? Searching "python install twilio" on Google yielded: https://stackoverflow.com/questions/51985401/how-to-install-twilio-via-pip It may help. -- Alan G Author of the Learn to Program web site http://www.alan-g.me

Re: [Tutor] tkinter

2018-09-30 Thread Alan Gauld via Tutor
On 30/09/18 02:22, Jorge Herrera wrote: > Hello, I'm new to Python and I've been having a frustrating time with > python because I'm trying to import tkinter and it's saying that tkinter is > not defined, that it doesn't exist That suggests that Tkinter is not installed on your system. What OS ar

Re: [Tutor] Running programs that import 3rd party packages installed using pip.

2018-10-04 Thread Alan Gauld via Tutor
On 04/10/18 04:20, Roger B. Atkins wrote: > System: Windows 10, Anaconda, Python 3, Spyder3 > > I changed my system path variable to include: > C:\Users\rba21\Anaconda3\lib\site-packages# Result: same error message When you say the "system path" do you mean the PYTHONPATH variable? It's PYT

Re: [Tutor] coding problem

2018-10-04 Thread Alan Gauld via Tutor
On 04/10/18 05:22, ramanpreet baidwan wrote: > Can anyone tell me how to code to display permutations in a table > for all values of z=x^2+y by getting input from user for range of x and y? There are several problems with your question. First it sounds suspiciously like homework and we won't do t

Re: [Tutor] Running programs that import 3rd party packages installed using pip.

2018-10-04 Thread Alan Gauld via Tutor
On 04/10/18 15:15, Roger B. Atkins wrote: > That's very helpful, thanks. After reading the Tutor information last > night, I wrote a little program I named sysinfo. The code run line by > line in a Spyder console yields: > > In [3]: sys.path > Out[3]: > ['', > 'C:\\Users\\rba21\\Anaconda3\\python

Re: [Tutor] Numpy documentation

2018-10-04 Thread Alan Gauld via Tutor
On 04/10/18 20:02, Roger Lea Scherer wrote: > In the example pictured below, the array has 2 axes. The first axis has a > length of 2, the second axis has a length of 3. > [[ 1., 0., 0.], > [ 0., 1., 2.]] > > (I think) I understand the 2 axes. [1,0,0] (I'm lazy and don't want to type > the peri

Re: [Tutor] Shifting arrays as though they are a 'word'

2018-10-05 Thread Alan Gauld via Tutor
On 05/10/18 21:17, Chip Wachob wrote: > > I have an array of bytes. Up to 64, which makes for 512 bits. > > I am reading these bytes in serially, and once I have a collection of > them, I want to shift them by 'n' bits. The size of the array and the > number of bits are both variable up to the l

Re: [Tutor] [spoiler] Re: Shifting arrays as though they are a 'word'

2018-10-09 Thread Alan Gauld via Tutor
On 09/10/18 02:48, Chip Wachob wrote: >> bytearray(b'\x00\xff\x7f\x00') >> py> n = int.from_bytes(b, 'big') > > I'm not familiar with this int.from_bytes. > > Being new to Python, I don't have a mental library of these nifty > functions. How / where does one find a library of these wonderful >

Re: [Tutor] [spoiler] Re: Shifting arrays as though they are a 'word'

2018-10-09 Thread Alan Gauld via Tutor
On 09/10/18 02:55, Chip Wachob wrote: > This bit stream is complicated in that I have to reverse the bytes as > well since I'm reading off the 'end' of a bunch of registers. So, the > MSByte comes to me first and goes into the [0] location and the extra > bits get added to the '0th' end of the LS

Re: [Tutor] [spoiler] Re: Shifting arrays as though they are a 'word'

2018-10-09 Thread Alan Gauld via Tutor
On 09/10/18 13:45, Chip Wachob wrote: > Another related question. How do I know I want to do dir(int) vs.. I > don't know dir(long)? Because you want to convert the byte array into an int. And there is no long in Python... > And, when I do dir(int) I get the following results. I must not be >

Re: [Tutor] [spoiler] Re: Shifting arrays as though they are a 'word'

2018-10-09 Thread Alan Gauld via Tutor
On 09/10/18 14:21, Chip Wachob wrote: > The API is providing me with a bytearray-formatted result, but the API > only reads one whole byte, or eight bits, at a time. Being slightly picky but an octet and a byte are subtly different. An octet is a group of 8 bits with no meaning attached. So an

Re: [Tutor] [spoiler] Re: Shifting arrays as though they are a 'word'

2018-10-09 Thread Alan Gauld via Tutor
On 09/10/18 17:32, Mark Lawrence wrote: > On 09/10/18 17:10, Alan Gauld via Tutor wrote: >> On 09/10/18 13:45, Chip Wachob wrote: >> >>> Another related question. How do I know I want to do dir(int) vs.. I >>> don't know dir(long)? >> >> Beca

Re: [Tutor] Advanced python recommendations

2018-10-09 Thread Alan Gauld via Tutor
On 09/10/18 20:09, Mariam Haji wrote: > Hi guys, I am on the last exercises of learn python the hard> by Zed.A Shaw > and I am looking for recommendations on what > to follow next or what book to try next The main thing is to write a lot of code, so think of a project and build it. The experience

Re: [Tutor] Advanced python recommendations

2018-10-10 Thread Alan Gauld via Tutor
On 10/10/18 10:53, Mariam Haji wrote: >...my current challenge > with the projects bit is how to pseudo-code and which approach to use as I > am not very familiar with the entire python syntax and how I can use it And that's the whole point of doing projects. You need to really be comfortable wit

Re: [Tutor] Advanced python recommendations

2018-10-11 Thread Alan Gauld via Tutor
On 10/10/18 20:54, Mats Wichmann wrote: >>> This is actually the concept of test driven development (TDD), which I'm >>> not a huge proponent of personally, but kind of useful for this: >> >> I'm curious: What are the things you find less than satisfactory for TDD? > "TDD as religion" seems to m

Re: [Tutor] Help please

2018-10-11 Thread Alan Gauld via Tutor
On 11/10/18 04:19, Holly Jo wrote: > > I have no clue what I’m doing wrong, I’m a new student > > food_1=input("Sushi") > food_2=input("Quesdilla") > new_food=food_1+food_2 > print("Combining these foods will you,",new_food) > input("Press enter to continue") Please always tell us what has gon

Re: [Tutor] Regarding python functions

2018-10-11 Thread Alan Gauld via Tutor
On 11/10/18 14:25, Siddharth V wrote: > I am not clear with the functions in python, which we can create while > programming in order to make our program efficient and neat... > Please brief me with those at the earliest... Its not clear exactly what kind of help you need so for now I will point

Re: [Tutor] Asynchronous http requests in Python

2018-10-11 Thread Alan Gauld via Tutor
On 10/10/18 23:17, Lulu wrote: > Hi everyone, > I am using python 2.7 and I wanted to ask the list the best way> to issue > multiple concurrent http requests from a Django application: This may be better addressed on the Django mailing list since Django may well have its own support for this. How

Re: [Tutor] Help please

2018-10-12 Thread Alan Gauld via Tutor
On 12/10/18 04:31, Adam Eyring wrote: > Also, it looks better to use " + " instead of a comma: > print("Combining these foods will you," + new_food) It may "look better" but be aware that they don't do the same thing and the plus sign is a lot less efficient computationally since it creates a new

Re: [Tutor] Python

2018-10-12 Thread Alan Gauld via Tutor
On 12/10/18 02:41, Tyler Travis via Tutor wrote: > I used a shortcut by import the statistics function. ... > it does not print the expected output, Did you by any chance include your code as an attachment? If so this mail server will strip it out as a security risk. Please post any code in the

Re: [Tutor] python game error

2018-10-15 Thread Alan Gauld via Tutor
On 15/10/18 08:57, Peter Otten wrote: > By the way, you do not need a map (dict) at all to implement a game like > this, you may return the next scene directly. A sketch: > > class Bridge: > def enter(self): > ... > action = ... > if action == "jump off the bridge": >

Re: [Tutor] Performance Issue

2018-10-17 Thread Alan Gauld via Tutor
On 17/10/18 22:25, Stephen Smith wrote: > I have written a screen scraping program that watches a clock (on the app's > server) and at 7:00:00 AM dashes to make a reservation on line. It works > fine. However, i have spent time trying to improve its performance. I am > using selenium, with chrome d

Re: [Tutor] Performance Issue

2018-10-18 Thread Alan Gauld via Tutor
it reaches 7:00:00. So I am not sure there are improvements to be made in that area. -Original Message- From: Tutor On Behalf Of Alan Gauld via Tutor Sent: Wednesday, October 17, 2018 8:12 PM To: tutor@python.org Subject: Re: [Tutor] Performa

Re: [Tutor] How to find optimisations for code

2018-10-19 Thread Alan Gauld via Tutor
On 19/10/18 17:12, Pat Martin wrote: > TLDR; How do you figure out if code is inefficient (if it isn't necessarily > obvious) and how do you find a more efficient solution? Others have addressed most of the issues but I'd just add the caveat that you can spend forever trying to make your code "mo

Re: [Tutor] sftp in python without using pysftp or paramiko

2018-10-20 Thread Alan Gauld via Tutor
On 20/10/18 21:07, Asad wrote: > hi All , > > I am looking to create a python script which logs in to the server and > copies the fie from ftp to local system .: The obvious answer is use pysftp. But your subject says you don't want to do that. So the next option is for you to write your own ver

Re: [Tutor] Can tempfile.NamedTemporaryFile(delete=False) be used to create *permanent* uniquely named files?

2018-10-21 Thread Alan Gauld via Tutor
On 21/10/18 07:13, boB Stepp wrote: > My initial thought was to just have a sequence of game names with > incrementing numerical suffixes: game_0, game_1, ... , game_n. But > this would require the program to keep track of what the next > available numerical suffix is. The traditional approach

Re: [Tutor] Python Help (shits killing me)

2018-10-26 Thread Alan Gauld via Tutor
Plain text is preferred for code since otherwise the mail system removes all indentation making the code hard to understand. On 25/10/2018 23:13, Ben Placella wrote: > So I have to make a fibonacci sequence, and I'm not sure what is wrong with > my code > #This program illustrates the fibonacci se

Re: [Tutor] Python Help

2018-10-26 Thread Alan Gauld via Tutor
On 25/10/2018 23:14, Ben Placella wrote: Please always post code in plain text not HTML or Rich text. Otherwise we lose all the formatting which is important in Python. > beefmeals=int(input("Enter number of beef meals: ")) > shitmeals=int(input("Enter number of vegan meals: ")) > party=beefmeals

Re: [Tutor] How to print lines within two timestamp

2018-10-26 Thread Alan Gauld via Tutor
On 26/10/2018 12:33, Asad wrote: > Hi , > > Yes i have the code : It woiyukld help us to help you if you provided some clues as to what it was doing. A good start would be some comments - especially around the regexes. Don't make us parse them without some idea of what you are expecting. Also mor

Re: [Tutor] How to print lines within two timestamp

2018-10-26 Thread Alan Gauld via Tutor
On 26/10/2018 18:45, Alan Gauld via Tutor wrote: > It woiyukld No idea what happened there. Should be "would" of course! -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://w

Re: [Tutor] Python Help

2018-10-26 Thread Alan Gauld via Tutor
On 26/10/2018 18:20, Adam Eyring wrote: > beef = (beefmeals * 15.95) Note that the parens here are completely redundant. They don't break anything but neither do they contribute anything. WE already have LISP(*) for those who love parens, no need for (so many of) them in Python (*)Lots of Irrel

Re: [Tutor] How to print lines within two timestamp

2018-10-27 Thread Alan Gauld via Tutor
On 27/10/2018 08:02, Asad wrote: >>> string = f3.read () >>> regex = re.compile ( "\n" ) >>> st = regex.sub ( " ", string ) >> >> I suspect regular string methods would be simpler here. >> answer : can you please provide the code to replace above st = string.replace("\n"," ") >>> if re.search ('

Re: [Tutor] How to print lines within two timestamps

2018-10-27 Thread Alan Gauld via Tutor
On 27/10/2018 10:28, Asad wrote: > C:\Python27\python.exe D:/QI/test_qopatch.py > Traceback (most recent call last): > 2018-10-22 10:21:15 > File "D:/QI/test_qopatch.py", line 32, in > 2018-10-22 10:21:25 > newtime = datetime.datetime.strptime ( a[0], '%m/%d/%y %H:%M:%S' ) > ['04/26/18 06:1

[Tutor] Turtle graphics - was Re: (no subject)

2018-10-27 Thread Alan Gauld via Tutor
On 27/10/2018 12:09, Jesse Stockman wrote: > Hi there Hi, Please always provide a meaningful subject line. Also always include the output of your program, especially if its an error message - these are full of useful information. > I need to draw a patten with turtle in python 3.7 but > I cant

Re: [Tutor] Problem with task, please help!

2018-10-28 Thread Alan Gauld via Tutor
On 27/10/2018 20:41, michiel nijs wrote: > I am an engineering student and we have to use Python. > We don't have lessons so we all have to learn it on our own. What, no lessons at all?! Or just no lessons on Python? Have you done any kind of programming before? > We got a task and I am stuck o

Re: [Tutor] Module (.py file) that behaves like package

2018-10-29 Thread Alan Gauld via Tutor
On 29/10/2018 14:10, Quentin Agren wrote: > ... (Maybe I should just get out more...) That depends on whether you can foresee a use for importlib in your code. If so then getting to know it isn't a bad thing. If not, do you really want to be looking back on your 60th birthday thinking "Did I real

Re: [Tutor] TESTING

2018-11-01 Thread Alan Gauld via Tutor
On 01/11/2018 14:01, richard mwenya via Tutor wrote: > Hello. > Everyone is quiet or is it my email thats not working? Just quiet, I've seen nothing in the moderators queue for 5 days. But that happens sometimes. I guess it just means nobody is having any Python issues right now. -- Alan G Lis

Re: [Tutor] TESTING

2018-11-02 Thread Alan Gauld via Tutor
On 02/11/2018 03:45, Avi Gross wrote: > I am not totally up on the exact purposes of this group but have noted how > many of the questions asked have been frustrating. Unfortunately that goes with the territory. We are a list catering to beginners to Python and, frequently, to programming. As a re

Re: [Tutor] Installing python

2018-11-02 Thread Alan Gauld via Tutor
On 02/11/2018 21:13, Roger Lea Scherer wrote: > I have installed python 3.7 on my computer Windows10 > (C:\Users\Roger\AppData\Local\Programs\Python\Python37), Caveat: I'm no expert on modern Windoze. But... That looks like the wrong path to me. My Windows install is usually either in C:\Pytho

Re: [Tutor] Installing python

2018-11-02 Thread Alan Gauld via Tutor
On 02/11/2018 23:44, Mats Wichmann wrote: > that's actually exactly the right path for a Python 3.5+ if you chose a > "user install", which you usually should. Ah, I always install for all users. That's why I've not seen that path presumably? But why *should* you install for a single user? I o

Re: [Tutor] Regex for Filesystem path

2018-11-06 Thread Alan Gauld via Tutor
On 06/11/2018 13:13, Asad wrote: > Can you provide some advice and code for the following problem : The first thing is to go read the documentation for the os.path module. It is designed for reliable path manipulation. > /a/b/c/d/test/test_2814__2018_10_05_12_12_45/logA.log > > f3 = ope

Re: [Tutor] Regex for Filesystem path

2018-11-06 Thread Alan Gauld via Tutor
On 06/11/2018 19:47, Cameron Simpson wrote: > It is better to just construct the required path. Chdir there requires a > chdir back, and chdir affects all the relative paths your programme may > be using. > > I'd use os.path.dirname to get '/a/b/c/d/test' and then just append to > it with os.p

Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-06 Thread Alan Gauld via Tutor
On 06/11/2018 18:07, srinivasan wrote: > bash command in python using subprocess module, I ma seeing the below > *        cmd = "blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)* In general you should try to do as little as possible using bash and subprocess. Especially try to avoid long

Re: [Tutor] best way to dynamically set class variables?

2018-11-07 Thread Alan Gauld via Tutor
On 07/11/2018 14:48, Albert-Jan Roskam wrote: > What is the best way to dynamically set class variables? Remember the golden rule of OOP is that objects(and classes) should do it to themselves. Ideally the class variables should be there to support some kind of class behaviour and that behaviour

Re: [Tutor] Displaying Status on the Command Line

2018-11-07 Thread Alan Gauld via Tutor
On 07/11/2018 16:22, Chip Wachob wrote: > What I would like to do is display, on a single line, in the terminal > / command line a progress percentage, or, simply a sequence of - / - > \, etc.. or even, accumulating period characters. > > What would the escape codes be, or is there a better way t

Re: [Tutor] Regex for Filesystem path (Asad)

2018-11-07 Thread Alan Gauld via Tutor
On 07/11/2018 15:56, Asad wrote: > Hi All, > > I tired seems its not working as required : > > from os.path import dirname, join > > testdir = dirname("/a/b/c/d/test/test_2814__2018_10_05_12_12_45/logA.log") Note that this will set testdir to /a/b/c/d/test/test_2814__2018_10_05_12_12_

Re: [Tutor] SyntaxError: can't assign to literal while using ""blkid -o export %s | grep 'TYPE' | cut -d"=" -f3" % (fs)" using subprocess module in Python

2018-11-07 Thread Alan Gauld via Tutor
On 07/11/2018 11:31, srinivasan wrote: > Even after changing as per the below > "blkid -o export %s | grep 'TYPE' | cut -d'=' -f3" > or: > 'blkid -o export %s | grep "TYPE" | cut -d"=" -f3' > or: > "blkid -o export %s | grep \"TYPE\" | cut -d\"=\" -f3" > > Still my output is: > */dev/mmcblk1p1: LA

Re: [Tutor] best way to dynamically set class variables?

2018-11-07 Thread Alan Gauld via Tutor
On 07/11/2018 20:07, Albert-Jan Roskam wrote: > I should have mentioned that the code ... should be able to convert > an *arbitrary* Sql server table into hdf5 format*). Umm, yes that would have helped! from tables import * class Particle(IsDescription): > ... name = StringC

Re: [Tutor] best way to dynamically set class variables?

2018-11-07 Thread Alan Gauld via Tutor
On 07/11/2018 23:06, Alan Gauld via Tutor wrote: > Another option would be to explore metaclasses > and modify the class creation mechanism Which, of course, is what you were doing with the type(...) call in your post... -- Alan G Author of the Learn to Program web site http://www.alan-g

Re: [Tutor] best way to dynamically set class variables?

2018-11-07 Thread Alan Gauld via Tutor
On 07/11/2018 23:06, Alan Gauld via Tutor wrote: >> Imagine having to write this for 100 columns, brrr. > > No problem, I've done that dozens of time for production C++ code, > it's business as usual in commercial programming. > > Of course I'd get the da

Re: [Tutor] Displaying Status on the Command Line

2018-11-08 Thread Alan Gauld via Tutor
On 08/11/2018 04:06, Chip Wachob wrote: > I should have mentioned that I'm working with Python 2, but I think I > can parse my way through these examples. OK, In that case you may want to investigate the sys.stdout approach. Just remember it's a pre opened file and use the write() method. But it

Re: [Tutor] Regex for Filesystem path (Asad)

2018-11-08 Thread Alan Gauld via Tutor
On 08/11/2018 02:55, Asad wrote: > Why is it putting \ this breaks the unix path it should be: > > /a/b/c/d/test/28163133/22326541 ===> for unix platform logs > > \a\b\c\d\test\28163133\22326541 ===> for windows platform logs os.path.join uses the separator that is correct for your OS. Sinc

Re: [Tutor] best way to dynamically set class variables?

2018-11-08 Thread Alan Gauld via Tutor
On 08/11/2018 07:46, Peter Otten wrote: > By the way I don't think exec() is bad as long as you control its input and > as long as this input is fairly simple. Yes, but reading arbitrary column names from a database is not exactly controlled input... -- Alan G Author of the Learn to Program w

Re: [Tutor] Require Python assistance

2018-11-11 Thread Alan Gauld via Tutor
On 10/11/2018 18:10, Avi Gross wrote: > WARNING to any that care: > > As the following letter is a repeat request without any hint they read the > earlier comments here, I did a little searching and see very much the same > request on another forum asking how to do this in MATLAB: The OP has a

Re: [Tutor] Example for read and readlines()

2018-11-11 Thread Alan Gauld via Tutor
On 11/11/2018 06:49, Asad wrote: > Hi All , > > If I am loading a logfile what should I use from the option 1,2,3 > > f3 = open ( r"/a/b/c/d/test/test_2814__2018_10_05_12_12_45/logA.log", 'r' ) > > 1) should only iterate over f3 This is best for processing line by line which is the mos

Re: [Tutor] Example for read and readlines()

2018-11-11 Thread Alan Gauld via Tutor
On 11/11/2018 09:40, Steven D'Aprano wrote: >> f3 = open ( r"/a/b/c/d/test/test_2814__2018_10_05_12_12_45/logA.log", 'r' ) > > Don't use raw strings r"..." for pathnames. Umm, Why not? -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_

Re: [Tutor] Example for read and readlines()

2018-11-11 Thread Alan Gauld via Tutor
On 11/11/2018 10:04, Asad wrote: > 1) and I want to extract the start time , error number and end > time from this logfile so in this case what should I use I guess option 1 : > > with open(filename, 'r') as f: > for line in f: > process(line) Yes, that woyuld be the best

Re: [Tutor] Pythonic way

2018-11-20 Thread Alan Gauld via Tutor
On 20/11/2018 18:08, Avi Gross wrote: > ... So there isn’t really ONE pythonic way for many things. That's true and, I think, inevitable for anything developed in the open source world. If you compare it to a language entirely controlled by a single mind - like Oberon or Eiffel say - then there i

Re: [Tutor] Pythonic way

2018-11-21 Thread Alan Gauld via Tutor
On 20/11/2018 22:35, Steven D'Aprano wrote: > On Tue, Nov 20, 2018 at 08:22:01PM +0000, Alan Gauld via Tutor wrote: > >> I think that's a very deliberate feature of Python going back >> to its original purpose of being a teaching language that >> can be used

Re: [Tutor] evolutionary drift

2018-11-21 Thread Alan Gauld via Tutor
On 21/11/2018 03:05, Avi Gross wrote: > <> is not currently used as a matched set as it has many other uses like in > comparisons.> Some languages even use <> as the same as != or ~= to mean not > equals. Indeed, Python used to do the same but it was removed in, I think, v2. > A simple teachin

Re: [Tutor] origins bootstrapped.

2018-11-21 Thread Alan Gauld via Tutor
On 21/11/2018 16:31, Avi Gross wrote: > Alan has been involved with Python for a long time so he has more to offer > historically. I'm not so sure about that, several folks on this list have been around longer than me. And I don't follow the main comp.lang.python list that closely. I'm simply giv

Re: [Tutor] origins bootstrapped.

2018-11-22 Thread Alan Gauld via Tutor
On 22/11/2018 06:05, Steven D'Aprano wrote: > I don't know of any non-free (free as in beer, or free as in speech) > implementations of Python. Can you elaborate? There are several commercial distributions (as opposed to implementations) of Python, that may be what Avi has in mind. Some of these

Re: [Tutor] A required question

2018-11-23 Thread Alan Gauld via Tutor
On 23/11/2018 05:34, Avi Gross wrote: > Just to be different, and perhaps return to the purpose of this group, Actually I think the higher level debate of Python's direction as a teaching language is entirely appropriate for this group. It kind of defines the group and and its current and future r

Re: [Tutor] Help.Please!

2018-11-24 Thread Alan Gauld via Tutor
On 24/11/2018 20:37, Brian Ngari wrote: > miles of that number. Please prompt the user for the current mileage > recorded on the car and also for the mileage recorded on the car at the > time of the last oil change. Then, please let the user know if it’s time to > change the oil. You do some of

Re: [Tutor] click() performs unreliably

2018-11-26 Thread Alan Gauld via Tutor
On 26/11/2018 10:21, stephen.m.sm...@comcast.net wrote: > I am trying to click on one of two buttons on a page. Here is an image of > the relevant portion of the page, the HTML and the two xpaths. I assume this is related to your earlier post about using Selenium? If so, you will probably get a be

Re: [Tutor] Writing the right code rite

2018-11-27 Thread Alan Gauld via Tutor
On 27/11/2018 00:18, Avi Gross wrote: > But in watching, I conclude that a subset of the requests come from people > who are some form of early students and only aware of selected aspects of > the language. One of the challenges of this list is identifying the level of the requester. We get seve

Re: [Tutor] Need help,please!

2018-11-27 Thread Alan Gauld via Tutor
On 27/11/2018 21:04, Kamina Kamtarin wrote: > A De/Coder. Think back to 3rd grade when you passed notes to friends in > class. We can't let the teacher see what we're writing so we used a code. > A=1, B=2, C=3, etc. Your job is to create a program which does the > following: > >1. Presents the

Re: [Tutor] I need help with my project

2018-11-28 Thread Alan Gauld via Tutor
On 28/11/2018 00:30, Treyton Hendrix wrote: > If the user selected a sandwich, french fries, and a beverage, reduce the > total cost of the order by $1.00. > > This is what I have to do and I don't know where to start. Neither do we because we don't know what you are talking about. There is no co

Re: [Tutor] online interactive Py resource?

2018-11-29 Thread Alan Gauld via Tutor
On 29/11/2018 01:49, Mats Wichmann wrote: > It occurs to me it would be cool to work interactively in a distributed > Internet editing environment that could run Python code. Why not just share your desktop? I assume you trust the person you are mentoring?! I don't recall exactly how you do that

Re: [Tutor] Trouble about creating database

2018-11-29 Thread Alan Gauld via Tutor
On 29/11/2018 09:24, Muhammed Esen wrote: > I can't create a database even tough I imported pymysql. I have Xammp on my > Mac and I already started MySQL Database. What could be the problem? Just about anything since you haven't shown us your code. It could be a syntax error, a problem with argume

Re: [Tutor] Search error code in a logfile and print all lines until the error code

2018-11-29 Thread Alan Gauld via Tutor
On 29/11/2018 12:53, Asad wrote: > Hi All , > > I need some help to print error lines from a log file : I don;t have time right now for a detailed analysis but there are some obvious starting points: > f4 = open (r"file1.log", 'r') > string2=f4.readlines() > for i in range(len(string2)):

Re: [Tutor] Moving a conda environment to an off-line computer

2018-11-30 Thread Alan Gauld via Tutor
On 30/11/2018 13:47, Henrique Castro wrote: > ... use one of the powerful computers on my university It would help if we knew what kind of powerful computer this is. What OS does it run? It sounds like some variety of Unix, but which? Does it have a C compiler on board? > The computer does not ha

Re: [Tutor] Moving a conda environment to an off-line computer

2018-12-01 Thread Alan Gauld via Tutor
On 01/12/2018 00:43, Henrique Castro wrote: >a cluster with 4 nodes each running Linux (our Fedora-based distro), OK, The good news is you should be able to get a pre-built distro rather than try to build your own. But I still think the Conda users are more likely to be able to assist. -- Alan

Re: [Tutor] Moving a conda environment to an off-line computer

2018-12-01 Thread Alan Gauld via Tutor
On 01/12/2018 11:41, Henrique Castro wrote: > Thank you guys, I'll try to contact the Conda community. > Alan Gauld, good to know. I suggest that you try to spread the news I only meant that because it was Fedora (rather than a bespoke Linux build) that you should find a binary package someplace

Re: [Tutor] Moving a conda environment to an off-line computer

2018-12-01 Thread Alan Gauld via Tutor
On 01/12/2018 11:41, Henrique Castro wrote: > Thank you guys, I'll try to contact the Conda community. Try: https://support.anaconda.com/ "Community Support" looks a likely option -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_

Re: [Tutor] subprocess.Popen()

2018-12-03 Thread Alan Gauld via Tutor
On 02/12/2018 10:29, Dave Hill wrote: > Having 'graduated' to Python 3.7, I thought I would explore > Traceback (most recent call last): >File "/home/pi/Code/TestVideo#4.py", line 31, in > player.playVideo(FILE, 'HDMI') >File "/home/pi/Code/VideoPlayer.py", line 51, in playVideo >

Re: [Tutor] Regarding Python api script

2018-12-03 Thread Alan Gauld via Tutor
On 03/12/2018 22:15, Ravi Kumar wrote: > I have developed a python script to get api calls for meraki > clientlogevents I am wanting the output of apicalls which is in xml format > integrated to sql server management studio how do i do that? XML is such a flexible format that without seeing the

Re: [Tutor] Regarding Python api script

2018-12-04 Thread Alan Gauld via Tutor
CCd the list, please use Reply All when responding to the tutor list. On 04/12/2018 00:52, Ravi Kumar wrote: > Thanks a lot! I was wondering is it easier to access JSON format into > Sql Server from python rather than XML If so how do I format my output > from xml to Json  > JSON is generally easi

Re: [Tutor] Regarding Python api script

2018-12-04 Thread Alan Gauld via Tutor
On 04/12/2018 01:31, Ravi Kumar wrote: > My output api calls in python is in xml so I want the output to be in the > database I'm still not 100% clear but I think you are saying that your API currently returns XML when you call it from Python. And you want to extract the data from the XML and stor

Re: [Tutor] sftp using subprocess

2018-12-04 Thread Alan Gauld via Tutor
On 04/12/2018 06:25, Asad wrote: > Permission denied (keyboard-interactive,publickey,password). > Connection closed > > Is there any other way to acheive this because I cannot import pexcept > module . That looks like the problem that David already highlighted with sftp. When you say you cannot

Re: [Tutor] sftp using subprocess

2018-12-04 Thread Alan Gauld via Tutor
On 04/12/2018 18:30, David Rock wrote: > you MUST stop trying to use batch mode, because it will never work. But you could presumably use interactive mode via Popen by taking control of the stdin/out pipes. But then you are basically re writing expect! -- Alan G Author of the Learn to Program w

Re: [Tutor] Borrowing free code

2018-12-04 Thread Alan Gauld via Tutor
On 04/12/2018 19:31, Avi Gross wrote: > But some packages are simply python code that you can > simply insert into your own python files. If they are fully public domain that's probably true. If they are copyright (even if open/free) you would be potentially liable for prosecution since you are

Re: [Tutor] Any 'graphical' ways of learning Python

2018-12-05 Thread Alan Gauld via Tutor
On 05/12/2018 00:39, Matthew Polack wrote: > Can anyone recommend any ways of integrating 'graphics' but in a simpler > way. > Have you considered the turtle module. Its limited to drawing shapes but does give some immediate results. You can of course create functions to draw more sophisticated

Re: [Tutor] Beginners Book, Python and PyScripter

2018-12-05 Thread Alan Gauld via Tutor
On 04/12/2018 23:52, James Stapleton-Cotton wrote: > USERs-MacBook-Pro:~ user$ python hello.py > python: can't open file 'hello.py': [Errno 2] No such file or directory You need to provide the full path to the Python file. > I previously created a python file called 'hello.py' using the PyCharmE

Re: [Tutor] Borrowing free code

2018-12-05 Thread Alan Gauld via Tutor
On 05/12/2018 06:14, Steven D'Aprano wrote: > On Tue, Dec 04, 2018 at 11:43:05PM +0000, Alan Gauld via Tutor wrote: >> On 04/12/2018 19:31, Avi Gross wrote: >> >>> But some packages are simply python code that you can >>> simply insert into your own python

Re: [Tutor] Regarding Python api script

2018-12-05 Thread Alan Gauld via Tutor
CCing the list, please use Reply All when responding to the tutor list. On 05/12/2018 03:44, Ravi Kumar wrote: > Yes  thats right I want to extract the xml and store into database(SQL > Server) and I will have to cteate a new table > > Here is the sample output I am getting similarly there bulk d

Re: [Tutor] Borrowing restricted code

2018-12-06 Thread Alan Gauld via Tutor
On 06/12/2018 00:45, Steven D'Aprano wrote: > So you can see why many organisations are so paranoid about having > licences for every line of code they use. Failure to be fully licenced > could be *incredibly* time-consuming and expensive if they get into a > legal dispute. The only way to win

Re: [Tutor] Regarding Python api script

2018-12-06 Thread Alan Gauld via Tutor
On 06/12/2018 14:17, Ravi Kumar wrote: > 1)The for loops that have written I am able to access all the networks,able > to loop through all access points(Devices) in the network,able to loop > through and get all clients in each access points but when it comea to > client log events I am able to l

Re: [Tutor] Trouble in dealing with special characters.

2018-12-07 Thread Alan Gauld via Tutor
On 07/12/2018 07:58, Sunil Tech wrote: > I have a trouble with dealing with special characters in Python Below is > the sentence with a special character(apostrophe) "MOUNTAIN VIEW WOMEN’S > HEALTH CLINIC" with actually should be "MOUNTAIN VIEW WOMEN'S HEALTH CLINIC > ". How do you define "specia

Re: [Tutor] Trouble in dealing with special characters.

2018-12-07 Thread Alan Gauld via Tutor
On 07/12/2018 08:36, Sunil Tech wrote: > I am using Python 2.7.8 tx = "MOUNTAIN VIEW WOMEN’S HEALTH CLINIC" tx.decode() > Traceback (most recent call last): > File "", line 1, in > UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 19: > ordinal not in range(128) >

Re: [Tutor] Regarding Python api script

2018-12-07 Thread Alan Gauld via Tutor
On 07/12/2018 02:13, Avi Gross wrote: > Alan says he had a challenge evaluating code (below) because the same > variable names were reused It wasn't the reuse per se but the generic nature of the names combined with reuse. Reusing names like i,j,k for simple integer indices etc is not a problem.

Re: [Tutor] unzip and connect to Oracle database

2018-12-07 Thread Alan Gauld via Tutor
On 07/12/2018 14:00, Asad wrote: > Hi All , > > I would like to unzip a file using python and then execute the sql > scripts in the file on Oracle database . Are you absolutely sure? That's a very dangerous thing to do from a security point of view. Potentially similar to using exec() o

Re: [Tutor] Increase performance of the script

2018-12-09 Thread Alan Gauld via Tutor
On 09/12/2018 10:15, Asad wrote: > f4 = open (r" /A/B/file1.log ", 'r' ) Are you sure you want that space at the start ofthe filename? > string2=f4.readlines() Here you read the entire file into memory. OK for small files but if it really can be 5GB that's a lot of memory being used. > for i

<    7   8   9   10   11   12   13   14   15   >