Re: [Tutor] which of these is more efficient?

2019-08-19 Thread Mats Wichmann
On 8/18/19 5:55 PM, nathan tech wrote: > Hi there, > > So I am running over some coding ideas in my head for creating a map for > a game. > > This map would expand based on how far the user explores. > > I figure there are two ways to do this: > > 1: the list method: > > map=[] > for x in

Re: [Tutor] Package which can extract data from pdf

2019-08-14 Thread Mats Wichmann
On 8/14/19 10:10 AM, Nupur Jha wrote: > Hi All, > > I have many pdf invoices with different formats. I want to extract the line > items from these pdf files using python coding. > > I would request you all to guide me how can i achieve this. > There are many packages that attempt to extract

Re: [Tutor] Union

2019-08-12 Thread Mats Wichmann
On 8/12/19 2:50 PM, Jim wrote: > I was reading the docs for PySimpbleGUI here: > https://pysimplegui.readthedocs.io/en/latest/#building-custom-windows > > In the table of parameters for the Window() function for example the > icon parameter the meaning is  Union[str, str] Can be either a filename

Re: [Tutor] HELP PLEASE

2019-08-12 Thread Mats Wichmann
On 8/12/19 10:54 AM, Marissa Russo wrote: > Hello, > > I am trying to figure out what is going on and why my output is saying > “” instead of giving me a number. Please let me know if > you see the error in my code!! to quickly illustrate the specific question you asked - you got comments on

Re: [Tutor] instantiate and name a class from / with a string

2019-08-09 Thread Mats Wichmann
On 8/9/19 11:55 AM, ingo wrote: > With the available classes Root, Channel and SSE I build the following > (in CherryPy): > > root = Root() > root.channel = Channel() > > root.channel.weather = SSE('weather') > root.channel.energy = SSE('energy') > root.channel.mail = SSE('mail') >

Re: [Tutor] Error terminal

2019-08-07 Thread Mats Wichmann
On 8/7/19 5:27 PM, Richard Rizk wrote: > Thank you Cameron for your message. > > Please find below the error message i am receiving. > > I think the command line i'm running is trying to connect with the > python3.7 that i have on my computer which is a requirement for the command > line to work

Re: [Tutor] Name for this type of class?

2019-08-03 Thread Mats Wichmann
On 8/3/19 10:56 AM, Malcolm Greene wrote: > Thanks for everyone's feedback. Some interesting thoughts including Alan's > "classes should never be named for their data but for their function" > feedback. I'm going to have to noodle on that one. Good stuff! And more: if the class is really just

Re: [Tutor] Difference between decorator and inheritance

2019-08-02 Thread Mats Wichmann
On 7/31/19 11:57 AM, Gursimran Maken wrote: > Hi, > > Anyone could please let me know the difference between decorators and > inheritance in python. > > Both are required to add additional functionality to a method then why are > we having 2 separate things in python for doing same kind of work.

Re: [Tutor] Which is better in principle: to store (in file) calculated data or to re-calculate it upon restarting program?

2019-07-30 Thread Mats Wichmann
On 7/30/19 5:58 PM, Alan Gauld via Tutor wrote: > On 30/07/2019 17:21, boB Stepp wrote: > >> musings I am wondering about -- in general -- whether it is best to >> store calculated data values in a file and reload these values, or >> whether to recalculate such data upon each new run of a

Re: [Tutor] Inserting long URL's into comments & docstrings?

2019-07-29 Thread Mats Wichmann
On 7/29/19 2:36 PM, James Hartley wrote: > This should be a slow ball pitch. Unfortunately, I haven't stumbled across > a reasonable answer yet. > > On occasion, I put long URL's into comments/docstrings simply to document > where I found specific information. However, to be a good disciple of

Re: [Tutor] REQUIRED SUPPORT FOR CODE

2019-07-25 Thread Mats Wichmann
On 7/25/19 9:58 AM, NITESH KUMAR wrote: > Dear Sir/Madam > > I want to make Autocomplete searchbox using database .Please suggest me the > code for this. Your question leaves many more questions... A searchbox implies you're using a graphical toolkit. Which one do you intend to use (there are

Re: [Tutor] __weakref__ question

2019-07-25 Thread Mats Wichmann
On 7/24/19 1:57 PM, Sarah Hembree wrote: > Can anyone provide some simple example/s or two or three of using weakref? > I'm baffled and not seeing any documentation that is meaningful. My > interest is to minimize memory usage (generally speaking, overall) and am > wondering if this might help.

Re: [Tutor] Python Generator expressions

