Re: [Tutor] How to separate UI code from program logic?

2018-05-06 Thread boB Stepp
On Sun, May 6, 2018 at 5:05 PM, Alan Gauld wrote: > On 6 May 2018, at 23:00, boB Stepp wrote: >>My understanding of best practice here is that I should not have any >>print() calls inside my generate_collatz_sequence() function. I >>_could_ store the generated sequence in a list and return it,

Re: [Tutor] How to separate UI code from program logic?

2018-05-06 Thread Mark Lawrence
On 06/05/18 22:59, boB Stepp wrote: I was solving a programming problem in one of my books concerning the generation of a Collatz sequence (https://en.wikipedia.org/wiki/Collatz_conjecture), and started to wonder how I should separate my program's output from its logic. It seems like this should

Re: [Tutor] How to separate UI code from program logic?

2018-05-06 Thread boB Stepp
On Sun, May 6, 2018 at 5:05 PM, Alan Gauld wrote: > On 6 May 2018, at 23:00, boB Stepp wrote: >>My understanding of best practice here is that I should not have any >>print() calls inside my generate_collatz_sequence() function. I >>_could_ store the generated sequence in a list and return it,

Re: [Tutor] How to separate UI code from program logic?

2018-05-06 Thread Alan Gauld via Tutor
On 6 May 2018, at 23:00, boB Stepp wrote: >I was solving a programming problem in one of my books concerning the >generation of a Collatz sequence >(https://en.wikipedia.org/wiki/Collatz_conjecture), and started to >wonder how I should separate my program's output from its logic.  It >seems lik

Re: [Tutor] Need help with a virtual environment mess

2018-05-06 Thread boB Stepp
On Sun, May 6, 2018 at 11:05 AM, Jim wrote: > In a prior thread you guys helped me fix a problem with pip after I upgraded > an installed version of python 3.6 on my Mint 18 system. Pip would not run > in my python 3.6 virtual environment. The fix was to use synaptic to install > python3-distutils

[Tutor] How to separate UI code from program logic?

2018-05-06 Thread boB Stepp
I was solving a programming problem in one of my books concerning the generation of a Collatz sequence (https://en.wikipedia.org/wiki/Collatz_conjecture), and started to wonder how I should separate my program's output from its logic. It seems like this should be obvious to me, but, unfortunately,

Re: [Tutor] passing values and C pointers

2018-05-06 Thread eryk sun
On Sun, May 6, 2018 at 2:17 AM, Brad M wrote: > > Say I have an array of values, say addresses or int produced by a c module/ > c function that's in a DLL , how do I pass that array back to > the python code? C arrays are passed and returned automatically as pointers to the first element. The arr

Re: [Tutor] Python C extension - which method?

2018-05-06 Thread eryk sun
On Sun, May 6, 2018 at 12:49 AM, Brad M wrote: > If I may ask, what's the difference between these two? > > 1) > import ctypes > hello = ctypes.WinDLL('hello', use_last_error=True) > > 2) > from ctypes import cdll > hello = cdll.LoadLibrary('hello.dll') Use ctypes.CDLL and ctypes.WinDLL instead o

[Tutor] passing values and C pointers

2018-05-06 Thread Brad M
Hi all: Although I have college C++ 101 and Python 101 down my belt, I wan't taught how to read a reference manual to figure this out :( Say I have an array of values, say addresses or int produced by a c module/ c function that's in a DLL , how do I pass that array back to the python code? from

Re: [Tutor] Python C extension - which method?

2018-05-06 Thread Brad M
Does this have any downside? I have noticed that printf("HI") in my .DLL; doesn't really print anything. I am on windows. cdll.LoadLibrary('helloworld.dll') My next question is that I need to return an array or a list of address or int or some type of data, but if I returned a pointer to the ar

Re: [Tutor] Extract main text from HTML document

2018-05-06 Thread Brian Lockwood
Two things. The first thing is that you can download the page as a string and delete a everything between tags. Secondly It might be worth looking at Udacity cs101 as this course is all about a search engine. On Sat, 5 May 2018 at 22:27, Simon Connah wrote: > Hi, > > I'm writing a very simple web

[Tutor] ValueError: Procedure probably called with too many arguments (8 bytes in excess)

2018-05-06 Thread Brad M
Hi all: I am experimenting with python calling some .DLL and this is my setup: scan.py memscan = ctypes.WinDLL('mahdll', use_last_error=True) print(memscan.say_something(1,2)) # So I pass to int to the DLL function. DLL: #include __declspec(dllexport) int say_something(int a, int b) { print

Re: [Tutor] Python C extension - which method?

2018-05-06 Thread Brad M
If I may ask, what's the difference between these two? 1) import ctypes hello = ctypes.WinDLL('hello', use_last_error=True) 2) from ctypes import cdll hello = cdll.LoadLibrary('hello.dll') Both of them can return "1980" from this: hello.c #include __declspec(dllexport) int say_something()

Re: [Tutor] Extract main text from HTML document

2018-05-06 Thread Simon Connah
Thanks for the replies, everyone. Beautiful Soup looks like a good option. My primary goal is to extract the main body text, the title and the meta description from a web page and run it through one of the cloud Natural Language processing services to find out some information that I'd like to kno

Re: [Tutor] Extract main text from HTML document

2018-05-06 Thread Mark Lawrence
On 05/05/18 18:59, Simon Connah wrote: Hi, I'm writing a very simple web scraper. It'll download a page from a website and then store the result in a database of some sort. The problem is that this will obviously include a whole heap of HTML, JavaScript and maybe even some CSS. None of which is

[Tutor] Need help with a virtual environment mess

2018-05-06 Thread Jim
In a prior thread you guys helped me fix a problem with pip after I upgraded an installed version of python 3.6 on my Mint 18 system. Pip would not run in my python 3.6 virtual environment. The fix was to use synaptic to install python3-distutils. I thought everything was ok until I tried to ru

Re: [Tutor] Figuring out selective actions in Python

2018-05-06 Thread Steven D'Aprano
On Fri, May 04, 2018 at 03:53:41PM -0400, Daniel Bosah wrote: > Hello, > > I'm trying to figure out how to do blank in blank things. For example, if I > want to delete 5 MB ( or anything ) for every 20 MB, how would the could > look like? I'm essentially trying to do an action in one order of the