Re: [Tutor] Best way to write this countdown code

2019-01-12 Thread Alan Gauld via Tutor
On 12/01/2019 15:44, Joseph Gulizia wrote: > I want to integrate the following working code into a website: First thing to note is that web sites speak HTML, so anything you output for display needs to be in HTML not plain text. (Plain text will usually be understood by a browser but will look ter

Re: [Tutor] Log file for to search in order

2019-01-11 Thread Alan Gauld via Tutor
On 11/01/2019 14:12, Asad wrote: Let metry and translate your description into pseudo code... > >> Anywhere forward from the line which matches the search > > >> You are looking for two patterns, but does the order they appear, or the >> distance apart, matter? >> >> Yes the order does

[Tutor] Fwd: Data pattern query.

2019-01-07 Thread Alan Gauld via Tutor
POSIT-vendor-name Aust organisation_name # -Original Message----- From: Tutor On Behalf Of Alan Gauld via Tutor Sent: Monday, 7 January 2019 8:20 PM To: tutor@python.org Subject: Re: [Tutor] Data pattern query. On 07/01/2019 02:38, mhysnm1...@gmail.com wrote: > All the descriptions of th

Re: [Tutor] Bulk update to a SQL Server table

2019-01-07 Thread Alan Gauld via Tutor
On 07/01/2019 02:15, ram wrote: > I load these 7000+ records into a Pandas DataFrame and update a subset of > these records. > > What's the optimal way to update this subset of records to SQL table? First 7000 records is not a lot so performance shouldn't be a big issue even if you do update the

Re: [Tutor] Data pattern query.

2019-01-07 Thread Alan Gauld via Tutor
On 07/01/2019 02:38, mhysnm1...@gmail.com wrote: > All the descriptions of the transactions are > in a single column. I am trying to work out the > easiest method of identifying the same pattern > of text in the fields. What does a singe column mean? That presumably is how it appears in the s

Re: [Tutor] running a game server

2019-01-06 Thread Alan Gauld via Tutor
On 06/01/2019 20:40, nathan tech wrote: > Hi Alan, > > Thanks for the swift response. > > Are there any places in python code I need to free variables? Its more about not hanging on to them by accident. For example putting them into a list and then deleting the original variable. The reference in

Re: [Tutor] running a game server

2019-01-06 Thread Alan Gauld via Tutor
On 06/01/2019 14:14, nathan tech wrote: > My question is, is python really the way to go for game servers? Its certainly one possibility. Without a lot more details about the design, expected load, OS etc its impossible to say with any certainty. > I remember, long ago, running a script that we

Re: [Tutor] function question

2019-01-05 Thread Alan Gauld via Tutor
On 05/01/2019 16:18, David Lynch wrote: > Hello, > I'm not sure if this is where I can find this sort of help but I am > struggling understanding functions. I have written a simple math code but I > feel like it could be improved if I were to use it in a function. You arein the right place and you

Re: [Tutor] Defining variable arguments in a function in python

2018-12-30 Thread Alan Gauld via Tutor
On 30/12/2018 22:25, Avi Gross wrote: > I admit I have not studied the charter for the group. As moderator I feel the need to step in here because the charter is extremely apropos to that function and some clarification may be helpful. Mark is correct in that the group is focused on the core lan

Re: [Tutor] Defining variable arguments in a function in python

2018-12-29 Thread Alan Gauld via Tutor
On 29/12/2018 06:12, Karthik Bhat wrote: > def fun_varargs(a=5, *numbers, **dict): > print("Value of a is",a) > > for i in numbers: > print("Value of i is",i) > > for i, j in dict.items(): > print("The value of i and j are:",i,j) > > fun_varargs(1,2,3,4,5,6,7,8,9,10,

Re: [Tutor] decomposing a problem

2018-12-28 Thread Alan Gauld via Tutor
On 28/12/2018 20:34, Avi Gross wrote: > So before I respond, here is a general statement. I am NOT particularly > interested in much of what we discuss here from a specific point of view. > Someone raises a question and I think about it. They want to know of a > better way to get a random key from

Re: [Tutor] Interpreter pasting Question

2018-12-28 Thread Alan Gauld via Tutor
On 28/12/2018 17:13, Avi Gross wrote: > It sounds like the problem is that IDLE is (invisibly) intercepting what I > type or paste and then passing it on to a slaved interpreter. There likely > are other side effects and another editor/environment may not have this > issue. I will try some. Do no

Re: [Tutor] Interpreter pasting Question

2018-12-28 Thread Alan Gauld via Tutor
On 28/12/2018 05:58, Avi Gross wrote: > This is a serious question. I have tried things and searched and remain > stumped. It is about python and perhaps just the interpreter. > > Copying and pasting multiple lines into the interpreter fails in mysterious > ways, unless they are a logical single e

Re: [Tutor] Re Module

2018-12-27 Thread Alan Gauld via Tutor
On 27/12/2018 15:10, Asad wrote: > file1 - I need a search a error say x if the error matches > > Look for the same error x in other file 2 > > Here is the code : > I have 10 different patterns therefore I used list comprehension and > compiling the pattern so I loop over and find the exact patt

Re: [Tutor] decomposing a problem

2018-12-25 Thread Alan Gauld via Tutor
On 26/12/2018 00:00, Avi Gross wrote: > great. Many things in python can be made to fit and some need work. Dumb > example is that sorting something internally returns None and not the object > itself. This is one of my few complaints about Python. In Smalltalk the default return value from any

Re: [Tutor] look back comprehensively

2018-12-24 Thread Alan Gauld via Tutor
On 24/12/2018 05:25, Asokan Pichai wrote: > That said, sometimes text processing at the shell can precede or even > replace some of these. Of course that assumes Unix/Linux OS. > It's a good point except that any OS will do. Even MS DOS had basic text processing commands suitable for filtering l

Re: [Tutor] graphics library for teaching Python

2018-12-21 Thread Alan Gauld via Tutor
On 21/12/2018 04:16, Michael Mossey wrote: > I'm a computer science tutor and I'm asking advice about a graphics or game > library that can be used with Python effectively for teaching purposes. I'll start by saying that Python is not the berst programming language for graphics. However there are

Re: [Tutor] Long Lines techniques

2018-12-13 Thread Alan Gauld via Tutor
On 13/12/2018 17:36, Avi Gross wrote: > When lines get long, what points does splitting them make sense and what > methods are preferred? Its down to personal preference and convenience plus a smidge of idiom. > Yes, I am aware of ways to break up something long by breaking in into > multiple st

Re: [Tutor] Extract URL

2018-12-13 Thread Alan Gauld via Tutor
On 13/12/2018 17:14, Sammy Lee wrote: > I need help on the problem stated below. > > > Given a URL, open the webpage and return the first anchor link url (a href). You will find a very similar example in the Web Client topic of my tutorial, see below... -- Alan G Author of the Learn to Program

Re: [Tutor] Python function

2018-12-13 Thread Alan Gauld via Tutor
On 13/12/2018 17:21, Sammy Lee wrote: > How do I create a python function that opens a CSV file and determines how > many columns > of data are in the file? The CSV files have been randomly generated from > https://www.mockaroo.com/ > > def csv_column_count(openfile): You will find a bunch of s

Re: [Tutor] Import CSV

2018-12-13 Thread Alan Gauld via Tutor
On 13/12/2018 16:56, Sammy Lee wrote: > I need help on how to open a webpage and save the HTML to a given file path, > given a URL. You can use the standard library urllib module to fetch the file but most folks find the requests module easier to use. requests is a 3rd party module you will need

Re: [Tutor] Python script errors

2018-12-12 Thread Alan Gauld via Tutor
On 12/12/2018 12:57, Ravi Kumar wrote: > '{0:20} {1:30} {2:16} {3:18} {4:10} {5:11} '.format( > deviceserial, type, macaddress,occurredAt, details)) > TypeError: unsupported format string passed to NoneType.__format__ You have 6 format holders in your string but you only pass 5 values

Re: [Tutor] Python_About "Guess my number" program

2018-12-12 Thread Alan Gauld via Tutor
On 12/12/2018 05:26, Hoang Quoc Dat wrote: > find out 1 similar program but the coding logic is like: The computer keeps > guessing the middle number of the range and narrow down the range by > focusing on only the upper/lower part of the range after receiving our > answer. > > I somehow have com

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

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] 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] 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] 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] 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] 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-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 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] 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] 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] 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] 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] 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] 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] 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-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] 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] 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] 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 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-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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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 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] 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] 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] 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] 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] 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] 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 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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

[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] 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

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] 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-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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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] 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

<    1   2   3   4   5   6   7   8   9   10   >