2019-07-23 Thread Mats Wichmann
On 7/23/19 11:06 AM, Animesh Bhadra wrote: > Hi All, > > Need one help in understanding generator expression/comprehensions. > > This is my sample code. > > # This code creates a generator and not a tuple comprehensions. > my_square =(num *num fornum inrange(11)) > print(my_square) # at

[Tutor] multiprocessing: getting data back from the processes

2019-07-22 Thread Mats Wichmann
Time for me to ask something... I've got a scenario where I need to pass data in both directions of a multiprocessing program. Specifically what I'm working with is a test runner from a homegrown testing harness (aside having nothing to do with the question: if it was me, I would build this

Re: [Tutor] Stylometry Help

2019-07-20 Thread Mats Wichmann
On 7/19/19 4:53 AM, ali...@mailbox.org wrote: > Hello together, > > I try to write a Python tool but after hours of trying , reading and looking > for help nothing an no one would help me. So this is my most desperate call > for help. I attached the project and my required files. If there is

Re: [Tutor] Unit testing: Just the API or internal use only methods, too?

2019-07-16 Thread Mats Wichmann
On 7/16/19 4:41 PM, boB Stepp wrote: > Peter Otten, while responding to one of my questions in the past, > mentioned something in passing that apparently has been mulling around > in the back of my head. I don't recall his exact words, but he > essentially said that I should be testing the public

Re: [Tutor] raising exceptions in constructor code?

2019-07-16 Thread Mats Wichmann
On 7/16/19 3:29 PM, James Hartley wrote: > I ask this having more C++ knowledge than sense. > > There is an adage in the halls of everything Stroustrup that one needs to > think about how resource allocation will be unwound if an exception is > thrown. This gets watered down to the mantra "Don't

Re: [Tutor] Object references in Python

2019-07-16 Thread Mats Wichmann
On 7/16/19 2:33 PM, Steven D'Aprano wrote: > x = Parrot() > > Now x is a reference to a Parrot instance. y remains a reference to the > list. > > x.colour is a reference to the string "blue" (by default). > > x.speak is a reference to the "speak" method of Parrot objects. > > > > Does this

Re: [Tutor] Lengthy copyright notices?

2019-07-15 Thread Mats Wichmann
On 7/15/19 3:25 PM, James Hartley wrote: > help(module_name) will place any text in the *first* module-level docstring > into the description section of the help page in Python 3.4.5. Subsequent > docstrings found at module level are ignored. > > I have been using this factoid for placement of a

Re: [Tutor] Reading .csv data vs. reading an array

2019-07-15 Thread Mats Wichmann
On 7/15/19 1:59 PM, Chip Wachob wrote: > Mats, > > Thank you! > > So I included the QUOTE_NONNUMERIC to my csv.reader() call and it almost > worked. > > Now, how wonderful that the scope's csv file simply wrote an s for > seconds and didn't include quotes.  Now Python tells me it can't create >

Re: [Tutor] Reading .csv data vs. reading an array

2019-07-15 Thread Mats Wichmann
.html#csv.reader There's an option to convert unquoted values to floats, and leave quoted values alone as strings, which would seem to match your data above quite well. > Desc1, Val1, Desc2, TimeVal, VoltVal = row > > TimeVal and VoltVal return type of str, which makes sense. > >

Re: [Tutor] Reading .csv data vs. reading an array

2019-07-13 Thread Mats Wichmann
On 7/11/19 8:15 AM, Chip Wachob wrote: kinda restating what Oscar said, he came to the same conclusions, I'm just being a lot more wordy: > So, here's where it gets interesting. And, I'm presuming that someone out > there knows exactly what is going on and can help me get past this hurdle.

Re: [Tutor] Multiprocessing with many input input parameters

2019-07-12 Thread Mats Wichmann
On 7/12/19 5:53 AM, Shall, Sydney via Tutor wrote: > Thanks Mike, > > But I am still not clear. > > do I write: > > def f([x,y,z]) ? > How exactly do one write the function and how does one ensure that each > positional argument is accounted for. The concept of packing will be useful, you

Re: [Tutor] Output reason

2019-07-12 Thread Mats Wichmann
On 7/12/19 11:39 AM, Alan Gauld via Tutor wrote: > On 12/07/2019 15:24, Gursimran Maken wrote: > >> Can someone please explain me the reason for below output. > > You've been bitten by one of the most common gotchas in Python :-) > >> def fun(n,li = []): >> a = list(range(5)) >>

Re: [Tutor] Make a linked list subscriptable?

2019-07-11 Thread Mats Wichmann
On 7/10/19 6:30 PM, Sarah Hembree wrote: > How might I best make a linked list subscriptable? Below is skeleton code > for a linked list (my > actual is much more). I've done __iter__ and __next__ but I would like to > be able to do start:stop:stride I just can't figure out how. Suggestions or >

Re: [Tutor] pointers or references to variables or sub-sets of variables query.

2019-07-07 Thread Mats Wichmann
On 7/6/19 8:39 PM, mhysnm1...@gmail.com wrote: > Hi all. > > In C, you can use pointers to reference variables, arrays, ETC. In python, I > do not recall anything specifically that refers to such a capability. What I > want to do is: > > I want to create different data structures such as

Re: [Tutor] enumerate over Dictionaries

2019-07-05 Thread Mats Wichmann
On 7/4/19 3:53 PM, Alan Gauld via Tutor wrote: >> Does this means that the Dict is ordered? or it is implementation dependent? > > Neither, it means the items in a list always have indexes > starting at zero. > > By pure coincidence dictionaries in recent Python versions (since 3.6 > or 3.7???)

Re: [Tutor] Timsort on short lists

2019-07-02 Thread Mats Wichmann
On 7/2/19 1:48 AM, Jordan Baltes wrote: > I've been researching python's sorting algorithm, Timsort, and know that > it's a hybrid between insertion sort (best case time complexity O(n)) and > merge sort (O(n log(n))), and has an overall time complexity of O(n > log(n)). What I'm trying to figure

Re: [Tutor] path

2019-06-30 Thread Mats Wichmann
On 6/30/19 12:01 AM, ingo wrote: > > > On 29-6-2019 15:42, Mats Wichmann wrote: >> >> Most people don't use pathlib, and that's kind of sad, since it tries to >> mitigate the kinds of questions you just asked. Kudos for trying. > > In the end, it works, Soun

Re: [Tutor] path

2019-06-29 Thread Mats Wichmann
Sigh... something dropped my raw string, so that was a really bad sample :( inp = r"c:\test\drive\this" On Sat, Jun 29, 2019, at 07:44, Mats Wichmann wrote: > > For your example, when you define inp as a string, it needs to be a raw > string because otherwise Py

Re: [Tutor] path

2019-06-29 Thread Mats Wichmann
On 6/29/19 6:46 AM, ingo wrote: > A user has to type a path in the commandline on Win 10, so just a > string. > A short excerpt: > > Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 > bit (AMD64)] on win32 > Type "copyright", "credits" or "license()" for more information.

Re: [Tutor] double nodes being enter into tree structure

2019-06-28 Thread Mats Wichmann
On 6/28/19 12:10 AM, mhysnm1...@gmail.com wrote: > class Node(object): > > # I am not 100% sure the purpose of (object) does. as to this bit: having your class inherit from object means it's a "new-style class". That's only significant if you're writing code that is expected to run under

Re: [Tutor] Environment variables and Flask

2019-06-28 Thread Mats Wichmann
On 6/27/19 11:24 PM, Mayo Adams wrote: > I have for some time been flummoxed as to the significance of setting > environment variables, for example in order to run a Flask application. > What are these environment variables, exactly, and why is it necessary to > set them? "Googling" here simply

Re: [Tutor] Python and DB

2019-06-27 Thread Mats Wichmann
On 6/27/19 3:20 PM, Brave Heart via Tutor wrote: > I have a little RSS program , I current the out are basically outputted on my > screen, but I would like python to write to DB so I can from DB write on a > webpage with PHP... > > Kinda like I want to run a news website .. There doesn't seem

Re: [Tutor] Range command

2019-06-26 Thread Mats Wichmann
On 6/26/19 5:07 PM, Brick Howse via Tutor wrote: > Hello all, > > New to programming and I noticed the range command did not function like it > does in the tutorial. > For example, > I type > range(5, 10) > And the output is > range(5, 10) > > In section 4.3 > It shows it should display

Re: [Tutor] data structures general query

2019-06-26 Thread Mats Wichmann
On 6/26/19 11:59 AM, William Ray Wing via Tutor wrote: > One of the most useful (to me) structures is the double-ended queue ("from > collections import deque”). It creates a queue that can quickly remove an > item from one end and add an item to the other. Particularly useful for >

Re: [Tutor] data structures general query

2019-06-26 Thread Mats Wichmann
On 6/26/19 4:40 AM, mhysnm1...@gmail.com wrote: > All, > > > > General computer science question for data structures. > > When would you use the below structures and why? If you can provide a real > life example on when they would be used in a program This would be great. I > am not after

Re: [Tutor] Basic Question about Visualization for enduser

2019-06-25 Thread Mats Wichmann
On 6/25/19 6:39 AM, Sinardy Xing wrote: > Hi, > > I am a newbie with python and the data visualization. > I have completed pandas.DataFrame stuff and also the matplotlib. > > All of the example that I learned from internet currently are using the > Anaconda Jupyter Notebook. > I know there are

Re: [Tutor] replacing a loop

2019-06-24 Thread Mats Wichmann
On 6/24/19 4:24 PM, johnf wrote: > Thank you - it worked!  I'm glad you are no longer sleepy! > > Actually I wanted the naming to remain consistent with the other loops > > So the name of the function/method (it is in a class) caused the use of > the underscore > > locChoices == location

Re: [Tutor] Python type annotation question

2019-06-24 Thread Mats Wichmann
On 6/24/19 12:48 PM, Arup Rakshit wrote: > I am little experimenting with Python type annotation today. I wrote a simple > class as below: > from datetime import date class Person: > ... dob: date > ... def __init__(self, dob): > ... self.dob = dob > ...

Re: [Tutor] replacing a loop

2019-06-24 Thread Mats Wichmann
On 6/24/19 10:15 AM, johnf wrote: . > > Since I use a lot of similar loops to populate many dropdown controls I > started investigating the use of list comprehensions.  But I can't > figure out how to use them in this loop and wonder if it will improve > the performance. To amplify a tiny bit

Re: [Tutor] difference between array([1,0,1]) and array([[1,0,1]])

2019-06-21 Thread Mats Wichmann
On 6/20/19 5:39 PM, Markos wrote: > Hi, > > I'm studying Numpy and I don't understand the difference between > vector_1 = np.array( [ 1,0,1 ] ) > > with 1 bracket and > vector_2 = np.array( [ [ 1,0,1 ] ] ) > > with 2 brackets the first is one-dimensional, the second

Re: [Tutor] Installing Python v3 on a laptop Windows 10

2019-06-15 Thread Mats Wichmann
On 6/15/19 3:23 PM, Ken Green wrote:\ You've already gotten some good answers, don't consider this as contradictory. > I understood there is a preferable method > of installing Python into Windows. I pray > tell on how about to do it, gentlemen. There isn't, there are actually many ways, and

Re: [Tutor] Follow-up on my removing elements from lists question.

2019-06-15 Thread Mats Wichmann
On 6/15/19 3:35 AM, mhysnm1...@gmail.com wrote: Data structure: ['123123',[2019-2-18', 'transaction text', 'amount'], I presume the second opening brace is a typo and was supposed to be a quote mark? > The 2nd column where the transaction text I am modifying the content and > using the end

Re: [Tutor] Download audios & videos using web scraping from news website or facebook

2019-06-14 Thread Mats Wichmann
On 6/14/19 12:35 AM, Sijin John wrote: > Hello Sir/Mam, > I am trying to Download audios & videos using web scraping from news website > (eg: https://www.bbc.com/news/video_and_audio/headlines) or Facebook & I > could't. So in real scenario is it really possible to download audios/videos >

Re: [Tutor] Running Lib/test/test_shutil.py

2019-06-13 Thread Mats Wichmann
On 6/13/19 12:19 PM, Peter Otten wrote: > Tom Hale wrote: > >> Hi all, >> >> I hope this is the best place to ask (please let me know if there is a >> more appropriate list): >> >> Checking out CPython v3.8.0b1, I'm trying to run: >> >>% python Lib/test/test_shutil.py > > Are you sure > >

Re: [Tutor] Where to store test-code?

2019-06-13 Thread Mats Wichmann
On 6/13/19 2:22 AM, Thomas Güttler wrote: > Up to now I use this structure: > > src/myapp/setup.py > src/myapp/myapp/real_code.py > > Now I want to write a test for a method which is implemented real_code.py. > > Where should I write store the file which contains the unittest? > > Is there a

Re: [Tutor] Python printing parentheses and quotes

2019-06-10 Thread Mats Wichmann
On 6/10/19 10:50 AM, Sai Allu wrote: > Hello! > > I was just wondering if anybody encountered an issue where the Python > interpreter was changing how it interprets print statements. So I'm using > default Python on Mac OSX (2.7.10 I'm pretty sure) and running with the > "python script.py"

Re: [Tutor] Interactive editing of variables.

2019-06-04 Thread Mats Wichmann
On 6/4/19 2:49 AM, Steven D'Aprano wrote: > The bad news is that this only works on Linux and other Unix systems > with readline installed (which nearly all of them do). It won't work > under Windows. > > But if you install the third-party library pyreadline, you *may* be able > to use that

Re: [Tutor] Interactive editing of variables.

2019-06-01 Thread Mats Wichmann
>> The issue I have with a lot of GUI programs built for Python they generally >> fail in the accessibility department for a screen reader. > > I can't help there I have nearly zero experience of using accessibility > tools. But I'd expect any GUI toolkit to work with the standard > OS tools.

Re: [Tutor] is this doable

2019-05-31 Thread Mats Wichmann
On 5/31/19 1:41 PM, nathan tech wrote: > Hi there, > > So for a future project of mine, I was wondering something. > > Is it possible, in python, to store a running task id in the registry? > > I might be using the complete wrong terms here, because I'm only used to > doing this with a

Re: [Tutor] Query about python recipies for practices

2019-05-27 Thread Mats Wichmann
On 5/27/19 11:43 AM, boB Stepp wrote: > On Sun, May 19, 2019 at 12:55 PM bijaya dalei <2212bij...@gmail.com> wrote: >> >> Hii, Good morning. I am a new user of python programming language. I have a >> small query on "where to get python recepies for practices".plz >> suggest.Thanks. > > It is not

Re: [Tutor] Fwd: Re: Setting Command Line Arguments in IDLE

2019-05-26 Thread Mats Wichmann
> On 26/05/2019 02:55, Richard Damon wrote: >> I am working on a python script that will be provided arguments when run >> from the system command line. Is there any place in IDLE to provide >> equivalent arguments for testing while developing in IDLE? >> > > There used to be a dialog for that

Re: [Tutor] regular expressions query

2019-05-24 Thread Mats Wichmann
On 5/23/19 6:15 PM, mhysnm1...@gmail.com wrote: > All, > > > > Below I am just providing the example of what I want to achieve, not the > original strings that I will be using the regular expression against. > > > > The original strings could have: > > > > "Hello world" > > "hello

Re: [Tutor] How arguments to the super() function works?

2019-05-19 Thread Mats Wichmann
On 5/19/19 12:28 AM, Arup Rakshit wrote: > >> On 19-May-2019, at 4:46 AM, Mark Lawrence wrote: >> >> On 18/05/2019 17:21, Arup Rakshit wrote: >>> I am writing an Flask app following a book, where a piece of python concept >>> I am not getting how it works. Code is: >>> class Role(db.Model): >>>

Re: [Tutor] Case Insensitive Globing

2019-05-18 Thread Mats Wichmann
On 5/17/19 8:14 PM, Richard Damon wrote: > I am working on a program to process some files created by an old > windows program that created it files with varying case with a python > program. > > Using glob.glob on Windows seems to ignore the case, and find all the > matching files. > > The same

Re: [Tutor] simple question about scope

2019-05-18 Thread Mats Wichmann
On 5/18/19 2:20 AM, marcus lütolf wrote: > Dear experts > > in learning the principles of Python I came across scope in the > control structure's section. > There I read the notion that variables createted inside a > control structute can't be seen or accessed from outside that > structure,

Re: [Tutor] Consequences of removing python3-venv

2019-05-09 Thread Mats Wichmann
On 5/9/19 9:52 AM, Jim wrote: > My Linux mint18 system recently wanted to up date python 3.6. When I > clicked install I got the following message: > > The following 2 packages will be removed: > python3-dev > python3-venv > > I have 2 virtual environments installed: python 3.5.2 & 3.6.7. > >

Re: [Tutor] Can't reinstall pip for Python 3.7.3

2019-05-08 Thread Mats Wichmann
On 5/8/19 5:36 AM, Zelphy wrote: > Dear tutor members, > > After spending a lot of time on forums trying to fix this problem, I come > here hoping for a solution to my problem. > In fact, after upgrading my version of Python ( I was on 3.6.5 and then on > 3.7.3 ) I wanted to reinstall pip (

Re: [Tutor] don't steel my code Mister user

2019-05-05 Thread Mats Wichmann
On 5/4/19 8:35 AM, nathan tech wrote: > It has to be said, after extensive research, and responses here, it > seems python was just not designed to be a commercial product. > > Licenses are all well and good, but if you're hacking a product, you're > just not going to be stopped by a lisence. >

Re: [Tutor] pip issue

2019-05-02 Thread Mats Wichmann
On 5/2/19 6:14 PM, Cameron Simpson wrote: > On 02May2019 17:24, Anil Duggirala wrote: >> I executed the pip3 install --user -r >> contrib/requirements/requirements.txt (I actually did sudo before that). > > Please don't use sudo for this. The notion "install" does not imply > being root. > The

Re: [Tutor] self.name is calling the __set__ method of another class

2019-05-02 Thread Mats Wichmann
On 5/2/19 9:25 AM, Arup Rakshit wrote: > On 30/04/19 6:34 AM, David L Neil wrote: >> As Steven explained, this is a complex environment where only those >> with a good understanding of the meta abstractions would even want to >> play (IMHO). Perhaps you would be better served by actually writing

Re: [Tutor] feedparser in python

2019-04-29 Thread Mats Wichmann
On 4/28/19 6:26 PM, nathan tech wrote: > Hello everyone, > > Most recently, I have started work using feedparser. > > I noticed, almost straight away, it's a  bit slow. > > For instance: > >     url="http://feeds.bbci.co.uk/news/rss.xml; > >     f1=feedparser.parse(url) > > > On some

Re: [Tutor] Help request ERROR installing beautifulsoup

2019-04-29 Thread Mats Wichmann
On 4/29/19 1:44 AM, Alan Gauld via Tutor wrote: > On 28/04/2019 17:11, Dr. Luca T wrote: > ^ >> SyntaxError: Missing parentheses in call to 'print'. Did you mean >> print("Unit tests have failed!")? >> > >> I use windows

Re: [Tutor] str.replace error

2019-04-26 Thread Mats Wichmann
On 4/25/19 10:29 PM, Steven D'Aprano wrote: > On Thu, Apr 25, 2019 at 10:46:31AM -0700, Roger Lea Scherer wrote: > >> with open('somefile') as csvDataFile: >> csvReader = csv.reader(csvDataFile) >> for row in range(100): >> a = "Basic P1" >> str.replace(a, "") >>

Re: [Tutor] Question on implmenting __getitem__ on custom classes

2019-04-23 Thread Mats Wichmann
On 4/23/19 8:57 AM, Arup Rakshit wrote: > On 23/04/19 3:40 PM, Steven D'Aprano wrote: >> Watch out here, you have a mutable default value, that probably doesn't >> work the way you expect. The default value is created ONCE, and then >> shared, so if you do this: >> >> a = MyCustomList()  # Use the

Re: [Tutor] Fwd: uploading images in pygame

2019-04-16 Thread Mats Wichmann
On 4/16/19 1:54 PM, fatima butt wrote: > please i am getting error..i am trying to upload image from openspaceart > from internet . I have downloaded the image on my desktop and i am trying > to upload this to the pygame. Please provide us with more information. What are you trying (hint:

Re: [Tutor] Questions about the deprecation of standard library modules

2019-03-30 Thread Mats Wichmann
On March 30, 2019 9:13:16 PM MDT, boB Stepp wrote: >While reading in chapter 3 of "Learning Python, 5th ed." by Mark Lutz, >I was playing around with reload() in the imp module. In the >interpreter I did a "from imp import reload" and then help(reload). >This had a warning that it was

Re: [Tutor] (no subject)

2019-03-26 Thread Mats Wichmann
On 3/26/19 12:26 PM, Matthew Herzog wrote: > elif fileDate = datetime.strptime(name[0:8], DATEFMT).date(): >                    ^ > SyntaxError: invalid syntax are you assigning (=) or comparing (==)? you can't do both in one statement because of the side effect implications. [except that

Re: [Tutor] (no subject)

2019-03-23 Thread Mats Wichmann
On 3/23/19 3:16 AM, Peter Otten wrote: > Personally I would use a try...except clause because with that you can > handle invalid dates like _etc.xls gracefully. So > > ERASED = "erased_" > > > def strip_prefix(name): > if name.startswith(ERASED): > name =

Re: [Tutor] My problem in simple terms

2019-03-22 Thread Mats Wichmann
On 3/21/19 11:54 PM, Edward Kanja wrote: > Greetings, > I'm referring to my question i sent earlier, kindly if you have a hint on > how i can solve > my problem i will really appreciate. After running regular expressions > using python > my output has lot of square brackets i.e.

Re: [Tutor] Import error, no module named app script

2019-03-21 Thread Mats Wichmann
On 3/21/19 5:00 PM, nathan tech wrote: > Hi guys, > So I recently begun using Mac to program in python. > For one of the modules I am going to be using, it calls app script in order > to send commands to voiceover, which is a screen reader for the MAC. > The only problem is, it gives an error

Re: [Tutor] LPTHW ex15 question

2019-03-21 Thread Mats Wichmann
On 3/21/19 2:42 PM, Alan Gauld via Tutor wrote: > On 21/03/19 12:43, Jones, Kayla wrote: >> ...getting an error message in powershell that I can't figure out. > >> I've attached a screenshot to help.  Any suggestions would be > appreciated. > > First suggestion is not to send images as

Re: [Tutor] Merge a dictionary into a string

2019-03-17 Thread Mats Wichmann
On 3/16/19 11:39 AM, Valerio Pachera wrote: > Consider this: > > import collections > d = OrderedDict(a='hallo', b='world') > > I wish to get a single string like this: > > 'a "hallo" b "world"' > > Notice I wish the double quote to be part of the string. > In other words I want to wrap the

Re: [Tutor] Merge a dictionary into a string

2019-03-16 Thread Mats Wichmann
On March 16, 2019 5:57:23 PM MDT, Alan Gauld via Tutor wrote: >On 16/03/2019 18:44, Peter Otten wrote: >> >> In Python 3.6 and above you can use f-strings: >> > d = dict(a="hello", b="world") > " ".join(f'{k} "{v}"' for k, v in d.items()) >> 'a "hello" b "world"' > >Cool, I'd missed

Re: [Tutor] How to create a structure from a Log file

2019-03-09 Thread Mats Wichmann
On March 9, 2019 6:08:03 AM MST, Asad wrote: >Hi All , > > I would like to know , how can I approach this problem to create >a easy structure from the logfile using python so I can review the >logfiles >quite efficiently . Please share suggestion tip or already written >codes. > > >

Re: [Tutor] directory structure with tests?

2019-03-06 Thread Mats Wichmann
On 3/6/19 3:17 PM, James Hartley wrote: > It is preferable to sprinkle tests files throughout the directories of a > project, or coalesce all tests in a test directory? "It depends". There are people who have strong opinions. If you're going to use conventions like naming the test for the

Re: [Tutor] Only appending one object to list, when I am expecting more than 1

2019-02-27 Thread Mats Wichmann
Without spending a lot of time on an answer, you can use default arguments in the cases where only the number of arts differs in your instance creation. If there's larger differences, look into @classmethod. On February 27, 2019 5:25:02 AM PST, AdamC wrote: >That's great - bug found. Thanks.

Re: [Tutor] Doubt

2019-02-26 Thread Mats Wichmann
On 2/26/19 11:36 AM, Maninath sahoo wrote: is it possible reverse inheritance? mean child class to parent class Well, it's Python, so you can do all sorts of things, some of them good ideas, some bad... Like Alan says, the question as asked doesn't really make a lot of sense to us, but

Re: [Tutor] How to use "curses.resizeterm(nlines, ncols)"

2019-02-24 Thread Mats Wichmann
All is is_term_resized, resizeterm and the "internal" resize_term functions are recent additions :-) From "man 3 resizeterm":  This extension of ncurses was introduced in mid-1995.  It  was  adopted in NetBSD curses (2001) and PDCurses (2003). For some definition of "recent" :) I have

Re: [Tutor] How to use "curses.resizeterm(nlines, ncols)"

2019-02-24 Thread Mats Wichmann
On 2/24/19 1:30 PM, boB Stepp wrote: So what am I misunderstanding? Can someone show me a code snippet that I can run which will demonstrate the usefulness and usage of curses.resizeterm()? TIA! If it's snippets you want, I always look at programcreek. These are always part of something

Re: [Tutor] Visual studio Code -Python

2019-02-23 Thread Mats Wichmann
On 2/23/19 5:23 AM, Asad wrote: Hi All ,          I am using : pdb.set_trace()           can you all share some good tricks i using n ,s , l . The tedious part which I see is  if it is a loop like for loop then I need to do next till the length for the data is completed for x in string :

Re: [Tutor] import failure

2019-02-22 Thread Mats Wichmann
On 2/22/19 9:55 AM, Alex Kleider wrote: (p2) alex@one:$ python src/gdata/oauth/rsa.py key_factory = '/home/alex/.virtualenvs/p2/local/lib/python2.7/site-packages/tlslite/utils/keyfactory.pyc'> (p2) alex@one:$ python Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) [GCC 7.3.0] on linux2 Type

Re: [Tutor] Visual studio Code -Python

2019-02-17 Thread Mats Wichmann
On 2/17/19 1:50 AM, Asad wrote: > Hi All , > > I am using Visual Studio Code for Python . However I was using > the debug option F5 i see it list the variables in my program neatly ,I set > breakpoints it stops there but I am unable to preview each line of the > execution of the

Re: [Tutor] Python Websocket Server

2019-02-14 Thread Mats Wichmann
On 2/14/19 9:44 AM, Simon Connah wrote: > Hi, > > I was wondering what the best practice for writing web socket servers in > Python was in 2019? I found an old example on the web which used the > tornado library but that was talking about Chrome 22 as the client which > is ancient now so I'm not

Re: [Tutor] Putting a Bow on It

2019-02-11 Thread Mats Wichmann
On 2/11/19 6:48 AM, Chip Wachob wrote: > Thanks. These are both great helps to get me started. > > The little bit of searching does leave me a little bit confused, but the > reference to the book is somewhat helpful / encouraging. > > I see a lot of people saying that certain approaches have

Re: [Tutor] help

2019-02-05 Thread Mats Wichmann
>> Error: >> ./python2.py: line 1: syntax error near unexpected token `(' > > That is not a Python error, that's a complaint of your shell. > If you make a Python script executable you also have to insert the proper > hash-bang line. In the case of Python 2 > > #!/usr/bin/python2 > > will

Re: [Tutor] Remove soft line break

2019-02-04 Thread Mats Wichmann
On 2/4/19 10:13 AM, Valerio Pachera wrote: > > I have a file with row that split at the 80th character. > The next row start with a blank space, meaning that i part of the previous > row. > > Example: > > Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam non justo enim. > Viv >

Re: [Tutor] Not able to get to Script Mode

2019-01-29 Thread Mats Wichmann
On 1/29/19 2:07 PM, jetspacejt wrote: > Using version 3.7.1 > Where is File Edit Shell...etc. > Not at the top of my screen You're looking (probably) for IDLE, not for Python itself (IDLE is an editor/simple IDE written in Python, that is usually bundled with Python). On the wild guess you're

Re: [Tutor] python - files

2019-01-26 Thread Mats Wichmann
On 1/26/19 1:20 AM, Asad wrote: > Hi All , > >I would like to know how do I make and option file as an argument on > command propmnt in python I don't know your context for asking this question. Alan has already explained what you need to do for your issue, and whatever your needs it is

[Tutor] asking questions

2019-01-24 Thread Mats Wichmann
Just for a bit of amusement, one of the scenarios we see here is famous enough it has its very own website: http://xyproblem.info/ enjoy :) ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

Re: [Tutor] Running Python 3 on Linux Mint

2019-01-14 Thread Mats Wichmann
On 1/14/19 4:08 PM, Cranky Frankie wrote: > On Sun, Jan 13, 2019 at 2:04 PM Alan Gauld via Tutor > wrote: >> "You don't say which Mint version but assuming its 17 or >> greater then you can just use the software manager >> (or Synaptic) and install the python3 packages." > Thanks so much, I'm

Re: [Tutor] Doubt

2019-01-07 Thread Mats Wichmann
On 1/7/19 9:29 AM, Amit Yadav wrote: > How can simply typing > > print "hello world" > > work? > Like without including any header file or import statements how can it work. because you're using a function (or in your case - which looks like Python 2.x because it is not written as a function

Re: [Tutor] Interpreter pasting Question

2018-12-28 Thread Mats Wichmann
On 12/28/18 10:13 AM, Avi Gross wrote: > As one of my programming styles includes lots of hands-on incremental > analysis of bits and pieces to get them working before combining them, I > have no time for an idyllic experience. don't presume to know what environment will actually work for you,

Re: [Tutor] look back comprehensively

2018-12-25 Thread Mats Wichmann
On 12/24/18 5:45 PM, Avi Gross wrote: > As for the UNIX tools, one nice thing about them was using them in a > pipeline where each step made some modification and often that merely > allowed the next step to modify that. The solution did not depend on one > tool doing everything. I know we're

Re: [Tutor] look back comprehensively

2018-12-24 Thread Mats Wichmann
On 12/24/18 2:14 AM, Alan Gauld via Tutor wrote: > 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. > In fact for most log file analysis I still use [ng]awk. > Its

Re: [Tutor] look back comprehensively

2018-12-23 Thread Mats Wichmann
On 11/14/18 3:01 PM, Steven D'Aprano wrote: > On Tue, Nov 13, 2018 at 11:59:24PM -0500, Avi Gross wrote: >> I have been thinking about the thread we have had where the job seemed to be >> to read in a log file and if some string was found, process the line before >> it and generate some report. Is

Re: [Tutor] Python

2018-12-20 Thread Mats Wichmann
On 12/20/18 8:49 AM, Mary Sauerland wrote: > Hi, > > I want to get rid of words that are less than three characters but I keep > getting errors. I tried multiple ways but keep getting errors. Just a quick note or two: > > Here is my code: > > f1_name =

Re: [Tutor] Obfuscated Python [was Long Lines techniques]

2018-12-14 Thread Mats Wichmann
On 12/13/18 11:15 PM, Avi Gross wrote: > Steven, > > There are dunderheads who will maliciously misuse things. Yes, we know what > __add__ is supposed to do. But if someone codes a class with one that > ignores addition to a collection if it has reached a maximum size, or does > addition modulo

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

2018-12-07 Thread Mats Wichmann
On 12/7/18 3:20 AM, Steven D'Aprano wrote: >> How to know whether in a given string(sentence) is there any that is not >> ASCII character and how to replace? > > That's usually the wrong solution. That's like saying, "My program can't > add numbers greater than 100. How do I tell if a number is

  1   2   3   4   >